esbuild 0.17.1 → 0.17.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/esbuild CHANGED
@@ -198,7 +198,7 @@ for your current platform.`);
198
198
  "node_modules",
199
199
  ".cache",
200
200
  "esbuild",
201
- `pnpapi-${pkg.replace("/", "-")}-${"0.17.1"}-${path.basename(subpath)}`
201
+ `pnpapi-${pkg.replace("/", "-")}-${"0.17.2"}-${path.basename(subpath)}`
202
202
  );
203
203
  if (!fs.existsSync(binTargetPath)) {
204
204
  fs.mkdirSync(path.dirname(binTargetPath), { recursive: true });
package/install.js CHANGED
@@ -126,8 +126,8 @@ which means the "esbuild" binary executable can't be run. You can either:
126
126
  }
127
127
  throw err;
128
128
  }
129
- if (stdout !== "0.17.1") {
130
- throw new Error(`Expected ${JSON.stringify("0.17.1")} but got ${JSON.stringify(stdout)}`);
129
+ if (stdout !== "0.17.2") {
130
+ throw new Error(`Expected ${JSON.stringify("0.17.2")} but got ${JSON.stringify(stdout)}`);
131
131
  }
132
132
  }
133
133
  function isYarn() {
@@ -179,7 +179,7 @@ function installUsingNPM(pkg, subpath, binPath) {
179
179
  try {
180
180
  fs2.writeFileSync(path2.join(installDir, "package.json"), "{}");
181
181
  child_process.execSync(
182
- `npm install --loglevel=error --prefer-offline --no-audit --progress=false ${pkg}@${"0.17.1"}`,
182
+ `npm install --loglevel=error --prefer-offline --no-audit --progress=false ${pkg}@${"0.17.2"}`,
183
183
  { cwd: installDir, stdio: "pipe", env }
184
184
  );
185
185
  const installedBinPath = path2.join(installDir, "node_modules", pkg, subpath);
@@ -230,7 +230,7 @@ function maybeOptimizePackage(binPath) {
230
230
  }
231
231
  }
232
232
  async function downloadDirectlyFromNPM(pkg, subpath, binPath) {
233
- const url = `https://registry.npmjs.org/${pkg}/-/${pkg.replace("@esbuild/", "")}-${"0.17.1"}.tgz`;
233
+ const url = `https://registry.npmjs.org/${pkg}/-/${pkg.replace("@esbuild/", "")}-${"0.17.2"}.tgz`;
234
234
  console.error(`[esbuild] Trying to download ${JSON.stringify(url)}`);
