Repository navigation
feat(core): support opt-in Node lazy compilation - #8629
ScriptedAlchemy wants to merge 6 commits into
Conversation
Require an explicit Node opt-in, eager entries, and HMR. Derive activation URLs from the bound server and validate explicit HTTP(S) endpoints. Exercise original lazy requests and source updates through retained native CommonJS and ESM runtimes. Apply pending hot revisions until runtime and compiler hashes match.
Document native output requirements, sequential hot updates, and dependency acceptance boundaries. Describe the framework responsibilities that remain after the opt-in.
Deploying rsbuild with
|
| Latest commit: |
465c960
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://4eb5c41f.rsbuild-v2.pages.dev |
| Branch Preview URL: | https://codex-node-lazy-compilation.rsbuild-v2.pages.dev |
chenjiahan
left a comment
There was a problem hiding this comment.
I'm not sure whether lazy compilation for Node targets currently works reliably in all supported scenarios. If we can confirm that it does, I'd prefer to keep the configuration aligned with Rspack and avoid introducing a separate node option.
@stormslowly cc
|
Lazy compilation makes the SSR server startup quickly, but it may introduce some APP restarts (like a full page reload in the web target). Maybe we need to evaluate whether the quick startup benefits cover the effects of restarts. |
|
I haven't seen server restarts or other tabs reloading during lazy imports in the cases I tested. I also ran the startup comparison: lazy compilation was slower in all 40 paired runs on the example workload, with identical packages. I didn't find a performance benefit, so I'm closing this PR. |
Motivation
Node targets currently ignore
dev.lazyCompilation. Frameworks that retain a Node runtime need to compile an optional server module when its dynamic import is requested, then resume that request without re-evaluating the entry.Related to React Router plugin #155. Framework integration is tracked in plugin #158.
Changes
dev.lazyCompilation.nodeto opt Node targets into lazy imports during development. Keep entries eager and require HMR; reject production andnonemodes.<port>placeholder.Upstream dependency
Temporarily pin
@rspack/coretonpm:@rspack-canary/core@2.2.9-canary-a9cfd15e-20261009001219. It includes the lazy/HMR dependency-identity fix needed to resume imports in a retained runtime, plus the rebuild-origin support from Rspack #15968.Before stable release: replace the canary pin and its loader-path snapshots with a released Rspack version containing the required fix.
Validation
At
02cc90587c13864bfd20c0e6e4f0191f1820e300:pnpm buildandpnpm checkpassed.Open questions
The tests establish retained-runtime behavior for the covered CJS/ESM scenarios. They do not establish universal restart-free Node support or a net startup/first-request performance benefit. Edits outside an application's acceptance boundaries still require framework handling.
Whether to keep the separate
nodeoption or align the configuration directly with Rspack remains a maintainer decision. See the review follow-up for the cross-project evidence and remaining coverage limits.