esbuild 0.12.25 → 0.12.29

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/install.js CHANGED
@@ -23,7 +23,7 @@ const path = require("path");
23
23
  const zlib = require("zlib");
24
24
  const https = require("https");
25
25
  const child_process = require("child_process");
26
- const version = "0.12.25";
26
+ const version = "0.12.29";
27
27
  const binPath = path.join(__dirname, "bin", "esbuild");
28
28
  async function installBinaryFromPackage(name, fromPath, toPath) {
29
29
  const cachePath = getCachePath(name);
package/lib/main.d.ts CHANGED
@@ -322,6 +322,11 @@ export interface FormatMessagesOptions {
322
322
  terminalWidth?: number;
323
323
  }
324
324
 
325
+ export interface AnalyzeMetafileOptions {
326
+ color?: boolean;
327
+ verbose?: boolean;
328
+ }
329
+
325
330
  // This function invokes the "esbuild" command-line tool for you. It returns a
326
331
  // promise that either resolves with a "BuildResult" object or rejects with a
327
332
  // "BuildFailure" object.
@@ -356,6 +361,14 @@ export declare function transform(input: string, options?: TransformOptions): Pr
356
361
  // Works in browser: yes
357
362
  export declare function formatMessages(messages: PartialMessage[], options: FormatMessagesOptions): Promise<string[]>;
358
363
 
364
+ // Pretty-prints an analysis of the metafile JSON to a string. This is just for
365
+ // convenience to be able to match esbuild's pretty-printing exactly. If you want
366
+ // to customize it, you can just inspect the data in the metafile yourself.
367
+ //
368
+ // Works in node: yes
369
+ // Works in browser: yes
370
+ export declare function analyzeMetafile(metafile: Metafile | string, options?: AnalyzeMetafileOptions): Promise<string>;
371
+
359
372
  // A synchronous version of "build".
360
373
  //
361
374
  // Works in node: yes
@@ -375,6 +388,12 @@ export declare function transformSync(input: string, options?: TransformOptions)
375
388
  // Works in browser: no
376
389
  export declare function formatMessagesSync(messages: PartialMessage[], options: FormatMessagesOptions): string[];
377
390
 
391
+ // A synchronous version of "analyzeMetafile".
392
+ //
393
+ // Works in node: yes
394
+ // Works in browser: no
395
+ export declare function analyzeMetafileSync(metafile: Metafile | string, options?: AnalyzeMetafileOptions): string;
396
+
378
397
  // This configures the browser-based version of esbuild. It is necessary to
379
398
  // call this first and wait for the returned promise to be resolved before
380
399
  // making other API calls when using esbuild in the browser.
package/lib/main.js CHANGED
@@ -26,6 +26,8 @@ var __export = (target, all) => {
26
26
 
27
27
  // lib/npm/node.ts
28
28
  __export(exports, {
29
+ analyzeMetafile: () => analyzeMetafile,
30
+ analyzeMetafileSync: () => analyzeMetafileSync,
29
31
  build: () => build,
30
32
  buildSync: () => buildSync,
31
33
  formatMessages: () => formatMessages,
@@ -689,8 +691,8 @@ function createChannel(streamIn) {
689
691
  if (isFirstPacket) {
690
692
  isFirstPacket = false;
691
693
  let binaryVersion = String.fromCharCode(...bytes);
692
- if (binaryVersion !== "0.12.25") {
693
- throw new Error(`Cannot start service: Host version "${"0.12.25"}" does not match binary version ${JSON.stringify(binaryVersion)}`);
694
+ if (binaryVersion !== "0.12.29") {
695
+ throw new Error(`Cannot start service: Host version "${"0.12.29"}" does not match binary version ${JSON.stringify(binaryVersion)}`);
694
696
  }
695
697
  return;
696
698
  }
@@ -1331,13 +1333,35 @@ function createChannel(streamIn) {
1331
1333
  callback(null, response.messages);
1332
1334
  });
1333
1335
  };
1336
+ let analyzeMetafile2 = ({ callName, refs, metafile, options, callback }) => {
1337
+ if (options === void 0)
1338
+ options = {};
1339
+ let keys = {};
1340
+ let color = getFlag(options, keys, "color", mustBeBoolean);
1341
+ let verbose = getFlag(options, keys, "verbose", mustBeBoolean);
1342
+ checkForInvalidFlags(options, keys, `in ${callName}() call`);
1343
+ let request = {
1344
+ command: "analyze-metafile",
1345
+ metafile
1346
+ };
1347
+ if (color !== void 0)
1348
+ request.color = color;
1349
+ if (verbose !== void 0)
1350
+ request.verbose = verbose;
1351
+ sendRequest(refs, request, (error, response) => {
1352
+ if (error)
1353
+ return callback(new Error(error), null);
1354
+ callback(null, response.result);
1355
+ });
1356
+ };
1334
1357
  return {
1335
1358
  readFromStdout,
1336
1359
  afterClose,
1337
1360
  service: {
1338
1361
  buildOrServe,
1339
1362
  transform: transform2,
1340
- formatMessages: formatMessages2
1363
+ formatMessages: formatMessages2,
1364
+ analyzeMetafile: analyzeMetafile2
1341
1365
  }
1342
1366
  };
1343
1367
  }
@@ -1558,7 +1582,7 @@ if (process.env.ESBUILD_WORKER_THREADS !== "0") {
1558
1582
  }
1559
1583
  }
1560
1584
  var _a;
1561
- var isInternalWorkerThread = ((_a = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a.esbuildVersion) === "0.12.25";
1585
+ var isInternalWorkerThread = ((_a = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a.esbuildVersion) === "0.12.29";
1562
1586
  var esbuildCommandAndArgs = () => {
1563
1587
  if (process.env.ESBUILD_BINARY_PATH) {
1564
1588
  return [path.resolve(process.env.ESBUILD_BINARY_PATH), []];
@@ -1627,11 +1651,12 @@ var fsAsync = {
1627
1651
  }
1628
1652
  }
1629
1653
  };
1630
- var version = "0.12.25";
1654
+ var version = "0.12.29";
1631
1655
  var build = (options) => ensureServiceIsRunning().build(options);
1632
1656
  var serve = (serveOptions, buildOptions) => ensureServiceIsRunning().serve(serveOptions, buildOptions);
1633
1657
  var transform = (input, options) => ensureServiceIsRunning().transform(input, options);
1634
1658
  var formatMessages = (messages, options) => ensureServiceIsRunning().formatMessages(messages, options);
1659
+ var analyzeMetafile = (messages, options) => ensureServiceIsRunning().analyzeMetafile(messages, options);
1635
1660
  var buildSync = (options) => {
1636
1661
  if (worker_threads && !isInternalWorkerThread) {
1637
1662
  if (!workerThreadService)
@@ -1696,6 +1721,26 @@ var formatMessagesSync = (messages, options) => {
1696
1721
  }));
1697
1722
  return result;
1698
1723
  };
1724
+ var analyzeMetafileSync = (metafile, options) => {
1725
+ if (worker_threads && !isInternalWorkerThread) {
1726
+ if (!workerThreadService)
1727
+ workerThreadService = startWorkerThreadService(worker_threads);
1728
+ return workerThreadService.analyzeMetafileSync(metafile, options);
1729
+ }
1730
+ let result;
1731
+ runServiceSync((service) => service.analyzeMetafile({
1732
+ callName: "analyzeMetafileSync",
1733
+ refs: null,
1734
+ metafile: typeof metafile === "string" ? metafile : JSON.stringify(metafile),
1735
+ options,
1736
+ callback: (err, res) => {
1737
+ if (err)
1738
+ throw err;
1739
+ result = res;
1740
+ }
1741
+ }));
1742
+ return result;
1743
+ };
1699
1744
  var initializeWasCalled = false;
1700
1745
  var initialize = (options) => {
1701
1746
  options = validateInitializeOptions(options || {});
@@ -1715,7 +1760,7 @@ var ensureServiceIsRunning = () => {
1715
1760
  if (longLivedService)
1716
1761
  return longLivedService;
1717
1762
  let [command, args] = esbuildCommandAndArgs();
1718
- let child = child_process.spawn(command, args.concat(`--service=${"0.12.25"}`, "--ping"), {
1763
+ let child = child_process.spawn(command, args.concat(`--service=${"0.12.29"}`, "--ping"), {
1719
1764
  windowsHide: true,
1720
1765
  stdio: ["pipe", "pipe", "inherit"],
1721
1766
  cwd: defaultWD
@@ -1796,6 +1841,15 @@ var ensureServiceIsRunning = () => {
1796
1841
  options,
1797
1842
  callback: (err, res) => err ? reject(err) : resolve(res)
1798
1843
  }));
1844
+ },
1845
+ analyzeMetafile: (metafile, options) => {
1846
+ return new Promise((resolve, reject) => service.analyzeMetafile({
1847
+ callName: "analyzeMetafile",
1848
+ refs,
1849
+ metafile: typeof metafile === "string" ? metafile : JSON.stringify(metafile),
1850
+ options,
1851
+ callback: (err, res) => err ? reject(err) : resolve(res)
1852
+ }));
1799
1853
  }
1800
1854
  };
1801
1855
  return longLivedService;
@@ -1813,7 +1867,7 @@ var runServiceSync = (callback) => {
1813
1867
  isBrowser: false
1814
1868
  });
1815
1869
  callback(service);
1816
- let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.12.25"}`), {
1870
+ let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.12.29"}`), {
1817
1871
  cwd: defaultWD,
1818
1872
  windowsHide: true,
1819
1873
  input: stdin,
@@ -1829,7 +1883,7 @@ var workerThreadService = null;
1829
1883
  var startWorkerThreadService = (worker_threads2) => {
1830
1884
  let { port1: mainPort, port2: workerPort } = new worker_threads2.MessageChannel();
1831
1885
  let worker = new worker_threads2.Worker(__filename, {
1832
- workerData: { workerPort, defaultWD, esbuildVersion: "0.12.25" },
1886
+ workerData: { workerPort, defaultWD, esbuildVersion: "0.12.29" },
1833
1887
  transferList: [workerPort],
1834
1888
  execArgv: []
1835
1889
  });
@@ -1892,6 +1946,9 @@ error: ${text}`);
1892
1946
  },
1893
1947
  formatMessagesSync(messages, options) {
1894
1948
  return runCallSync("formatMessages", [messages, options]);
1949
+ },
1950
+ analyzeMetafileSync(metafile, options) {
1951
+ return runCallSync("analyzeMetafile", [metafile, options]);
1895
1952
  }
1896
1953
  };
1897
1954
  };
@@ -1914,14 +1971,21 @@ var startSyncServiceWorker = () => {
1914
1971
  let { sharedBuffer, id, command, args } = msg;
1915
1972
  let sharedBufferView = new Int32Array(sharedBuffer);
1916
1973
  try {
1917
- if (command === "build") {
1918
- workerPort.postMessage({ id, resolve: await service.build(args[0]) });
1919
- } else if (command === "transform") {
1920
- workerPort.postMessage({ id, resolve: await service.transform(args[0], args[1]) });
1921
- } else if (command === "formatMessages") {
1922
- workerPort.postMessage({ id, resolve: await service.formatMessages(args[0], args[1]) });
1923
- } else {
1924
- throw new Error(`Invalid command: ${command}`);
1974
+ switch (command) {
1975
+ case "build":
1976
+ workerPort.postMessage({ id, resolve: await service.build(args[0]) });
1977
+ break;
1978
+ case "transform":
1979
+ workerPort.postMessage({ id, resolve: await service.transform(args[0], args[1]) });
1980
+ break;
1981
+ case "formatMessages":
1982
+ workerPort.postMessage({ id, resolve: await service.formatMessages(args[0], args[1]) });
1983
+ break;
1984
+ case "analyzeMetafile":
1985
+ workerPort.postMessage({ id, resolve: await service.analyzeMetafile(args[0], args[1]) });
1986
+ break;
1987
+ default:
1988
+ throw new Error(`Invalid command: ${command}`);
1925
1989
  }
1926
1990
  } catch (reject) {
1927
1991
  workerPort.postMessage({ id, reject, properties: extractProperties(reject) });
@@ -1936,6 +2000,8 @@ if (isInternalWorkerThread) {
1936
2000
  }
1937
2001
  // Annotate the CommonJS export names for ESM import in node:
1938
2002
  0 && (module.exports = {
2003
+ analyzeMetafile,
2004
+ analyzeMetafileSync,
1939
2005
  build,
1940
2006
  buildSync,
1941
2007
  formatMessages,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esbuild",
3
- "version": "0.12.25",
3
+ "version": "0.12.29",
4
4
  "description": "An extremely fast JavaScript bundler and minifier.",
5
5
  "repository": "https://github.com/evanw/esbuild",
6
6
  "scripts": {