Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
24 changes: 20 additions & 4 deletions packages/core/src/plugins/lazyCompilation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,26 @@ export const pluginLazyCompilation = (): RsbuildPlugin => ({
return;
}

chain.experiments({
...chain.get('experiments'),
lazyCompilation: options,
});
if (options === true) {
const entries = chain.entryPoints.entries() || {};

// If there is only one entry, do not enable lazy compilation for entries
// this can reduce the rebuild time
if (Object.keys(entries).length <= 1) {
chain.experiments({
...chain.get('experiments'),
lazyCompilation: {
entries: false,
imports: true,
},
});
}
} else {
chain.experiments({
...chain.get('experiments'),
lazyCompilation: options,
});
}
});
},
});
1 change: 1 addition & 0 deletions website/docs/en/config/dev/lazy-compilation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export default {
dev: {
lazyCompilation: {
imports: true,
// If there is only one entry, Rsbuild will not enable the entries option by default
entries: true,
},
},
Expand Down
1 change: 1 addition & 0 deletions website/docs/zh/config/dev/lazy-compilation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export default {
dev: {
lazyCompilation: {
imports: true,
// 如果只有一个入口,则 Rsbuild 默认不启用 entries 选项
entries: true,
},
},
Expand Down
Loading