Skip to content

Commit c66782b

Browse files
clydinjkrems
authored andcommitted
refactor(@angular/build): only load chunk optimizer if enabled
The experimental chunk optimizer is now only imported if it is enabled via its environment variable (`NG_BUILD_OPTIMIZE_CHUNKS=1`). This prevents the loading of the rollup package as well as any transitive dependencies when these packages will not be used by the build.
1 parent 7fda6b5 commit c66782b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/angular/build/src/builders/application/execute-build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import {
3131
generateAngularServerAppEngineManifest,
3232
} from '../../utils/server-rendering/manifest';
3333
import { getSupportedBrowsers } from '../../utils/supported-browsers';
34-
import { optimizeChunks } from './chunk-optimizer';
3534
import { executePostBundleSteps } from './execute-post-bundle';
3635
import { inlineI18n, loadActiveTranslations } from './i18n';
3736
import { NormalizedApplicationBuildOptions } from './options';
@@ -129,6 +128,7 @@ export async function executeBuild(
129128
}
130129

131130
if (options.optimizationOptions.scripts && shouldOptimizeChunks) {
131+
const { optimizeChunks } = await import('./chunk-optimizer');
132132
bundlingResult = await profileAsync('OPTIMIZE_CHUNKS', () =>
133133
optimizeChunks(
134134
bundlingResult,

0 commit comments

Comments
 (0)