Repository navigation
fix(vue-start): pre-bundle @tanstack/vue-store so a cold dev start doesn't reload the page - #8869
Conversation
…esn't reload Vue Start excludes `@tanstack/vue-router` from optimization, so Vite's scanner never sees its `@tanstack/vue-store` import. Discovered while the first page loads, it imports `vue` and re-chunks the already optimized `vue`: Vite logs "optimized dependencies changed. reloading" and reloads the page on every cold start. Declare it through `optimizeDeps.include`, as React Start does for `@tanstack/react-store`. From #8817. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 1ec10c7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
View your CI Pipeline Execution ↗ for commit 1ec10c7
☁️ Nx Cloud last updated this comment at |
🚀 Changeset Version Preview9 package(s) bumped directly, 2 bumped as dependents. 🟨 Minor bumps
🟩 Patch bumps
|
Bundle Size BenchmarksThis pull request does not affect bundle size in any measured scenario. |
Merging this PR will improve performance by 3.58%2 warnings
Performance Changes
Tip Curious why performance improved? Comment Comparing Footnotes
|
main c156097: #8858, #8863, #8805, #8269, #8866, #8867, #8868, #8869, #8870, #8871, #8876, #8888, #8889, #8890, #8892, Version Packages (#8854, #8891) and docs. - #8817's side and deletions throughout (Babel compilers, start-compiler, add-hmr, start-app.ts, server-fn-id-check.ts, router-utils ast.ts). The lines main changed for #8863, #8866, #8868, #8269 and #8889/#8892 stay #8817's here: their fixes follow as separate commits after the tests that reproduce them. - @rsbuild/core 2.3.1 (#8890) in the catalog, the examples and benchmarks/compiler-perf; Start's peers keep #8817's ^2.2.13 floor. Lockfile and e2e/react-start/basic's route tree regenerated. - Tests: main's start-vite-root, start-rsbuild-root, rsbuild server-compress and router-plugin production-warnings tests are replaced by their ports in the harness (start-build-roots, dev-server-config, production-bundle); main's start-dev-restart test is ported to the dev-server harness and replaces resolve-entries.test.ts (internals). #8817's Rsbuild SPA dev case gives way to main's spa-shell e2e. The route HMR `hot` binding test gains main's unsplit case (#8870). - KNOWN-BUGS: main fixed decorators after `export` (#8867) and the Rsbuild sibling-route manifest (#8780, #8876). - Changesets: drop what main ships now (custom server-fn ids, the Rsbuild manifest and SPA/compress items, exsolve, Vue store pre-bundling, falsy `use` entries, `.ts` route HMR). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
Vue Start excludes
@tanstack/vue-routerfrom Vite's dependency optimization, so the scanner never sees the router's@tanstack/vue-storeimport. The first page load on a cold dependency cache discovers it late. It importsvue, so Vite re-chunks the already optimizedvue, logsoptimized dependencies changed. reloading, and reloads the page. That happens on every cold start.The fix declares
@tanstack/vue-router > @tanstack/vue-storeinoptimizeDeps.include, as React Start does for@tanstack/react-store. The change comes from #8817 (packages/vue-start/src/plugin/vite.ts). It's only the Vue half of #8817's cold-start fix. The other half, Start no longer pre-bundling@tanstack/<framework>-router/hmr, concerns a subpath that only exists in #8817.Evidence (no automated test on main)
The behaviour depends on Vite's optimizer state: a cold
node_modules/.vite, a real browser crawling the module graph, and a count of document loads. main has no harness for that:start-plugin-core'sstart-app.tsdoesn't drive a browser;e2e/vue-startapps run with whatever cache the previous run left, and their first test would carry the assertion, so it would depend on test order.A unit test checking that the config contains the string would only restate the change. #8817 tests the behaviour in
start-plugin-core/tests/integration/start-dev-cold-start.test.ts("vue: the page hydrates in the document it first loaded"), on its own browser and dev-server harness. That stays the single test.Manual check on
e2e/vue-start/basic, withvite devon an emptynode_modules/.viteeach time. A Playwright script opens/and countsloadevents until 8 s pass without one:dependencies optimized: @tanstack/vue-store, cookie-es, seroval-plugins/web, thenoptimized dependencies changed. reloading(3/3)dependencies optimized: cookie-es, seroval-plugins/web, no reload (3/3)In the main run with a single load, the reload was announced before the page's HMR client connected.
cookie-esandseroval-plugins/webare still discovered late, but they don't re-chunk anything, so no reload.Validation
Run locally with Node 26.12.1, a frozen install, through Nx:
pnpm format;test:buildpasses (it's the package's only test target);tanstack-vue-start-e2e-dev-ssr-styles:test:e2e(vite dev, normal and bundled dev) passes;optimizeDepsapplies only to the dev server.Merging into #8817
Merging this branch into #8817's head adds no conflicts to the ones main already has:
vue-start/src/plugin/vite.tsmerges to #8817's exact text.After that, #8817 should drop:
.changeset/dev-cold-start-and-invalidate-index.md: the sentence "Vue Start declares@tanstack/vue-router > @tanstack/vue-storefor the optimizer, … so a cold start no longer reloads the page once.", and the'@tanstack/vue-start': patchline, since nothing else in that changeset concerns vue-start;Its
start-dev-cold-start.test.tsstays: it's the only test, and it also covers the/hmrhalf.🤖 Generated with Claude Code
Summary by CodeRabbit