Skip to content

Commit

Permalink
perf(@angular-devkit/build-angular): asynchronously delete output pat…
Browse files Browse the repository at this point in the history
…h 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.

(cherry picked from commit df49c35)
  • Loading branch information
clydin authored and dgp1130 committed Apr 12, 2023
1 parent b2ece91 commit 28c2756
Showing 1 changed file with 7 additions and 2 deletions.
Expand Up @@ -12,7 +12,6 @@ import assert from 'node:assert';
import { constants as fsConstants } from 'node:fs';
import fs from 'node:fs/promises';
import path from 'node:path';
import { deleteOutputDir } from '../../utils';
import { copyAssets } from '../../utils/copy-assets';
import { assertIsError } from '../../utils/error';
import { transformSupportedBrowsersToTargets } from '../../utils/esbuild-targets';
Expand Down Expand Up @@ -623,7 +622,13 @@ export async function* buildEsbuildBrowser(
if (shouldWriteResult) {
// Clean output path if enabled
if (userOptions.deleteOutputPath) {
deleteOutputDir(normalizedOptions.workspaceRoot, userOptions.outputPath);
if (normalizedOptions.outputPath === normalizedOptions.workspaceRoot) {
context.logger.error('Output path MUST not be workspace root directory!');

return;
}

await fs.rm(normalizedOptions.outputPath, { force: true, recursive: true, maxRetries: 3 });
}

// Create output directory if needed
Expand Down

0 comments on commit 28c2756

Please sign in to comment.