Skip to content

Commit

Permalink
perf(@angular-devkit/build-angular): reduce rebuilt times when using …
Browse files Browse the repository at this point in the history
…the `scripts` option

In some cases, using the `scripts` option caused a lot of `DescriptionFileUtils.loadDescriptionFile` calls which caused a bottleneck during build times.

The why to this is still unknown, but a workaround is to use the resolver from the Webpack compilation instead of the compiler.

Closes #24634
  • Loading branch information
alan-agius4 authored and angular-robot[bot] committed Feb 14, 2023
1 parent beae316 commit 1e52863
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,17 @@ export class ScriptsWebpackPlugin {
return;
}

const resolver = compiler.resolverFactory.get('normal', {
preferRelative: true,
useSyncFileSystemCalls: true,
fileSystem: compiler.inputFileSystem,
});

compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
// Use the resolver from the compilation instead of compiler.
// Using the latter will causes a lot of `DescriptionFileUtils.loadDescriptionFile` calls.
// See: https://github.com/angular/angular-cli/issues/24634#issuecomment-1425782668
const resolver = compilation.resolverFactory.get('normal', {
preferRelative: true,
useSyncFileSystemCalls: true,
// Caching must be disabled because it causes the resolver to become async after a rebuild.
cache: false,
});

const scripts: string[] = [];

for (const script of this.options.scripts) {
Expand Down

0 comments on commit 1e52863

Please sign in to comment.