235
235
  try {
236
236
  fs2.writeFileSync(binPath, extractFileFromTarGzip(await fetch(url), subpath));
package/lib/main.d.ts CHANGED
@@ -296,6 +296,9 @@ export interface PluginBuild {
296
296
  onLoad(options: OnLoadOptions, callback: (args: OnLoadArgs) =>
297
297
  (OnLoadResult | null | undefined | Promise<OnLoadResult | null | undefined>)): void
298
298
 
299
+ /** Documentation: https://esbuild.github.io/plugins/#on-dispose */
300
+ onDispose(callback: () => void): void
301
+
299
302
  // This is a full copy of the esbuild library in case you need it
300
303
  esbuild: {
301
304
  context: typeof context,
@@ -489,7 +492,7 @@ export interface BuildContext<SpecificOptions extends BuildOptions = BuildOption
489
492
  rebuild(): Promise<BuildResult<SpecificOptions>>
490
493
 
491
494
  /** Documentation: https://esbuild.github.io/api/#watch */
492
- watch(options?: WatchOptions): void
495
+ watch(options?: WatchOptions): Promise<void>
493
496
 
494
497
  /** Documentation: https://esbuild.github.io/api/#serve */
495
498
  serve(options?: ServeOptions): Promise<ServeResult>
package/lib/main.js CHANGED
@@ -735,8 +735,8 @@ function createChannel(streamIn) {
735
735
  if (isFirstPacket) {
736
736
  isFirstPacket = false;
737
737
  let binaryVersion = String.fromCharCode(...bytes);
738
- if (binaryVersion !== "0.17.1") {
739
- throw new Error(`Cannot start service: Host version "${"0.17.1"}" does not match binary version ${quote(binaryVersion)}`);
738
+ if (binaryVersion !== "0.17.2") {
739
+ throw new Error(`Cannot start service: Host version "${"0.17.2"}" does not match binary version ${quote(binaryVersion)}`);
740
740
  }
741
741
  return;
742
742
  }
@@ -980,7 +980,7 @@ function buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs,
980
980
  if (!result.ok)
981
981
  return handleError(result.error, result.pluginName);
982
982
  try {
983
- buildOrContextContinue(result.requestPlugins, result.runOnEndCallbacks);
983
+ buildOrContextContinue(result.requestPlugins, result.runOnEndCallbacks, result.scheduleOnDisposeCallbacks);
984
984
  } catch (e) {
985
985
  handleError(e, "");
986
986
  }
@@ -990,11 +990,12 @@ function buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs,
990
990
  return;
991
991
  }
992
992
  try {
993
- buildOrContextContinue(null, (result, done) => done([], []));
993
+ buildOrContextContinue(null, (result, done) => done([], []), () => {
994
+ });
994
995
  } catch (e) {
995
996
  handleError(e, "");
996
997
  }
997
- function buildOrContextContinue(requestPlugins, runOnEndCallbacks) {
998
+ function buildOrContextContinue(requestPlugins, runOnEndCallbacks, scheduleOnDisposeCallbacks) {
998
999
  const writeDefault = streamIn.hasFS;
999
1000
  const {
1000
1001
  entries,
@@ -1071,7 +1072,10 @@ function buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs,
1071
1072
  if (error)
1072
1073
  return callback(new Error(error), null);
1073
1074
  if (!isContext) {
1074
- return buildResponseToResult(response, callback);
1075
+ return buildResponseToResult(response, (err, res) => {
1076
+ scheduleOnDisposeCallbacks();
1077
+ return callback(err, res);
1078
+ });
1075
1079
  }
1076
1080
  if (response.errors.length > 0) {
1077
1081
  return callback(failureErrorWithLog("Context failed", response.errors, response.warnings), null);
@@ -1173,12 +1177,14 @@ function buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs,
1173
1177
  dispose: () => new Promise((resolve) => {
1174
1178
  if (didDispose)
1175
1179
  return resolve();
1180
+ didDispose = true;
1176
1181
  const request2 = {
1177
1182
  command: "dispose",
1178
1183
  key: buildKey
1179
1184
  };
1180
1185
  sendRequest(refs, request2, () => {
1181
1186
  resolve();
1187
+ scheduleOnDisposeCallbacks();
1182
1188
  refs.unref();
1183
1189
  });
1184
1190
  })
@@ -1193,6 +1199,7 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
1193
1199
  let onEndCallbacks = [];
1194
1200
  let onResolveCallbacks = {};
1195
1201
  let onLoadCallbacks = {};
1202
+ let onDisposeCallbacks = [];
1196
1203
  let nextCallbackID = 0;
1197
1204
  let i = 0;
1198
1205
  let requestPlugins = [];
@@ -1310,6 +1317,9 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
1310
1317
  onLoadCallbacks[id] = { name, callback, note: registeredNote };
1311
1318
  plugin.onLoad.push({ id, filter: filter.source, namespace: namespace || "" });
1312
1319
  },
1320
+ onDispose(callback) {
1321
+ onDisposeCallbacks.push(callback);
1322
+ },
1313
1323
  esbuild: streamIn.esbuild
1314
1324
  });
1315
1325
  if (promise)
@@ -1503,11 +1513,17 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
1503
1513
  })();
1504
1514
  };
1505
1515
  }
1516
+ let scheduleOnDisposeCallbacks = () => {
1517
+ for (const cb of onDisposeCallbacks) {
1518
+ setTimeout(() => cb(), 0);
1519
+ }
1520
+ };
1506
1521
  isSetupDone = true;
1507
1522
  return {
1508
1523
  ok: true,
1509
1524
  requestPlugins,
1510
- runOnEndCallbacks
1525
+ runOnEndCallbacks,
1526
+ scheduleOnDisposeCallbacks
1511
1527
  };
1512
1528
  };
