esbuild 0.19.5 → 0.19.7

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
@@ -199,7 +199,7 @@ for your current platform.`);
199
199
  "node_modules",
200
200
  ".cache",
201
201
  "esbuild",
202
- `pnpapi-${pkg.replace("/", "-")}-${"0.19.5"}-${path.basename(subpath)}`
202
+ `pnpapi-${pkg.replace("/", "-")}-${"0.19.7"}-${path.basename(subpath)}`
203
203
  );
204
204
  if (!fs.existsSync(binTargetPath)) {
205
205
  fs.mkdirSync(path.dirname(binTargetPath), { recursive: true });
package/lib/main.d.ts CHANGED
@@ -425,6 +425,7 @@ export interface OnLoadArgs {
425
425
  namespace: string
426
426
  suffix: string
427
427
  pluginData: any
428
+ with: Record<string, string>
428
429
  }
429
430
 
430
431
  /** Documentation: https://esbuild.github.io/plugins/#on-load-results */
@@ -467,8 +468,10 @@ export interface Metafile {
467
468
  kind: ImportKind
468
469
  external?: boolean
469
470
  original?: string
471
+ with?: Record<string, string>
470
472
  }[]
471
473
  format?: 'cjs' | 'esm'
474
+ with?: Record<string, string>
472
475
  }
473
476
  }
474
477
  outputs: {
package/lib/main.js CHANGED
@@ -746,8 +746,8 @@ function createChannel(streamIn) {
746
746
  if (isFirstPacket) {
747
747
  isFirstPacket = false;
748
748
  let binaryVersion = String.fromCharCode(...bytes);
749
- if (binaryVersion !== "0.19.5") {
750
- throw new Error(`Cannot start service: Host version "${"0.19.5"}" does not match binary version ${quote(binaryVersion)}`);
749
+ if (binaryVersion !== "0.19.7") {
750
+ throw new Error(`Cannot start service: Host version "${"0.19.7"}" does not match binary version ${quote(binaryVersion)}`);
751
751
  }
752
752
  return;
753
753
  }
@@ -890,7 +890,6 @@ function createChannel(streamIn) {
890
890
  start(null);
891
891
  };
892
892
  let formatMessages2 = ({ callName, refs, messages, options, callback }) => {
893
- let result = sanitizeMessages(messages, "messages", null, "");
894
893
  if (!options)
895
894
  throw new Error(`Missing second argument in ${callName}() call`);
896
895
  let keys = {};
@@ -904,7 +903,7 @@ function createChannel(streamIn) {
904
903
  throw new Error(`Expected "kind" to be "error" or "warning" in ${callName}() call`);
905
904
  let request = {
906
905
  command: "format-msgs",
907
- messages: result,
906
+ messages: sanitizeMessages(messages, "messages", null, "", terminalWidth),
908
907
  isWarning: kind === "warning"
909
908
  };
910
909
  if (color !== void 0)
@@ -1356,9 +1355,9 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
1356
1355
  let warnings = getFlag(result, keys, "warnings", mustBeArray);
1357
1356
  checkForInvalidFlags(result, keys, `from onStart() callback in plugin ${quote(name)}`);
1358
1357
  if (errors != null)
1359
- response.errors.push(...sanitizeMessages(errors, "errors", details, name));
1358
+ response.errors.push(...sanitizeMessages(errors, "errors", details, name, void 0));
1360
1359
  if (warnings != null)
1361
- response.warnings.push(...sanitizeMessages(warnings, "warnings", details, name));
1360
+ response.warnings.push(...sanitizeMessages(warnings, "warnings", details, name, void 0));
1362
1361
  }
1363
1362
  } catch (e) {
1364
1363
  response.errors.push(extractErrorMessageV8(e, streamIn, details, note && note(), name));
@@ -1411,9 +1410,9 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
1411
1410
  if (pluginData != null)
1412
1411
  response.pluginData = details.store(pluginData);
1413
1412
  if (errors != null)
1414
- response.errors = sanitizeMessages(errors, "errors", details, name);
1413
+ response.errors = sanitizeMessages(errors, "errors", details, name, void 0);
1415
1414
  if (warnings != null)
1416
- response.warnings = sanitizeMessages(warnings, "warnings", details, name);
1415
+ response.warnings = sanitizeMessages(warnings, "warnings", details, name, void 0);
1417
1416
  if (watchFiles != null)
1418
1417
  response.watchFiles = sanitizeStringArray(watchFiles, "watchFiles");
1419
1418
  if (watchDirs != null)
@@ -1436,7 +1435,8 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
1436
1435
  path: request.path,
1437
1436
  namespace: request.namespace,
1438
1437
  suffix: request.suffix,
1439
- pluginData: details.load(request.pluginData)
1438
+ pluginData: details.load(request.pluginData),
1439
+ with: request.with
1440
1440
  });
1441
1441
  if (result != null) {
1442
1442
  if (typeof result !== "object")
@@ -1466,9 +1466,9 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
1466
1466
  if (loader != null)
1467
1467
  response.loader = loader;
1468
1468
  if (errors != null)
1469
- response.errors = sanitizeMessages(errors, "errors", details, name);
1469
+ response.errors = sanitizeMessages(errors, "errors", details, name, void 0);
1470
1470
  if (warnings != null)
1471
- response.warnings = sanitizeMessages(warnings, "warnings", details, name);
1471
+ response.warnings = sanitizeMessages(warnings, "warnings", details, name, void 0);
1472
1472
  if (watchFiles != null)
1473
1473
  response.watchFiles = sanitizeStringArray(watchFiles, "watchFiles");
1474
1474
  if (watchDirs != null)
@@ -1501,9 +1501,9 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
1501
1501
  let warnings = getFlag(value, keys, "warnings", mustBeArray);
1502
1502
  checkForInvalidFlags(value, keys, `from onEnd() callback in plugin ${quote(name)}`);
1503
1503
  if (errors != null)
1504
- newErrors = sanitizeMessages(errors, "errors", details, name);
1504
+ newErrors = sanitizeMessages(errors, "errors", details, name, void 0);
1505
1505
  if (warnings != null)
1506
- newWarnings = sanitizeMessages(warnings, "warnings", details, name);
1506
+ newWarnings = sanitizeMessages(warnings, "warnings", details, name, void 0);
1507
1507
  }
1508
1508
  } catch (e) {
1509
1509
  newErrors = [extractErrorMessageV8(e, streamIn, details, note && note(), name)];
@@ -1668,7 +1668,7 @@ function replaceDetailsInMessages(messages, stash) {
1668
1668
  }
1669
1669
  return messages;
1670
1670
  }
1671
- function sanitizeLocation(location, where) {
1671
+ function sanitizeLocation(location, where, terminalWidth) {
1672
1672
  if (location == null)
1673
1673
  return null;
1674
1674
  let keys = {};
@@ -1680,6 +1680,15 @@ function sanitizeLocation(location, where) {
1680
1680
  let lineText = getFlag(location, keys, "lineText", mustBeString);
1681
1681
  let suggestion = getFlag(location, keys, "suggestion", mustBeString);
1682
1682
  checkForInvalidFlags(location, keys, where);
1683
+ if (lineText) {
1684
+ const relevantASCII = lineText.slice(
1685
+ 0,
1686
+ (column && column > 0 ? column : 0) + (length && length > 0 ? length : 0) + (terminalWidth && terminalWidth > 0 ? terminalWidth : 80)
1687
+ );
1688
+ if (!/[\x7F-\uFFFF]/.test(relevantASCII) && !/\n/.test(lineText)) {
1689
+ lineText = relevantASCII;
1690
+ }
1691
+ }
1683
1692
  return {
1684
1693
  file: file || "",
1685
1694
  namespace: namespace || "",
@@ -1690,7 +1699,7 @@ function sanitizeLocation(location, where) {
1690
1699
  suggestion: suggestion || ""
1691
1700
  };
1692
1701
  }
1693
- function sanitizeMessages(messages, property, stash, fallbackPluginName) {
1702
+ function sanitizeMessages(messages, property, stash, fallbackPluginName, terminalWidth) {
1694
1703
  let messagesClone = [];
1695
1704
  let index = 0;
1696
1705
  for (const message of messages) {
@@ -1712,7 +1721,7 @@ function sanitizeMessages(messages, property, stash, fallbackPluginName) {
1712
1721
  checkForInvalidFlags(note, noteKeys, where);
1713
1722
  notesClone.push({
1714
1723
  text: noteText || "",
1715
- location: sanitizeLocation(noteLocation, where)
1724
+ location: sanitizeLocation(noteLocation, where, terminalWidth)
1716
1725
  });
1717
1726
  }
1718
1727
  }
@@ -1720,7 +1729,7 @@ function sanitizeMessages(messages, property, stash, fallbackPluginName) {
1720
1729
  id: id || "",
1721
1730
  pluginName: pluginName || fallbackPluginName,
1722
1731
  text: text || "",
1723
- location: sanitizeLocation(location, where),
1732
+ location: sanitizeLocation(location, where, terminalWidth),
1724
1733
  notes: notesClone,
1725
1734
  detail: stash ? stash.store(detail) : -1
1726
1735
  });
@@ -1930,7 +1939,7 @@ for your current platform.`);
1930
1939
  "node_modules",
