esbuild 0.15.18 → 0.17.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. package/bin/esbuild +33 -25
  2. package/install.js +70 -30
  3. package/lib/main.d.ts +274 -243
  4. package/lib/main.js +410 -350
  5. package/package.json +23 -23
package/bin/esbuild CHANGED
@@ -15,6 +15,10 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
+ // If the importer is in node compatibility mode or this is not an ESM
19
+ // file that has been converted to a CommonJS file using a Babel-
20
+ // compatible transform (i.e. "__esModule" has not been set), then set
21
+ // "default" to the CommonJS "module.exports" for node compatibility.
18
22
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
19
23
  mod
20
24
  ));
@@ -24,35 +28,35 @@ var fs = require("fs");
24
28
  var os = require("os");
25
29
  var path = require("path");
26
30
  var ESBUILD_BINARY_PATH = process.env.ESBUILD_BINARY_PATH || ESBUILD_BINARY_PATH;
27
- var packageDarwin_arm64 = "esbuild-darwin-arm64";
28
- var packageDarwin_x64 = "esbuild-darwin-64";
31
+ var packageDarwin_arm64 = "@esbuild/darwin-arm64";
32
+ var packageDarwin_x64 = "@esbuild/darwin-x64";
29
33
  var knownWindowsPackages = {
30
- "win32 arm64 LE": "esbuild-windows-arm64",
31
- "win32 ia32 LE": "esbuild-windows-32",
32
- "win32 x64 LE": "esbuild-windows-64"
34
+ "win32 arm64 LE": "@esbuild/win32-arm64",
35
+ "win32 ia32 LE": "@esbuild/win32-ia32",
36
+ "win32 x64 LE": "@esbuild/win32-x64"
33
37
  };
34
38
  var knownUnixlikePackages = {
35
- "android arm64 LE": "esbuild-android-arm64",
36
- "darwin arm64 LE": "esbuild-darwin-arm64",
37
- "darwin x64 LE": "esbuild-darwin-64",
38
- "freebsd arm64 LE": "esbuild-freebsd-arm64",
39
- "freebsd x64 LE": "esbuild-freebsd-64",
40
- "linux arm LE": "esbuild-linux-arm",
41
- "linux arm64 LE": "esbuild-linux-arm64",
42
- "linux ia32 LE": "esbuild-linux-32",
43
- "linux mips64el LE": "esbuild-linux-mips64le",
44
- "linux ppc64 LE": "esbuild-linux-ppc64le",
45
- "linux riscv64 LE": "esbuild-linux-riscv64",
46
- "linux s390x BE": "esbuild-linux-s390x",
47
- "linux x64 LE": "esbuild-linux-64",
39
+ "android arm64 LE": "@esbuild/android-arm64",
40
+ "darwin arm64 LE": "@esbuild/darwin-arm64",
41
+ "darwin x64 LE": "@esbuild/darwin-x64",
42
+ "freebsd arm64 LE": "@esbuild/freebsd-arm64",
43
+ "freebsd x64 LE": "@esbuild/freebsd-x64",
44
+ "linux arm LE": "@esbuild/linux-arm",
45
+ "linux arm64 LE": "@esbuild/linux-arm64",
46
+ "linux ia32 LE": "@esbuild/linux-ia32",
47
+ "linux mips64el LE": "@esbuild/linux-mips64el",
48
+ "linux ppc64 LE": "@esbuild/linux-ppc64",
49
+ "linux riscv64 LE": "@esbuild/linux-riscv64",
50
+ "linux s390x BE": "@esbuild/linux-s390x",
51
+ "linux x64 LE": "@esbuild/linux-x64",
48
52
  "linux loong64 LE": "@esbuild/linux-loong64",
49
- "netbsd x64 LE": "esbuild-netbsd-64",
50
- "openbsd x64 LE": "esbuild-openbsd-64",
51
- "sunos x64 LE": "esbuild-sunos-64"
53
+ "netbsd x64 LE": "@esbuild/netbsd-x64",
54
+ "openbsd x64 LE": "@esbuild/openbsd-x64",
55
+ "sunos x64 LE": "@esbuild/sunos-x64"
52
56
  };
53
57
  var knownWebAssemblyFallbackPackages = {
54
58
  "android arm LE": "@esbuild/android-arm",
55
- "android x64 LE": "esbuild-android-64"
59
+ "android x64 LE": "@esbuild/android-x64"
56
60
  };
