From 1ece7674231f5c422df4d2cae12ce3920a7346b9 Mon Sep 17 00:00:00 2001 From: Ahn <27772165+ahnpnl@users.noreply.github.com> Date: Mon, 6 Jun 2022 16:08:09 +0200 Subject: [PATCH] fix: add esbuild check to fallback to WASM if needed (#1619) --- esbuild-check.js | 8 ++++++++ src/ng-jest-transformer.ts | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 esbuild-check.js diff --git a/esbuild-check.js b/esbuild-check.js new file mode 100644 index 0000000000..8f02bab1b0 --- /dev/null +++ b/esbuild-check.js @@ -0,0 +1,8 @@ +// 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( + () => {}, + () => {} + ); diff --git a/src/ng-jest-transformer.ts b/src/ng-jest-transformer.ts index bd8a1a88ed..573d56fba5 100644 --- a/src/ng-jest-transformer.ts +++ b/src/ng-jest-transformer.ts @@ -32,7 +32,7 @@ export class NgJestTransformer extends TsJestTransformer { if (useNativeEsbuild === undefined) { try { - const esbuildCheckPath = require.resolve('@angular-devkit/build-angular/esbuild-check.js'); + const esbuildCheckPath = require.resolve('../esbuild-check.js'); const { status, error } = spawnSync(process.execPath, [esbuildCheckPath]); useNativeEsbuild = status === 0 && error === undefined; } catch (e) {