Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ Object {
inlineEnum: false,
layers: false,
lazyBarrel: false,
lazyCompilation: false,
lazyCompilation: Object {
entries: true,
imports: true,
},
parallelCodeSplitting: false,
parallelLoader: false,
rspackFuture: Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ describe("with lazy compilation", function () {
const configs = [
{
entry: "./esm/a.js",
context
context,
experiments: {
lazyCompilation: false
}
},
{
entry: "./esm/b.js",
Expand Down
7 changes: 6 additions & 1 deletion packages/rspack/src/config/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,12 @@ const applyExperimentsDefaults = (

D(experiments, "futureDefaults", false);
// IGNORE(experiments.lazyCompilation): In webpack, lazyCompilation is undefined by default
D(experiments, "lazyCompilation", false);
D(experiments, "lazyCompilation", {});
if (typeof experiments.lazyCompilation === "object") {
D(experiments.lazyCompilation, "entries", true);
D(experiments.lazyCompilation, "imports", true);
}
Copy link
Preview

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting an empty object as the default and then conditionally populating it creates unnecessary complexity. Consider directly setting the default object with the desired properties: D(experiments, "lazyCompilation", { entries: true, imports: true });

Suggested change
}
D(experiments, "lazyCompilation", { entries: true, imports: true });

Copilot uses AI. Check for mistakes.


D(experiments, "asyncWebAssembly", experiments.futureDefaults);
D(experiments, "css", experiments.futureDefaults ? true : undefined);
D(experiments, "layers", false);
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack/src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2642,7 +2642,7 @@ export type Experiments = {
cache?: ExperimentCacheOptions;
/**
* Enable lazy compilation.
* @default false
* @default true
*/
lazyCompilation?: boolean | LazyCompilationOptions;
/**
Expand Down
2 changes: 1 addition & 1 deletion website/docs/en/config/experiments.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export default {
## experiments.lazyCompilation

- **Type:** `boolean | LazyCompilationOptions`
- **Default:** `false`
- **Default:** `true`

```ts
type LazyCompilationOptions =
Expand Down
2 changes: 1 addition & 1 deletion website/docs/zh/config/experiments.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export default {
## experiments.lazyCompilation

- **类型:** `boolean | LazyCompilationOptions`
- **默认值:** `false`
- **默认值:** `true`

```ts
type LazyCompilationOptions =
Expand Down
Loading