mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-18 03:23:57 +08:00
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.
This commit is contained in:
parent
11fa1221f0
commit
df49c359de
@ -12,7 +12,6 @@ import assert from 'node:assert';
|
|||||||
import { constants as fsConstants } from 'node:fs';
|
import { constants as fsConstants } from 'node:fs';
|
||||||
import fs from 'node:fs/promises';
|
import fs from 'node:fs/promises';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import { deleteOutputDir } from '../../utils';
|
|
||||||
import { copyAssets } from '../../utils/copy-assets';
|
import { copyAssets } from '../../utils/copy-assets';
|
||||||
import { assertIsError } from '../../utils/error';
|
import { assertIsError } from '../../utils/error';
|
||||||
import { transformSupportedBrowsersToTargets } from '../../utils/esbuild-targets';
|
import { transformSupportedBrowsersToTargets } from '../../utils/esbuild-targets';
|
||||||
@ -623,7 +622,13 @@ export async function* buildEsbuildBrowser(
|
|||||||
if (shouldWriteResult) {
|
if (shouldWriteResult) {
|
||||||
// Clean output path if enabled
|
// Clean output path if enabled
|
||||||
if (userOptions.deleteOutputPath) {
|
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
|
// Create output directory if needed
|
||||||
|
Loading…
x
Reference in New Issue
Block a user