-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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: correctly resolve hmr dep ids and fallback to url #18840
base: main
Are you sure you want to change the base?
Conversation
Thank you for the PR!
I think there are two ways to fix the issue. The first is to make The second is to make the IIUC this PR makes |
hi, alright, I think it should accept Ids, since the imports can be transformed based on imported and specifier. i think meta.hot.accept should do the same. is it necessary a breaking change? I did not find that its documented to use url for deps. |
7b43c21
to
c7d118a
Compare
c7d118a
to
0ba0ae5
Compare
@sapphi-red this is now passing and still uses urls, but tries first to resolve the module via resolveId and then uses the resolved module.url. on meta.hot.accept:
|
@sapphi-red does this look okay now? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the change!
Co-authored-by: 翠 / green <[email protected]>
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
I looked at vitest failure. vitest is currently failing on main |
This comment was marked as outdated.
This comment was marked as outdated.
@patricklx Would you also describe where you needed to use |
Co-authored-by: 翠 / green <[email protected]>
I have a vite plugin that generates virtual files which can also change depending on other files on the filesystem. |
Is self-accepting on the virtual module side (i.e. call |
no, the o
no, the files having the virtual file dependency need to update their values that come from the virtual file |
@@ -753,9 +753,36 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin { | |||
// normalize and rewrite accepted urls | |||
const normalizedAcceptedUrls = new Set<string>() | |||
for (const { url, start, end } of acceptedUrls) { | |||
const [normalized] = await moduleGraph.resolveUrl(toAbsoluteUrl(url)) | |||
let [normalized, resolvedId] = await normalizeUrl(url, start) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sapphi-red I changed this to use normalizeUrl
which already does the resolve and also calls _ensureEntryFromUrl
.
I had to move _ensureEntryFromUrl
out of if (environment.config.consumer === 'client') {
check so its also called in ssr
Co-authored-by: 翠 / green <[email protected]>
/ecosystem-ci run |
commit: |
📝 Ran ecosystem CI on
✅ analogjs, astro, ladle, laravel, marko, previewjs, quasar, qwik, sveltekit, unocss, vite-environment-examples, vite-plugin-pwa, vite-plugin-react, vite-plugin-react-swc, vite-setup-catalogue, vitest, vuepress |
Hmm, it seems rakkas and vitepress is passing a URL. cc @patak-dev |
vue is also failing in their hmr tests |
plugin-vue's fail is a flaky fail, so that one is fine (vitejs/vite-plugin-vue#485). |
Maybe we could add back the URL fallback in the next minor if we're clear that this is just for backward compat and we'll move to a warning on Vite v7. |
So, should i add back the fallback then? |
Yeah. Would you add back the fallback with a comment that this is just for backward compat and will remove it in Vite 7? |
0db7f02
to
d5d7b94
Compare
I added the change |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you
/ecosystem-ci run |
This comment was marked as duplicate.
This comment was marked as duplicate.
📝 Ran ecosystem CI on
✅ analogjs, astro, ladle, nuxt, previewjs, quasar, qwik, sveltekit, unocss, vite-environment-examples, vite-plugin-pwa, vite-plugin-react, vite-plugin-react-swc, vite-plugin-vue, vite-setup-catalogue, vitest, vuepress |
The fallback does not seem to be working
@@ -753,9 +756,38 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin { | |||
// normalize and rewrite accepted urls | |||
const normalizedAcceptedUrls = new Set<string>() | |||
for (const { url, start, end } of acceptedUrls) { | |||
const [normalized] = await moduleGraph.resolveUrl(toAbsoluteUrl(url)) | |||
let [normalized, resolvedId] = await normalizeUrl(url, start) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not taken a deeper look, but my guess is that this normalizeUrl
throws an error when it fails to resolve, which is why the fallback isn't working.
Description
fixes #12912
fixes #16375
this is the most basic to get it working. There are more issues regarding this, like having multiple modules in the module graph. one for
0virtual:file
and another for/@id/__00__/virtual:file