fix(vite): start HMR graph population after every plugin's configureServer - #11479
Merged
Merged
Conversation
…erver Population kicked off inside the HMR plugin's own configureServer, so its transforms could run while a later plugin's configureServer was still pending. @vitejs/plugin-vue only receives the dev server there: SFCs it compiled earlier split their TS script into a separate sub-request (and omit HMR accept code), the result is cached, and the graph records no .vue -> .ts edges, so plain .ts edits intermittently stopped reaching their .vue screens. Population now starts from a configureServer post hook.
|
View your CI Pipeline Execution ↗ for commit 2255b41
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
What is the current behavior?
Follow-up to #11478. On 8.0.15, plain
.tsedits in a nativescript-vue app hot-update only intermittently. In a failing session, the HMR graph records each.vuescreen with only 3 deps: its own?vue&type=scriptsub-request, the export helper andnativescript-vue. The real script imports (music.ts,appearance.ts) are missing, so the client's boundary walk finds no.vueto reload.Cause:
populateInitialGraphwas started inside the HMR plugin's ownconfigureServer. Vite awaits each plugin'sconfigureServerin order, and Vite'stransformRequesthas no startup guard. So when a plugin between ours and@vitejs/plugin-vuehas an asyncconfigureServer(the vue config's type-check plugins), populate transforms SFCs before plugin-vue'sconfigureServersetsoptions.devServer. WithoutdevServer, plugin-vue:lang="ts"script (canInlineMain), so its imports live on an untransformed sub-request that the graph never sees;import.meta.hot.acceptcode;What is the new behavior?
Graph population starts from a
configureServerpost hook, which Vite runs only after every plugin'sconfigureServer. It still gets the whole build/launch window as a head start.NS_VITE_HMR_DISABLE_POPULATEbehaves as before.Tests:
hmr/server/websocket-populate-order.spec.tsstarts a real dev server with the HMR plugin, a plugin with a slow asyncconfigureServer, and a probe plugin. It asserts no app module is transformed before the probe'sconfigureServerruns, and that the walk still transforms the app module afterwards. The test fails onmain, whereprobe.tsis transformed while the slow plugin is still configuring.Verified on the iOS simulator:
.vue→.tsedges and reload screens in place on a.tsedit. The released 8.0.15 missed them..html/.ts/.tsx/.cssedits unchanged, and the graph populates as before.