fix: allow to enable lazy compilation via Rspack config#4928
Merged
chenjiahan merged 7 commits intomainfrom Jun 25, 2025
Merged
fix: allow to enable lazy compilation via Rspack config#4928chenjiahan merged 7 commits intomainfrom
chenjiahan merged 7 commits intomainfrom
Conversation
✅ Deploy Preview for rsbuild ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR updates the dev middleware to detect lazy compilation from Rspack’s experiments.lazyCompilation setting (in addition to Rsbuild’s own dev.lazyCompilation), and adds E2E tests to verify both configuration paths.
- core: replace direct
dev.lazyCompilationcheck with a helper that readsexperiments.lazyCompilation(and should also fall back todev.lazyCompilation) - e2e: remove hard-coded
dev.lazyCompilationin config and add tests for both Rsbuild and Rspack experiment flags
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/core/src/server/devMiddlewares.ts | Add isLazyCompilationEnabled helper using Rspack experiments and wire up middleware |
| e2e/cases/lazy-compilation/basic/rsbuild.config.ts | Remove legacy dev.lazyCompilation from sample config |
| e2e/cases/lazy-compilation/basic/index.test.ts | Add tests for both Rsbuild dev.lazyCompilation and tools.rspack.experiments.lazyCompilation |
Comments suppressed due to low confidence (3)
packages/core/src/server/devMiddlewares.ts:69
- You removed the
devparameter from the middleware setup, but it’s needed to readdev.lazyCompilation. Consider re-addingdevto the destructure so it can be passed into your lazy check.
const applyDefaultMiddlewares = async ({
e2e/cases/lazy-compilation/basic/rsbuild.config.ts:9
- [nitpick] The sample config no longer includes
dev.lazyCompilation; consider adding a second E2E variant that exercises the legacy flag in the actual config file, not just via thedev()call override.
page2: './src/page2/index.js',
packages/core/src/server/devMiddlewares.ts:135
- The helper only checks
experiments.lazyCompilation, but Rsbuild’s owndev.lazyCompilationwas removed from the condition. Re-includedev.lazyCompilation(from the originaldevparameter) in this function so both flags enable lazy compilation.
const isLazyCompilationEnabled = () => {
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
Rsbuild now checks the compiler options to determine whether lazy compilation is enabled.
Rsbuild users can enable lazy compilation in two ways:
dev.lazyCompilationoptionexperiments.lazyCompilationoption (see the added test case)Checklist