1513
1529
  function createObjectStash() {
@@ -1888,7 +1904,7 @@ for your current platform.`);
1888
1904
  "node_modules",
1889
1905
  ".cache",
1890
1906
  "esbuild",
1891
- `pnpapi-${pkg.replace("/", "-")}-${"0.17.1"}-${path.basename(subpath)}`
1907
+ `pnpapi-${pkg.replace("/", "-")}-${"0.17.2"}-${path.basename(subpath)}`
1892
1908
  );
1893
1909
  if (!fs.existsSync(binTargetPath)) {
1894
1910
  fs.mkdirSync(path.dirname(binTargetPath), { recursive: true });
@@ -1923,7 +1939,7 @@ if (process.env.ESBUILD_WORKER_THREADS !== "0") {
1923
1939
  }
1924
1940
  }
1925
1941
  var _a;
1926
- var isInternalWorkerThread = ((_a = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a.esbuildVersion) === "0.17.1";
1942
+ var isInternalWorkerThread = ((_a = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a.esbuildVersion) === "0.17.2";
1927
1943
  var esbuildCommandAndArgs = () => {
1928
1944
  if ((!ESBUILD_BINARY_PATH || false) && (path2.basename(__filename) !== "main.js" || path2.basename(__dirname) !== "lib")) {
1929
1945
  throw new Error(
@@ -1990,7 +2006,7 @@ var fsAsync = {
1990
2006
  }
1991
2007
  }
1992
2008
  };
1993
- var version = "0.17.1";
2009
+ var version = "0.17.2";
1994
2010
  var build = (options) => ensureServiceIsRunning().build(options);
1995
2011
  var context = (buildOptions) => ensureServiceIsRunning().context(buildOptions);
1996
2012
  var transform = (input, options) => ensureServiceIsRunning().transform(input, options);
@@ -2100,7 +2116,7 @@ var ensureServiceIsRunning = () => {
2100
2116
  if (longLivedService)
2101
2117
  return longLivedService;
2102
2118
  let [command, args] = esbuildCommandAndArgs();
2103
- let child = child_process.spawn(command, args.concat(`--service=${"0.17.1"}`, "--ping"), {
2119
+ let child = child_process.spawn(command, args.concat(`--service=${"0.17.2"}`, "--ping"), {
2104
2120
  windowsHide: true,
2105
2121
  stdio: ["pipe", "pipe", "inherit"],
2106
2122
  cwd: defaultWD
@@ -2200,7 +2216,7 @@ var runServiceSync = (callback) => {
2200
2216
  esbuild: node_exports
2201
2217
  });
2202
2218
  callback(service);
2203
- let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.17.1"}`), {
2219
+ let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.17.2"}`), {
2204
2220
  cwd: defaultWD,
2205
2221
  windowsHide: true,
2206
2222
  input: stdin,
@@ -2220,7 +2236,7 @@ var workerThreadService = null;
2220
2236
  var startWorkerThreadService = (worker_threads2) => {
2221
2237
  let { port1: mainPort, port2: workerPort } = new worker_threads2.MessageChannel();
2222
2238
  let worker = new worker_threads2.Worker(__filename, {
2223
- workerData: { workerPort, defaultWD, esbuildVersion: "0.17.1" },
2239
+ workerData: { workerPort, defaultWD, esbuildVersion: "0.17.2" },
2224
2240
  transferList: [workerPort],
2225
2241
  // From node's documentation: https://nodejs.org/api/worker_threads.html
2226
2242
  //
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esbuild",
3
- "version": "0.17.1",
3
+ "version": "0.17.2",
4
4
  "description": "An extremely fast JavaScript and CSS bundler and minifier.",
5
5
  "repository": "https://github.com/evanw/esbuild",
6
6
  "scripts": {
@@ -15,28 +15,28 @@
15
15
  "esbuild": "bin/esbuild"
16
16
  },
17
17
  "optionalDependencies": {
18
- "@esbuild/android-arm": "0.17.1",
19
- "@esbuild/android-arm64": "0.17.1",
20
- "@esbuild/android-x64": "0.17.1",
21
- "@esbuild/darwin-arm64": "0.17.1",
22
- "@esbuild/darwin-x64": "0.17.1",
23
- "@esbuild/freebsd-arm64": "0.17.1",
24
- "@esbuild/freebsd-x64": "0.17.1",
25
- "@esbuild/linux-arm": "0.17.1",
26
- "@esbuild/linux-arm64": "0.17.1",
27
- "@esbuild/linux-ia32": "0.17.1",
28
- "@esbuild/linux-loong64": "0.17.1",
29
- "@esbuild/linux-mips64el": "0.17.1",
30
- "@esbuild/linux-ppc64": "0.17.1",
31
- "@esbuild/linux-riscv64": "0.17.1",
32
- "@esbuild/linux-s390x": "0.17.1",
33
- "@esbuild/linux-x64": "0.17.1",
34
- "@esbuild/netbsd-x64": "0.17.1",
35
- "@esbuild/openbsd-x64": "0.17.1",
36
- "@esbuild/sunos-x64": "0.17.1",
37
- "@esbuild/win32-arm64": "0.17.1",
38
- "@esbuild/win32-ia32": "0.17.1",
39
- "@esbuild/win32-x64": "0.17.1"
18
+ "@esbuild/android-arm": "0.17.2",
19
+ "@esbuild/android-arm64": "0.17.2",
20
+ "@esbuild/android-x64": "0.17.2",
21
+ "@esbuild/darwin-arm64": "0.17.2",
22
+ "@esbuild/darwin-x64": "0.17.2",
23
+ "@esbuild/freebsd-arm64": "0.17.2",
24
+ "@esbuild/freebsd-x64": "0.17.2",
25
+ "@esbuild/linux-arm": "0.17.2",
26
+ "@esbuild/linux-arm64": "0.17.2",
27
+ "@esbuild/linux-ia32": "0.17.2",
28
+ "@esbuild/linux-loong64": "0.17.2",
29
+ "@esbuild/linux-mips64el": "0.17.2",
30
+ "@esbuild/linux-ppc64": "0.17.2",
31
+ "@esbuild/linux-riscv64": "0.17.2",
32
+ "@esbuild/linux-s390x": "0.17.2",
33
+ "@esbuild/linux-x64": "0.17.2",
34
+ "@esbuild/netbsd-x64": "0.17.2",
35
+ "@esbuild/openbsd-x64": "0.17.2",
36
+ "@esbuild/sunos-x64": "0.17.2",
37
+ "@esbuild/win32-arm64": "0.17.2",
38
+ "@esbuild/win32-ia32": "0.17.2",
39
+ "@esbuild/win32-x64": "0.17.2"
40
40
  },
41
41
  "license": "MIT"
42
42
  }