Skip to content

fix(vite): start HMR graph population after every plugin's configureServer - #11479

Merged
NathanWalker merged 1 commit into
mainfrom
fix/vite-populate-after-configure
Sep 30, 2026
Merged

NathanWalker merged 1 commit into
mainfrom
fix/vite-populate-after-configure

Conversation

@NathanWalker

Copy link
Copy Markdown
Contributor

PR Checklist

What is the current behavior?

Follow-up to #11478. On 8.0.15, plain .ts edits in a nativescript-vue app hot-update only intermittently. In a failing session, the HMR graph records each .vue screen with only 3 deps: its own ?vue&type=script sub-request, the export helper and nativescript-vue. The real script imports (music.ts, appearance.ts) are missing, so the client's boundary walk finds no .vue to reload.

Cause: populateInitialGraph was started inside the HMR plugin's own configureServer. Vite awaits each plugin's configureServer in order, and Vite's transformRequest has no startup guard. So when a plugin between ours and @vitejs/plugin-vue has an async configureServer (the vue config's type-check plugins), populate transforms SFCs before plugin-vue's configureServer sets options.devServer. Without devServer, plugin-vue:

  • does not inline a lang="ts" script (canInlineMain), so its imports live on an untransformed sub-request that the graph never sees;
  • omits the import.meta.hot.accept code;
  • caches that compiled script per descriptor, so the dev server keeps serving it.

What is the new behavior?

Graph population starts from a configureServer post hook, which Vite runs only after every plugin's configureServer. It still gets the whole build/launch window as a head start. NS_VITE_HMR_DISABLE_POPULATE behaves as before.

Tests: hmr/server/websocket-populate-order.spec.ts starts a real dev server with the HMR plugin, a plugin with a slow async configureServer, and a probe plugin. It asserts no app module is transformed before the probe's configureServer runs, and that the walk still transforms the app module afterwards. The test fails on main, where probe.ts is transformed while the slow plugin is still configuring.

Verified on the iOS simulator:

  • nativescript-vue: 3 of 3 cold runs record the .vue → .ts edges and reload screens in place on a .ts edit. The released 8.0.15 missed them.
  • Angular, Solid and Octane: .html/.ts/.tsx/.css edits unchanged, and the graph populates as before.

…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.
@nx-cloud

nx-cloud Bot commented Sep 30, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 2255b41

Command Status Duration Result
nx run-many --target=test --configuration=ci --... ✅ Succeeded <1s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-09-30 00:05:31 UTC

@NathanWalker
NathanWalker merged commit 282205d into main Sep 30, 2026
3 of 8 checks passed
@NathanWalker
NathanWalker deleted the fix/vite-populate-after-configure branch September 30, 2026 00:07
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.

1 participant