()
| 49 | let isInternalWorkerThread = worker_threads?.workerData?.esbuildVersion === ESBUILD_VERSION |
| 50 | |
| 51 | let esbuildCommandAndArgs = (): [string, string[]] => { |
| 52 | // Try to have a nice error message when people accidentally bundle esbuild |
| 53 | // without providing an explicit path to the binary, or when using WebAssembly. |
| 54 | if ((!ESBUILD_BINARY_PATH || WASM) && (path.basename(__filename) !== 'main.js' || path.basename(__dirname) !== 'lib')) { |
| 55 | throw new Error( |
| 56 | `The esbuild JavaScript API cannot be bundled. Please mark the "esbuild" ` + |
| 57 | `package as external so it's not included in the bundle.\n` + |
| 58 | `\n` + |
| 59 | `More information: The file containing the code for esbuild's JavaScript ` + |
| 60 | `API (${__filename}) does not appear to be inside the esbuild package on ` + |
| 61 | `the file system, which usually means that the esbuild package was bundled ` + |
| 62 | `into another file. This is problematic because the API needs to run a ` + |
| 63 | `binary executable inside the esbuild package which is located using a ` + |
| 64 | `relative path from the API code to the executable. If the esbuild package ` + |
| 65 | `is bundled, the relative path will be incorrect and the executable won't ` + |
| 66 | `be found.`) |
| 67 | } |
| 68 | |
| 69 | if (WASM) { |
| 70 | return ['node', [path.join(__dirname, '..', 'bin', 'esbuild')]] |
| 71 | } else { |
| 72 | const { binPath, isWASM } = generateBinPath() |
| 73 | if (isWASM) { |
| 74 | return ['node', [binPath]] |
| 75 | } else { |
| 76 | return [binPath, []] |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | // Return true if stderr is a TTY |
| 82 | let isTTY = () => tty.isatty(2) |
no test coverage detected
searching dependent graphs…