Skip to content

Commit 34947fc

Browse files
clydindgp1130
authored andcommitted
fix(@angular-devkit/build-angular): use incremental component style bundling only in watch mode
Component style bundling when using the application builder will now only generate incremental contexts when in watch mode. During non-watch build, this incremental context information is not needed and unnecessarily increases memory usage during a build. (cherry picked from commit 8d1d353)
1 parent 2a10fa8 commit 34947fc

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

packages/angular_devkit/build_angular/src/tools/esbuild/angular/compiler-plugin.ts

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export interface CompilerPluginOptions {
4747
fileReplacements?: Record<string, string>;
4848
sourceFileCache?: SourceFileCache;
4949
loadResultCache?: LoadResultCache;
50+
incremental: boolean;
5051
}
5152

5253
// eslint-disable-next-line max-lines-per-function
@@ -100,6 +101,7 @@ export function createCompilerPlugin(
100101
// Track incremental component stylesheet builds
101102
const stylesheetBundler = new ComponentStylesheetBundler(
102103
styleOptions,
104+
pluginOptions.incremental,
103105
pluginOptions.loadResultCache,
104106
);
105107
let sharedTSCompilationState: SharedTSCompilationState | undefined;

packages/angular_devkit/build_angular/src/tools/esbuild/angular/component-stylesheets.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export class ComponentStylesheetBundler {
4545
*/
4646
constructor(
4747
private readonly options: BundleStylesheetOptions,
48+
private readonly incremental: boolean,
4849
private readonly cache?: LoadResultCache,
4950
) {}
5051

@@ -53,7 +54,7 @@ export class ComponentStylesheetBundler {
5354
const buildOptions = createStylesheetBundleOptions(this.options, this.cache);
5455
buildOptions.entryPoints = [entry];
5556

56-
return new BundlerContext(this.options.workspaceRoot, true, buildOptions);
57+
return new BundlerContext(this.options.workspaceRoot, this.incremental, buildOptions);
5758
});
5859

5960
return extractResult(await bundlerContext.bundle(), bundlerContext.watchFiles);
@@ -95,7 +96,7 @@ export class ComponentStylesheetBundler {
9596
},
9697
});
9798

98-
return new BundlerContext(this.options.workspaceRoot, true, buildOptions);
99+
return new BundlerContext(this.options.workspaceRoot, this.incremental, buildOptions);
99100
});
100101

101102
// Extract the result of the bundling from the output files

packages/angular_devkit/build_angular/src/tools/esbuild/compiler-plugin-options.ts

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export function createCompilerPluginOptions(
4747
fileReplacements,
4848
sourceFileCache,
4949
loadResultCache: sourceFileCache?.loadResultCache,
50+
incremental: !!options.watch,
5051
},
5152
// Component stylesheet options
5253
styleOptions: {

0 commit comments

Comments
 (0)