57
61
  function pkgAndSubpathForCurrentPlatform() {
58
62
  let pkg;
@@ -99,11 +103,15 @@ function pkgForSomeOtherPlatform() {
99
103
  }
100
104
  function downloadedBinPath(pkg, subpath) {
101
105
  const esbuildLibDir = path.dirname(require.resolve("esbuild"));
102
- return path.join(esbuildLibDir, `downloaded-${pkg}-${path.basename(subpath)}`);
106
+ return path.join(esbuildLibDir, `downloaded-${pkg.replace("/", "-")}-${path.basename(subpath)}`);
103
107
  }
104
108
  function generateBinPath() {
105
109
  if (ESBUILD_BINARY_PATH) {
106
- return { binPath: ESBUILD_BINARY_PATH, isWASM: false };
110
+ if (!fs.existsSync(ESBUILD_BINARY_PATH)) {
111
+ console.warn(`[esbuild] Ignoring bad configuration: ESBUILD_BINARY_PATH=${ESBUILD_BINARY_PATH}`);
112
+ } else {
113
+ return { binPath: ESBUILD_BINARY_PATH, isWASM: false };
114
+ }
107
115
  }
108
116
  const { pkg, subpath, isWASM: isWASM2 } = pkgAndSubpathForCurrentPlatform();
109
117
  let binPath2;
@@ -190,7 +198,7 @@ for your current platform.`);
190
198
  "node_modules",
191
199
  ".cache",
192
200
  "esbuild",
193
- `pnpapi-${pkg}-${"0.15.18"}-${path.basename(subpath)}`
201
+ `pnpapi-${pkg.replace("/", "-")}-${"0.17.2"}-${path.basename(subpath)}`
194
202
  );
195
203
  if (!fs.existsSync(binTargetPath)) {
196
204
  fs.mkdirSync(path.dirname(binTargetPath), { recursive: true });
package/install.js CHANGED
@@ -14,6 +14,10 @@ var __copyProps = (to, from, except, desc) => {
14
14
  return to;
15
15
  };
16
16
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
17
21
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
18
22
  mod
19
23
  ));
@@ -24,32 +28,32 @@ var os = require("os");
24
28
  var path = require("path");
25
29
  var ESBUILD_BINARY_PATH = process.env.ESBUILD_BINARY_PATH || ESBUILD_BINARY_PATH;
26
30
  var knownWindowsPackages = {
27
- "win32 arm64 LE": "esbuild-windows-arm64",
28
- "win32 ia32 LE": "esbuild-windows-32",
29
- "win32 x64 LE": "esbuild-windows-64"
31
+ "win32 arm64 LE": "@esbuild/win32-arm64",
32
+ "win32 ia32 LE": "@esbuild/win32-ia32",
33
+ "win32 x64 LE": "@esbuild/win32-x64"
30
34
  };
31
35
  var knownUnixlikePackages = {
32
- "android arm64 LE": "esbuild-android-arm64",
33
- "darwin arm64 LE": "esbuild-darwin-arm64",
34
- "darwin x64 LE": "esbuild-darwin-64",
35
- "freebsd arm64 LE": "esbuild-freebsd-arm64",
36
- "freebsd x64 LE": "esbuild-freebsd-64",
37
- "linux arm LE": "esbuild-linux-arm",
38
- "linux arm64 LE": "esbuild-linux-arm64",
39
- "linux ia32 LE": "esbuild-linux-32",
40
- "linux mips64el LE": "esbuild-linux-mips64le",
41
- "linux ppc64 LE": "esbuild-linux-ppc64le",
42
- "linux riscv64 LE": "esbuild-linux-riscv64",
43
- "linux s390x BE": "esbuild-linux-s390x",
44
- "linux x64 LE": "esbuild-linux-64",
36
+ "android arm64 LE": "@esbuild/android-arm64",
37
+ "darwin arm64 LE": "@esbuild/darwin-arm64",
38
+ "darwin x64 LE": "@esbuild/darwin-x64",
39
+ "freebsd arm64 LE": "@esbuild/freebsd-arm64",
40
+ "freebsd x64 LE": "@esbuild/freebsd-x64",
41
+ "linux arm LE": "@esbuild/linux-arm",
42
+ "linux arm64 LE": "@esbuild/linux-arm64",
43
+ "linux ia32 LE": "@esbuild/linux-ia32",
44
+ "linux mips64el LE": "@esbuild/linux-mips64el",
45
+ "linux ppc64 LE": "@esbuild/linux-ppc64",
46
+ "linux riscv64 LE": "@esbuild/linux-riscv64",
47
+ "linux s390x BE": "@esbuild/linux-s390x",
48
+ "linux x64 LE": "@esbuild/linux-x64",
45
49
  "linux loong64 LE": "@esbuild/linux-loong64",
46
- "netbsd x64 LE": "esbuild-netbsd-64",
47
- "openbsd x64 LE": "esbuild-openbsd-64",
48
- "sunos x64 LE": "esbuild-sunos-64"
50
+ "netbsd x64 LE": "@esbuild/netbsd-x64",
51
+ "openbsd x64 LE": "@esbuild/openbsd-x64",
52
+ "sunos x64 LE": "@esbuild/sunos-x64"
49
53
  };
50
54
  var knownWebAssemblyFallbackPackages = {
51
55
  "android arm LE": "@esbuild/android-arm",
52
- "android x64 LE": "esbuild-android-64"
56
+ "android x64 LE": "@esbuild/android-x64"
53
57
  };
54
58
  function pkgAndSubpathForCurrentPlatform() {
55
59
  let pkg;
@@ -73,7 +77,7 @@ function pkgAndSubpathForCurrentPlatform() {
73
77
  }
74
78
  function downloadedBinPath(pkg, subpath) {
75
79
  const esbuildLibDir = path.dirname(require.resolve("esbuild"));
76
- return path.join(esbuildLibDir, `downloaded-${pkg}-${path.basename(subpath)}`);
80
+ return path.join(esbuildLibDir, `downloaded-${pkg.replace("/", "-")}-${path.basename(subpath)}`);
77
81
  }
78
82
 
79
83
  // lib/npm/node-install.ts
@@ -87,11 +91,43 @@ var toPath = path2.join(__dirname, "bin", "esbuild");
87
91
  var isToPathJS = true;
88
92
  function validateBinaryVersion(...command) {
89
93
  command.push("--version");
90
- const stdout = child_process.execFileSync(command.shift(), command, {
91
- stdio: "pipe"
92
- }).toString().trim();
93
- if (stdout !== "0.15.18") {
94
- throw new Error(`Expected ${JSON.stringify("0.15.18")} but got ${JSON.stringify(stdout)}`);
94
+ let stdout;
95
+ try {
96
+ stdout = child_process.execFileSync(command.shift(), command, {
97
+ // Without this, this install script strangely crashes with the error
98
+ // "EACCES: permission denied, write" but only on Ubuntu Linux when node is
99
+ // installed from the Snap Store. This is not a problem when you download
100
+ // the official version of node. The problem appears to be that stderr
101
+ // (i.e. file descriptor 2) isn't writable?
102
+ //
103
+ // More info:
104
+ // - https://snapcraft.io/ (what the Snap Store is)
105
+ // - https://nodejs.org/dist/ (download the official version of node)
106
+ // - https://github.com/evanw/esbuild/issues/1711#issuecomment-1027554035
107
+ //
108
+ stdio: "pipe"
109
+ }).toString().trim();
110
+ } catch (err) {
111
+ if (os2.platform() === "darwin" && /_SecTrustEvaluateWithError/.test(err + "")) {
112
+ let os3 = "this version of macOS";
113
+ try {
114
+ os3 = "macOS " + child_process.execFileSync("sw_vers", ["-productVersion"]).toString().trim();
115
+ } catch {
116
+ }
117
+ throw new Error(`The "esbuild" package cannot be installed because ${os3} is too outdated.
118
+
119
+ The Go compiler (which esbuild relies on) no longer supports ${os3},
120
+ which means the "esbuild" binary executable can't be run. You can either:
121
+
122
+ * Update your version of macOS to one that the Go compiler supports
123
+ * Use the "esbuild-wasm" package instead of the "esbuild" package
124
+ * Build esbuild yourself using an older version of the Go compiler
125
+ `);
126
+ }
127
+ throw err;
128
+ }
129
+ if (stdout !== "0.17.2") {
130
+ throw new Error(`Expected ${JSON.stringify("0.17.2")} but got ${JSON.stringify(stdout)}`);
95
131
  }
96
132
  }
97
133
  function isYarn() {
@@ -143,7 +179,7 @@ function installUsingNPM(pkg, subpath, binPath) {
143
179
  try {
144
180
  fs2.writeFileSync(path2.join(installDir, "package.json"), "{}");
145
181
  child_process.execSync(
146
- `npm install --loglevel=error --prefer-offline --no-audit --progress=false ${pkg}@${"0.15.18"}`,
182
+ `npm install --loglevel=error --prefer-offline --no-audit --progress=false ${pkg}@${"0.17.2"}`,
147
183
  { cwd: installDir, stdio: "pipe", env }
148
184
  );
149
185
  const installedBinPath = path2.join(installDir, "node_modules", pkg, subpath);
@@ -194,7 +230,7 @@ function maybeOptimizePackage(binPath) {
194
230
  }
195
231
  }
196
232
  async function downloadDirectlyFromNPM(pkg, subpath, binPath) {
197
- const url = `https://registry.npmjs.org/${pkg}/-/${pkg}-${"0.15.18"}.tgz`;
233
+ const url = `https://registry.npmjs.org/${pkg}/-/${pkg.replace("@esbuild/", "")}-${"0.17.2"}.tgz`;
198
234
  console.error(`[esbuild] Trying to download ${JSON.stringify(url)}`);
199
235
  try {
200
236
  fs2.writeFileSync(binPath, extractFileFromTarGzip(await fetch(url), subpath));
@@ -206,8 +242,12 @@ async function downloadDirectlyFromNPM(pkg, subpath, binPath) {
206
242
  }
207
243
  async function checkAndPreparePackage() {
208
244
  if (ESBUILD_BINARY_PATH) {
209
- applyManualBinaryPathOverride(ESBUILD_BINARY_PATH);
210
- return;
245
+ if (!fs2.existsSync(ESBUILD_BINARY_PATH)) {
246
+ console.warn(`[esbuild] Ignoring bad configuration: ESBUILD_BINARY_PATH=${ESBUILD_BINARY_PATH}`);
247
+ } else {
248
+ applyManualBinaryPathOverride(ESBUILD_BINARY_PATH);
249
+ return;
250
+ }
211
251
  }
212
252
  const { pkg, subpath } = pkgAndSubpathForCurrentPlatform();
213
253
  let binPath;