esbuild 0.14.12 → 0.14.16

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
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env node
1
2
  var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __defProps = Object.defineProperties;
@@ -93,8 +94,8 @@ var isToPathJS = true;
93
94
  function validateBinaryVersion(...command) {
94
95
  command.push("--version");
95
96
  const stdout = child_process.execFileSync(command.shift(), command).toString().trim();
96
- if (stdout !== "0.14.12") {
97
- throw new Error(`Expected ${JSON.stringify("0.14.12")} but got ${JSON.stringify(stdout)}`);
97
+ if (stdout !== "0.14.16") {
98
+ throw new Error(`Expected ${JSON.stringify("0.14.16")} but got ${JSON.stringify(stdout)}`);
98
99
  }
99
100
  }
100
101
  function isYarn() {
@@ -145,7 +146,7 @@ function installUsingNPM(pkg, subpath, binPath) {
145
146
  fs2.mkdirSync(installDir);
146
147
  try {
147
148
  fs2.writeFileSync(path2.join(installDir, "package.json"), "{}");
148
- child_process.execSync(`npm install --loglevel=error --prefer-offline --no-audit --progress=false ${pkg}@${"0.14.12"}`, { cwd: installDir, stdio: "pipe", env });
149
+ child_process.execSync(`npm install --loglevel=error --prefer-offline --no-audit --progress=false ${pkg}@${"0.14.16"}`, { cwd: installDir, stdio: "pipe", env });
149
150
  const installedBinPath = path2.join(installDir, "node_modules", pkg, subpath);
150
151
  fs2.renameSync(installedBinPath, binPath);
151
152
  } finally {
@@ -194,7 +195,7 @@ function maybeOptimizePackage(binPath) {
194
195
  }
195
196
  }
196
197
  async function downloadDirectlyFromNPM(pkg, subpath, binPath) {
197
- const url = `https://registry.npmjs.org/${pkg}/-/${pkg}-${"0.14.12"}.tgz`;
198
+ const url = `https://registry.npmjs.org/${pkg}/-/${pkg}-${"0.14.16"}.tgz`;
198
199
  console.error(`[esbuild] Trying to download ${JSON.stringify(url)}`);
199
200
  try {
200
201
  fs2.writeFileSync(binPath, extractFileFromTarGzip(await fetch(url), subpath));
package/lib/main.d.ts CHANGED
@@ -22,6 +22,11 @@ interface CommonOptions {
22
22
  /** Documentation: https://esbuild.github.io/api/#target */
23
23
  target?: string | string[];
24
24
 
25
+ /** Documentation: https://esbuild.github.io/api/#mangle-props */
26
+ mangleProps?: RegExp;
27
+ /** Documentation: https://esbuild.github.io/api/#mangle-props */
28
+ reserveProps?: RegExp;
29
+ /** Documentation: https://esbuild.github.io/api/#drop */
25
30
  drop?: Drop[];
26
31
  /** Documentation: https://esbuild.github.io/api/#minify */
27
32
  minify?: boolean;
package/lib/main.js CHANGED
@@ -290,6 +290,8 @@ function pushCommonFlags(flags, options, keys) {
290
290
  let target = getFlag(options, keys, "target", mustBeStringOrArray);
291
291
  let format = getFlag(options, keys, "format", mustBeString);
292
292
  let globalName = getFlag(options, keys, "globalName", mustBeString);
293
+ let mangleProps = getFlag(options, keys, "mangleProps", mustBeRegExp);
294
+ let reserveProps = getFlag(options, keys, "reserveProps", mustBeRegExp);
293
295
  let minify = getFlag(options, keys, "minify", mustBeBoolean);
294
296
  let minifySyntax = getFlag(options, keys, "minifySyntax", mustBeBoolean);
295
297
  let minifyWhitespace = getFlag(options, keys, "minifyWhitespace", mustBeBoolean);
@@ -337,6 +339,10 @@ function pushCommonFlags(flags, options, keys) {
337
339
  if (drop)
338
340
  for (let what of drop)
339
341
  flags.push(`--drop:${what}`);
342
+ if (mangleProps)
343
+ flags.push(`--mangle-props=${mangleProps.source}`);
344
+ if (reserveProps)
345
+ flags.push(`--reserve-props=${reserveProps.source}`);
340
346
  if (jsx)
341
347
  flags.push(`--jsx=${jsx}`);
342
348
  if (jsxFactory)
@@ -717,8 +723,8 @@ function createChannel(streamIn) {
717
723
  if (isFirstPacket) {
718
724
  isFirstPacket = false;
719
725
  let binaryVersion = String.fromCharCode(...bytes);
720
- if (binaryVersion !== "0.14.12") {
721
- throw new Error(`Cannot start service: Host version "${"0.14.12"}" does not match binary version ${JSON.stringify(binaryVersion)}`);
726
+ if (binaryVersion !== "0.14.16") {
727
+ throw new Error(`Cannot start service: Host version "${"0.14.16"}" does not match binary version ${JSON.stringify(binaryVersion)}`);
722
728
  }
723
729
  return;
724
730
  }
@@ -1687,6 +1693,29 @@ function pkgAndSubpathForCurrentPlatform() {
1687
1693
  }
1688
1694
  return { pkg, subpath };
1689
1695
  }
1696
+ function pkgForSomeOtherPlatform() {
1697
+ const libMainJS = require.resolve("esbuild");
1698
+ const nodeModulesDirectory = path.dirname(path.dirname(path.dirname(libMainJS)));
1699
+ if (path.basename(nodeModulesDirectory) === "node_modules") {
1700
+ for (const unixKey in knownUnixlikePackages) {
1701
+ try {
1702
+ const pkg = knownUnixlikePackages[unixKey];
1703
+ if (fs.existsSync(path.join(nodeModulesDirectory, pkg)))
1704
+ return pkg;
1705
+ } catch {
1706
+ }
1707
+ }
1708
+ for (const windowsKey in knownWindowsPackages) {
1709
+ try {
1710
+ const pkg = knownWindowsPackages[windowsKey];
1711
+ if (fs.existsSync(path.join(nodeModulesDirectory, pkg)))
1712
+ return pkg;
1713
+ } catch {
1714
+ }
1715
+ }
1716
+ }
1717
+ return null;
1718
+ }
1690
1719
  function downloadedBinPath(pkg, subpath) {
1691
1720
  const esbuildLibDir = path.dirname(require.resolve("esbuild"));
1692
1721
  return path.join(esbuildLibDir, `downloaded-${pkg}-${path.basename(subpath)}`);
@@ -1705,6 +1734,36 @@ function generateBinPath() {
1705
1734
  try {
1706
1735
  require.resolve(pkg);
1707
1736
  } catch {
1737
+ const otherPkg = pkgForSomeOtherPlatform();
1738
+ if (otherPkg) {
1739
+ throw new Error(`
1740
+ You installed esbuild on another platform than the one you're currently using.
1741
+ This won't work because esbuild is written with native code and needs to
1742
+ install a platform-specific binary executable.
1743
+
1744
+ Specifically the "${otherPkg}" package is present but this platform
1745
+ needs the "${pkg}" package instead. People often get into this
1746
+ situation by installing esbuild on Windows or macOS and copying "node_modules"
1747
+ into a Docker image that runs Linux, or by copying "node_modules" between
1748
+ Windows and WSL environments.
1749
+
1750
+ If you are installing with npm, you can try not copying the "node_modules"
1751
+ directory when you copy the files over, and running "npm ci" or "npm install"
1752
+ on the destination platform after the copy. Or you could consider using yarn
1753
+ instead which has built-in support for installing a package on multiple
1754
+ platforms simultaneously.
1755
+
1756
+ If you are installing with yarn, you can try listing both this platform and the
1757
+ other platform in your ".yarnrc.yml" file using the "supportedArchitectures"
1758
+ feature: https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
1759
+ Keep in mind that this means multiple copies of esbuild will be present.
1760
+
1761
+ Another alternative is to use the "esbuild-wasm" package instead, which works
1762
+ the same way on all platforms. But it comes with a heavy performance cost and
1763
+ can sometimes be 10x slower than the "esbuild" package, so you may also not
1764
+ want to do that.
1765
+ `);
1766
+ }
1708
1767
  throw new Error(`The package "${pkg}" could not be found, and is needed by esbuild.
1709
1768
 
1710
1769
  If you are installing esbuild with npm, make sure that you don't specify the
@@ -1751,7 +1810,7 @@ if (process.env.ESBUILD_WORKER_THREADS !== "0") {
1751
1810
  }
1752
1811
  }
1753
1812
  var _a;
1754
- var isInternalWorkerThread = ((_a = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a.esbuildVersion) === "0.14.12";
1813
+ var isInternalWorkerThread = ((_a = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a.esbuildVersion) === "0.14.16";
1755
1814
  var esbuildCommandAndArgs = () => {
1756
1815
  if ((!ESBUILD_BINARY_PATH || false) && (path2.basename(__filename) !== "main.js" || path2.basename(__dirname) !== "lib")) {
1757
1816
  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.
@@ -1810,7 +1869,7 @@ var fsAsync = {
1810
1869
  }
1811
1870
  }
1812
1871
  };
1813
- var version = "0.14.12";
1872
+ var version = "0.14.16";
1814
1873
  var build = (options) => ensureServiceIsRunning().build(options);
1815
1874
  var serve = (serveOptions, buildOptions) => ensureServiceIsRunning().serve(serveOptions, buildOptions);
1816
1875
  var transform = (input, options) => ensureServiceIsRunning().transform(input, options);
@@ -1919,7 +1978,7 @@ var ensureServiceIsRunning = () => {
1919
1978
  if (longLivedService)
1920
1979
  return longLivedService;
1921
1980
  let [command, args] = esbuildCommandAndArgs();
1922
- let child = child_process.spawn(command, args.concat(`--service=${"0.14.12"}`, "--ping"), {
1981
+ let child = child_process.spawn(command, args.concat(`--service=${"0.14.16"}`, "--ping"), {
1923
1982
  windowsHide: true,
1924
1983
  stdio: ["pipe", "pipe", "inherit"],
1925
1984
  cwd: defaultWD
@@ -2028,7 +2087,7 @@ var runServiceSync = (callback) => {
2028
2087
  esbuild: node_exports
2029
2088
  });
2030
2089
  callback(service);
2031
- let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.14.12"}`), {
2090
+ let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.14.16"}`), {
2032
2091
  cwd: defaultWD,
2033
2092
  windowsHide: true,
2034
2093
  input: stdin,
@@ -2044,7 +2103,7 @@ var workerThreadService = null;
2044
2103
  var startWorkerThreadService = (worker_threads2) => {
2045
2104
  let { port1: mainPort, port2: workerPort } = new worker_threads2.MessageChannel();
2046
2105
  let worker = new worker_threads2.Worker(__filename, {
2047
- workerData: { workerPort, defaultWD, esbuildVersion: "0.14.12" },
2106
+ workerData: { workerPort, defaultWD, esbuildVersion: "0.14.16" },
2048
2107
  transferList: [workerPort],
2049
2108
  execArgv: []
2050
2109
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esbuild",
3
- "version": "0.14.12",
3
+ "version": "0.14.16",
4
4
  "description": "An extremely fast JavaScript and CSS bundler and minifier.",
5
5
  "repository": "https://github.com/evanw/esbuild",
6
6
  "scripts": {
@@ -8,28 +8,31 @@
8
8
  },
9
9
  "main": "lib/main.js",
10
10
  "types": "lib/main.d.ts",
11
+ "engines": {
12
+ "node": ">=12"
13
+ },
11
14
  "bin": {
12
15
  "esbuild": "bin/esbuild"
13
16
  },
14
17
  "optionalDependencies": {
15
- "esbuild-android-arm64": "0.14.12",
16
- "esbuild-darwin-64": "0.14.12",
17
- "esbuild-darwin-arm64": "0.14.12",
18
- "esbuild-freebsd-64": "0.14.12",
19
- "esbuild-freebsd-arm64": "0.14.12",
20
- "esbuild-linux-32": "0.14.12",
21
- "esbuild-linux-64": "0.14.12",
22
- "esbuild-linux-arm": "0.14.12",
23
- "esbuild-linux-arm64": "0.14.12",
24
- "esbuild-linux-mips64le": "0.14.12",
25
- "esbuild-linux-ppc64le": "0.14.12",
26
- "esbuild-linux-s390x": "0.14.12",
27
- "esbuild-netbsd-64": "0.14.12",
28
- "esbuild-openbsd-64": "0.14.12",
29
- "esbuild-sunos-64": "0.14.12",
30
- "esbuild-windows-32": "0.14.12",
31
- "esbuild-windows-64": "0.14.12",
32
- "esbuild-windows-arm64": "0.14.12"
18
+ "esbuild-android-arm64": "0.14.16",
19
+ "esbuild-darwin-64": "0.14.16",
20
+ "esbuild-darwin-arm64": "0.14.16",
21
+ "esbuild-freebsd-64": "0.14.16",
22
+ "esbuild-freebsd-arm64": "0.14.16",
23
+ "esbuild-linux-32": "0.14.16",
24
+ "esbuild-linux-64": "0.14.16",
25
+ "esbuild-linux-arm": "0.14.16",
26
+ "esbuild-linux-arm64": "0.14.16",
27
+ "esbuild-linux-mips64le": "0.14.16",
28
+ "esbuild-linux-ppc64le": "0.14.16",
29
+ "esbuild-linux-s390x": "0.14.16",
30
+ "esbuild-netbsd-64": "0.14.16",
31
+ "esbuild-openbsd-64": "0.14.16",
32
+ "esbuild-sunos-64": "0.14.16",
33
+ "esbuild-windows-32": "0.14.16",
34
+ "esbuild-windows-64": "0.14.16",
35
+ "esbuild-windows-arm64": "0.14.16"
33
36
  },
34
37
  "license": "MIT"
35
38
  }