Skip to content

fix(vue-start): pre-bundle @tanstack/vue-store so a cold dev start doesn't reload the page - #8869

Merged
Sheraff merged 1 commit into
mainfrom
vue-start/prebundle-vue-store
Nov 4, 2026
Merged

Sheraff merged 1 commit into
mainfrom
vue-start/prebundle-vue-store

Conversation

@Sheraff

@Sheraff Sheraff commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

What

Vue Start excludes @tanstack/vue-router from Vite's dependency optimization, so the scanner never sees the router's @tanstack/vue-store import. The first page load on a cold dependency cache discovers it late. It imports vue, so Vite re-chunks the already optimized vue, logs optimized dependencies changed. reloading, and reloads the page. That happens on every cold start.

The fix declares @tanstack/vue-router > @tanstack/vue-store in optimizeDeps.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's start-app.ts doesn't drive a browser;
  • the e2e/vue-start apps 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, with vite dev on an empty node_modules/.vite each time. A Playwright script opens / and counts load events until 8 s pass without one:

run main this PR
Vite log dependencies optimized: @tanstack/vue-store, cookie-es, seroval-plugins/web, then optimized dependencies changed. reloading (3/3) dependencies optimized: cookie-es, seroval-plugins/web, no reload (3/3)
page loads 2, 1, 2 1, 1, 1

In the main run with a single load, the reload was announced before the page's HMR client connected. cookie-es and seroval-plugins/web are 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;
  • vue-start: test:build passes (it's the package's only test target);
  • tanstack-vue-start-e2e-dev-ssr-styles:test:e2e (vite dev, normal and bundled dev) passes;
  • bundle size: not run. optimizeDeps applies 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.ts merges to #8817's exact text.

After that, #8817 should drop:

  • from .changeset/dev-cold-start-and-invalidate-index.md: the sentence "Vue Start declares @tanstack/vue-router > @tanstack/vue-store for the optimizer, … so a cold start no longer reloads the page once.", and the '@tanstack/vue-start': patch line, since nothing else in that changeset concerns vue-start;
  • from its description: "Vue Start dev no longer reloads after dependency optimization."

Its start-dev-cold-start.test.ts stays: it's the only test, and it also covers the /hmr half.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • On a cold dependency cache, the first page load no longer re-optimizes Vue dependencies and reloads the page. Vue Start now pre-bundles the relevant Vue Router and Vue Store dependencies when client-side optimization is enabled, or when server-side optimization is opted into. This makes the initial page load more stable in those configurations.

…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-bot

changeset-bot Bot commented Nov 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1ec10c7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@tanstack/vue-start Patch

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

@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Vue Start now includes @tanstack/vue-router > @tanstack/vue-store in Vite dependency optimization for the client or an opted-in server environment. A patch changeset records the update and its stated effect on cold-cache first page loads.

Changes: Vue Store Pre-bundling

Layer / File(s) Summary
Dependency optimization and release note
packages/vue-start/src/plugin/vite.ts, .changeset/vue-start-prebundle-vue-store.md
Vite includes @tanstack/vue-router > @tanstack/vue-store in dependency optimization under the existing environment condition. The changeset records a patch release and the stated cold-cache effect.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: Minimal · up to 1ec10

No merge-blocking defect was identified in this dependency optimization change.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title names the fix (pre-bundling @tanstack/vue-store in vue-start) and the symptom it addresses (a cold dev start reloading the page). This matches the changeset and the code change, which adds @…
Description check Passed The description follows the template structure. It has a detailed What section explaining the cause and fix, and it gives evidence through a manual before-and-after table and validation steps. It disc…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the fix (pre-bundling @tanstack/vue-store in vue-start) and the symptom it addresses (a cold dev start reloading the page). This matches the changeset and the code change, which adds @tanstack/vue-router > @tanstack/vue-store to optimizeDeps.include in packages/vue-start/src/plugin/vite.ts. The title is specific and relevant, though it is slightly long at 90 characters.

Full details: Description check

Explanation

The description follows the template structure. It has a detailed What section explaining the cause and fix, and it gives evidence through a manual before-and-after table and validation steps. It discloses no AI authorship. It does state 'Generated with Claude Code' in the footer, which covers the AI-authorship disclosure rule. The Checklist and Release Impact sections are not filled in: no boxes are ticked, and it does not say whether a changeset was generated, although the raw summary shows a changeset was added. The description also does not explicitly tick the contributing guide or local testing items. These are minor gaps, and the core content is complete.

Resolution

Tick the checklist items the author has completed, including the contributing guide and local testing items. In Release Impact, tick the box for a published change with a generated changeset, since .changeset/vue-start-prebundle-vue-store.md is included in the PR.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files. (1 skipped: 1 unsupported.)

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share
Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 1ba19a0 and 1ec10c7.

Files selected for processing: 2
  • .changeset/vue-start-prebundle-vue-store.md
  • packages/vue-start/src/plugin/vite.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

@nx-cloud

nx-cloud Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 1ec10c7

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 3m 57s View ↗

☁️ Nx Cloud last updated this comment at 2026-11-04 11:44:10 UTC

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

9 package(s) bumped directly, 2 bumped as dependents.

🟨 Minor bumps

