Skip to content

fix: allow to enable lazy compilation via Rspack config #4928

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

Merged
merged 7 commits into from
Jun 25, 2025

Conversation

chenjiahan
Copy link
Member

@chenjiahan chenjiahan commented Mar 31, 2025

Summary

Rsbuild now checks the compiler options to determine whether lazy compilation is enabled.

Rsbuild users can enable lazy compilation in two ways:

  1. Use Rsbuild's dev.lazyCompilation option
  2. Use Rspack's experiments.lazyCompilation option (see the added test case)

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Sorry, something went wrong.

Copy link

netlify bot commented Mar 31, 2025

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit ca2ef6e
🔍 Latest deploy log https://app.netlify.com/projects/rsbuild/deploys/685b6816b6ed68000894c760
😎 Deploy Preview https://deploy-preview-4928--rsbuild.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 72 (🔴 down 1 from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: 60 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@chenjiahan chenjiahan marked this pull request as draft June 13, 2025 13:44
@chenjiahan chenjiahan marked this pull request as ready for review June 25, 2025 03:10
@Copilot Copilot AI review requested due to automatic review settings June 25, 2025 03:10
Copy link
Contributor

@Copilot Copilot AI left a 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 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.lazyCompilation check with a helper that reads experiments.lazyCompilation (and should also fall back to dev.lazyCompilation)
  • e2e: remove hard-coded dev.lazyCompilation in 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 dev parameter from the middleware setup, but it’s needed to read dev.lazyCompilation. Consider re-adding dev to 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 the dev() call override.
      page2: './src/page2/index.js',

packages/core/src/server/devMiddlewares.ts:135

  • The helper only checks experiments.lazyCompilation, but Rsbuild’s own dev.lazyCompilation was removed from the condition. Re-include dev.lazyCompilation (from the original dev parameter) in this function so both flags enable lazy compilation.
    const isLazyCompilationEnabled = () => {

@chenjiahan chenjiahan merged commit 12c33e5 into main Jun 25, 2025
11 checks passed
@chenjiahan chenjiahan deleted the lazy_rspack_config_0331 branch June 25, 2025 03:15
@chenjiahan chenjiahan mentioned this pull request Jun 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant