Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): use incremental component style b…
Browse files Browse the repository at this point in the history
…undling 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)
  • Loading branch information
clydin authored and dgp1130 committed Oct 17, 2023
1 parent 2a10fa8 commit 34947fc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export interface CompilerPluginOptions {
fileReplacements?: Record<string, string>;
sourceFileCache?: SourceFileCache;
loadResultCache?: LoadResultCache;
incremental: boolean;
}

// eslint-disable-next-line max-lines-per-function
Expand Down Expand Up @@ -100,6 +101,7 @@ export function createCompilerPlugin(
// Track incremental component stylesheet builds
const stylesheetBundler = new ComponentStylesheetBundler(
styleOptions,
pluginOptions.incremental,
pluginOptions.loadResultCache,
);
let sharedTSCompilationState: SharedTSCompilationState | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class ComponentStylesheetBundler {
*/
constructor(
private readonly options: BundleStylesheetOptions,
private readonly incremental: boolean,
private readonly cache?: LoadResultCache,
) {}

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

return new BundlerContext(this.options.workspaceRoot, true, buildOptions);
return new BundlerContext(this.options.workspaceRoot, this.incremental, buildOptions);
});

return extractResult(await bundlerContext.bundle(), bundlerContext.watchFiles);
Expand Down Expand Up @@ -95,7 +96,7 @@ export class ComponentStylesheetBundler {
},
});

return new BundlerContext(this.options.workspaceRoot, true, buildOptions);
return new BundlerContext(this.options.workspaceRoot, this.incremental, buildOptions);
});

// Extract the result of the bundling from the output files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export function createCompilerPluginOptions(
fileReplacements,
sourceFileCache,
loadResultCache: sourceFileCache?.loadResultCache,
incremental: !!options.watch,
},
// Component stylesheet options
styleOptions: {
Expand Down

0 comments on commit 34947fc

Please sign in to comment.