esbuild 0.14.9 → 0.14.13

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
@@ -60,6 +60,29 @@ function pkgAndSubpathForCurrentPlatform() {
60
60
  }
61
61
  return { pkg, subpath };
62
62
  }
63
+ function pkgForSomeOtherPlatform() {
64
+ const libMainJS = require.resolve("esbuild");
65
+ const nodeModulesDirectory = path.dirname(path.dirname(path.dirname(libMainJS)));
66
+ if (path.basename(nodeModulesDirectory) === "node_modules") {
67
+ for (const unixKey in knownUnixlikePackages) {
68
+ try {
69
+ const pkg = knownUnixlikePackages[unixKey];
70
+ if (fs.existsSync(path.join(nodeModulesDirectory, pkg)))
71
+ return pkg;
72
+ } catch {
73
+ }
74
+ }
75
+ for (const windowsKey in knownWindowsPackages) {
76
+ try {
77
+ const pkg = knownWindowsPackages[windowsKey];
78
+ if (fs.existsSync(path.join(nodeModulesDirectory, pkg)))
79
+ return pkg;
80
+ } catch {
81
+ }
82
+ }
83
+ }
84
+ return null;
85
+ }
63
86
  function downloadedBinPath(pkg, subpath) {
64
87
  const esbuildLibDir = path.dirname(require.resolve("esbuild"));
65
88
  return path.join(esbuildLibDir, `downloaded-${pkg}-${path.basename(subpath)}`);
@@ -78,6 +101,36 @@ function generateBinPath() {
78
101
  try {
79
102
  require.resolve(pkg);
80
103
  } catch {
104
+ const otherPkg = pkgForSomeOtherPlatform();
105
+ if (otherPkg) {
106
+ throw new Error(`
107
+ You installed esbuild on another platform than the one you're currently using.
108
+ This won't work because esbuild is written with native code and needs to
109
+ install a platform-specific binary executable.
110
+
111
+ Specifically the "${otherPkg}" package is present but this platform
112
+ needs the "${pkg}" package instead. People often get into this
113
+ situation by installing esbuild on Windows or macOS and copying "node_modules"
114
+ into a Docker image that runs Linux, or by copying "node_modules" between
115
+ Windows and WSL environments.
116
+
117
+ If you are installing with npm, you can try not copying the "node_modules"
118
+ directory when you copy the files over, and running "npm ci" or "npm install"
119
+ on the destination platform after the copy. Or you could consider using yarn
120
+ instead which has built-in support for installing a package on multiple
121
+ platforms simultaneously.
122
+
123
+ If you are installing with yarn, you can try listing both this platform and the
124
+ other platform in your ".yarnrc.yml" file using the "supportedArchitectures"
125
+ feature: https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
126
+ Keep in mind that this means multiple copies of esbuild will be present.
127
+
128
+ Another alternative is to use the "esbuild-wasm" package instead, which works
129
+ the same way on all platforms. But it comes with a heavy performance cost and
130
+ can sometimes be 10x slower than the "esbuild" package, so you may also not
131
+ want to do that.
132
+ `);
133
+ }
81
134
  throw new Error(`The package "${pkg}" could not be found, and is needed by esbuild.
82
135
 
83
136
  If you are installing esbuild with npm, make sure that you don't specify the
package/install.js CHANGED
@@ -93,8 +93,8 @@ var isToPathJS = true;
93
93
  function validateBinaryVersion(...command) {
94
94
  command.push("--version");
95
95
  const stdout = child_process.execFileSync(command.shift(), command).toString().trim();
96
- if (stdout !== "0.14.9") {
97
- throw new Error(`Expected ${JSON.stringify("0.14.9")} but got ${JSON.stringify(stdout)}`);
96
+ if (stdout !== "0.14.13") {
97
+ throw new Error(`Expected ${JSON.stringify("0.14.13")} but got ${JSON.stringify(stdout)}`);
98
98
  }
99
99
  }
100
100
  function isYarn() {
@@ -145,7 +145,7 @@ function installUsingNPM(pkg, subpath, binPath) {
145
145
  fs2.mkdirSync(installDir);
146
146
  try {
147
147
  fs2.writeFileSync(path2.join(installDir, "package.json"), "{}");
148
- child_process.execSync(`npm install --loglevel=error --prefer-offline --no-audit --progress=false ${pkg}@${"0.14.9"}`, { cwd: installDir, stdio: "pipe", env });
148
+ child_process.execSync(`npm install --loglevel=error --prefer-offline --no-audit --progress=false ${pkg}@${"0.14.13"}`, { cwd: installDir, stdio: "pipe", env });
149
149
  const installedBinPath = path2.join(installDir, "node_modules", pkg, subpath);
150
150
  fs2.renameSync(installedBinPath, binPath);
151
151
  } finally {
@@ -194,7 +194,7 @@ function maybeOptimizePackage(binPath) {
194
194
  }
195
195
  }
196
196
  async function downloadDirectlyFromNPM(pkg, subpath, binPath) {
197
- const url = `https://registry.npmjs.org/${pkg}/-/${pkg}-${"0.14.9"}.tgz`;
197
+ const url = `https://registry.npmjs.org/${pkg}/-/${pkg}-${"0.14.13"}.tgz`;
198
198
  console.error(`[esbuild] Trying to download ${JSON.stringify(url)}`);
199
199
  try {
200
200
  fs2.writeFileSync(binPath, extractFileFromTarGzip(await fetch(url), subpath));
package/lib/main.d.ts CHANGED
@@ -3,6 +3,7 @@ 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 Drop = 'console' | 'debugger';
6
7
 
7
8
  interface CommonOptions {
8
9
  /** Documentation: https://esbuild.github.io/api/#sourcemap */
@@ -21,6 +22,7 @@ interface CommonOptions {
21
22
  /** Documentation: https://esbuild.github.io/api/#target */
22
23
  target?: string | string[];
23
24
 
25
+ drop?: Drop[];
24
26
  /** Documentation: https://esbuild.github.io/api/#minify */
25
27
  minify?: boolean;
26
28
  /** Documentation: https://esbuild.github.io/api/#minify */
@@ -447,7 +449,9 @@ export interface AnalyzeMetafileOptions {
447
449
  * Documentation: https://esbuild.github.io/api/#build-api
448
450
  */
449
451
  export declare function build(options: BuildOptions & { write: false }): Promise<BuildResult & { outputFiles: OutputFile[] }>;
452
+ export declare function build(options: BuildOptions & { incremental: true, metafile: true }): Promise<BuildIncremental & { metafile: Metafile }>;
450
453
  export declare function build(options: BuildOptions & { incremental: true }): Promise<BuildIncremental>;
454
+ export declare function build(options: BuildOptions & { metafile: true }): Promise<BuildResult & { metafile: Metafile }>;
451
455
  export declare function build(options: BuildOptions): Promise<BuildResult>;
452
456
 
453
457
  /**
package/lib/main.js CHANGED
@@ -263,7 +263,7 @@ function checkForInvalidFlags(object, keys, where) {
263
263
  }
264
264
  }
265
265
  function validateInitializeOptions(options) {
266
- let keys = Object.create(null);
266
+ let keys = /* @__PURE__ */ Object.create(null);
267
267
  let wasmURL = getFlag(options, keys, "wasmURL", mustBeString);
268
268
  let worker = getFlag(options, keys, "worker", mustBeBoolean);
269
269
  checkForInvalidFlags(options, keys, "in startService() call");
@@ -294,6 +294,7 @@ function pushCommonFlags(flags, options, keys) {
294
294
  let minifySyntax = getFlag(options, keys, "minifySyntax", mustBeBoolean);
295
295
  let minifyWhitespace = getFlag(options, keys, "minifyWhitespace", mustBeBoolean);
296
296
  let minifyIdentifiers = getFlag(options, keys, "minifyIdentifiers", mustBeBoolean);
297
+ let drop = getFlag(options, keys, "drop", mustBeArray);
297
298
  let charset = getFlag(options, keys, "charset", mustBeString);
298
299
  let treeShaking = getFlag(options, keys, "treeShaking", mustBeBoolean);
299
300
  let ignoreAnnotations = getFlag(options, keys, "ignoreAnnotations", mustBeBoolean);
@@ -333,6 +334,9 @@ function pushCommonFlags(flags, options, keys) {
333
334
  flags.push(`--tree-shaking=${treeShaking}`);
334
335
  if (ignoreAnnotations)
335
336
  flags.push(`--ignore-annotations`);
337
+ if (drop)
338
+ for (let what of drop)
339
+ flags.push(`--drop:${what}`);
336
340
  if (jsx)
337
341
  flags.push(`--jsx=${jsx}`);
338
342
  if (jsxFactory)
@@ -356,7 +360,7 @@ function flagsForBuildOptions(callName, options, isTTY2, logLevelDefault, writeD
356
360
  var _a2;
357
361
  let flags = [];
358
362
  let entries = [];
359
- let keys = Object.create(null);
363
+ let keys = /* @__PURE__ */ Object.create(null);
360
364
  let stdinContents = null;
361
365
  let stdinResolveDir = null;
362
366
  let watchMode = null;
@@ -406,7 +410,7 @@ function flagsForBuildOptions(callName, options, isTTY2, logLevelDefault, writeD
406
410
  if (typeof watch === "boolean") {
407
411
  watchMode = {};
408
412
  } else {
409
- let watchKeys = Object.create(null);
413
+ let watchKeys = /* @__PURE__ */ Object.create(null);
410
414
  let onRebuild = getFlag(watch, watchKeys, "onRebuild", mustBeFunction);
411
415
  checkForInvalidFlags(watch, watchKeys, `on "watch" in ${callName}() call`);
412
416
  watchMode = { onRebuild };
@@ -512,7 +516,7 @@ function flagsForBuildOptions(callName, options, isTTY2, logLevelDefault, writeD
512
516
  }
513
517
  }
514
518
  if (stdin) {
515
- let stdinKeys = Object.create(null);
519
+ let stdinKeys = /* @__PURE__ */ Object.create(null);
516
520
  let contents = getFlag(stdin, stdinKeys, "contents", mustBeString);
517
521
  let resolveDir = getFlag(stdin, stdinKeys, "resolveDir", mustBeString);
518
522
  let sourcefile = getFlag(stdin, stdinKeys, "sourcefile", mustBeString);
@@ -547,7 +551,7 @@ function flagsForBuildOptions(callName, options, isTTY2, logLevelDefault, writeD
547
551
  }
548
552
  function flagsForTransformOptions(callName, options, isTTY2, logLevelDefault) {
549
553
  let flags = [];
550
- let keys = Object.create(null);
554
+ let keys = /* @__PURE__ */ Object.create(null);
551
555
  pushLogFlags(flags, options, keys, isTTY2, logLevelDefault);
552
556
  pushCommonFlags(flags, options, keys);
553
557
  let sourcemap = getFlag(options, keys, "sourcemap", mustBeStringOrBoolean);
@@ -713,8 +717,8 @@ function createChannel(streamIn) {
713
717
  if (isFirstPacket) {
714
718
  isFirstPacket = false;
715
719
  let binaryVersion = String.fromCharCode(...bytes);
716
- if (binaryVersion !== "0.14.9") {
717
- throw new Error(`Cannot start service: Host version "${"0.14.9"}" does not match binary version ${JSON.stringify(binaryVersion)}`);
720
+ if (binaryVersion !== "0.14.13") {
721
+ throw new Error(`Cannot start service: Host version "${"0.14.13"}" does not match binary version ${JSON.stringify(binaryVersion)}`);
718
722
  }
719
723
  return;
720
724
  }
@@ -763,7 +767,7 @@ function createChannel(streamIn) {
763
767
  throw new Error('Cannot call "resolve" before plugin setup has completed');
764
768
  if (typeof path3 !== "string")
765
769
  throw new Error(`The path to resolve must be a string`);
766
- let keys2 = Object.create(null);
770
+ let keys2 = /* @__PURE__ */ Object.create(null);
767
771
  let pluginName = getFlag(options, keys2, "pluginName", mustBeString);
768
772
  let importer = getFlag(options, keys2, "importer", mustBeString);
769
773
  let namespace = getFlag(options, keys2, "namespace", mustBeString);
@@ -1683,6 +1687,29 @@ function pkgAndSubpathForCurrentPlatform() {
1683
1687
  }
1684
1688
  return { pkg, subpath };
1685
1689
  }
1690
+ function pkgForSomeOtherPlatform() {
1691
+ const libMainJS = require.resolve("esbuild");
1692
+ const nodeModulesDirectory = path.dirname(path.dirname(path.dirname(libMainJS)));
1693
+ if (path.basename(nodeModulesDirectory) === "node_modules") {
1694
+ for (const unixKey in knownUnixlikePackages) {
1695
+ try {
1696
+ const pkg = knownUnixlikePackages[unixKey];
1697
+ if (fs.existsSync(path.join(nodeModulesDirectory, pkg)))
1698
+ return pkg;
1699
+ } catch {
1700
+ }
1701
+ }
1702
+ for (const windowsKey in knownWindowsPackages) {
1703
+ try {
1704
+ const pkg = knownWindowsPackages[windowsKey];
1705
+ if (fs.existsSync(path.join(nodeModulesDirectory, pkg)))
1706
+ return pkg;
1707
+ } catch {
1708
+ }
1709
+ }
1710
+ }
1711
+ return null;
1712
+ }
1686
1713
  function downloadedBinPath(pkg, subpath) {
1687
1714
  const esbuildLibDir = path.dirname(require.resolve("esbuild"));
1688
1715
  return path.join(esbuildLibDir, `downloaded-${pkg}-${path.basename(subpath)}`);
@@ -1701,6 +1728,36 @@ function generateBinPath() {
1701
1728
  try {
1702
1729
  require.resolve(pkg);
1703
1730
  } catch {
1731
+ const otherPkg = pkgForSomeOtherPlatform();
1732
+ if (otherPkg) {
1733
+ throw new Error(`
1734
+ You installed esbuild on another platform than the one you're currently using.
1735
+ This won't work because esbuild is written with native code and needs to
1736
+ install a platform-specific binary executable.
1737
+
1738
+ Specifically the "${otherPkg}" package is present but this platform
1739
+ needs the "${pkg}" package instead. People often get into this
1740
+ situation by installing esbuild on Windows or macOS and copying "node_modules"
1741
+ into a Docker image that runs Linux, or by copying "node_modules" between
1742
+ Windows and WSL environments.
1743
+
1744
+ If you are installing with npm, you can try not copying the "node_modules"
1745
+ directory when you copy the files over, and running "npm ci" or "npm install"
1746
+ on the destination platform after the copy. Or you could consider using yarn
1747
+ instead which has built-in support for installing a package on multiple
1748
+ platforms simultaneously.
1749
+
1750
+ If you are installing with yarn, you can try listing both this platform and the
1751
+ other platform in your ".yarnrc.yml" file using the "supportedArchitectures"
1752
+ feature: https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
1753
+ Keep in mind that this means multiple copies of esbuild will be present.
1754
+
1755
+ Another alternative is to use the "esbuild-wasm" package instead, which works
1756
+ the same way on all platforms. But it comes with a heavy performance cost and
1757
+ can sometimes be 10x slower than the "esbuild" package, so you may also not
1758
+ want to do that.
1759
+ `);
1760
+ }
1704
1761
  throw new Error(`The package "${pkg}" could not be found, and is needed by esbuild.
1705
1762
 
1706
1763
  If you are installing esbuild with npm, make sure that you don't specify the
@@ -1747,7 +1804,7 @@ if (process.env.ESBUILD_WORKER_THREADS !== "0") {
1747
1804
  }
1748
1805
  }
1749
1806
  var _a;
1750
- var isInternalWorkerThread = ((_a = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a.esbuildVersion) === "0.14.9";
1807
+ var isInternalWorkerThread = ((_a = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a.esbuildVersion) === "0.14.13";
1751
1808
  var esbuildCommandAndArgs = () => {
1752
1809
  if ((!ESBUILD_BINARY_PATH || false) && (path2.basename(__filename) !== "main.js" || path2.basename(__dirname) !== "lib")) {
1753
1810
  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.
@@ -1806,7 +1863,7 @@ var fsAsync = {
1806
1863
  }
1807
1864
  }
1808
1865
  };
1809
- var version = "0.14.9";
1866
+ var version = "0.14.13";
1810
1867
  var build = (options) => ensureServiceIsRunning().build(options);
1811
1868
  var serve = (serveOptions, buildOptions) => ensureServiceIsRunning().serve(serveOptions, buildOptions);
1812
1869
  var transform = (input, options) => ensureServiceIsRunning().transform(input, options);
@@ -1915,7 +1972,7 @@ var ensureServiceIsRunning = () => {
1915
1972
  if (longLivedService)
1916
1973
  return longLivedService;
1917
1974
  let [command, args] = esbuildCommandAndArgs();
1918
- let child = child_process.spawn(command, args.concat(`--service=${"0.14.9"}`, "--ping"), {
1975
+ let child = child_process.spawn(command, args.concat(`--service=${"0.14.13"}`, "--ping"), {
1919
1976
  windowsHide: true,
1920
1977
  stdio: ["pipe", "pipe", "inherit"],
1921
1978
  cwd: defaultWD
@@ -2024,7 +2081,7 @@ var runServiceSync = (callback) => {
2024
2081
  esbuild: node_exports
2025
2082
  });
2026
2083
  callback(service);
2027
- let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.14.9"}`), {
2084
+ let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.14.13"}`), {
2028
2085
  cwd: defaultWD,
2029
2086
  windowsHide: true,
2030
2087
  input: stdin,
@@ -2040,7 +2097,7 @@ var workerThreadService = null;
2040
2097
  var startWorkerThreadService = (worker_threads2) => {
2041
2098
  let { port1: mainPort, port2: workerPort } = new worker_threads2.MessageChannel();
2042
2099
  let worker = new worker_threads2.Worker(__filename, {
2043
- workerData: { workerPort, defaultWD, esbuildVersion: "0.14.9" },
2100
+ workerData: { workerPort, defaultWD, esbuildVersion: "0.14.13" },
2044
2101
  transferList: [workerPort],
2045
2102
  execArgv: []
2046
2103
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esbuild",
3
- "version": "0.14.9",
3
+ "version": "0.14.13",
4
4
  "description": "An extremely fast JavaScript and CSS bundler and minifier.",
5
5
  "repository": "https://github.com/evanw/esbuild",
6
6
  "scripts": {
@@ -12,24 +12,24 @@
12
12
  "esbuild": "bin/esbuild"
13
13
  },
14
14
  "optionalDependencies": {
15
- "esbuild-android-arm64": "0.14.9",
16
- "esbuild-darwin-64": "0.14.9",
17
- "esbuild-darwin-arm64": "0.14.9",
18
- "esbuild-freebsd-64": "0.14.9",
19
- "esbuild-freebsd-arm64": "0.14.9",
20
- "esbuild-linux-32": "0.14.9",
21
- "esbuild-linux-64": "0.14.9",
22
- "esbuild-linux-arm": "0.14.9",
23
- "esbuild-linux-arm64": "0.14.9",
24
- "esbuild-linux-mips64le": "0.14.9",
25
- "esbuild-linux-ppc64le": "0.14.9",
26
- "esbuild-linux-s390x": "0.14.9",
27
- "esbuild-netbsd-64": "0.14.9",
28
- "esbuild-openbsd-64": "0.14.9",
29
- "esbuild-sunos-64": "0.14.9",
30
- "esbuild-windows-32": "0.14.9",
31
- "esbuild-windows-64": "0.14.9",
32
- "esbuild-windows-arm64": "0.14.9"
15
+ "esbuild-android-arm64": "0.14.13",
16
+ "esbuild-darwin-64": "0.14.13",
17
+ "esbuild-darwin-arm64": "0.14.13",
18
+ "esbuild-freebsd-64": "0.14.13",
19
+ "esbuild-freebsd-arm64": "0.14.13",
20
+ "esbuild-linux-32": "0.14.13",
21
+ "esbuild-linux-64": "0.14.13",
22
+ "esbuild-linux-arm": "0.14.13",
23
+ "esbuild-linux-arm64": "0.14.13",
24
+ "esbuild-linux-mips64le": "0.14.13",
25
+ "esbuild-linux-ppc64le": "0.14.13",
26
+ "esbuild-linux-s390x": "0.14.13",
27
+ "esbuild-netbsd-64": "0.14.13",
28
+ "esbuild-openbsd-64": "0.14.13",
29
+ "esbuild-sunos-64": "0.14.13",
30
+ "esbuild-windows-32": "0.14.13",
31
+ "esbuild-windows-64": "0.14.13",
32
+ "esbuild-windows-arm64": "0.14.13"
33
33
  },
34
34
  "license": "MIT"
35
35
  }