Skip to content
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

fix(runner): replace runner path normalization with fetchModule resolve #18361

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

hi-ogawa
Copy link
Collaborator

@hi-ogawa hi-ogawa commented Oct 16, 2024

Description

Not so confident that this is a proper fix nor the issue needs fix, but I'm thinking about what would require to support #18223 and hopefully it helps deciding the fate of the issue (bug or wontfix).

One thing I noticed that it looks possible to dedupe/normalize /abs-path-to/src/etc -> /src/etc on server side (fetchModule) and module identity is still kept intact on runner side since they are keyed by resolved id. For FetchModuleResult.cache detection, I replaced getModuleByUrl with ensureEntryFromUrl and I'm wondering what's the downside of this.

todo

  • decide on file:// support
    • it doesn't work on build (nor v5 ssr dev, nor client dev/build), so for now, I think it's better to remove dev only file:// support. It's still possible to use custom plugin resolveId to resolve file:// and I added tests for this usage.

Copy link

stackblitz bot commented Oct 16, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@hi-ogawa hi-ogawa force-pushed the fix-normalize-url-in-fetchModule branch from bb8c402 to 5e8e7ec Compare October 16, 2024 04:24
@hi-ogawa hi-ogawa changed the title fix(runner): normalize absolute path in fetchModule fix(runner): resolve and normalize absolute path in fetchModule Oct 16, 2024
@hi-ogawa
Copy link
Collaborator Author

normalizeAbsoluteUrl also noramlizes file:///... to support this test case, but I'm not sure if we needs to keep this if we go with externalizing file:// entirely #17369. Also v5's ssrLoadModule('file://') doesn't seem to work either.

// loads the same module if id is a file url
const fileUrl = new _URL('./fixtures/simple.js', import.meta.url)
const mod2 = await runner.import(fileUrl.toString())
expect(mod).toBe(mod2)

@hi-ogawa hi-ogawa marked this pull request as ready for review October 16, 2024 07:06
@hi-ogawa
Copy link
Collaborator Author

/ecosystem-ci run

@vite-ecosystem-ci
Copy link

@hi-ogawa hi-ogawa marked this pull request as draft October 16, 2024 23:12
@hi-ogawa
Copy link
Collaborator Author

/ecosystem-ci run

@vite-ecosystem-ci
Copy link

📝 Ran ecosystem CI on b1236bf: Open

suite result latest scheduled
astro failure failure
remix failure failure
sveltekit failure failure
vike failure failure
vite-environment-examples failure failure
vite-plugin-svelte failure failure
vitest failure failure

analogjs, histoire, ladle, laravel, marko, nuxt, previewjs, quasar, qwik, rakkas, redwoodjs, storybook, unocss, vite-plugin-pwa, vite-plugin-react, vite-plugin-react-swc, vite-plugin-vue, vite-setup-catalogue, vitepress, vuepress

@hi-ogawa hi-ogawa changed the title fix(runner): resolve and normalize absolute path in fetchModule fix(runner): move path normalization from runner to fetchModule Oct 21, 2024
@hi-ogawa hi-ogawa changed the title fix(runner): move path normalization from runner to fetchModule fix(runner): replace runner path normalization with fetchModule resolve Oct 21, 2024
@sheremet-va
Copy link
Member

  • it doesn't work on build (nor v5 ssr dev, nor client dev/build), so for now, I think it's better to remove dev only file:// support. It's still possible to use custom plugin resolveId to resolve file:// and I added tests for this usage.

file:// works in production though. It's a valid (and the only) way to pass down the full path on Windows, for example. It also works in vite-node:

runner.executeId('file:///C:/Users/name/dev/index.js')

This is a valid Node.js code:

await import('file:///C:/Users/name/dev/index.js')

@hi-ogawa
Copy link
Collaborator Author

I agree that file:// should be supported in some way, but I'm worrying about the inconsistency in current state. Putting aside client case, I think we want this to work consistently for ssr dev/build at least. Let me think about how to move custom file url resolve to core.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

virtual file system is broken in v6
2 participants