esbuild 0.13.0 → 0.13.4

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 (4) hide show
  1. package/bin/esbuild +48 -33
  2. package/install.js +179 -36
  3. package/lib/main.js +52 -40
  4. package/package.json +17 -17
package/bin/esbuild CHANGED
@@ -1,4 +1,22 @@
1
1
  #!/usr/bin/env node
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
+ };
2
20
 
3
21
  // lib/npm/node-platform.ts
4
22
  var fs = require("fs");
@@ -25,52 +43,48 @@ var knownUnixlikePackages = {
25
43
  "linux x64 LE": "esbuild-linux-64",
26
44
  "sunos x64 LE": "esbuild-sunos-64"
27
45
  };
28
- function pkgAndBinForCurrentPlatform() {
46
+ function pkgAndSubpathForCurrentPlatform() {
29
47
  let pkg;
30
- let bin;
48
+ let subpath;
31
49
  let platformKey = `${process.platform} ${os.arch()} ${os.endianness()}`;
32
50
  if (platformKey in knownWindowsPackages) {
33
51
  pkg = knownWindowsPackages[platformKey];
34
- bin = `${pkg}/esbuild.exe`;
52
+ subpath = "esbuild.exe";
35
53
  } else if (platformKey in knownUnixlikePackages) {
36
54
  pkg = knownUnixlikePackages[platformKey];
37
- bin = `${pkg}/bin/esbuild`;
55
+ subpath = "bin/esbuild";
38
56
  } else {
39
57
  throw new Error(`Unsupported platform: ${platformKey}`);
40
58
  }
59
+ return { pkg, subpath };
60
+ }
61
+ function downloadedBinPath(pkg, subpath) {
62
+ const esbuildLibDir = path.dirname(require.resolve("esbuild"));
63
+ return path.join(esbuildLibDir, `downloaded-${pkg}-${path.basename(subpath)}`);
64
+ }
65
+ function generateBinPath() {
66
+ if (ESBUILD_BINARY_PATH) {
67
+ return ESBUILD_BINARY_PATH;
68
+ }
69
+ const { pkg, subpath } = pkgAndSubpathForCurrentPlatform();
70
+ let binPath;
41
71
  try {
42
- bin = require.resolve(bin);
72
+ binPath = require.resolve(`${pkg}/${subpath}`);
43
73
  } catch (e) {
44
- try {
45
- require.resolve(pkg);
46
- } catch (e2) {
47
- throw new Error(`The package "${pkg}" could not be found, and is needed by esbuild.
74
+ binPath = downloadedBinPath(pkg, subpath);
75
+ if (!fs.existsSync(binPath)) {
76
+ try {
77
+ require.resolve(pkg);
78
+ } catch (e2) {
79
+ throw new Error(`The package "${pkg}" could not be found, and is needed by esbuild.
48
80
 
49
81
  If you are installing esbuild with npm, make sure that you don't specify the
50
82
  "--no-optional" flag. The "optionalDependencies" package.json feature is used
51
83
  by esbuild to install the correct binary executable for your current platform.`);
84
+ }
85
+ throw e;
52
86
  }
53
- throw e;
54
- }
55
- return { pkg, bin };
56
- }
57
- function getCachePath(name) {
58
- const home = os.homedir();
59
- const common = ["esbuild", "bin", `${name}@${"0.13.0"}`];
60
- if (process.platform === "darwin")
61
- return path.join(home, "Library", "Caches", ...common);
62
- if (process.platform === "win32")
63
- return path.join(home, "AppData", "Local", "Cache", ...common);
64
- const XDG_CACHE_HOME = process.env.XDG_CACHE_HOME;
65
- if (process.platform === "linux" && XDG_CACHE_HOME && path.isAbsolute(XDG_CACHE_HOME))
66
- return path.join(XDG_CACHE_HOME, ...common);
67
- return path.join(home, ".cache", ...common);
68
- }
69
- function extractedBinPath() {
70
- if (ESBUILD_BINARY_PATH) {
71
- return ESBUILD_BINARY_PATH;
72
87
  }
73
- const { pkg, bin } = pkgAndBinForCurrentPlatform();
74
88
  let isYarnPnP = false;
75
89
  try {
76
90
  require("pnpapi");
@@ -78,15 +92,16 @@ function extractedBinPath() {
78
92
  } catch (e) {
79
93
  }
80
94
  if (isYarnPnP) {
81
- const binTargetPath = getCachePath(pkg);
95
+ const esbuildLibDir = path.dirname(require.resolve("esbuild"));
96
+ const binTargetPath = path.join(esbuildLibDir, `pnpapi-${pkg}-${path.basename(subpath)}`);
82
97
  if (!fs.existsSync(binTargetPath)) {
83
- fs.copyFileSync(bin, binTargetPath);
98
+ fs.copyFileSync(binPath, binTargetPath);
84
99
  fs.chmodSync(binTargetPath, 493);
85
100
  }
86
101
  return binTargetPath;
87
102
  }
88
- return bin;
103
+ return binPath;
89
104
  }
90
105
 
91
106
  // lib/npm/node-shim.ts
92
- require("child_process").execFileSync(extractedBinPath(), process.argv.slice(2), { stdio: "inherit" });
107
+ require("child_process").execFileSync(generateBinPath(), process.argv.slice(2), { stdio: "inherit" });
package/install.js CHANGED
@@ -1,3 +1,39 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
22
+ };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
25
+ var __reExport = (target, module2, desc) => {
26
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
27
+ for (let key of __getOwnPropNames(module2))
28
+ if (!__hasOwnProp.call(target, key) && key !== "default")
29
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
30
+ }
31
+ return target;
32
+ };
33
+ var __toModule = (module2) => {
34
+ 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);
35
+ };
36
+
1
37
  // lib/npm/node-platform.ts
2
38
  var fs = require("fs");
3
39
  var os = require("os");
@@ -23,61 +59,118 @@ var knownUnixlikePackages = {
23
59
  "linux x64 LE": "esbuild-linux-64",
24
60
  "sunos x64 LE": "esbuild-sunos-64"
25
61
  };
26
- function pkgAndBinForCurrentPlatform() {
62
+ function pkgAndSubpathForCurrentPlatform() {
27
63
  let pkg;
28
- let bin;
64
+ let subpath;
29
65
  let platformKey = `${process.platform} ${os.arch()} ${os.endianness()}`;
30
66
  if (platformKey in knownWindowsPackages) {
31
67
  pkg = knownWindowsPackages[platformKey];
32
- bin = `${pkg}/esbuild.exe`;
68
+ subpath = "esbuild.exe";
33
69
  } else if (platformKey in knownUnixlikePackages) {
34
70
  pkg = knownUnixlikePackages[platformKey];
35
- bin = `${pkg}/bin/esbuild`;
71
+ subpath = "bin/esbuild";
36
72
  } else {
37
73
  throw new Error(`Unsupported platform: ${platformKey}`);
38
74
  }
39
- try {
40
- bin = require.resolve(bin);
41
- } catch (e) {
42
- try {
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.`);
50
- }
51
- throw e;
52
- }
53
- return { pkg, bin };
75
+ return { pkg, subpath };
76
+ }
77
+ function downloadedBinPath(pkg, subpath) {
78
+ const esbuildLibDir = path.dirname(require.resolve("esbuild"));
79
+ return path.join(esbuildLibDir, `downloaded-${pkg}-${path.basename(subpath)}`);
54
80
  }
55
81
 
56
82
  // lib/npm/node-install.ts
57
83
  var fs2 = require("fs");
58
84
  var os2 = require("os");
59
85
  var path2 = require("path");
86
+ var zlib = require("zlib");
87
+ var https = require("https");
60
88
  var child_process = require("child_process");
61
89
  var toPath = path2.join(__dirname, "bin", "esbuild");
90
+ var isToPathJS = true;
62
91
  function validateBinaryVersion(...command) {
63
92
  command.push("--version");
64
93
  const stdout = child_process.execFileSync(command.shift(), command).toString().trim();
65
- if (stdout !== "0.13.0") {
66
- throw new Error(`Expected ${JSON.stringify("0.13.0")} but got ${JSON.stringify(stdout)}`);
94
+ if (stdout !== "0.13.4") {
95
+ throw new Error(`Expected ${JSON.stringify("0.13.4")} but got ${JSON.stringify(stdout)}`);
67
96
  }
68
97
  }
69
- function isYarn2OrAbove() {
98
+ function isYarn() {
70
99
  const { npm_config_user_agent } = process.env;
71
100
  if (npm_config_user_agent) {
72
- const match = npm_config_user_agent.match(/yarn\/(\d+)/);
73
- if (match && match[1]) {
74
- return parseInt(match[1], 10) >= 2;
75
- }
101
+ return /\byarn\//.test(npm_config_user_agent);
76
102
  }
77
103
  return false;
78
104
  }
79
- if (process.env.ESBUILD_BINARY_PATH) {
80
- const pathString = JSON.stringify(process.env.ESBUILD_BINARY_PATH);
105
+ function fetch(url) {
106
+ return new Promise((resolve, reject) => {
107
+ https.get(url, (res) => {
108
+ if ((res.statusCode === 301 || res.statusCode === 302) && res.headers.location)
109
+ return fetch(res.headers.location).then(resolve, reject);
110
+ if (res.statusCode !== 200)
111
+ return reject(new Error(`Server responded with ${res.statusCode}`));
112
+ let chunks = [];
113
+ res.on("data", (chunk) => chunks.push(chunk));
114
+ res.on("end", () => resolve(Buffer.concat(chunks)));
115
+ }).on("error", reject);
116
+ });
117
+ }
118
+ function extractFileFromTarGzip(buffer, subpath) {
119
+ try {
120
+ buffer = zlib.unzipSync(buffer);
121
+ } catch (err) {
122
+ throw new Error(`Invalid gzip data in archive: ${err && err.message || err}`);
123
+ }
124
+ let str = (i, n) => String.fromCharCode(...buffer.subarray(i, i + n)).replace(/\0.*$/, "");
125
+ let offset = 0;
126
+ subpath = `package/${subpath}`;
127
+ while (offset < buffer.length) {
128
+ let name = str(offset, 100);
129
+ let size = parseInt(str(offset + 124, 12), 8);
130
+ offset += 512;
131
+ if (!isNaN(size)) {
132
+ if (name === subpath)
133
+ return buffer.subarray(offset, offset + size);
134
+ offset += size + 511 & ~511;
135
+ }
136
+ }
137
+ throw new Error(`Could not find ${JSON.stringify(subpath)} in archive`);
138
+ }
139
+ function installUsingNPM(pkg, subpath, binPath) {
140
+ const env = __spreadProps(__spreadValues({}, process.env), { npm_config_global: void 0 });
141
+ const esbuildLibDir = path2.dirname(require.resolve("esbuild"));
142
+ const installDir = path2.join(esbuildLibDir, "npm-install");
143
+ fs2.mkdirSync(installDir);
144
+ try {
145
+ fs2.writeFileSync(path2.join(installDir, "package.json"), "{}");
146
+ child_process.execSync(`npm install --loglevel=error --prefer-offline --no-audit --progress=false ${pkg}@${"0.13.4"}`, { cwd: installDir, stdio: "pipe", env });
147
+ const installedBinPath = path2.join(installDir, "node_modules", pkg, subpath);
148
+ fs2.renameSync(installedBinPath, binPath);
149
+ } finally {
150
+ try {
151
+ removeRecursive(installDir);
152
+ } catch (e) {
153
+ }
154
+ }
155
+ }
156
+ function removeRecursive(dir) {
157
+ for (const entry of fs2.readdirSync(dir)) {
158
+ const entryPath = path2.join(dir, entry);
159
+ let stats;
160
+ try {
161
+ stats = fs2.lstatSync(entryPath);
162
+ } catch (e) {
163
+ continue;
164
+ }
165
+ if (stats.isDirectory())
166
+ removeRecursive(entryPath);
167
+ else
168
+ fs2.unlinkSync(entryPath);
169
+ }
170
+ fs2.rmdirSync(dir);
171
+ }
172
+ function applyManualBinaryPathOverride(overridePath) {
173
+ const pathString = JSON.stringify(overridePath);
81
174
  fs2.writeFileSync(toPath, `#!/usr/bin/env node
82
175
  require('child_process').execFileSync(${pathString}, process.argv.slice(2), { stdio: 'inherit' });
83
176
  `);
@@ -85,15 +178,65 @@ require('child_process').execFileSync(${pathString}, process.argv.slice(2), { st
85
178
  const code = fs2.readFileSync(libMain, "utf8");
86
179
  fs2.writeFileSync(libMain, `var ESBUILD_BINARY_PATH = ${pathString};
87
180
  ${code}`);
88
- validateBinaryVersion("node", toPath);
89
- } else if (os2.platform() !== "win32" && !isYarn2OrAbove()) {
90
- const { bin } = pkgAndBinForCurrentPlatform();
181
+ }
182
+ function maybeOptimizePackage(binPath) {
183
+ if (os2.platform() !== "win32" && !isYarn()) {
184
+ const tempPath = path2.join(__dirname, "bin-esbuild");
185
+ try {
186
+ fs2.linkSync(binPath, tempPath);
187
+ fs2.renameSync(tempPath, toPath);
188
+ isToPathJS = false;
189
+ } catch (e) {
190
+ }
191
+ }
192
+ }
193
+ async function downloadDirectlyFromNPM(pkg, subpath, binPath) {
194
+ const url = `https://registry.npmjs.org/${pkg}/-/${pkg}-${"0.13.4"}.tgz`;
195
+ console.error(`[esbuild] Trying to download ${JSON.stringify(url)}`);
196
+ try {
197
+ fs2.writeFileSync(binPath, extractFileFromTarGzip(await fetch(url), subpath));
198
+ fs2.chmodSync(binPath, 493);
199
+ } catch (e) {
200
+ console.error(`[esbuild] Failed to download ${JSON.stringify(url)}: ${e && e.message || e}`);
201
+ throw e;
202
+ }
203
+ }
204
+ async function checkAndPreparePackage() {
205
+ if (process.env.ESBUILD_BINARY_PATH) {
206
+ applyManualBinaryPathOverride(process.env.ESBUILD_BINARY_PATH);
207
+ return;
208
+ }
209
+ const { pkg, subpath } = pkgAndSubpathForCurrentPlatform();
210
+ let binPath;
91
211
  try {
92
- fs2.unlinkSync(toPath);
93
- fs2.linkSync(bin, toPath);
212
+ binPath = require.resolve(`${pkg}/${subpath}`);
94
213
  } catch (e) {
214
+ console.error(`[esbuild] Failed to find package "${pkg}" on the file system
215
+
216
+ This can happen if you use the "--no-optional" flag. The "optionalDependencies"
217
+ package.json feature is used by esbuild to install the correct binary executable
218
+ for your current platform. This install script will now attempt to work around
219
+ this. If that fails, you need to remove the "--no-optional" flag to use esbuild.
220
+ `);
221
+ binPath = downloadedBinPath(pkg, subpath);
222
+ try {
223
+ console.error(`[esbuild] Trying to install package "${pkg}" using npm`);
224
+ installUsingNPM(pkg, subpath, binPath);
225
+ } catch (e2) {
226
+ console.error(`[esbuild] Failed to install package "${pkg}" using npm: ${e2 && e2.message || e2}`);
227
+ try {
228
+ await downloadDirectlyFromNPM(pkg, subpath, binPath);
229
+ } catch (e3) {
230
+ throw new Error(`Failed to install package "${pkg}"`);
231
+ }
232
+ }
95
233
  }
96
- validateBinaryVersion(toPath);
97
- } else {
98
- validateBinaryVersion("node", toPath);
234
+ maybeOptimizePackage(binPath);
99
235
  }
236
+ checkAndPreparePackage().then(() => {
237
+ if (isToPathJS) {
238
+ validateBinaryVersion("node", toPath);
239
+ } else {
240
+ validateBinaryVersion(toPath);
241
+ }
242
+ });
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;
@@ -23,6 +27,17 @@ var __export = (target, all) => {
23
27
  for (var name in all)
24
28
  __defProp(target, name, { get: all[name], enumerable: true });
25
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
+ };
26
41
 
27
42
  // lib/npm/node.ts
28
43
  __export(exports, {
@@ -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.13.0") {
698
- throw new Error(`Cannot start service: Host version "${"0.13.0"}" does not match binary version ${JSON.stringify(binaryVersion)}`);
712
+ if (binaryVersion !== "0.13.4") {
713
+ throw new Error(`Cannot start service: Host version "${"0.13.4"}" does not match binary version ${JSON.stringify(binaryVersion)}`);
699
714
  }
700
715
  return;
701
716
  }
@@ -1591,52 +1606,48 @@ var knownUnixlikePackages = {
1591
1606
  "linux x64 LE": "esbuild-linux-64",
1592
1607
  "sunos x64 LE": "esbuild-sunos-64"
1593
1608
  };
1594
- function pkgAndBinForCurrentPlatform() {
1609
+ function pkgAndSubpathForCurrentPlatform() {
1595
1610
  let pkg;
1596
- let bin;
1611
+ let subpath;
1597
1612
  let platformKey = `${process.platform} ${os.arch()} ${os.endianness()}`;
1598
1613
  if (platformKey in knownWindowsPackages) {
1599
1614
  pkg = knownWindowsPackages[platformKey];
1600
- bin = `${pkg}/esbuild.exe`;
1615
+ subpath = "esbuild.exe";
1601
1616
  } else if (platformKey in knownUnixlikePackages) {
1602
1617
  pkg = knownUnixlikePackages[platformKey];
1603
- bin = `${pkg}/bin/esbuild`;
1618
+ subpath = "bin/esbuild";
1604
1619
  } else {
1605
1620
  throw new Error(`Unsupported platform: ${platformKey}`);
1606
1621
  }
1622
+ return { pkg, subpath };
1623
+ }
1624
+ function downloadedBinPath(pkg, subpath) {
1625
+ const esbuildLibDir = path.dirname(require.resolve("esbuild"));
1626
+ return path.join(esbuildLibDir, `downloaded-${pkg}-${path.basename(subpath)}`);
1627
+ }
1628
+ function generateBinPath() {
1629
+ if (ESBUILD_BINARY_PATH) {
1630
+ return ESBUILD_BINARY_PATH;
1631
+ }
1632
+ const { pkg, subpath } = pkgAndSubpathForCurrentPlatform();
1633
+ let binPath;
1607
1634
  try {
1608
- bin = require.resolve(bin);
1635
+ binPath = require.resolve(`${pkg}/${subpath}`);
1609
1636
  } catch (e) {
1610
- try {
1611
- require.resolve(pkg);
1612
- } catch (e2) {
1613
- throw new Error(`The package "${pkg}" could not be found, and is needed by esbuild.
1637
+ binPath = downloadedBinPath(pkg, subpath);
1638
+ if (!fs.existsSync(binPath)) {
1639
+ try {
1640
+ require.resolve(pkg);
1641
+ } catch (e2) {
1642
+ throw new Error(`The package "${pkg}" could not be found, and is needed by esbuild.
1614
1643
 
1615
1644
  If you are installing esbuild with npm, make sure that you don't specify the
1616
1645
  "--no-optional" flag. The "optionalDependencies" package.json feature is used
1617
1646
  by esbuild to install the correct binary executable for your current platform.`);
1647
+ }
1648
+ throw e;
1618
1649
  }
1619
- throw e;
1620
- }
1621
- return { pkg, bin };
1622
- }
1623
- function getCachePath(name) {
1624
- const home = os.homedir();
1625
- const common2 = ["esbuild", "bin", `${name}@${"0.13.0"}`];
1626
- if (process.platform === "darwin")
1627
- return path.join(home, "Library", "Caches", ...common2);
1628
- if (process.platform === "win32")
1629
- return path.join(home, "AppData", "Local", "Cache", ...common2);
1630
- const XDG_CACHE_HOME = process.env.XDG_CACHE_HOME;
1631
- if (process.platform === "linux" && XDG_CACHE_HOME && path.isAbsolute(XDG_CACHE_HOME))
1632
- return path.join(XDG_CACHE_HOME, ...common2);
1633
- return path.join(home, ".cache", ...common2);
1634
- }
1635
- function extractedBinPath() {
1636
- if (ESBUILD_BINARY_PATH) {
1637
- return ESBUILD_BINARY_PATH;
1638
1650
  }
1639
- const { pkg, bin } = pkgAndBinForCurrentPlatform();
1640
1651
  let isYarnPnP = false;
1641
1652
  try {
1642
1653
  require("pnpapi");
@@ -1644,14 +1655,15 @@ function extractedBinPath() {
1644
1655
  } catch (e) {
1645
1656
  }
1646
1657
  if (isYarnPnP) {
1647
- const binTargetPath = getCachePath(pkg);
1658
+ const esbuildLibDir = path.dirname(require.resolve("esbuild"));
1659
+ const binTargetPath = path.join(esbuildLibDir, `pnpapi-${pkg}-${path.basename(subpath)}`);
1648
1660
  if (!fs.existsSync(binTargetPath)) {
1649
- fs.copyFileSync(bin, binTargetPath);
1661
+ fs.copyFileSync(binPath, binTargetPath);
1650
1662
  fs.chmodSync(binTargetPath, 493);
1651
1663
  }
1652
1664
  return binTargetPath;
1653
1665
  }
1654
- return bin;
1666
+ return binPath;
1655
1667
  }
1656
1668
 
1657
1669
  // lib/npm/node.ts
@@ -1673,7 +1685,7 @@ if (process.env.ESBUILD_WORKER_THREADS !== "0") {
1673
1685
  }
1674
1686
  }
1675
1687
  var _a;
1676
- var isInternalWorkerThread = ((_a = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a.esbuildVersion) === "0.13.0";
1688
+ var isInternalWorkerThread = ((_a = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a.esbuildVersion) === "0.13.4";
1677
1689
  var esbuildCommandAndArgs = () => {
1678
1690
  if (path2.basename(__filename) !== "main.js" || path2.basename(__dirname) !== "lib") {
1679
1691
  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.
@@ -1683,7 +1695,7 @@ More information: The file containing the code for esbuild's JavaScript API (${_
1683
1695
  if (false) {
1684
1696
  return ["node", [path2.join(__dirname, "..", "bin", "esbuild")]];
1685
1697
  }
1686
- return [extractedBinPath(), []];
1698
+ return [generateBinPath(), []];
1687
1699
  };
1688
1700
  var isTTY = () => tty.isatty(2);
1689
1701
  var fsSync = {
@@ -1732,7 +1744,7 @@ var fsAsync = {
1732
1744
  }
1733
1745
  }
1734
1746
  };
1735
- var version = "0.13.0";
1747
+ var version = "0.13.4";
1736
1748
  var build = (options) => ensureServiceIsRunning().build(options);
1737
1749
  var serve = (serveOptions, buildOptions) => ensureServiceIsRunning().serve(serveOptions, buildOptions);
1738
1750
  var transform = (input, options) => ensureServiceIsRunning().transform(input, options);
@@ -1841,7 +1853,7 @@ var ensureServiceIsRunning = () => {
1841
1853
  if (longLivedService)
1842
1854
  return longLivedService;
1843
1855
  let [command, args] = esbuildCommandAndArgs();
1844
- let child = child_process.spawn(command, args.concat(`--service=${"0.13.0"}`, "--ping"), {
1856
+ let child = child_process.spawn(command, args.concat(`--service=${"0.13.4"}`, "--ping"), {
1845
1857
  windowsHide: true,
1846
1858
  stdio: ["pipe", "pipe", "inherit"],
1847
1859
  cwd: defaultWD
@@ -1948,7 +1960,7 @@ var runServiceSync = (callback) => {
1948
1960
  isBrowser: false
1949
1961
  });
1950
1962
  callback(service);
1951
- let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.13.0"}`), {
1963
+ let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.13.4"}`), {
1952
1964
  cwd: defaultWD,
1953
1965
  windowsHide: true,
1954
1966
  input: stdin,
@@ -1964,7 +1976,7 @@ var workerThreadService = null;
1964
1976
  var startWorkerThreadService = (worker_threads2) => {
1965
1977
  let { port1: mainPort, port2: workerPort } = new worker_threads2.MessageChannel();
1966
1978
  let worker = new worker_threads2.Worker(__filename, {
1967
- workerData: { workerPort, defaultWD, esbuildVersion: "0.13.0" },
1979
+ workerData: { workerPort, defaultWD, esbuildVersion: "0.13.4" },
1968
1980
  transferList: [workerPort],
1969
1981
  execArgv: []
1970
1982
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esbuild",
3
- "version": "0.13.0",
3
+ "version": "0.13.4",
4
4
  "description": "An extremely fast JavaScript bundler and minifier.",
5
5
  "repository": "https://github.com/evanw/esbuild",
6
6
  "scripts": {
@@ -12,22 +12,22 @@
12
12
  "esbuild": "bin/esbuild"
13
13
  },
14
14
  "optionalDependencies": {
15
- "esbuild-android-arm64": "0.13.0",
16
- "esbuild-darwin-64": "0.13.0",
17
- "esbuild-darwin-arm64": "0.13.0",
18
- "esbuild-freebsd-64": "0.13.0",
19
- "esbuild-freebsd-arm64": "0.13.0",
20
- "esbuild-linux-32": "0.13.0",
21
- "esbuild-linux-64": "0.13.0",
22
- "esbuild-linux-arm": "0.13.0",
23
- "esbuild-linux-arm64": "0.13.0",
24
- "esbuild-linux-mips64le": "0.13.0",
25
- "esbuild-linux-ppc64le": "0.13.0",
26
- "esbuild-openbsd-64": "0.13.0",
27
- "esbuild-sunos-64": "0.13.0",
28
- "esbuild-windows-32": "0.13.0",
29
- "esbuild-windows-64": "0.13.0",
30
- "esbuild-windows-arm64": "0.13.0"
15
+ "esbuild-android-arm64": "0.13.4",
16
+ "esbuild-darwin-64": "0.13.4",
17
+ "esbuild-darwin-arm64": "0.13.4",
18
+ "esbuild-freebsd-64": "0.13.4",
19
+ "esbuild-freebsd-arm64": "0.13.4",
20
+ "esbuild-linux-32": "0.13.4",
21
+ "esbuild-linux-64": "0.13.4",
22
+ "esbuild-linux-arm": "0.13.4",
23
+ "esbuild-linux-arm64": "0.13.4",
24
+ "esbuild-linux-mips64le": "0.13.4",
25
+ "esbuild-linux-ppc64le": "0.13.4",
26
+ "esbuild-openbsd-64": "0.13.4",
27
+ "esbuild-sunos-64": "0.13.4",
28
+ "esbuild-windows-32": "0.13.4",
29
+ "esbuild-windows-64": "0.13.4",
30
+ "esbuild-windows-arm64": "0.13.4"
31
31
  },
32
32
  "license": "MIT"
33
33
  }