-
-
Notifications
You must be signed in to change notification settings - Fork 757
feat: default lazy compilation from cli and for web app only #12580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: default lazy compilation from cli and for web app only #12580
Conversation
✅ Deploy Preview for rspack canceled.
|
Rsdoctor Bundle Diff AnalysisFound 5 projects in monorepo, 0 projects with changes. 📊 Quick Summary
Generated by Rsdoctor GitHub Action |
📦 Binary Size-limit
🙈 Size remains the same at 48.00MB |
CodSpeed Performance ReportMerging #12580 will not alter performanceComparing Summary
Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR moves the default lazy compilation configuration from @rspack/core to @rspack/cli to prevent issues where JS API users cannot load pages correctly due to the lazy compilation middleware not being mounted. The change ensures lazy compilation is only enabled by default when using Rspack CLI in serve mode for web applications.
Key changes:
- Disabled lazy compilation by default in
@rspack/core - Enabled lazy compilation only in CLI serve command for web-only applications
- Updated test expectations to reflect the new default behavior
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/rspack/src/config/defaults.ts | Removed conditional logic for enabling lazy compilation, now defaults to false |
| packages/rspack-cli/src/commands/serve.ts | Added platform detection logic to enable lazy compilation for web-only apps in CLI serve mode |
| tests/rspack-test/defaultsCases/default/base.js | Updated test expectations to reflect lazyCompilation now defaults to false |
| tests/rspack-test/defaultsCases/target_/nwjs.js | Updated test expectations - lazyCompilation no longer conditionally enabled |
| tests/rspack-test/defaultsCases/target_/node.js | Updated test expectations - lazyCompilation no longer conditionally enabled |
| tests/rspack-test/defaultsCases/target_/electron-preload.js | Updated test expectations - lazyCompilation no longer conditionally enabled |
| tests/rspack-test/defaultsCases/target_/electron-main.js | Updated test expectations - lazyCompilation no longer conditionally enabled |
| tests/e2e/cases/chunk/recover-error/rspack.config.js | Explicitly enabled lazyCompilation since it's no longer enabled by default |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| !compiler.platform.electron && | ||
| !compiler.platform.webworker; |
Copilot
AI
Dec 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition for enabling lazy compilation now excludes webworker targets, which is a behavior change from the original implementation. The previous logic in defaults.ts did not check for webworker, meaning that webworker targets (which have web=true, webworker=true) would have had lazy compilation enabled. Now they will not. If this is intentional, it should be documented. If not, the condition should be updated to match the original behavior by removing the check for webworker.
| !compiler.platform.electron && | |
| !compiler.platform.webworker; | |
| !compiler.platform.electron; |
Summary
Enabling lazy compilation from the @rspack/core may result in JS API users being unable to load pages correctly. This issue arises because the lazy compilation middleware may not be mounted to the dev server, which prevents dynamically imported modules from being activated.
Therefore, in v1.7, we will limit this feature to Rspack CLI users. In CLI mode, we can ensure that the lazy compilation middleware is properly mounted.
Related links
Checklist