Skip to content

Commit df49c35

Browse files
clydinangular-robot[bot]
authored andcommitted
perf(@angular-devkit/build-angular): asynchronously delete output path in esbuild builder
When using the esbuild-based browser application builder, the output path is deleted prior to performing a build to ensure a clean output with only the built files. The deletion will now be performed asynchronously using the Node.js promised-based API. This should provide a small performance improvement for projects with large output directories.
1 parent 11fa122 commit df49c35

File tree

1 file changed

+7
-2
lines changed
  • packages/angular_devkit/build_angular/src/builders/browser-esbuild

1 file changed

+7
-2
lines changed

packages/angular_devkit/build_angular/src/builders/browser-esbuild/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import assert from 'node:assert';
1212
import { constants as fsConstants } from 'node:fs';
1313
import fs from 'node:fs/promises';
1414
import path from 'node:path';
15-
import { deleteOutputDir } from '../../utils';
1615
import { copyAssets } from '../../utils/copy-assets';
1716
import { assertIsError } from '../../utils/error';
1817
import { transformSupportedBrowsersToTargets } from '../../utils/esbuild-targets';
@@ -623,7 +622,13 @@ export async function* buildEsbuildBrowser(
623622
if (shouldWriteResult) {
624623
// Clean output path if enabled
625624
if (userOptions.deleteOutputPath) {
626-
deleteOutputDir(normalizedOptions.workspaceRoot, userOptions.outputPath);
625+
if (normalizedOptions.outputPath === normalizedOptions.workspaceRoot) {
626+
context.logger.error('Output path MUST not be workspace root directory!');
627+
628+
return;
629+
}
630+
631+
await fs.rm(normalizedOptions.outputPath, { force: true, recursive: true, maxRetries: 3 });
627632
}
628633

629634
// Create output directory if needed

0 commit comments

Comments
 (0)