Package Version Reason
@tanstack/router-cli 1.167.46 → 1.168.0 Changeset
@tanstack/router-generator 1.167.46 → 1.168.0 Changeset
@tanstack/router-plugin 1.168.48 → 1.169.0 Changeset
@tanstack/router-utils 1.162.4 → 1.163.0 Changeset

🟩 Patch bumps

Package Version Reason
@tanstack/react-start 1.169.4 → 1.169.5 Changeset
@tanstack/react-start-client 1.168.44 → 1.168.45 Changeset
@tanstack/solid-start 1.169.4 → 1.169.5 Changeset
@tanstack/start-plugin-core 1.171.55 → 1.171.56 Changeset
@tanstack/vue-start 1.169.4 → 1.169.5 Changeset
@tanstack/react-start-rsc 0.1.65 → 0.1.66 Dependent
@tanstack/router-vite-plugin 1.167.48 → 1.167.49 Dependent

@pkg-pr-new

pkg-pr-new Bot commented Nov 4, 2026

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/@tanstack/arktype-adapter@8869

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@8869

@tanstack/eslint-plugin-start

npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@8869

@tanstack/history

npm i https://pkg.pr.new/@tanstack/history@8869

@tanstack/react-router

npm i https://pkg.pr.new/@tanstack/react-router@8869

@tanstack/react-router-devtools

npm i https://pkg.pr.new/@tanstack/react-router-devtools@8869

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@8869

@tanstack/react-start

npm i https://pkg.pr.new/@tanstack/react-start@8869

@tanstack/react-start-client

npm i https://pkg.pr.new/@tanstack/react-start-client@8869

@tanstack/react-start-rsc

npm i https://pkg.pr.new/@tanstack/react-start-rsc@8869

@tanstack/react-start-server

npm i https://pkg.pr.new/@tanstack/react-start-server@8869

@tanstack/router-cli

npm i https://pkg.pr.new/@tanstack/router-cli@8869

@tanstack/router-core

npm i https://pkg.pr.new/@tanstack/router-core@8869

@tanstack/router-devtools

npm i https://pkg.pr.new/@tanstack/router-devtools@8869

@tanstack/router-devtools-core

npm i https://pkg.pr.new/@tanstack/router-devtools-core@8869

@tanstack/router-generator

npm i https://pkg.pr.new/@tanstack/router-generator@8869

@tanstack/router-plugin

npm i https://pkg.pr.new/@tanstack/router-plugin@8869

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@8869

@tanstack/router-utils

npm i https://pkg.pr.new/@tanstack/router-utils@8869

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/@tanstack/router-vite-plugin@8869

@tanstack/solid-router

npm i https://pkg.pr.new/@tanstack/solid-router@8869

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/@tanstack/solid-router-devtools@8869

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@8869

@tanstack/solid-start

npm i https://pkg.pr.new/@tanstack/solid-start@8869

@tanstack/solid-start-client

npm i https://pkg.pr.new/@tanstack/solid-start-client@8869

@tanstack/solid-start-server

npm i https://pkg.pr.new/@tanstack/solid-start-server@8869

@tanstack/start-client-core

npm i https://pkg.pr.new/@tanstack/start-client-core@8869

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/@tanstack/start-fn-stubs@8869

@tanstack/start-plugin-core

npm i https://pkg.pr.new/@tanstack/start-plugin-core@8869

@tanstack/start-server-core

npm i https://pkg.pr.new/@tanstack/start-server-core@8869

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/@tanstack/start-static-server-functions@8869

@tanstack/start-storage-context

npm i https://pkg.pr.new/@tanstack/start-storage-context@8869

@tanstack/valibot-adapter

npm i https://pkg.pr.new/@tanstack/valibot-adapter@8869

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/@tanstack/virtual-file-routes@8869

@tanstack/vue-router

npm i https://pkg.pr.new/@tanstack/vue-router@8869

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/@tanstack/vue-router-devtools@8869

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@8869

@tanstack/vue-start

npm i https://pkg.pr.new/@tanstack/vue-start@8869

@tanstack/vue-start-client

npm i https://pkg.pr.new/@tanstack/vue-start-client@8869

@tanstack/vue-start-server

npm i https://pkg.pr.new/@tanstack/vue-start-server@8869

@tanstack/zod-adapter

npm i https://pkg.pr.new/@tanstack/zod-adapter@8869

commit: 1ec10c7

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Benchmarks

This pull request does not affect bundle size in any measured scenario.

@codspeed

codspeed Bot commented Nov 4, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 3.58%

2 warnings

⚠️ 58 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚠️ 2 benchmarks with a significant change ran on different hardware

Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

⚡ 2 improved benchmarks
✅ 192 untouched benchmarks
⏩ 3 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ Memory mem client unique-location-churn (react) 79.3 KB 76.5 KB +3.7%
⚡ Memory mem client navigation-churn (solid) 108.5 KB 104.9 KB +3.46%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing vue-start/prebundle-vue-store (1ec10c7) with main (1ba19a0)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@Sheraff
Sheraff merged commit d05c6c6 into main Nov 4, 2026
28 of 29 checks passed
@Sheraff
Sheraff deleted the vue-start/prebundle-vue-store branch November 4, 2026 12:38
Sheraff added a commit that referenced this pull request Nov 8, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant