Repository navigation
Description
Problem
src/simlin-serve/web is the only frontend in the monorepo that builds with Vite. src/app builds with Rsbuild (src/app/config/rsbuild/{rsbuild.config.js,rsbuild.component.config.js,shared.config.js}), and website builds with Rspress (also Rspack-based). serve-web carries its own bundler:
src/simlin-serve/web/vite.config.ts- devDependencies:
vite ^7.0.0,@vitejs/plugin-react ^5.2.0,vite-plugin-wasm ^3.6.0,vite-plugin-top-level-await ^1.6.0
Carrying two bundlers means two dependency trees, two plugin ecosystems, two sets of wasm/top-level-await workarounds, and two places to keep asset/publicPath behavior in sync. The repo owner considers this a bug ("IMO simlin-serve using vite instead of rsbuild is a bug").
Why it matters
- Maintainability / supply chain: a whole second bundler dependency tree exists to build one SPA. The deploy-staging tooling already calls this out as bloat it has to work around --
scripts/deploy-web-staged.sh,scripts/build-deploy-staging.mjs, andscripts/deploy-staging-manifests.mjsall namevitein the list of workspace deps that GAE would otherwise install (see also thepnpm deploy:webinstall-bloat entry indocs/tech-debt.md). - Divergent semantics at exactly the wrong boundary: bundler differences in
sideEffectshandling and module resolution are a live failure mode here, not a hypothetical. rsbuild/rspack tree-shakes reset.css side-effect import out of src/app production CSS bundle #708 was an rspack-specific CSS side-effect drop insrc/app; build: nothing checks that diagram CSS reaches the serve bundle #828 exists precisely because the diagram-CSS contract crossessrc/diagram-> builtlib.browser/-> serve-web's Vite bundle, where unit tests can't see it. One bundler means one set of semantics to reason about. - The toolchain is already half-converged: after the Jest -> Rstest migration, serve-web's tests run on Rstest (Rspack-based) via
src/simlin-serve/web/rstest.config.mts, while its build still runs on Vite. Rstest was chosen over Vitest partly to avoid entrenching the second bundler (Vitest hard-depends on Vite). Finishing the job removes the split.
Current state
src/simlin-serve/web/rstest.config.mts-- tests on Rstest (Rspack).src/simlin-serve/web/vite.config.ts-- still drivespnpm dev/pnpm build.src/simlin-serve/web/tsconfig.json-- still declares"types": ["vite/client"]andincludesvite.config.ts.src/simlin-serve/CLAUDE.md:55-- "React 19 + Vite + Jest". Already stale on Jest; would become fully stale on Vite..github/workflows/ci.yaml(~lines 380-390) -- the "Build embedded SPA" step's comments are written in terms ofvite buildand what it does/doesn't build.src/simlin-serve/build.rs-- shells topnpmto produceweb/dist/forrust-embed; it invokes the package'sbuildscript, so it is bundler-agnostic as long as the output stays atweb/dist/.
Components affected
src/simlin-serve/web(build config,package.json,tsconfig.json)src/simlin-serve(CLAUDE.md;build.rsonly if the output dir changes).github/workflows/ci.yaml(comments; the step itself should keep working as-is)
Proposed fix
Port src/simlin-serve/web/vite.config.ts to an Rsbuild config, mirroring src/app/config/rsbuild/.
Notes for whoever picks it up:
- Rsbuild 2 is already in the repo (
@rsbuild/core ^2.1.5,@rsbuild/plugin-react ^2.1.0,@rsbuild/plugin-type-check ^1.5.0insrc/app/package.json). - The two Vite plugins exist because
@simlin/engine's browser entry importslibsimlin.wasmvia the "ESM integration proposal for Wasm" syntax (see the comment invite.config.ts). Rspack supports this throughexperiments.asyncWebAssembly/experiments.topLevelAwait, sovite-plugin-wasmandvite-plugin-top-level-awaitshould drop out. - Preserve
base: './'(relative asset URLs, so the SPA can be served from any subpath when the Rust binary embeds it at/or a proxy mounts it elsewhere). The Rsbuild equivalent isoutput.assetPrefix: './'. - Preserve the worker config: the current Vite config sets
worker.format: 'es'and re-applies both plugins to the worker pipeline.@simlin/enginespawns a module worker, andworker-trampoline.ts/backend-factory.browser.tshave explicit webpack-vs-vite branches -- verify the worker still resolves and bundles under Rspack (new URL(..., import.meta.url)detection). - Keep the output at
dist/(Vitebuild.outDir-> Rsbuildoutput.distPath.root), sincebuild.rsandrust-embedexpectweb/dist/. - Then remove
vite,@vitejs/plugin-react,vite-plugin-wasm,vite-plugin-top-level-awaitfrom devDependencies; drop"types": ["vite/client"]fromtsconfig.jsonand swap theincludeofvite.config.tsfor the new config; updatesrc/simlin-serve/CLAUDE.mdin the same change (fix the stale "Jest" while there).
Out of scope
@simlin/engine is a published package ("name": "@simlin/engine", v2.0.0, not private), and src/engine/README.md documents vite-plugin-wasm / top-level-await for downstream consumers. Its bundler-detection branches (backend-factory.browser.ts, worker-trampoline.ts, engine-worker.ts) support both webpack and Vite for external callers and should stay even after serve-web stops using Vite.
Interaction with #828
#828 proposes a dist-level CSS smoke check that greps src/simlin-serve/web/dist/assets/index-*.css -- a Vite output-naming convention. Whoever lands either issue should keep the other in mind: under Rsbuild the emitted CSS filename/path changes (static/css/* by default). If #828 lands first, this port must update its glob; if this port lands first, #828 should be written against the Rsbuild layout.
How it was discovered
Noted during the Jest -> Rstest migration (branch typescript-7-migration), which converged serve-web's test runner onto Rspack and left the build as the last Vite holdout.
Activity