build(frontend): upgrade rsbuild to 2.2.1 - #2613
Conversation
malinskibeniamin
left a comment
There was a problem hiding this comment.
Automated /review: 9 finding(s).
These findings could not be anchored to a changed line:
- P1
frontend/bun.lock:400— Duplicate@rspack/coreinstance for module federation.
@rsbuild/core@2.2.0-beta.2 resolves @rspack/core@2.2.0-rc.0, but this lock now nests a second copy: @module-federation/rspack/@rspack/core → 2.0.6 (and the same for @rsdoctor/rspack-plugin / @rsdoctor/types). Before this change everything deduped on 2.0.6.
@module-federation/rspack imports @rspack/core directly, so its plugin classes and hook taps come from a different rspack instance — and a different native binding — than the compiler that runs them. Console ships embedded.js as a federated remote consumed by Cloud UI, so this sits on the critical output path, and it also pulls a second rspack native binary into the install.
Correction: align the versions — either hold @rsbuild/core on the 2.0.x line until @module-federation/rsbuild-plugin supports rspack 2.2, or add an override so a single @rspack/core resolves for all consumers.
Verify: cd frontend && bun install && bun pm ls | grep rspack (expect exactly one @rspack/core and one @rspack/binding), then bun run build and load embedded.js from a federation host.
- P2
frontend/package.json:788— A beta build toolchain is pinned for release builds, with a floating prerelease range underneath.
@rsbuild/core: 2.2.0-beta.2 declares @rspack/core: ~2.2.0-beta.1, which the lock satisfied with @rspack/core@2.2.0-rc.0 — a different prerelease than the one named. That range keeps floating across prereleases (beta.3, rc.1, …) on any lock refresh, so the bundler that produces the shipped artifact can change without a reviewed diff, and prereleases carry no compatibility guarantee.
Correction: if the 2.2 features are needed now, state that in the commit body and add an exact override for @rspack/core so the prerelease cannot drift; otherwise wait for @rsbuild/core@2.2.0 stable.
Verify: cd frontend && bun install --frozen-lockfile && bun pm ls | grep '@rspack/core' — the resolved version should equal the pinned one on a clean install.
f20a76e to
8df6382
Compare
Review feedback addressed
All review threads resolved. CI is green, including Enterprise E2E and Snyk. |
4954d83 to
cbffb6b
Compare
Proven impact
Decision rule: prove at least a 20% reduction in the largest emitted JavaScript asset while keeping total emitted JavaScript growth below 1% and preserving production runtime entrypoints.
d146e98094954d83e7Selected-cap A/B at exact PR head:
A 512 KiB cap emitted 595 async JavaScript files (+127 versus no cap) but did not improve the 5,650,771 B maximum reached at 4 MiB, so 4 MiB is the measured Pareto choice.
Value proven: the primary metric exceeded the 20% threshold, total JavaScript improved rather than regressed, and the final cap captures the chunk-size benefit with 114 fewer async files than 512 KiB.
Method:
bun run build-local-testwith fixed build variables and independent frozen-lockfile installs for merge-based146e9809and exact PR head4954d83e7; production asset bytes enumerated from cleanbuild/**/*.jsoutputs. Chunk-cap A/B usedcreateRsbuild().build()at exact head with identical source/dependencies and onlymaxAsyncSizevaried. macOS 26.6.2, Apple M5 Max, AC power, Bun 1.4.0. Exact byte counts are deterministic; build timings are deliberately excluded because the earlier timing sample did not measure the final commit under the controlled paired protocol.Runtime guardrail: whole-PR dogfood passed overview/topics/SQL/deep-link/invalid routes, 30/30 Module Federation sync assets, and 4/4 Monaco workers; all fetched artifacts returned HTTP 200 and were byte-identical, with zero chunk/worker browser errors. No live Redpanda backend was available.
Summary
fasterModuleConcatenationandlazyBarrel, which Rspack removed before GA.Why
Adopt Rsbuild 2.2's GA compiler, watcher, forward defaults, and bundling improvements while reducing the worst emitted chunk size. Application behavior and backend integrations are out of scope.
Surface review skipped: build-only change; no rendered UI changed.
Experiment scope
asyncWebAssembly: true: current Rspack default, pinned explicitly for the supported async Wasm pipeline.futureDefaults: true: opts into the next-major defaults now so incompatibilities fail during deliberate upgrades.nativeWatcher: true: uses Rust file watching for development rebuilds.pureFunctions: isProd: enables cross-module pure-function analysis only where production tree shaking applies.sourceImport: true: enabled by Rsbuild 2.2 and protected by the config contract.buildHttpbecause Console has no remote URL imports and enabling network-backed builds would expand the supply-chain surface.deferImportbecause Console uses no deferred-import proposal syntax.runtimeMode: 'rspack'because it remains under development and targets ESMmodern-moduleoutput, while Console uses Module Federation's current runtime.useInputFileSystembecause Console does not replace Rspack's input filesystem.Commits
8df6382bbbuild(frontend): upgrade rsbuild to 2.2b5e10815cbuild(frontend): enable rspack experiments4954d83e7build(frontend): address rsbuild review feedbackReviewer guide
Start with
frontend/rsbuild.config.ts, then review dependency intent infrontend/package.json, the fully resolved config contract infrontend/tests/rsbuild-config.integration.test.ts, suite routing in the two Vitest configs, and finally the generated lockfiles.Dogfood evidence
bun run start -- --port 57086,bun x rsbuild preview --port 57087, production browser routes, emitted worker files, and Module Federation HTTP artifacts.Dependency upgrade path
@rsbuild/core@2.2.0; React2.1.0; Sass2.0.1; SVGR2.0.5; Tailwind CSS2.0.3; YAML2.0.0; Node polyfill remains latest at1.4.6. Removed@rsbuild/plugin-babel,babel-plugin-react-compiler, andreact-compiler-runtime.2.2.0;bun.lockcontains exactly one@rspack/core@2.2.0and one matching@rspack/binding@2.2.0. Official plugin upgrades use their current compatible releases.Test plan
bun install --frozen-lockfilebun run lint:check:file rsbuild.config.ts tests/rsbuild-config.integration.test.ts vitest.config.integration.mts vitest.config.unit.mtsbun run type:checkRSDOCTOR=1production build