Repository navigation
perf(rspack-plugin): specialize imported void roots and component calls in production builds - #1840
Merged
Merged
Conversation
…ls in production builds Rspack production client builds kept the generic root and component-call paths for compiled components imported from other modules, because the loader never supplied the cross-module void-export proof that the Vite plugin does. The one-root hydrateRoot app from the issue drops from about 86 KB to 52 KB gzip. A main-thread controller proves each candidate import from the effective module graph after make, then rebuilds the importer with the proof. A proof needs both Octane's authored void-export claim for the module it was compiled from and the provider's final JavaScript, after SWC and every later loader, still unable to return a value. The importer's final code must also bind the import to the same module and export. An importer whose proof does not hold after its rebuild is rebuilt once more without one. A proven module that changes later fails the build at seal or asset emission. Watch builds record facts for the cache but never consume proofs. octane/compiler/bundler adds analyzeCompiledModule() for the final-code facts. The CSS-module controller's graph helpers move to module-graph.js so both controllers share them. Fixes #1839 Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
October 7, 2026 07:53
Contributor
Benchmark report🟢 No budget breaches, no added work, and no timing changes beyond ±3%. Compares js-framework: 1k/10k row operationsAll 20 timed operations (20 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)No changes across 60 measured values. Public-import reachability bundles (bytes)No changes across 108 measured values. |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website | fcece29 | Commit Preview URL Branch Preview URL |
Oct 07 2026, 08:19 AM |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website-mcp | fcece29 | Commit Preview URL Branch Preview URL |
Oct 07 2026, 08:21 AM |
This was referenced Oct 7, 2026
trueadm
added a commit
that referenced
this pull request
Oct 7, 2026
Conflicts: the 87 react-parity manifests and the user-apps-v1 manifest record the lockfile hash, which main changed by adding jsdom to the codegen-size benchmark (#1840); pnpm sync regenerated them. The merged lockfile needs no changes from `pnpm install --lockfile-only`. The new anonymous-default-component fixture (#1842) is already in the new layout and compiles in both modes; #1842's tests pass on this branch's parser. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Summary
Fixes #1839. Rspack production client builds now specialize a
createRootorhydrateRootroot, and a<Component />call, over an imported void@{}component, as the Vite plugin already does. Before, the Rspack loader never gave the compiler a cross-module proof, so every imported root kept the generic returned-value renderer.A loader can't see another module's final output when it runs. So the proof is built from the module graph after make, and each importer that can use it is compiled once more. This follows the same pattern as the existing CSS-module constants controller. An import is proven only when all three of these hold:
findVoidComponentExportslists the export as void.analyzeCompiledModule()inoctane/compiler/bundlerchecks this. It follows the wrappers the compiler emits (__s,markWarm,bindPresentationView, and a comparator-freememo) and the setup IIFEs that transpilers lower. Reassigned bindings,eval, async functions, generators, re-exports and value returns stay unproven.Edges are read from the real ESM connections, so aliases, layers and issuer rules are respected.
When an importer's proof fails on its rebuilt graph, it is rebuilt once more without the proof. That covers a later loader that rewrites a provider or rebinds an import. A proven module that changes after that, for example through another plugin's
rebuildModule, fails the build at seal or asset emission. Watch builds record the facts their cached modules need, but never consume proofs. Dev, HMR, profiling and Lynx-style builds keep the generic paths; those are builds with a customruntime,universalRuntimeorlayerSpecializations.The CSS controller's graph helpers move unchanged to
module-graph.js, so both controllers share them.Measurements
Production builds with the runtime bundled. Baseline is the same tree with the controller not installed; median of 5–7 runs.
hydrateRootleaf){count as any}holeThe 200-component case shows the cost side. Its renderable holes keep the generic return path in the runtime, so there's no byte win. Every non-leaf importer is still compiled twice. A first version of this PR cost +41% there; two changes brought it down:
What remains is mostly the inherent rebuild.
Validation
pnpm format:check—pnpm format:files:checkon every changed file onlypnpm typecheck—pnpm typecheck:fileson the changed files only (both projects clean)pnpm test— not run in fullvitest --project rspack-plugin: 13 files, 182 tests, including the newvoid-component-proofs.test.ts, which covers main thread and workers.vitest --project rsbuild-plugin: 59 tests.vitest --project rspeedy-plugin: 64 tests. The demo tests need the pnpm 12 binary onPATHlocally.octanetests/compiler/void-root-exports.test.tsandbundler-compiler.test.ts: 81 tests.void-root-exportsandvoid-component-proofsafter merging currentmain.Each new test was checked by breaking the matching part of the implementation:
<main><b>value</b></main>, becauseLoud's output is dropped.'').The authored void claims for 1,971 of 1,972 exports across 444 repo
.tsrxfiles re-prove on both Octane's own output and its SWC ES5 lowering. The one miss is a direct-call twin with anisRenderCallguard return, which stays generic.Risk / follow-ups
benchmarks/codegen-sizeexternalizes the runtime and has nojsdomfor a semantic control. Specialization is guarded by the adapter tests instead, following the Vite adapter tests.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Production-only but changes compile/caching behavior (double-compile importers, fail-closed graph verification) and relies on static analysis of final JS; incorrect proofs could mis-specialize roots/calls, though conservative checks and tests mitigate this.
Overview
Rspack production client builds now match the Vite plugin by specializing
createRoot/hydrateRootand<Component />when the target is a proven imported void@{}component, enabling tree-shaking of the generic return-value path (reported ~40% gzip on a one-roothydrateRootapp).Because loaders cannot see other modules’ final output, the plugin adds a post-
makeproof controller (same shape as CSS-module constants): it walks ESM edges, requires Octane’s authored void export claim andanalyzeCompiledModule()on provider/importer JavaScript after SWC and later loaders, then rebuilds proof-consuming importers withisVoidComponentImport. Importers using proofs are non-cacheable; proofs fail the build if sources change after specialization. Watch/dev/HMR/profiling and customruntime/universalRuntime/layerSpecializationsstay generic.octane/compiler/bundlerexportsanalyzeCompiledModule(voidComponentExports,importBindings). Shared Rspack graph helpers move tomodule-graph.js; loaders/workers carry void build metadata like CSS constants.Reviewed by Cursor Bugbot for commit fcece29. Bugbot is set up for automated code reviews on this repo. Configure here.