Skip to content

feat(bolt-vite-react-ts): upgrade to vite 7 - #134

Open
sheepsteak wants to merge 3 commits into
mainfrom
chris/bolt-vite-react-ts-vite-7
Open

sheepsteak wants to merge 3 commits into
mainfrom
chris/bolt-vite-react-ts-vite-7

Conversation

@sheepsteak

@sheepsteak sheepsteak commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Problem

bolt-vite-react-ts is on Vite 5 (vite ^5.4.2). Vite 8 is ready in #132, but inside WebContainer its first dev start is about 6.5s slower than Vite 5: Rolldown downloads @rolldown/binding-wasm32-wasi on every new boot. That needs a platform fix before Vite 8 is a good default.

Solution

Move the template to Vite 7.3.7, the latest 7.x. Vite 7 still bundles with esbuild and Rollup, so it does not hit the Rolldown WASM download. React 18, Tailwind 3 with PostCSS, ESLint, TypeScript, and vite.config.ts stay as they are.

@vitejs/plugin-react moves from ^4.3.1 to ^5.1.1, the range in Vite's own Vite 7 React TypeScript template. The lockfile resolves 5.2.0. v5 still transforms with Babel. The Oxc plugin is v6, which is the Vite 8 line.

Implementation Details

  • Lockfile regenerated with the repo's pinned npm 10.2.3. Vite 7.3.7 pulls in esbuild 0.28 and Rollup 4.64. It depends on postcss ^8.5.6, so the lockfile resolves postcss 8.5.30. The declared range ^8.4.35 already allows that.
  • Node requirement for Vite 7 is ^20.19.0 || >=22.12.0. WebContainer's Node 22.22.3 satisfies it.
  • The dev preview test now checks the page inside the preview iframe. preview.getByText() and preview.getByRole() from @webcontainer/test never enter the iframe and do not wait, so the old test passed with no server running. The preview is cross-origin, so the wait runs through Playwright (page.frameLocator plus a waitForVisible browser command).
  • The test no longer uses setup(). Restoring that snapshot drops the executable bit on node_modules/vite/bin/vite.js, and npm run dev then fails with spawn vite EACCES while jsh still exits 0. beforeEach mounts and installs instead. Asset names are sorted before the snapshot compare, because readdir order is not stable.

Performance in WebContainer

Rerun after the @vitejs/plugin-react 5.2.0 bump. Vite 7 is faster than Vite 5 on dev and build in this batch. Install is slower. It does not have the Vite 8 cold-start cost from #132.

Phase (median) Vite 5.4.8 Vite 7.3.7 vs Vite 5
npm install 2.77s (2.69-7.54) 3.18s (2.56-5.17) +15%
Cold npm run dev to styled first render 3.60s (2.88-5.52) 2.41s (2.33-2.79) -33%
Vite "ready in" on cold start 1.14s (0.79-2.97) 0.84s (0.74-0.92) -26%
HMR (new JSX plus a new Tailwind class) 66ms (54-91) 47ms (45-107) -28%
Dev server restart to styled render 2.41s (1.92-2.81) 1.63s (1.53-2.65) -33%
npm run build (wall clock) 2.62s (1.91-6.50) 2.00s (1.87-2.14) -24%
Vite "built in" 744ms (711-2750) 678ms (671-870) -9%

Method matches #132: @webcontainer/test with Vitest browser mode in headless Chromium on an Apple Silicon Mac, Oct 14 2026. Each run launches a fresh Chromium and boots a fresh WebContainer. 5 runs per version, alternating which one goes first. "Styled first render" is a Playwright wait inside the preview iframe until the starter text is present and Tailwind's bg-gray-100 is the computed background. Parentheses are min-max.

Vite 7's five cold renders stayed between 2.33s and 2.79s. Vite 5 was wider: one install took 7.5s, one cold render took 5.5s, and one build took 6.5s wall (Vite reported 2.75s). An earlier run of this comparison, before the plugin bump (plugin-react 4.7.0), was tighter and the gap was smaller: cold styled render 2.35s vs 2.16s. Absolute times moved between the two runs, so the percentage gap here should not be read as the plugin upgrade itself being 30% faster. Neither side downloaded a Rolldown binding (0 of 5 runs). Vite 7 installed the esbuild and Rollup native packages, same as Vite 5, plus @rolldown/pluginutils only. No WASI warning in dev or build output.

Test plan

  • npm ci, npm run build, npm run typecheck, tsc --noEmit -p tsconfig.node.json, and npm run lint in bolt-vite-react-ts
  • test/bolt-vite-react-ts.test.ts in Chromium: production build, and the dev preview renders and updates on edit
  • WebContainer timing compared against Vite 5 (see above)
  • Firefox test project
  • New Bolt project from this template

Vite 8's Rolldown binding downloads on every WebContainer boot. Vite 7
stays on esbuild and Rollup, so ship that while the platform fix is open.
preview.getByText() never enters the preview iframe, and restoring the
setup() snapshot drops the executable bit on vite's bin. Wait from
Playwright's side and install in beforeEach instead.
@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@vitejs/plugin-react 5 is what the Vite 7 create-vite template ships.
It still transforms with Babel. The Oxc plugin is v6, for Vite 8.
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