-
Notifications
You must be signed in to change notification settings - Fork 309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Doesn't fallback to esbuild-wasm for systems without esbuild.exe
#1255
Comments
Thanks for the fix @ahnpnl, but I've tested this (applying the changes manually to a local |
Seem like we have to use |
@ahnpnl thanks for looking into it! let useNativeEsbuild = false;
try {
const esbuildCheckPath = require.resolve('@angular-devkit/build-angular/esbuild-check.js');
const { status, error } = child_process.spawnSync(process.execPath, [esbuildCheckPath]);
useNativeEsbuild = status === 0 && error === undefined;
} catch (e) {
useNativeEsbuild = false;
}
this.esbuildImpl = useNativeEsbuild ? require('esbuild') : require('esbuild-wasm');
//<...>
//Inside of process()
const { code, map } = this.esbuildImpl.transformSync(fileContent, {
loader: 'js', //...
//<...> Unless you meant something else in your previous reply. |
Thanks if that works I will make another attempt. |
If you have a PR or a branch - I can try running it on the machine. |
I created a draft PR #1283 |
The draft looks pretty similar to the code that worked and that code DOES work. As long as that code correctly uses |
Thanks! I gonna merge it in main then 👍 |
I just updated all my angular packages from 12.2.3 to 12.2.13. When I ran test I got this
Then I updated jest-preset-angular to latest and it didn't fix it. |
Version
11.0.0
Steps to reproduce
jest-preset-angular
on a computer, which cannot launch theesbuild
binary.3. Transformation takes a long time/never finishes - tests are never run.Expected behavior
Transformation should fallback to
esbuild-wasm
ifesbuild
binary is unavailable.Actual behavior
Transformation tries to launch the esbuild binary, which is blocked and never starts the actual transformation. Transformation takes a long time/never finishes - tests are never run
Additional context
Many corporate environments are locked down, where only specifically signed binaries are allowed to run. The
esbuild.exe
binary on Windows is unsigned, so it can not be run on such systems.This bug previously existed on
@angular
itself - angular/angular-cli#21687 - and was fixed via a similar fallback - angular/angular-cli#21763.A similar approach could be used for
jest-preset-angular
. A quick test revealed that changingesbuild
toesbuild-wasm
injest-preset-angular/src/ng-jest-transformer.ts
Line 6 in 1de3bf0
Environment
The text was updated successfully, but these errors were encountered: