Repository navigation
serve: port serve-web from Vite to Rsbuild - #1009
Merged
Merged
Conversation
serve-web was the last frontend in the monorepo building with Vite; src/app builds with Rsbuild and website with Rspress, and serve-web's tests already moved to Rstest during the Jest migration. Carrying the second bundler meant a second dependency tree, a second set of wasm/top-level-await workarounds, and divergent sideEffects/resolution semantics at exactly the boundary where the diagram-CSS contract is invisible to unit tests. The Rsbuild config preserves Vite's 'base: ./' via output.assetPrefix so the SPA stays relocatable under any mount path. The flat distPath layout is load-bearing for that: Rspack builds runtime asset URLs as publicPath + output-relative path resolved against the referencing context (the worker script's own URL inside the engine's Web Worker), so nesting chunks under static/js/ would make the worker resolve the WASM blob to static/js/static/wasm/. rspack's asyncWebAssembly handles the engine's ESM wasm import natively, replacing vite-plugin-wasm and vite-plugin-top-level-await; a local globals.d.ts CSS-module declaration replaces vite/client's. Verified in-browser against the rebuilt serve binary: editor renders teacup.xmile, the engine worker spawns, the simulation runs (sparkline plus full series in variable details), theme tokens and katex CSS land in the bundle, and the dist serves correctly from a subpath. Also drops the now-stale vite mentions from the deploy tooling comments and fixes the stale 'Vite + Jest' line in the serve CLAUDE.md.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1009 +/- ##
=======================================
Coverage 91.86% 91.86%
=======================================
Files 247 247
Lines 159159 159159
=======================================
+ Hits 146207 146210 +3
+ Misses 12952 12949 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Review: serve: port serve-web from Vite to RsbuildReviewed the bundler swap end-to-end (config, package manifest, tsconfig, index.html, tests, docs, and the rust-embed layout contract). No blocking issues found. The change is well-scoped and the config comments are thorough:
The author has manually verified worker/WASM resolution and subpath serving in a real browser -- the failure modes unit tests cannot see. Overall correctness: correctThe patch should not break existing code or tests. No bugs identified. |
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.
Fixes #901
Ports
src/simlin-serve/webfrom Vite to Rsbuild, removing the monorepo's second bundler (vite,@vitejs/plugin-react,vite-plugin-wasm,vite-plugin-top-level-awaitall drop out of the lockfile).Design notes
output.assetPrefix: './'preserves Vite'sbase: './'so the SPA stays relocatable under any mount path (the Rust binary embeds it at/; a proxy can mount it elsewhere).distPathlayout is load-bearing for that relative prefix, not cosmetic: Rspack builds runtime asset URLs aspublicPath + <output-relative path>, resolved against the referencing context's base URL — the document on the main thread, but the worker script's own URL inside the engine's Web Worker. Nesting chunks understatic/js/would make the worker resolve the WASM blob tostatic/js/static/wasm/.... Putting every chunk at the dist root mirrors the flatassets/directory Vite emitted, and is documented in the config.experiments.asyncWebAssembly(same setup assrc/app's rsbuild config) handles@simlin/engine's ESM-integration wasm import natively, replacing both Vite plugins.globals.d.tsdeclare module '*.css'replaces the declarationvite/clientused to provide (mirrorssrc/app/globals.d.ts).@simlin/engine's webpack-vs-vite bundler-detection branches are untouched — they exist for external consumers of the published package (out of scope per the issue).dist/index.*.cssat the root rather thandist/assets/index-*.css).Verification
Beyond the unit/lint/tsc gates, verified against the rebuilt
simlin-servebinary in a real browser, since worker/wasm resolution is exactly what unit tests can't see:teacup.xmile; the engine worker spawns and the simulation runs (stock sparkline + full series in the variable-details chart), with zero console errors;@simlin/diagramtheme tokens and katex CSS both land in the emitted CSS (the rsbuild/rspack tree-shakes reset.css side-effect import out of src/app production CSS bundle #708/build: no dist-level smoke check that @simlin/diagram CSS (theme.css/reset.css) lands in serve-web bundle #828 side-effect contract survived the bundler swap);dist/is served from a subpath, confirming the relative-URL property still holds.Also updates the now-stale Vite references: CI step comments, deploy-tooling comment lists,
docs/dev/deploy.md,docs/tech-debt.md, and fixes the stale "React 19 + Vite + Jest" line insrc/simlin-serve/CLAUDE.md.