From e4cf1b3f17d50db589f1f9bbf1ea5fb7c0def6a6 Mon Sep 17 00:00:00 2001 From: Evan Wallace Date: Tue, 10 Jan 2023 12:46:33 -0500 Subject: [PATCH] workaround for #2785 and #2812 --- lib/npm/node-install.ts | 8 ++++++-- lib/npm/node-platform.ts | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/npm/node-install.ts b/lib/npm/node-install.ts index c8840969cb5..4ed762c4648 100644 --- a/lib/npm/node-install.ts +++ b/lib/npm/node-install.ts @@ -234,8 +234,12 @@ async function checkAndPreparePackage(): Promise { // path without modifying the code itself. Do not remove this because // external code relies on this (in addition to esbuild's own test suite). if (ESBUILD_BINARY_PATH) { - applyManualBinaryPathOverride(ESBUILD_BINARY_PATH); - return; + if (!fs.existsSync(ESBUILD_BINARY_PATH)) { + console.warn(`[esbuild] Ignoring bad configuration: ESBUILD_BINARY_PATH=${ESBUILD_BINARY_PATH}`) + } else { + applyManualBinaryPathOverride(ESBUILD_BINARY_PATH); + return; + } } const { pkg, subpath } = pkgAndSubpathForCurrentPlatform(); diff --git a/lib/npm/node-platform.ts b/lib/npm/node-platform.ts index 02daa30915b..b2febfa8438 100644 --- a/lib/npm/node-platform.ts +++ b/lib/npm/node-platform.ts @@ -107,7 +107,11 @@ export function generateBinPath(): { binPath: string, isWASM: boolean } { // path without modifying the code itself. Do not remove this because // external code relies on this (in addition to esbuild's own test suite). if (ESBUILD_BINARY_PATH) { - return { binPath: ESBUILD_BINARY_PATH, isWASM: false }; + if (!fs.existsSync(ESBUILD_BINARY_PATH)) { + console.warn(`[esbuild] Ignoring bad configuration: ESBUILD_BINARY_PATH=${ESBUILD_BINARY_PATH}`) + } else { + return { binPath: ESBUILD_BINARY_PATH, isWASM: false }; + } } const { pkg, subpath, isWASM } = pkgAndSubpathForCurrentPlatform();