-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
virtual file system is broken in v6 #18223
Comments
Start a new pull request in StackBlitz Codeflow. |
I suppose minimal repro is just import { createServer } from 'vite';
const server = await createServer({
plugins: [
{
name: 'virtual-fs',
load(id) {
if (id === 'my-virtual-file.js') {
return 'export default "Hello, world!"';
}
},
},
],
});
console.log(await server.ssrLoadModule('my-virtual-file.js')); On v5 https://stackblitz.com/edit/stackblitz-starters-cr4to5?file=index.js
On v6 https://stackblitz.com/edit/stackblitz-starters-asgtkf?file=index.js
|
I don't see why this even worked before, to be honest. The import 'my-virtual-file.js' Reproduction: https://stackblitz.com/edit/stackblitz-starters-a9fxsa?file=actual-fs.js,index.js This however works as intended (if you provide import 'my-virtual-file' I'd say making the entry point work the same way as the |
Interesting, Vite 6's behavior looks legitimate to me. @himself65 Do you have any reason to do |
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 |
@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 |
yes |
Probably your reproduction was misleading and the issue might be more like this scenario: ssrLoadModule("/abs-path-to/entries")
plugin.resolveId: "/abs-path-to/entries" --> "/abs-path-to/entries.jsx"
plugin.load: "/abs-path-to/entries.jsx" --> ...virtual content... On Vite 6, ❯ node index.js
[resolveId] { id: '/home/projects/stackblitz-starters-prwdrf/entries' }
{ default: 'Hello, world!', [Symbol(Symbol.toStringTag)]: 'Module' } ❯ node index.js
[resolveId] { id: '/home/projects/stackblitz-starters-prwdrf/entries' }
[resolveId] { id: '/entries' }
5:52:39 PM [vite] (ssr) Error when evaluating SSR module /home/projects/stackblitz-starters-prwdrf/entries:
|- Error: [vite] cannot find entry point module '/entries'.
at fetchModule (file:///home/projects/stackblitz-starters-prwdrf/node_modules/vite/dist/node/chunks/dep-BHXIdTzn.js:66013:13) This seems like an odd case, but not sure. Let me re-open the issue for now. |
@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 |
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 |
@himself65 Other than switching to The issue (on Vite, fair to say) is that it stripes
|
Describe the bug
This is working in v5, but broken in v6.
Reproduction
https://stackblitz.com/edit/stackblitz-starters-prwdrf?file=index.js
Steps to reproduce
No response
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: