Commit c786f5f
⚡️ perf(console): build 85s→11.5s & peak RSS 4.3GB→1.7GB via Vite 8 (Rolldown) (#99)
## New features / improvements
- **Production build: 85s → 11.5s wall (vite: 8.2s), peak RSS 4.3GB → 1.72GB.** Migrated `vite` ^5.2.0 → **^8.0.16** (Rolldown-native bundler), `@vitejs/plugin-react` ^4 → ^6, `vite-plugin-pwa` ^1.2 → ^1.3. No app code changes.
- **Build script is plain `vite build` again** — the `node --max-old-space-size=4096` OOM guard is obsolete at 1.7GB peak. This also unblocks the console CI `build` job that was OOM-killed (exit 137) on the act runner.
- **Hash-stable service-worker precache exclusion**: every chunk containing `@stlite` prebuilt modules now gets a deterministic `stlite-` filename prefix (`build.rollupOptions.output.chunkFileNames`), and the three per-name workbox `globIgnores` patterns collapse to one `**/stlite-*.js`. The old hash-coupled patterns (`PlotlyChart-*` etc.) actually broke under Rolldown's chunking — its renamed stlite index chunk tripped workbox's 2MiB precache hard error.
## Root cause (why the build was slow)
App source is tiny (240 files / 2.3MB); the cost was dependency re-bundling, dominated by one package: `@stlite/browser` ships **52MB of prebuilt, already-minified Streamlit JS** (Plotly 7.4MB, index 4.1MB, DeckGL 3.5MB). Importing `@stlite/react` makes the bundler re-parse + re-minify all of it every build — `React.lazy` defers runtime loading, not build work. A control build with `@stlite/react` stub-aliased measured 24s/2.0GB, i.e. stlite alone was ~72% of build time and ~2.3GB of memory. Rolldown absorbs the whole graph natively.
## Stability / traps encoded
- `build.cssMinify: "esbuild"` pinned: Vite 8's new lightningcss default hard-errors (`Unexpected token Delim('$')`) on Tailwind's verbatim scan of the `shadow-[var(--${opts.elevation})]` template literal in `composer-shell.tsx`.
- vitest 1.6 is insulated from the major bump — it keeps its own nested `vite@5.4.21` dependency; lockfile regenerated cleanly.
- `apps/mewbo_console/CLAUDE.md` PWA section updated to the new `stlite-*` globIgnore contract.
## Validation
- Build: 11.5s wall / 1.72GB peak RSS (`/usr/bin/time -v`), repeated runs consistent
- Dist parity: `index.html`, `sw.js`, `manifest.webmanifest` present; **0** stlite chunks in the precache manifest (204 entries / 7.7MB vs baseline 279 / 13.7MB — the delta is the now-fully-excluded lazy stlite chunks)
- `tsc --noEmit` clean, `eslint` clean, **328 vitest tests pass** (4 skipped), dev server ready in 246ms
- Caveat: output parity verified structurally (chunks, SW precache, manifest) — a visual pass on a deployed console, especially mounting a stlite widget, is worth doing before redeploy.
---------
Co-authored-by: mewbo-ai[bot] <mewbo-ai@mewbo.com>
Reviewed-on: https://git.hurricane.home/bearlike/Assistant/pulls/991 parent b7ab930 commit c786f5f
4 files changed
Lines changed: 3134 additions & 2656 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
255 | | - | |
| 255 | + | |
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
| |||
0 commit comments