esbuild 0.12.28 → 0.13.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.
package/bin/esbuild CHANGED
@@ -1,13 +1,99 @@
1
1
  #!/usr/bin/env node
2
- throw new Error(`esbuild: Failed to install correctly
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
9
+ var __reExport = (target, module2, desc) => {
10
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
11
+ for (let key of __getOwnPropNames(module2))
12
+ if (!__hasOwnProp.call(target, key) && key !== "default")
13
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
14
+ }
15
+ return target;
16
+ };
17
+ var __toModule = (module2) => {
18
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
19
+ };
3
20
 
4
- Make sure you don't have "ignore-scripts" set to true. You can check this with
5
- "npm config get ignore-scripts". If that returns true you can reset it back to
6
- false using "npm config set ignore-scripts false" and then reinstall esbuild.
21
+ // lib/npm/node-platform.ts
22
+ var fs = require("fs");
23
+ var os = require("os");
24
+ var path = require("path");
25
+ var ESBUILD_BINARY_PATH = process.env.ESBUILD_BINARY_PATH || ESBUILD_BINARY_PATH;
26
+ var knownWindowsPackages = {
27
+ "win32 arm64 LE": "esbuild-windows-arm64",
28
+ "win32 ia32 LE": "esbuild-windows-32",
29
+ "win32 x64 LE": "esbuild-windows-64"
30
+ };
31
+ 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
+ "openbsd x64 LE": "esbuild-openbsd-64",
38
+ "linux arm LE": "esbuild-linux-arm",
39
+ "linux arm64 LE": "esbuild-linux-arm64",
40
+ "linux ia32 LE": "esbuild-linux-32",
41
+ "linux mips64el LE": "esbuild-linux-mips64le",
42
+ "linux ppc64 LE": "esbuild-linux-ppc64le",
43
+ "linux x64 LE": "esbuild-linux-64",
44
+ "sunos x64 LE": "esbuild-sunos-64"
45
+ };
46
+ function binPathForCurrentPlatform() {
47
+ let pkg;
48
+ let bin;
49
+ let platformKey = `${process.platform} ${os.arch()} ${os.endianness()}`;
50
+ if (platformKey in knownWindowsPackages) {
51
+ pkg = knownWindowsPackages[platformKey];
52
+ bin = `${pkg}/esbuild.exe`;
53
+ } else if (platformKey in knownUnixlikePackages) {
54
+ pkg = knownUnixlikePackages[platformKey];
55
+ bin = `${pkg}/bin/esbuild`;
56
+ } else {
57
+ throw new Error(`Unsupported platform: ${platformKey}`);
58
+ }
59
+ try {
60
+ bin = require.resolve(bin);
61
+ } catch (e) {
62
+ try {
63
+ require.resolve(pkg);
64
+ } catch (e2) {
65
+ throw new Error(`The package "${pkg}" could not be found, and is needed by esbuild.
7
66
 
8
- If you're using npm v7, make sure your package-lock.json file contains either
9
- "lockfileVersion": 1 or the code "hasInstallScript": true. If it doesn't have
10
- either of those, then it is likely the case that a known bug in npm v7 has
11
- corrupted your package-lock.json file. Regenerating your package-lock.json file
12
- should fix this issue.
13
- `);
67
+ If you are installing esbuild with npm, make sure that you don't specify the
68
+ "--no-optional" flag. The "optionalDependencies" package.json feature is used
69
+ by esbuild to install the correct binary executable for your current platform.`);
70
+ }
71
+ throw e;
72
+ }
73
+ return bin;
74
+ }
75
+ function extractedBinPath() {
76
+ if (ESBUILD_BINARY_PATH) {
77
+ return ESBUILD_BINARY_PATH;
78
+ }
79
+ const bin = binPathForCurrentPlatform();
80
+ let isYarnPnP = false;
81
+ try {
82
+ require("pnpapi");
83
+ isYarnPnP = true;
84
+ } catch (e) {
85
+ }
86
+ if (isYarnPnP) {
87
+ const esbuildLibDir = path.dirname(require.resolve("esbuild"));
88
+ const binTargetPath = path.join(esbuildLibDir, "yarn-pnp-" + path.basename(bin));
89
+ if (!fs.existsSync(binTargetPath)) {
90
+ fs.copyFileSync(bin, binTargetPath);
91
+ fs.chmodSync(binTargetPath, 493);
92
+ }
93
+ return binTargetPath;
94
+ }
95
+ return bin;
96
+ }
97
+
98
+ // lib/npm/node-shim.ts
99
+ require("child_process").execFileSync(extractedBinPath(), process.argv.slice(2), { stdio: "inherit" });
package/install.js CHANGED
@@ -1,187 +1,72 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
1
+ // lib/npm/node-platform.ts
2
+ var fs = require("fs");
3
+ var os = require("os");
4
+ var path = require("path");
5
+ var ESBUILD_BINARY_PATH = process.env.ESBUILD_BINARY_PATH || ESBUILD_BINARY_PATH;
6
+ var knownWindowsPackages = {
7
+ "win32 arm64 LE": "esbuild-windows-arm64",
8
+ "win32 ia32 LE": "esbuild-windows-32",
9
+ "win32 x64 LE": "esbuild-windows-64"
18
10
  };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __require = typeof require !== "undefined" ? require : (x) => {
21
- throw new Error('Dynamic require of "' + x + '" is not supported');
11
+ var knownUnixlikePackages = {
12
+ "android arm64 LE": "esbuild-android-arm64",
13
+ "darwin arm64 LE": "esbuild-darwin-arm64",
14
+ "darwin x64 LE": "esbuild-darwin-64",
15
+ "freebsd arm64 LE": "esbuild-freebsd-arm64",
16
+ "freebsd x64 LE": "esbuild-freebsd-64",
17
+ "openbsd x64 LE": "esbuild-openbsd-64",
18
+ "linux arm LE": "esbuild-linux-arm",
19
+ "linux arm64 LE": "esbuild-linux-arm64",
20
+ "linux ia32 LE": "esbuild-linux-32",
21
+ "linux mips64el LE": "esbuild-linux-mips64le",
22
+ "linux ppc64 LE": "esbuild-linux-ppc64le",
23
+ "linux x64 LE": "esbuild-linux-64",
24
+ "sunos x64 LE": "esbuild-sunos-64"
22
25
  };
23
- const fs = require("fs");
24
- const os = require("os");
25
- const path = require("path");
26
- const zlib = require("zlib");
27
- const https = require("https");
28
- const child_process = require("child_process");
29
- const version = "0.12.28";
30
- const binPath = path.join(__dirname, "bin", "esbuild");
31
- async function installBinaryFromPackage(name, fromPath, toPath) {
32
- const cachePath = getCachePath(name);
33
- try {
34
- fs.copyFileSync(cachePath, toPath);
35
- fs.chmodSync(toPath, 493);
36
- validateBinaryVersion(toPath);
37
- const now = new Date();
38
- fs.utimesSync(cachePath, now, now);
39
- return;
40
- } catch (e) {
41
- }
42
- let buffer;
43
- let didFail = false;
44
- try {
45
- buffer = installUsingNPM(name, fromPath);
46
- } catch (err) {
47
- didFail = true;
48
- console.error(`Trying to install "${name}" using npm`);
49
- console.error(`Failed to install "${name}" using npm: ${err && err.message || err}`);
50
- }
51
- if (!buffer) {
52
- const url = `https://registry.npmjs.org/${name}/-/${name}-${version}.tgz`;
53
- console.error(`Trying to download ${JSON.stringify(url)}`);
54
- try {
55
- buffer = extractFileFromTarGzip(await fetch(url), fromPath);
56
- } catch (err) {
57
- console.error(`Failed to download ${JSON.stringify(url)}: ${err && err.message || err}`);
58
- }
59
- }
60
- if (!buffer) {
61
- console.error(`Install unsuccessful`);
62
- process.exit(1);
63
- }
64
- fs.writeFileSync(toPath, buffer, { mode: 493 });
65
- try {
66
- validateBinaryVersion(toPath);
67
- } catch (err) {
68
- console.error(`The version of the downloaded binary is incorrect: ${err && err.message || err}`);
69
- console.error(`Install unsuccessful`);
70
- process.exit(1);
26
+ function binPathForCurrentPlatform() {
27
+ let pkg;
28
+ let bin;
29
+ let platformKey = `${process.platform} ${os.arch()} ${os.endianness()}`;
30
+ if (platformKey in knownWindowsPackages) {
31
+ pkg = knownWindowsPackages[platformKey];
32
+ bin = `${pkg}/esbuild.exe`;
33
+ } else if (platformKey in knownUnixlikePackages) {
34
+ pkg = knownUnixlikePackages[platformKey];
35
+ bin = `${pkg}/bin/esbuild`;
36
+ } else {
37
+ throw new Error(`Unsupported platform: ${platformKey}`);
71
38
  }
72
39
  try {
73
- fs.mkdirSync(path.dirname(cachePath), {
74
- recursive: true,
75
- mode: 448
76
- });
77
- fs.copyFileSync(toPath, cachePath);
78
- cleanCacheLRU(cachePath);
40
+ bin = require.resolve(bin);
79
41
  } catch (e) {
80
- }
81
- if (didFail)
82
- console.error(`Install successful`);
83
- }
84
- function validateBinaryVersion(binaryPath) {
85
- const stdout = child_process.execFileSync(binaryPath, ["--version"]).toString().trim();
86
- if (stdout !== version) {
87
- throw new Error(`Expected ${JSON.stringify(version)} but got ${JSON.stringify(stdout)}`);
88
- }
89
- }
90
- function getCachePath(name) {
91
- const home = os.homedir();
92
- const common = ["esbuild", "bin", `${name}@${version}`];
93
- if (process.platform === "darwin")
94
- return path.join(home, "Library", "Caches", ...common);
95
- if (process.platform === "win32")
96
- return path.join(home, "AppData", "Local", "Cache", ...common);
97
- const XDG_CACHE_HOME = process.env.XDG_CACHE_HOME;
98
- if (process.platform === "linux" && XDG_CACHE_HOME && path.isAbsolute(XDG_CACHE_HOME))
99
- return path.join(XDG_CACHE_HOME, ...common);
100
- return path.join(home, ".cache", ...common);
101
- }
102
- function cleanCacheLRU(fileToKeep) {
103
- const dir = path.dirname(fileToKeep);
104
- const entries = [];
105
- for (const entry of fs.readdirSync(dir)) {
106
- const entryPath = path.join(dir, entry);
107
42
  try {
108
- const stats = fs.statSync(entryPath);
109
- entries.push({ path: entryPath, mtime: stats.mtime });
110
- } catch (e) {
43
+ require.resolve(pkg);
44
+ } catch (e2) {
45
+ throw new Error(`The package "${pkg}" could not be found, and is needed by esbuild.
46
+
47
+ If you are installing esbuild with npm, make sure that you don't specify the
48
+ "--no-optional" flag. The "optionalDependencies" package.json feature is used
49
+ by esbuild to install the correct binary executable for your current platform.`);
111
50
  }
51
+ throw e;
112
52
  }
113
- entries.sort((a, b) => +b.mtime - +a.mtime);
114
- for (const entry of entries.slice(5)) {
115
- try {
116
- fs.unlinkSync(entry.path);
117
- } catch (e) {
118
- }
119
- }
120
- }
121
- function fetch(url) {
122
- return new Promise((resolve, reject) => {
123
- https.get(url, (res) => {
124
- if ((res.statusCode === 301 || res.statusCode === 302) && res.headers.location)
125
- return fetch(res.headers.location).then(resolve, reject);
126
- if (res.statusCode !== 200)
127
- return reject(new Error(`Server responded with ${res.statusCode}`));
128
- let chunks = [];
129
- res.on("data", (chunk) => chunks.push(chunk));
130
- res.on("end", () => resolve(Buffer.concat(chunks)));
131
- }).on("error", reject);
132
- });
53
+ return bin;
133
54
  }
134
- function extractFileFromTarGzip(buffer, file) {
135
- try {
136
- buffer = zlib.unzipSync(buffer);
137
- } catch (err) {
138
- throw new Error(`Invalid gzip data in archive: ${err && err.message || err}`);
55
+
56
+ // lib/npm/node-install.ts
57
+ var fs2 = require("fs");
58
+ var os2 = require("os");
59
+ var path2 = require("path");
60
+ var child_process = require("child_process");
61
+ var toPath = path2.join(__dirname, "bin", "esbuild");
62
+ function validateBinaryVersion(...command) {
63
+ command.push("--version");
64
+ const stdout = child_process.execFileSync(command.shift(), command).toString().trim();
65
+ if (stdout !== "0.13.2") {
66
+ throw new Error(`Expected ${JSON.stringify("0.13.2")} but got ${JSON.stringify(stdout)}`);
139
67
  }
140
- let str = (i, n) => String.fromCharCode(...buffer.subarray(i, i + n)).replace(/\0.*$/, "");
141
- let offset = 0;
142
- file = `package/${file}`;
143
- while (offset < buffer.length) {
144
- let name = str(offset, 100);
145
- let size = parseInt(str(offset + 124, 12), 8);
146
- offset += 512;
147
- if (!isNaN(size)) {
148
- if (name === file)
149
- return buffer.subarray(offset, offset + size);
150
- offset += size + 511 & ~511;
151
- }
152
- }
153
- throw new Error(`Could not find ${JSON.stringify(file)} in archive`);
154
- }
155
- function installUsingNPM(name, file) {
156
- const installDir = path.join(os.tmpdir(), "esbuild-" + Math.random().toString(36).slice(2));
157
- fs.mkdirSync(installDir, { recursive: true });
158
- fs.writeFileSync(path.join(installDir, "package.json"), "{}");
159
- const env = __spreadProps(__spreadValues({}, process.env), { npm_config_global: void 0 });
160
- child_process.execSync(`npm install --loglevel=error --prefer-offline --no-audit --progress=false ${name}@${version}`, { cwd: installDir, stdio: "pipe", env });
161
- const buffer = fs.readFileSync(path.join(installDir, "node_modules", name, file));
162
- try {
163
- removeRecursive(installDir);
164
- } catch (e) {
165
- }
166
- return buffer;
167
68
  }
168
- function removeRecursive(dir) {
169
- for (const entry of fs.readdirSync(dir)) {
170
- const entryPath = path.join(dir, entry);
171
- let stats;
172
- try {
173
- stats = fs.lstatSync(entryPath);
174
- } catch (e) {
175
- continue;
176
- }
177
- if (stats.isDirectory())
178
- removeRecursive(entryPath);
179
- else
180
- fs.unlinkSync(entryPath);
181
- }
182
- fs.rmdirSync(dir);
183
- }
184
- function isYarnBerryOrNewer() {
69
+ function isYarn2OrAbove() {
185
70
  const { npm_config_user_agent } = process.env;
186
71
  if (npm_config_user_agent) {
187
72
  const match = npm_config_user_agent.match(/yarn\/(\d+)/);
@@ -191,71 +76,24 @@ function isYarnBerryOrNewer() {
191
76
  }
192
77
  return false;
193
78
  }
194
- function installDirectly(name) {
195
- if (process.env.ESBUILD_BINARY_PATH) {
196
- fs.copyFileSync(process.env.ESBUILD_BINARY_PATH, binPath);
197
- validateBinaryVersion(binPath);
198
- } else {
199
- const tempBinPath = binPath + "__";
200
- installBinaryFromPackage(name, "bin/esbuild", tempBinPath).then(() => fs.renameSync(tempBinPath, binPath)).catch((e) => setImmediate(() => {
201
- throw e;
202
- }));
203
- }
204
- }
205
- function installWithWrapper(name, fromPath, toPath) {
206
- fs.writeFileSync(binPath, `#!/usr/bin/env node
207
- const path = require('path');
208
- const esbuild_exe = path.join(__dirname, '..', ${JSON.stringify(toPath)});
209
- const child_process = require('child_process');
210
- const { status } = child_process.spawnSync(esbuild_exe, process.argv.slice(2), { stdio: 'inherit' });
211
- process.exitCode = status === null ? 1 : status;
79
+ if (process.env.ESBUILD_BINARY_PATH) {
80
+ const pathString = JSON.stringify(process.env.ESBUILD_BINARY_PATH);
81
+ fs2.writeFileSync(toPath, `#!/usr/bin/env node
82
+ require('child_process').execFileSync(${pathString}, process.argv.slice(2), { stdio: 'inherit' });
212
83
  `);
213
- const absToPath = path.join(__dirname, toPath);
214
- if (process.env.ESBUILD_BINARY_PATH) {
215
- fs.copyFileSync(process.env.ESBUILD_BINARY_PATH, absToPath);
216
- validateBinaryVersion(absToPath);
217
- } else {
218
- installBinaryFromPackage(name, fromPath, absToPath).catch((e) => setImmediate(() => {
219
- throw e;
220
- }));
221
- }
222
- }
223
- function installOnUnix(name) {
224
- if (isYarnBerryOrNewer()) {
225
- installWithWrapper(name, "bin/esbuild", "esbuild");
226
- } else {
227
- installDirectly(name);
84
+ const libMain = path2.join(__dirname, "lib", "main.js");
85
+ const code = fs2.readFileSync(libMain, "utf8");
86
+ fs2.writeFileSync(libMain, `var ESBUILD_BINARY_PATH = ${pathString};
87
+ ${code}`);
88
+ validateBinaryVersion("node", toPath);
89
+ } else if (os2.platform() !== "win32" && !isYarn2OrAbove()) {
90
+ const bin = binPathForCurrentPlatform();
91
+ try {
92
+ fs2.unlinkSync(toPath);
93
+ fs2.linkSync(bin, toPath);
94
+ } catch (e) {
228
95
  }
229
- }
230
- function installOnWindows(name) {
231
- installWithWrapper(name, "esbuild.exe", "esbuild.exe");
232
- }
233
- const platformKey = `${process.platform} ${os.arch()} ${os.endianness()}`;
234
- const knownWindowsPackages = {
235
- "win32 arm64 LE": "esbuild-windows-arm64",
236
- "win32 ia32 LE": "esbuild-windows-32",
237
- "win32 x64 LE": "esbuild-windows-64"
238
- };
239
- const knownUnixlikePackages = {
240
- "android arm64 LE": "esbuild-android-arm64",
241
- "darwin arm64 LE": "esbuild-darwin-arm64",
242
- "darwin x64 LE": "esbuild-darwin-64",
243
- "freebsd arm64 LE": "esbuild-freebsd-arm64",
244
- "freebsd x64 LE": "esbuild-freebsd-64",
245
- "openbsd x64 LE": "esbuild-openbsd-64",
246
- "linux arm LE": "esbuild-linux-arm",
247
- "linux arm64 LE": "esbuild-linux-arm64",
248
- "linux ia32 LE": "esbuild-linux-32",
249
- "linux mips64el LE": "esbuild-linux-mips64le",
250
- "linux ppc64 LE": "esbuild-linux-ppc64le",
251
- "linux x64 LE": "esbuild-linux-64",
252
- "sunos x64 LE": "esbuild-sunos-64"
253
- };
254
- if (platformKey in knownWindowsPackages) {
255
- installOnWindows(knownWindowsPackages[platformKey]);
256
- } else if (platformKey in knownUnixlikePackages) {
257
- installOnUnix(knownUnixlikePackages[platformKey]);
96
+ validateBinaryVersion(toPath);
258
97
  } else {
259
- console.error(`Unsupported platform: ${platformKey}`);
260
- process.exit(1);
98
+ validateBinaryVersion("node", toPath);
261
99
  }
package/lib/main.d.ts CHANGED
@@ -3,7 +3,6 @@ export type Format = 'iife' | 'cjs' | 'esm';
3
3
  export type Loader = 'js' | 'jsx' | 'ts' | 'tsx' | 'css' | 'json' | 'text' | 'base64' | 'file' | 'dataurl' | 'binary' | 'default';
4
4
  export type LogLevel = 'verbose' | 'debug' | 'info' | 'warning' | 'error' | 'silent';
5
5
  export type Charset = 'ascii' | 'utf8';
6
- export type TreeShaking = true | 'ignore-annotations';
7
6
 
8
7
  interface CommonOptions {
9
8
  sourcemap?: boolean | 'inline' | 'external' | 'both';
@@ -20,7 +19,8 @@ interface CommonOptions {
20
19
  minifyIdentifiers?: boolean;
21
20
  minifySyntax?: boolean;
22
21
  charset?: Charset;
23
- treeShaking?: TreeShaking;
22
+ treeShaking?: boolean;
23
+ ignoreAnnotations?: boolean;
24
24
 
25
25
  jsx?: 'transform' | 'preserve';
26
26
  jsxFactory?: string;
package/lib/main.js CHANGED
@@ -1,7 +1,11 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
5
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
7
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __getProtoOf = Object.getPrototypeOf;
5
9
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
10
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
11
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -18,14 +22,22 @@ var __spreadValues = (a, b) => {
18
22
  };
19
23
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
24
  var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
21
- var __require = typeof require !== "undefined" ? require : (x) => {
22
- throw new Error('Dynamic require of "' + x + '" is not supported');
23
- };
24
25
  var __export = (target, all) => {
25
26
  __markAsModule(target);
26
27
  for (var name in all)
27
28
  __defProp(target, name, { get: all[name], enumerable: true });
28
29
  };
30
+ var __reExport = (target, module2, desc) => {
31
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
32
+ for (let key of __getOwnPropNames(module2))
33
+ if (!__hasOwnProp.call(target, key) && key !== "default")
34
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
35
+ }
36
+ return target;
37
+ };
38
+ var __toModule = (module2) => {
39
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
40
+ };
29
41
 
30
42
  // lib/npm/node.ts
31
43
  __export(exports, {
@@ -278,7 +290,8 @@ function pushCommonFlags(flags, options, keys) {
278
290
  let minifyWhitespace = getFlag(options, keys, "minifyWhitespace", mustBeBoolean);
279
291
  let minifyIdentifiers = getFlag(options, keys, "minifyIdentifiers", mustBeBoolean);
280
292
  let charset = getFlag(options, keys, "charset", mustBeString);
281
- let treeShaking = getFlag(options, keys, "treeShaking", mustBeStringOrBoolean);
293
+ let treeShaking = getFlag(options, keys, "treeShaking", mustBeBoolean);
294
+ let ignoreAnnotations = getFlag(options, keys, "ignoreAnnotations", mustBeBoolean);
282
295
  let jsx = getFlag(options, keys, "jsx", mustBeString);
283
296
  let jsxFactory = getFlag(options, keys, "jsxFactory", mustBeString);
284
297
  let jsxFragment = getFlag(options, keys, "jsxFragment", mustBeString);
@@ -311,8 +324,10 @@ function pushCommonFlags(flags, options, keys) {
311
324
  flags.push("--minify-identifiers");
312
325
  if (charset)
313
326
  flags.push(`--charset=${charset}`);
314
- if (treeShaking !== void 0 && treeShaking !== true)
327
+ if (treeShaking !== void 0)
315
328
  flags.push(`--tree-shaking=${treeShaking}`);
329
+ if (ignoreAnnotations)
330
+ flags.push(`--ignore-annotations`);
316
331
  if (jsx)
317
332
  flags.push(`--jsx=${jsx}`);
318
333
  if (jsxFactory)
@@ -464,8 +479,8 @@ function flagsForBuildOptions(callName, options, isTTY2, logLevelDefault, writeD
464
479
  }
465
480
  }
466
481
  if (inject)
467
- for (let path2 of inject)
468
- flags.push(`--inject:${path2}`);
482
+ for (let path3 of inject)
483
+ flags.push(`--inject:${path3}`);
469
484
  if (loader) {
470
485
  for (let ext in loader) {
471
486
  if (ext.indexOf("=") >= 0)
@@ -694,8 +709,8 @@ function createChannel(streamIn) {
694
709
  if (isFirstPacket) {
695
710
  isFirstPacket = false;
696
711
  let binaryVersion = String.fromCharCode(...bytes);
697
- if (binaryVersion !== "0.12.28") {
698
- throw new Error(`Cannot start service: Host version "${"0.12.28"}" does not match binary version ${JSON.stringify(binaryVersion)}`);
712
+ if (binaryVersion !== "0.13.2") {
713
+ throw new Error(`Cannot start service: Host version "${"0.13.2"}" does not match binary version ${JSON.stringify(binaryVersion)}`);
699
714
  }
700
715
  return;
701
716
  }
@@ -827,7 +842,7 @@ function createChannel(streamIn) {
827
842
  throw new Error(`Expected onResolve() callback in plugin ${JSON.stringify(name)} to return an object`);
828
843
  let keys = {};
829
844
  let pluginName = getFlag(result, keys, "pluginName", mustBeString);
830
- let path2 = getFlag(result, keys, "path", mustBeString);
845
+ let path3 = getFlag(result, keys, "path", mustBeString);
831
846
  let namespace = getFlag(result, keys, "namespace", mustBeString);
832
847
  let external = getFlag(result, keys, "external", mustBeBoolean);
833
848
  let sideEffects = getFlag(result, keys, "sideEffects", mustBeBoolean);
@@ -840,8 +855,8 @@ function createChannel(streamIn) {
840
855
  response.id = id;
841
856
  if (pluginName != null)
842
857
  response.pluginName = pluginName;
843
- if (path2 != null)
844
- response.path = path2;
858
+ if (path3 != null)
859
+ response.path = path3;
845
860
  if (namespace != null)
846
861
  response.namespace = namespace;
847
862
  if (external != null)
@@ -1243,7 +1258,7 @@ function createChannel(streamIn) {
1243
1258
  return buildResponseToResult(response, callback);
1244
1259
  });
1245
1260
  };
1246
- let transform2 = ({ callName, refs, input, options, isTTY: isTTY2, fs: fs2, callback }) => {
1261
+ let transform2 = ({ callName, refs, input, options, isTTY: isTTY2, fs: fs3, callback }) => {
1247
1262
  const details = createObjectStash();
1248
1263
  let start = (inputPath) => {
1249
1264
  try {
@@ -1267,7 +1282,7 @@ function createChannel(streamIn) {
1267
1282
  return callback(failureErrorWithLog("Transform failed", errors, warnings), null);
1268
1283
  if (response.codeFS) {
1269
1284
  outstanding++;
1270
- fs2.readFile(response.code, (err, contents) => {
1285
+ fs3.readFile(response.code, (err, contents) => {
1271
1286
  if (err !== null) {
1272
1287
  callback(err, null);
1273
1288
  } else {
@@ -1278,7 +1293,7 @@ function createChannel(streamIn) {
1278
1293
  }
1279
1294
  if (response.mapFS) {
1280
1295
  outstanding++;
1281
- fs2.readFile(response.map, (err, contents) => {
1296
+ fs3.readFile(response.map, (err, contents) => {
1282
1297
  if (err !== null) {
1283
1298
  callback(err, null);
1284
1299
  } else {
@@ -1304,7 +1319,7 @@ function createChannel(streamIn) {
1304
1319
  };
1305
1320
  if (typeof input === "string" && input.length > 1024 * 1024) {
1306
1321
  let next = start;
1307
- start = () => fs2.writeFile(input, next);
1322
+ start = () => fs3.writeFile(input, next);
1308
1323
  }
1309
1324
  start(null);
1310
1325
  };
@@ -1553,10 +1568,10 @@ function sanitizeStringArray(values, property) {
1553
1568
  }
1554
1569
  return result;
1555
1570
  }
1556
- function convertOutputFiles({ path: path2, contents }) {
1571
+ function convertOutputFiles({ path: path3, contents }) {
1557
1572
  let text = null;
1558
1573
  return {
1559
- path: path2,
1574
+ path: path3,
1560
1575
  contents,
1561
1576
  get text() {
1562
1577
  if (text === null)
@@ -1566,12 +1581,89 @@ function convertOutputFiles({ path: path2, contents }) {
1566
1581
  };
1567
1582
  }
1568
1583
 
1584
+ // lib/npm/node-platform.ts
1585
+ var fs = require("fs");
1586
+ var os = require("os");
1587
+ var path = require("path");
1588
+ var ESBUILD_BINARY_PATH = process.env.ESBUILD_BINARY_PATH || ESBUILD_BINARY_PATH;
1589
+ var knownWindowsPackages = {
1590
+ "win32 arm64 LE": "esbuild-windows-arm64",
1591
+ "win32 ia32 LE": "esbuild-windows-32",
1592
+ "win32 x64 LE": "esbuild-windows-64"
1593
+ };
1594
+ var knownUnixlikePackages = {
1595
+ "android arm64 LE": "esbuild-android-arm64",
1596
+ "darwin arm64 LE": "esbuild-darwin-arm64",
1597
+ "darwin x64 LE": "esbuild-darwin-64",
1598
+ "freebsd arm64 LE": "esbuild-freebsd-arm64",
1599
+ "freebsd x64 LE": "esbuild-freebsd-64",
1600
+ "openbsd x64 LE": "esbuild-openbsd-64",
1601
+ "linux arm LE": "esbuild-linux-arm",
1602
+ "linux arm64 LE": "esbuild-linux-arm64",
1603
+ "linux ia32 LE": "esbuild-linux-32",
1604
+ "linux mips64el LE": "esbuild-linux-mips64le",
1605
+ "linux ppc64 LE": "esbuild-linux-ppc64le",
1606
+ "linux x64 LE": "esbuild-linux-64",
1607
+ "sunos x64 LE": "esbuild-sunos-64"
1608
+ };
1609
+ function binPathForCurrentPlatform() {
1610
+ let pkg;
1611
+ let bin;
1612
+ let platformKey = `${process.platform} ${os.arch()} ${os.endianness()}`;
1613
+ if (platformKey in knownWindowsPackages) {
1614
+ pkg = knownWindowsPackages[platformKey];
1615
+ bin = `${pkg}/esbuild.exe`;
1616
+ } else if (platformKey in knownUnixlikePackages) {
1617
+ pkg = knownUnixlikePackages[platformKey];
1618
+ bin = `${pkg}/bin/esbuild`;
1619
+ } else {
1620
+ throw new Error(`Unsupported platform: ${platformKey}`);
1621
+ }
1622
+ try {
1623
+ bin = require.resolve(bin);
1624
+ } catch (e) {
1625
+ try {
1626
+ require.resolve(pkg);
1627
+ } catch (e2) {
1628
+ throw new Error(`The package "${pkg}" could not be found, and is needed by esbuild.
1629
+
1630
+ If you are installing esbuild with npm, make sure that you don't specify the
1631
+ "--no-optional" flag. The "optionalDependencies" package.json feature is used
1632
+ by esbuild to install the correct binary executable for your current platform.`);
1633
+ }
1634
+ throw e;
1635
+ }
1636
+ return bin;
1637
+ }
1638
+ function extractedBinPath() {
1639
+ if (ESBUILD_BINARY_PATH) {
1640
+ return ESBUILD_BINARY_PATH;
1641
+ }
1642
+ const bin = binPathForCurrentPlatform();
1643
+ let isYarnPnP = false;
1644
+ try {
1645
+ require("pnpapi");
1646
+ isYarnPnP = true;
1647
+ } catch (e) {
1648
+ }
1649
+ if (isYarnPnP) {
1650
+ const esbuildLibDir = path.dirname(require.resolve("esbuild"));
1651
+ const binTargetPath = path.join(esbuildLibDir, "yarn-pnp-" + path.basename(bin));
1652
+ if (!fs.existsSync(binTargetPath)) {
1653
+ fs.copyFileSync(bin, binTargetPath);
1654
+ fs.chmodSync(binTargetPath, 493);
1655
+ }
1656
+ return binTargetPath;
1657
+ }
1658
+ return bin;
1659
+ }
1660
+
1569
1661
  // lib/npm/node.ts
1570
1662
  var child_process = require("child_process");
1571
1663
  var crypto = require("crypto");
1572
- var path = require("path");
1573
- var fs = require("fs");
1574
- var os = require("os");
1664
+ var path2 = require("path");
1665
+ var fs2 = require("fs");
1666
+ var os2 = require("os");
1575
1667
  var tty = require("tty");
1576
1668
  var worker_threads;
1577
1669
  if (process.env.ESBUILD_WORKER_THREADS !== "0") {
@@ -1585,35 +1677,25 @@ if (process.env.ESBUILD_WORKER_THREADS !== "0") {
1585
1677
  }
1586
1678
  }
1587
1679
  var _a;
1588
- var isInternalWorkerThread = ((_a = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a.esbuildVersion) === "0.12.28";
1680
+ var isInternalWorkerThread = ((_a = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a.esbuildVersion) === "0.13.2";
1589
1681
  var esbuildCommandAndArgs = () => {
1590
- if (process.env.ESBUILD_BINARY_PATH) {
1591
- return [path.resolve(process.env.ESBUILD_BINARY_PATH), []];
1592
- }
1593
- if (path.basename(__filename) !== "main.js" || path.basename(__dirname) !== "lib") {
1682
+ if (path2.basename(__filename) !== "main.js" || path2.basename(__dirname) !== "lib") {
1594
1683
  throw new Error(`The esbuild JavaScript API cannot be bundled. Please mark the "esbuild" package as external so it's not included in the bundle.
1595
1684
 
1596
1685
  More information: The file containing the code for esbuild's JavaScript API (${__filename}) does not appear to be inside the esbuild package on the file system, which usually means that the esbuild package was bundled into another file. This is problematic because the API needs to run a binary executable inside the esbuild package which is located using a relative path from the API code to the executable. If the esbuild package is bundled, the relative path will be incorrect and the executable won't be found.`);
1597
1686
  }
1598
1687
  if (false) {
1599
- return ["node", [path.join(__dirname, "..", "bin", "esbuild")]];
1600
- }
1601
- if (process.platform === "win32") {
1602
- return [path.join(__dirname, "..", "esbuild.exe"), []];
1603
- }
1604
- let pathForYarn2 = path.join(__dirname, "..", "esbuild");
1605
- if (fs.existsSync(pathForYarn2)) {
1606
- return [pathForYarn2, []];
1688
+ return ["node", [path2.join(__dirname, "..", "bin", "esbuild")]];
1607
1689
  }
1608
- return [path.join(__dirname, "..", "bin", "esbuild"), []];
1690
+ return [extractedBinPath(), []];
1609
1691
  };
1610
1692
  var isTTY = () => tty.isatty(2);
1611
1693
  var fsSync = {
1612
1694
  readFile(tempFile, callback) {
1613
1695
  try {
1614
- let contents = fs.readFileSync(tempFile, "utf8");
1696
+ let contents = fs2.readFileSync(tempFile, "utf8");
1615
1697
  try {
1616
- fs.unlinkSync(tempFile);
1698
+ fs2.unlinkSync(tempFile);
1617
1699
  } catch (e) {
1618
1700
  }
1619
1701
  callback(null, contents);
@@ -1624,7 +1706,7 @@ var fsSync = {
1624
1706
  writeFile(contents, callback) {
1625
1707
  try {
1626
1708
  let tempFile = randomFileName();
1627
- fs.writeFileSync(tempFile, contents);
1709
+ fs2.writeFileSync(tempFile, contents);
1628
1710
  callback(tempFile);
1629
1711
  } catch (e) {
1630
1712
  callback(null);
@@ -1634,9 +1716,9 @@ var fsSync = {
1634
1716
  var fsAsync = {
1635
1717
  readFile(tempFile, callback) {
1636
1718
  try {
1637
- fs.readFile(tempFile, "utf8", (err, contents) => {
1719
+ fs2.readFile(tempFile, "utf8", (err, contents) => {
1638
1720
  try {
1639
- fs.unlink(tempFile, () => callback(err, contents));
1721
+ fs2.unlink(tempFile, () => callback(err, contents));
1640
1722
  } catch (e) {
1641
1723
  callback(err, contents);
1642
1724
  }
@@ -1648,13 +1730,13 @@ var fsAsync = {
1648
1730
  writeFile(contents, callback) {
1649
1731
  try {
1650
1732
  let tempFile = randomFileName();
1651
- fs.writeFile(tempFile, contents, (err) => err !== null ? callback(null) : callback(tempFile));
1733
+ fs2.writeFile(tempFile, contents, (err) => err !== null ? callback(null) : callback(tempFile));
1652
1734
  } catch (e) {
1653
1735
  callback(null);
1654
1736
  }
1655
1737
  }
1656
1738
  };
1657
- var version = "0.12.28";
1739
+ var version = "0.13.2";
1658
1740
  var build = (options) => ensureServiceIsRunning().build(options);
1659
1741
  var serve = (serveOptions, buildOptions) => ensureServiceIsRunning().serve(serveOptions, buildOptions);
1660
1742
  var transform = (input, options) => ensureServiceIsRunning().transform(input, options);
@@ -1763,7 +1845,7 @@ var ensureServiceIsRunning = () => {
1763
1845
  if (longLivedService)
1764
1846
  return longLivedService;
1765
1847
  let [command, args] = esbuildCommandAndArgs();
1766
- let child = child_process.spawn(command, args.concat(`--service=${"0.12.28"}`, "--ping"), {
1848
+ let child = child_process.spawn(command, args.concat(`--service=${"0.13.2"}`, "--ping"), {
1767
1849
  windowsHide: true,
1768
1850
  stdio: ["pipe", "pipe", "inherit"],
1769
1851
  cwd: defaultWD
@@ -1772,7 +1854,7 @@ var ensureServiceIsRunning = () => {
1772
1854
  writeToStdin(bytes) {
1773
1855
  child.stdin.write(bytes);
1774
1856
  },
1775
- readFileSync: fs.readFileSync,
1857
+ readFileSync: fs2.readFileSync,
1776
1858
  isSync: false,
1777
1859
  isBrowser: false
1778
1860
  });
@@ -1870,7 +1952,7 @@ var runServiceSync = (callback) => {
1870
1952
  isBrowser: false
1871
1953
  });
1872
1954
  callback(service);
1873
- let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.12.28"}`), {
1955
+ let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.13.2"}`), {
1874
1956
  cwd: defaultWD,
1875
1957
  windowsHide: true,
1876
1958
  input: stdin,
@@ -1880,13 +1962,13 @@ var runServiceSync = (callback) => {
1880
1962
  afterClose();
1881
1963
  };
1882
1964
  var randomFileName = () => {
1883
- return path.join(os.tmpdir(), `esbuild-${crypto.randomBytes(32).toString("hex")}`);
1965
+ return path2.join(os2.tmpdir(), `esbuild-${crypto.randomBytes(32).toString("hex")}`);
1884
1966
  };
1885
1967
  var workerThreadService = null;
1886
1968
  var startWorkerThreadService = (worker_threads2) => {
1887
1969
  let { port1: mainPort, port2: workerPort } = new worker_threads2.MessageChannel();
1888
1970
  let worker = new worker_threads2.Worker(__filename, {
1889
- workerData: { workerPort, defaultWD, esbuildVersion: "0.12.28" },
1971
+ workerData: { workerPort, defaultWD, esbuildVersion: "0.13.2" },
1890
1972
  transferList: [workerPort],
1891
1973
  execArgv: []
1892
1974
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esbuild",
3
- "version": "0.12.28",
3
+ "version": "0.13.2",
4
4
  "description": "An extremely fast JavaScript bundler and minifier.",
5
5
  "repository": "https://github.com/evanw/esbuild",
6
6
  "scripts": {
@@ -11,5 +11,23 @@
11
11
  "bin": {
12
12
  "esbuild": "bin/esbuild"
13
13
  },
14
+ "optionalDependencies": {
15
+ "esbuild-android-arm64": "0.13.2",
16
+ "esbuild-darwin-64": "0.13.2",
17
+ "esbuild-darwin-arm64": "0.13.2",
18
+ "esbuild-freebsd-64": "0.13.2",
19
+ "esbuild-freebsd-arm64": "0.13.2",
20
+ "esbuild-linux-32": "0.13.2",
21
+ "esbuild-linux-64": "0.13.2",
22
+ "esbuild-linux-arm": "0.13.2",
23
+ "esbuild-linux-arm64": "0.13.2",
24
+ "esbuild-linux-mips64le": "0.13.2",
25
+ "esbuild-linux-ppc64le": "0.13.2",
26
+ "esbuild-openbsd-64": "0.13.2",
27
+ "esbuild-sunos-64": "0.13.2",
28
+ "esbuild-windows-32": "0.13.2",
29
+ "esbuild-windows-64": "0.13.2",
30
+ "esbuild-windows-arm64": "0.13.2"
31
+ },
14
32
  "license": "MIT"
15
33
  }