Skip to content

Conversation

@stormslowly
Copy link
Contributor

@stormslowly stormslowly commented Dec 30, 2025

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

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

@netlify
Copy link

netlify bot commented Dec 30, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit e5afdc1
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/69534b9f872ece0008370108

@github-actions github-actions bot added release: feature release: feature related release(mr only) team The issue/pr is created by the member of Rspack. labels Dec 30, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 30, 2025

Rsdoctor Bundle Diff Analysis

Found 5 projects in monorepo, 0 projects with changes.

📊 Quick Summary
Project Total Size Change
react-10k 5.7 MB 0
react-1k 823.4 KB 0
react-5k 2.7 MB 0
rome 984.3 KB 0
ui-components 2.1 MB 0

Generated by Rsdoctor GitHub Action

@github-actions
Copy link
Contributor

github-actions bot commented Dec 30, 2025

📦 Binary Size-limit

Comparing e5afdc1 to refactor: refine exports info for CJS and ESM interop (#12577) by harpsealjs

🙈 Size remains the same at 48.00MB

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 30, 2025

CodSpeed Performance Report

Merging #12580 will not alter performance

Comparing feat/default_enable_lazy_compilation_in_cli_mode (e5afdc1) with main (4ecc031)

Summary

✅ 16 untouched
⏩ 1 skipped1

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

@stormslowly stormslowly marked this pull request as ready for review December 30, 2025 05:27
Copilot AI review requested due to automatic review settings December 30, 2025 05:27
@chenjiahan chenjiahan merged commit 5bf9ecc into main Dec 30, 2025
59 checks passed
@chenjiahan chenjiahan deleted the feat/default_enable_lazy_compilation_in_cli_mode branch December 30, 2025 05:28
Copy link
Contributor

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 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.

Comment on lines +89 to +90
!compiler.platform.electron &&
!compiler.platform.webworker;
Copy link

Copilot AI Dec 30, 2025

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.

Suggested change
!compiler.platform.electron &&
!compiler.platform.webworker;
!compiler.platform.electron;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: feature release: feature related release(mr only) team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants