mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-17 02:54:21 +08:00
refactor(@angular-devkit/build-angular): remove esbuild-check workaround
This check is no longer needed as of `0.14.29` as now esbuild correctly propagates errors. See: https://github.com/evanw/esbuild/blob/master/CHANGELOG.md#01429
This commit is contained in:
parent
6a6386a1ef
commit
af8dd62b74
@ -81,7 +81,6 @@ ts_library(
|
||||
include = [
|
||||
"package.json",
|
||||
"builders.json",
|
||||
"esbuild-check.js",
|
||||
"src/**/schema.json",
|
||||
"src/**/*.js",
|
||||
"src/**/*.html",
|
||||
|
@ -1,16 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
// If the platform does not support the native variant of esbuild, this will crash.
|
||||
// This script can then be spawned by the CLI to determine if native usage is supported.
|
||||
require('esbuild')
|
||||
.formatMessages([], { kind: 'error ' })
|
||||
.then(
|
||||
() => {},
|
||||
() => {},
|
||||
);
|
@ -6,14 +6,12 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import { spawnSync } from 'child_process';
|
||||
import type {
|
||||
FormatMessagesOptions,
|
||||
PartialMessage,
|
||||
TransformOptions,
|
||||
TransformResult,
|
||||
} from 'esbuild';
|
||||
import * as path from 'path';
|
||||
|
||||
/**
|
||||
* Provides the ability to execute esbuild regardless of the current platform's support
|
||||
@ -44,23 +42,15 @@ export class EsbuildExecutor
|
||||
/**
|
||||
* Determines whether the native variant of esbuild can be used on the current platform.
|
||||
*
|
||||
* @returns True, if the native variant of esbuild is support; False, if the WASM variant is required.
|
||||
* @returns A promise which resolves to `true`, if the native variant of esbuild is support or `false`, if the WASM variant is required.
|
||||
*/
|
||||
static hasNativeSupport(): boolean {
|
||||
static async hasNativeSupport(): Promise<boolean> {
|
||||
// Try to use native variant to ensure it is functional for the platform.
|
||||
// Spawning a separate esbuild check process is used to determine if the native
|
||||
// variant is viable. If check fails, the WASM variant is initialized instead.
|
||||
// Attempting to call one of the native esbuild functions is not a viable test
|
||||
// currently since esbuild spawn errors are currently not propagated through the
|
||||
// call stack for the esbuild function. If this limitation is removed in the future
|
||||
// then the separate process spawn check can be removed in favor of a direct function
|
||||
// call check.
|
||||
try {
|
||||
const { status, error } = spawnSync(process.execPath, [
|
||||
path.join(__dirname, '../../../esbuild-check.js'),
|
||||
]);
|
||||
const { formatMessages } = await import('esbuild');
|
||||
await formatMessages([], { kind: 'error' });
|
||||
|
||||
return status === 0 && error === undefined;
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
@ -77,7 +67,7 @@ export class EsbuildExecutor
|
||||
}
|
||||
|
||||
// If the WASM variant was preferred at class construction or native is not supported, use WASM
|
||||
if (this.alwaysUseWasm || !EsbuildExecutor.hasNativeSupport()) {
|
||||
if (this.alwaysUseWasm || !(await EsbuildExecutor.hasNativeSupport())) {
|
||||
await this.useWasm();
|
||||
this.initialized = true;
|
||||
|
||||
|
@ -178,7 +178,7 @@ export class JavaScriptOptimizerPlugin {
|
||||
// Perform a single native esbuild support check.
|
||||
// This removes the need for each worker to perform the check which would
|
||||
// otherwise require spawning a separate process per worker.
|
||||
alwaysUseWasm: !EsbuildExecutor.hasNativeSupport(),
|
||||
alwaysUseWasm: !(await EsbuildExecutor.hasNativeSupport()),
|
||||
};
|
||||
|
||||
// Sort scripts so larger scripts start first - worker pool uses a FIFO queue
|
||||
|
Loading…
x
Reference in New Issue
Block a user