You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
I don't see why this even worked before, to be honest. The my-virtual-file.js in the reproduction is the resolved ID, not the user ID that would be used in an import. For example, this fails in Vite 5 and Vite 6:
Interesting, Vite 6's behavior looks legitimate to me.
@himself65 Do you have any reason to do server.ssrLoadModule('my-virtual-file.js') instead of server.ssrLoadModule('my-virtual-file'). It looks like a simply typo to me and I don't think this change would be a blocker anyways, so I'll close this issue for now.
dose the virtual module can have import statement? like
if (id === resolvedId) {
return { code: import { isUndefined } from 'lodash'; console.log(123) };
}
Activity
bolt-new-by-stackblitz commentedon Sep 28, 2024
hi-ogawa commentedon Sep 29, 2024
I suppose minimal repro is just
loadhook:On v5 https://stackblitz.com/edit/stackblitz-starters-cr4to5?file=index.js
On v6 https://stackblitz.com/edit/stackblitz-starters-asgtkf?file=index.js
sheremet-va commentedon Oct 3, 2024
I don't see why this even worked before, to be honest. The
my-virtual-file.jsin the reproduction is the resolved ID, not the user ID that would be used in an import. For example, this fails in Vite 5 and Vite 6:Reproduction: https://stackblitz.com/edit/stackblitz-starters-a9fxsa?file=actual-fs.js,index.js
This however works as intended (if you provide
resolveIdhook like in the reproduction):I'd say making the entry point work the same way as the
importis a bug fix.hi-ogawa commentedon Oct 5, 2024
Interesting, Vite 6's behavior looks legitimate to me.
@himself65 Do you have any reason to do
server.ssrLoadModule('my-virtual-file.js')instead ofserver.ssrLoadModule('my-virtual-file'). It looks like a simply typo to me and I don't think this change would be a blocker anyways, so I'll close this issue for now.himself65 commentedon Oct 5, 2024
yes, in waku we build on top of vite, and we have a file import , when user not provided we will make a fake one. So in this case we wanna ts/js/tsx
hi-ogawa commentedon Oct 6, 2024
@himself65 Are you saying Vite 5 behavior is required for your use case? I cannot tell from your initial reproduction, so it would be great if you can elaborate it further. Maybe this plugin? https://github.com/dai-shi/waku/blob/711be51c02eac6a767fe5651fae6d6417d0679f8/packages/waku/src/lib/plugins/vite-plugin-rsc-managed.ts#L40
himself65 commentedon Oct 6, 2024
yes
hi-ogawa commentedon Oct 6, 2024
Probably your reproduction was misleading and the issue might be more like this scenario:
On Vite 6,
resolveIdis called differently and maybe that's causing an issue.This seems like an odd case, but not sure. Let me re-open the issue for now.
hi-ogawa commentedon Oct 7, 2024
@himself65 I haven't look into the issue, but I would probably try this to provide "optionally virtual entry" from plugin: https://stackblitz.com/edit/stackblitz-starters-t9hvyx?file=index.js
himself65 commentedon Oct 12, 2024
im not sure the best practice here, entries file is possible to be virtual or real file. I feel the logic is broken after we add
virtual:as prefixhi-ogawa commentedon Oct 16, 2024
@himself65 Other than switching to
virtual:, you might be able to workaround by removingrootfrom entries https://github.com/dai-shi/waku/blob/711be51c02eac6a767fe5651fae6d6417d0679f8/packages/waku/src/lib/plugins/vite-plugin-rsc-managed.ts#L55-L56 (for example, use/src/entriesinstead of/abs-path-to/src/entries).The issue (on Vite, fair to say) is that it stripes
rootas a part of normalization here, so your plugin'sresolveIddoesn't consistently seeroot.vite/packages/vite/src/module-runner/runner.ts
Line 223 in 93b03b2
fix(plugins): fix rscManagedPlugin (#1019)
2dragonly commentedon Dec 22, 2024
on v5, adding
?t=${Date.now()}works properlybut on v6, i get error
[vite] cannot find entry point module 'virtual:server-build?t=1734890638891'.^ this can be fix by removing
?t=${Date.now()}hi-ogawa commentedon Dec 23, 2024
@2dragonly Your issue seems a bit different though it looks like technically a regression. Can you create a separate issue?
Probably there was some special handling for the exact query
?t=${Date.now()}but the query in general form?abcd=1234isn't supported in Vite 5. https://stackblitz.com/edit/vitejs-vite-98ukz5g2?file=repro.js2dragonly commentedon Dec 23, 2024
I didn't mean
?abcd=1234tho,. I just want to know why?tspecial query doesn't work on vite 6Screenshot.2024-12-23.at.08.14.02.webm
hi-ogawa commentedon Dec 23, 2024
I haven't confirmed but I'm guessing
?tis handledtransformRequestlayer (in Vite 5ssrLoadModule)vite/packages/vite/src/node/server/transformRequest.ts
Lines 147 to 153 in ac32968
but Vite 6 has a different architecture and checks
resolveIdfirst, which doesn't have a special treatment of?t(or any query) for virtual modules.vite/packages/vite/src/node/ssr/fetchModule.ts
Lines 75 to 78 in ac32968
huskylovegold commentedon Dec 26, 2024
dose the virtual module can have import statement? like
if (id === resolvedId) {
return { code:
import { isUndefined } from 'lodash'; console.log(123)};}