1931
1940
  ".cache",
1932
1941
  "esbuild",
1933
- `pnpapi-${pkg.replace("/", "-")}-${"0.19.5"}-${path.basename(subpath)}`
1942
+ `pnpapi-${pkg.replace("/", "-")}-${"0.19.7"}-${path.basename(subpath)}`
1934
1943
  );
1935
1944
  if (!fs.existsSync(binTargetPath)) {
1936
1945
  fs.mkdirSync(path.dirname(binTargetPath), { recursive: true });
@@ -1965,7 +1974,7 @@ if (process.env.ESBUILD_WORKER_THREADS !== "0") {
1965
1974
  }
1966
1975
  }
1967
1976
  var _a;
1968
- var isInternalWorkerThread = ((_a = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a.esbuildVersion) === "0.19.5";
1977
+ var isInternalWorkerThread = ((_a = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a.esbuildVersion) === "0.19.7";
1969
1978
  var esbuildCommandAndArgs = () => {
1970
1979
  if ((!ESBUILD_BINARY_PATH || false) && (path2.basename(__filename) !== "main.js" || path2.basename(__dirname) !== "lib")) {
1971
1980
  throw new Error(
@@ -2032,7 +2041,7 @@ var fsAsync = {
2032
2041
  }
2033
2042
  }
2034
2043
  };
2035
- var version = "0.19.5";
2044
+ var version = "0.19.7";
2036
2045
  var build = (options) => ensureServiceIsRunning().build(options);
2037
2046
  var context = (buildOptions) => ensureServiceIsRunning().context(buildOptions);
2038
2047
  var transform = (input, options) => ensureServiceIsRunning().transform(input, options);
@@ -2142,7 +2151,7 @@ var ensureServiceIsRunning = () => {
2142
2151
  if (longLivedService)
2143
2152
  return longLivedService;
2144
2153
  let [command, args] = esbuildCommandAndArgs();
2145
- let child = child_process.spawn(command, args.concat(`--service=${"0.19.5"}`, "--ping"), {
2154
+ let child = child_process.spawn(command, args.concat(`--service=${"0.19.7"}`, "--ping"), {
2146
2155
  windowsHide: true,
2147
2156
  stdio: ["pipe", "pipe", "inherit"],
2148
2157
  cwd: defaultWD
@@ -2242,7 +2251,7 @@ var runServiceSync = (callback) => {
2242
2251
  esbuild: node_exports
2243
2252
  });
2244
2253
  callback(service);
2245
- let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.19.5"}`), {
2254
+ let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.19.7"}`), {
2246
2255
  cwd: defaultWD,
2247
2256
  windowsHide: true,
2248
2257
  input: stdin,
@@ -2262,7 +2271,7 @@ var workerThreadService = null;
2262
2271
  var startWorkerThreadService = (worker_threads2) => {
2263
2272
  let { port1: mainPort, port2: workerPort } = new worker_threads2.MessageChannel();
2264
2273
  let worker = new worker_threads2.Worker(__filename, {
2265
- workerData: { workerPort, defaultWD, esbuildVersion: "0.19.5" },
2274
+ workerData: { workerPort, defaultWD, esbuildVersion: "0.19.7" },
2266
2275
  transferList: [workerPort],
2267
2276
  // From node's documentation: https://nodejs.org/api/worker_threads.html
2268
2277
  //
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esbuild",
3
- "version": "0.19.5",
3
+ "version": "0.19.7",
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.19.5",
19
- "@esbuild/android-arm64": "0.19.5",
20
- "@esbuild/android-x64": "0.19.5",
21
- "@esbuild/darwin-arm64": "0.19.5",
22
- "@esbuild/darwin-x64": "0.19.5",
23
- "@esbuild/freebsd-arm64": "0.19.5",
24
- "@esbuild/freebsd-x64": "0.19.5",
25
- "@esbuild/linux-arm": "0.19.5",
26
- "@esbuild/linux-arm64": "0.19.5",
27
- "@esbuild/linux-ia32": "0.19.5",
28
- "@esbuild/linux-loong64": "0.19.5",
29
- "@esbuild/linux-mips64el": "0.19.5",
30
- "@esbuild/linux-ppc64": "0.19.5",
31
- "@esbuild/linux-riscv64": "0.19.5",
32
- "@esbuild/linux-s390x": "0.19.5",
33
- "@esbuild/linux-x64": "0.19.5",
34
- "@esbuild/netbsd-x64": "0.19.5",
35
- "@esbuild/openbsd-x64": "0.19.5",
36
- "@esbuild/sunos-x64": "0.19.5",
37
- "@esbuild/win32-arm64": "0.19.5",
38
- "@esbuild/win32-ia32": "0.19.5",
39
- "@esbuild/win32-x64": "0.19.5"
18
+ "@esbuild/android-arm": "0.19.7",
19
+ "@esbuild/android-arm64": "0.19.7",
20
+ "@esbuild/android-x64": "0.19.7",
21
+ "@esbuild/darwin-arm64": "0.19.7",
22
+ "@esbuild/darwin-x64": "0.19.7",
23
+ "@esbuild/freebsd-arm64": "0.19.7",
24
+ "@esbuild/freebsd-x64": "0.19.7",
25
+ "@esbuild/linux-arm": "0.19.7",
26
+ "@esbuild/linux-arm64": "0.19.7",
27
+ "@esbuild/linux-ia32": "0.19.7",
28
+ "@esbuild/linux-loong64": "0.19.7",
29
+ "@esbuild/linux-mips64el": "0.19.7",
30
+ "@esbuild/linux-ppc64": "0.19.7",
31
+ "@esbuild/linux-riscv64": "0.19.7",
32
+ "@esbuild/linux-s390x": "0.19.7",
33
+ "@esbuild/linux-x64": "0.19.7",
34
+ "@esbuild/netbsd-x64": "0.19.7",
35
+ "@esbuild/openbsd-x64": "0.19.7",
36
+ "@esbuild/sunos-x64": "0.19.7",
37
+ "@esbuild/win32-arm64": "0.19.7",
38
+ "@esbuild/win32-ia32": "0.19.7",
39
+ "@esbuild/win32-x64": "0.19.7"
40
40
  },
41
41
  "license": "MIT"
42
42
  }