cdk-appsync-typescript-resolver 0.0.24 → 0.0.26

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.
@@ -220,8 +220,7 @@ var buildLogLevelDefault = "warning";
220
220
  var transformLogLevelDefault = "silent";
221
221
  function validateTarget(target) {
222
222
  validateStringValue(target, "target");
223
- if (target.indexOf(",") >= 0)
224
- throw new Error(`Invalid target: ${target}`);
223
+ if (target.indexOf(",") >= 0) throw new Error(`Invalid target: ${target}`);
225
224
  return target;
226
225
  }
227
226
  var canBeAnything = () => null;
@@ -243,11 +242,9 @@ var mustBeStringOrURL = (value) => typeof value === "string" || value instanceof
243
242
  function getFlag(object, keys, key, mustBeFn) {
244
243
  let value = object[key];
245
244
  keys[key + ""] = true;
246
- if (value === void 0)
247
- return void 0;
245
+ if (value === void 0) return void 0;
248
246
  let mustBe = mustBeFn(value);
249
- if (mustBe !== null)
250
- throw new Error(`${quote(key)} must be ${mustBe}`);
247
+ if (mustBe !== null) throw new Error(`${quote(key)} must be ${mustBe}`);
251
248
  return value;
252
249
  }
253
250
  function checkForInvalidFlags(object, keys, where) {
@@ -288,10 +285,8 @@ function pushLogFlags(flags, options, keys, isTTY2, logLevelDefault) {
288
285
  let color = getFlag(options, keys, "color", mustBeBoolean);
289
286
  let logLevel = getFlag(options, keys, "logLevel", mustBeString);
290
287
  let logLimit = getFlag(options, keys, "logLimit", mustBeInteger);
291
- if (color !== void 0)
292
- flags.push(`--color=${color}`);
293
- else if (isTTY2)
294
- flags.push(`--color=true`);
288
+ if (color !== void 0) flags.push(`--color=${color}`);
289
+ else if (isTTY2) flags.push(`--color=true`);
295
290
  flags.push(`--log-level=${logLevel || logLevelDefault}`);
296
291
  flags.push(`--log-limit=${logLimit || 0}`);
297
292
  }
@@ -334,94 +329,58 @@ function pushCommonFlags(flags, options, keys) {
334
329
  let keepNames = getFlag(options, keys, "keepNames", mustBeBoolean);
335
330
  let platform = getFlag(options, keys, "platform", mustBeString);
336
331
  let tsconfigRaw = getFlag(options, keys, "tsconfigRaw", mustBeStringOrObject);
337
- if (legalComments)
338
- flags.push(`--legal-comments=${legalComments}`);
339
- if (sourceRoot !== void 0)
340
- flags.push(`--source-root=${sourceRoot}`);
341
- if (sourcesContent !== void 0)
342
- flags.push(`--sources-content=${sourcesContent}`);
332
+ if (legalComments) flags.push(`--legal-comments=${legalComments}`);
333
+ if (sourceRoot !== void 0) flags.push(`--source-root=${sourceRoot}`);
334
+ if (sourcesContent !== void 0) flags.push(`--sources-content=${sourcesContent}`);
343
335
  if (target) {
344
- if (Array.isArray(target))
345
- flags.push(`--target=${Array.from(target).map(validateTarget).join(",")}`);
346
- else
347
- flags.push(`--target=${validateTarget(target)}`);
336
+ if (Array.isArray(target)) flags.push(`--target=${Array.from(target).map(validateTarget).join(",")}`);
337
+ else flags.push(`--target=${validateTarget(target)}`);
348
338
  }
349
- if (format)
350
- flags.push(`--format=${format}`);
351
- if (globalName)
352
- flags.push(`--global-name=${globalName}`);
353
- if (platform)
354
- flags.push(`--platform=${platform}`);
355
- if (tsconfigRaw)
356
- flags.push(`--tsconfig-raw=${typeof tsconfigRaw === "string" ? tsconfigRaw : JSON.stringify(tsconfigRaw)}`);
357
- if (minify)
358
- flags.push("--minify");
359
- if (minifySyntax)
360
- flags.push("--minify-syntax");
361
- if (minifyWhitespace)
362
- flags.push("--minify-whitespace");
363
- if (minifyIdentifiers)
364
- flags.push("--minify-identifiers");
365
- if (lineLimit)
366
- flags.push(`--line-limit=${lineLimit}`);
367
- if (charset)
368
- flags.push(`--charset=${charset}`);
369
- if (treeShaking !== void 0)
370
- flags.push(`--tree-shaking=${treeShaking}`);
371
- if (ignoreAnnotations)
372
- flags.push(`--ignore-annotations`);
373
- if (drop)
374
- for (let what of drop)
375
- flags.push(`--drop:${validateStringValue(what, "drop")}`);
376
- if (dropLabels)
377
- flags.push(`--drop-labels=${Array.from(dropLabels).map((what) => validateStringValue(what, "dropLabels")).join(",")}`);
378
- if (mangleProps)
379
- flags.push(`--mangle-props=${mangleProps.source}`);
380
- if (reserveProps)
381
- flags.push(`--reserve-props=${reserveProps.source}`);
382
- if (mangleQuoted !== void 0)
383
- flags.push(`--mangle-quoted=${mangleQuoted}`);
384
- if (jsx)
385
- flags.push(`--jsx=${jsx}`);
386
- if (jsxFactory)
387
- flags.push(`--jsx-factory=${jsxFactory}`);
388
- if (jsxFragment)
389
- flags.push(`--jsx-fragment=${jsxFragment}`);
390
- if (jsxImportSource)
391
- flags.push(`--jsx-import-source=${jsxImportSource}`);
392
- if (jsxDev)
393
- flags.push(`--jsx-dev`);
394
- if (jsxSideEffects)
395
- flags.push(`--jsx-side-effects`);
339
+ if (format) flags.push(`--format=${format}`);
340
+ if (globalName) flags.push(`--global-name=${globalName}`);
341
+ if (platform) flags.push(`--platform=${platform}`);
342
+ if (tsconfigRaw) flags.push(`--tsconfig-raw=${typeof tsconfigRaw === "string" ? tsconfigRaw : JSON.stringify(tsconfigRaw)}`);
343
+ if (minify) flags.push("--minify");
344
+ if (minifySyntax) flags.push("--minify-syntax");
345
+ if (minifyWhitespace) flags.push("--minify-whitespace");
346
+ if (minifyIdentifiers) flags.push("--minify-identifiers");
347
+ if (lineLimit) flags.push(`--line-limit=${lineLimit}`);
348
+ if (charset) flags.push(`--charset=${charset}`);
349
+ if (treeShaking !== void 0) flags.push(`--tree-shaking=${treeShaking}`);
350
+ if (ignoreAnnotations) flags.push(`--ignore-annotations`);
351
+ if (drop) for (let what of drop) flags.push(`--drop:${validateStringValue(what, "drop")}`);
352
+ if (dropLabels) flags.push(`--drop-labels=${Array.from(dropLabels).map((what) => validateStringValue(what, "dropLabels")).join(",")}`);
353
+ if (mangleProps) flags.push(`--mangle-props=${mangleProps.source}`);
354
+ if (reserveProps) flags.push(`--reserve-props=${reserveProps.source}`);
355
+ if (mangleQuoted !== void 0) flags.push(`--mangle-quoted=${mangleQuoted}`);
356
+ if (jsx) flags.push(`--jsx=${jsx}`);
357
+ if (jsxFactory) flags.push(`--jsx-factory=${jsxFactory}`);
358
+ if (jsxFragment) flags.push(`--jsx-fragment=${jsxFragment}`);
359
+ if (jsxImportSource) flags.push(`--jsx-import-source=${jsxImportSource}`);
360
+ if (jsxDev) flags.push(`--jsx-dev`);
361
+ if (jsxSideEffects) flags.push(`--jsx-side-effects`);
396
362
  if (define) {
397
363
  for (let key in define) {
398
- if (key.indexOf("=") >= 0)
399
- throw new Error(`Invalid define: ${key}`);
364
+ if (key.indexOf("=") >= 0) throw new Error(`Invalid define: ${key}`);
400
365
  flags.push(`--define:${key}=${validateStringValue(define[key], "define", key)}`);
401
366
  }
402
367
  }
403
368
  if (logOverride) {
404
369
  for (let key in logOverride) {
405
- if (key.indexOf("=") >= 0)
406
- throw new Error(`Invalid log override: ${key}`);
370
+ if (key.indexOf("=") >= 0) throw new Error(`Invalid log override: ${key}`);
407
371
  flags.push(`--log-override:${key}=${validateStringValue(logOverride[key], "log override", key)}`);
408
372
  }
409
373
  }
410
374
  if (supported) {
411
375
  for (let key in supported) {
412
- if (key.indexOf("=") >= 0)
413
- throw new Error(`Invalid supported: ${key}`);
376
+ if (key.indexOf("=") >= 0) throw new Error(`Invalid supported: ${key}`);
414
377
  const value = supported[key];
415
- if (typeof value !== "boolean")
416
- throw new Error(`Expected value for supported ${quote(key)} to be a boolean, got ${typeof value} instead`);
378
+ if (typeof value !== "boolean") throw new Error(`Expected value for supported ${quote(key)} to be a boolean, got ${typeof value} instead`);
417
379
  flags.push(`--supported:${key}=${value}`);
418
380
  }
419
381
  }
420
- if (pure)
421
- for (let fn of pure)
422
- flags.push(`--pure:${validateStringValue(fn, "pure")}`);
423
- if (keepNames)
424
- flags.push(`--keep-names`);
382
+ if (pure) for (let fn of pure) flags.push(`--pure:${validateStringValue(fn, "pure")}`);
383
+ if (keepNames) flags.push(`--keep-names`);
425
384
  }
426
385
  function flagsForBuildOptions(callName, options, isTTY2, logLevelDefault, writeDefault) {
427
386
  var _a2;
@@ -465,52 +424,35 @@ function flagsForBuildOptions(callName, options, isTTY2, logLevelDefault, writeD
465
424
  let mangleCache = getFlag(options, keys, "mangleCache", mustBeObject);
466
425
  keys.plugins = true;
467
426
  checkForInvalidFlags(options, keys, `in ${callName}() call`);
468
- if (sourcemap)
469
- flags.push(`--sourcemap${sourcemap === true ? "" : `=${sourcemap}`}`);
470
- if (bundle)
471
- flags.push("--bundle");
472
- if (allowOverwrite)
473
- flags.push("--allow-overwrite");
474
- if (splitting)
475
- flags.push("--splitting");
476
- if (preserveSymlinks)
477
- flags.push("--preserve-symlinks");
478
- if (metafile)
479
- flags.push(`--metafile`);
480
- if (outfile)
481
- flags.push(`--outfile=${outfile}`);
482
- if (outdir)
483
- flags.push(`--outdir=${outdir}`);
484
- if (outbase)
485
- flags.push(`--outbase=${outbase}`);
486
- if (tsconfig)
487
- flags.push(`--tsconfig=${tsconfig}`);
488
- if (packages)
489
- flags.push(`--packages=${packages}`);
427
+ if (sourcemap) flags.push(`--sourcemap${sourcemap === true ? "" : `=${sourcemap}`}`);
428
+ if (bundle) flags.push("--bundle");
429
+ if (allowOverwrite) flags.push("--allow-overwrite");
430
+ if (splitting) flags.push("--splitting");
431
+ if (preserveSymlinks) flags.push("--preserve-symlinks");
432
+ if (metafile) flags.push(`--metafile`);
433
+ if (outfile) flags.push(`--outfile=${outfile}`);
434
+ if (outdir) flags.push(`--outdir=${outdir}`);
435
+ if (outbase) flags.push(`--outbase=${outbase}`);
436
+ if (tsconfig) flags.push(`--tsconfig=${tsconfig}`);
437
+ if (packages) flags.push(`--packages=${packages}`);
490
438
  if (resolveExtensions) {
491
439
  let values = [];
492
440
  for (let value of resolveExtensions) {
493
441
  validateStringValue(value, "resolve extension");
494
- if (value.indexOf(",") >= 0)
495
- throw new Error(`Invalid resolve extension: ${value}`);
442
+ if (value.indexOf(",") >= 0) throw new Error(`Invalid resolve extension: ${value}`);
496
443
  values.push(value);
497
444
  }
498
445
  flags.push(`--resolve-extensions=${values.join(",")}`);
499
446
  }
500
- if (publicPath)
501
- flags.push(`--public-path=${publicPath}`);
502
- if (entryNames)
503
- flags.push(`--entry-names=${entryNames}`);
504
- if (chunkNames)
505
- flags.push(`--chunk-names=${chunkNames}`);
506
- if (assetNames)
507
- flags.push(`--asset-names=${assetNames}`);
447
+ if (publicPath) flags.push(`--public-path=${publicPath}`);
448
+ if (entryNames) flags.push(`--entry-names=${entryNames}`);
449
+ if (chunkNames) flags.push(`--chunk-names=${chunkNames}`);
450
+ if (assetNames) flags.push(`--asset-names=${assetNames}`);
508
451
  if (mainFields) {
509
452
  let values = [];
510
453
  for (let value of mainFields) {
511
454
  validateStringValue(value, "main field");
512
- if (value.indexOf(",") >= 0)
513
- throw new Error(`Invalid main field: ${value}`);
455
+ if (value.indexOf(",") >= 0) throw new Error(`Invalid main field: ${value}`);
514
456
  values.push(value);
515
457
  }
516
458
  flags.push(`--main-fields=${values.join(",")}`);
@@ -519,50 +461,40 @@ function flagsForBuildOptions(callName, options, isTTY2, logLevelDefault, writeD
519
461
  let values = [];
520
462
  for (let value of conditions) {
521
463
  validateStringValue(value, "condition");
522
- if (value.indexOf(",") >= 0)
523
- throw new Error(`Invalid condition: ${value}`);
464
+ if (value.indexOf(",") >= 0) throw new Error(`Invalid condition: ${value}`);
524
465
  values.push(value);
525
466
  }
526
467
  flags.push(`--conditions=${values.join(",")}`);
527
468
  }
528
- if (external)
529
- for (let name of external)
530
- flags.push(`--external:${validateStringValue(name, "external")}`);
469
+ if (external) for (let name of external) flags.push(`--external:${validateStringValue(name, "external")}`);
531
470
  if (alias) {
532
471
  for (let old in alias) {
533
- if (old.indexOf("=") >= 0)
534
- throw new Error(`Invalid package name in alias: ${old}`);
472
+ if (old.indexOf("=") >= 0) throw new Error(`Invalid package name in alias: ${old}`);
535
473
  flags.push(`--alias:${old}=${validateStringValue(alias[old], "alias", old)}`);
536
474
  }
537
475
  }
538
476
  if (banner) {
539
477
  for (let type in banner) {
540
- if (type.indexOf("=") >= 0)
541
- throw new Error(`Invalid banner file type: ${type}`);
478
+ if (type.indexOf("=") >= 0) throw new Error(`Invalid banner file type: ${type}`);
542
479
  flags.push(`--banner:${type}=${validateStringValue(banner[type], "banner", type)}`);
543
480
  }
544
481
  }
545
482
  if (footer) {
546
483
  for (let type in footer) {
547
- if (type.indexOf("=") >= 0)
548
- throw new Error(`Invalid footer file type: ${type}`);
484
+ if (type.indexOf("=") >= 0) throw new Error(`Invalid footer file type: ${type}`);
549
485
  flags.push(`--footer:${type}=${validateStringValue(footer[type], "footer", type)}`);
550
486
  }
551
487
  }
552
- if (inject)
553
- for (let path3 of inject)
554
- flags.push(`--inject:${validateStringValue(path3, "inject")}`);
488
+ if (inject) for (let path3 of inject) flags.push(`--inject:${validateStringValue(path3, "inject")}`);
555
489
  if (loader) {
556
490
  for (let ext in loader) {
557
- if (ext.indexOf("=") >= 0)
558
- throw new Error(`Invalid loader extension: ${ext}`);
491
+ if (ext.indexOf("=") >= 0) throw new Error(`Invalid loader extension: ${ext}`);
559
492
  flags.push(`--loader:${ext}=${validateStringValue(loader[ext], "loader", ext)}`);
560
493
  }
561
494
  }
562
495
  if (outExtension) {
563
496
  for (let ext in outExtension) {
564
- if (ext.indexOf("=") >= 0)
565
- throw new Error(`Invalid out extension: ${ext}`);
497
+ if (ext.indexOf("=") >= 0) throw new Error(`Invalid out extension: ${ext}`);
566
498
  flags.push(`--out-extension:${ext}=${validateStringValue(outExtension[ext], "out extension", ext)}`);
567
499
  }
568
500
  }
@@ -575,10 +507,8 @@ function flagsForBuildOptions(callName, options, isTTY2, logLevelDefault, writeD
575
507
  let input = getFlag(entryPoint, entryPointKeys, "in", mustBeString);
576
508
  let output = getFlag(entryPoint, entryPointKeys, "out", mustBeString);
577
509
  checkForInvalidFlags(entryPoint, entryPointKeys, "in entry point at index " + i);
578
- if (input === void 0)
579
- throw new Error('Missing property "in" for entry point at index ' + i);
580
- if (output === void 0)
581
- throw new Error('Missing property "out" for entry point at index ' + i);
510
+ if (input === void 0) throw new Error('Missing property "in" for entry point at index ' + i);
511
+ if (output === void 0) throw new Error('Missing property "out" for entry point at index ' + i);
582
512
  entries.push([output, input]);
583
513
  } else {
584
514
  entries.push(["", validateStringValue(entryPoint, "entry point at index " + i)]);
@@ -597,16 +527,11 @@ function flagsForBuildOptions(callName, options, isTTY2, logLevelDefault, writeD
597
527
  let sourcefile = getFlag(stdin, stdinKeys, "sourcefile", mustBeString);
598
528
  let loader2 = getFlag(stdin, stdinKeys, "loader", mustBeString);
599
529
  checkForInvalidFlags(stdin, stdinKeys, 'in "stdin" object');
600
- if (sourcefile)
601
- flags.push(`--sourcefile=${sourcefile}`);
602
- if (loader2)
603
- flags.push(`--loader=${loader2}`);
604
- if (resolveDir)
605
- stdinResolveDir = resolveDir;
606
- if (typeof contents === "string")
607
- stdinContents = encodeUTF8(contents);
608
- else if (contents instanceof Uint8Array)
609
- stdinContents = contents;
530
+ if (sourcefile) flags.push(`--sourcefile=${sourcefile}`);
531
+ if (loader2) flags.push(`--loader=${loader2}`);
532
+ if (resolveDir) stdinResolveDir = resolveDir;
533
+ if (typeof contents === "string") stdinContents = encodeUTF8(contents);
534
+ else if (contents instanceof Uint8Array) stdinContents = contents;
610
535
  }
611
536
  let nodePaths = [];
612
537
  if (nodePathsInput) {
@@ -638,16 +563,11 @@ function flagsForTransformOptions(callName, options, isTTY2, logLevelDefault) {
638
563
  let footer = getFlag(options, keys, "footer", mustBeString);
639
564
  let mangleCache = getFlag(options, keys, "mangleCache", mustBeObject);
640
565
  checkForInvalidFlags(options, keys, `in ${callName}() call`);
641
- if (sourcemap)
642
- flags.push(`--sourcemap=${sourcemap === true ? "external" : sourcemap}`);
643
- if (sourcefile)
644
- flags.push(`--sourcefile=${sourcefile}`);
645
- if (loader)
646
- flags.push(`--loader=${loader}`);
647
- if (banner)
648
- flags.push(`--banner=${banner}`);
649
- if (footer)
650
- flags.push(`--footer=${footer}`);
566
+ if (sourcemap) flags.push(`--sourcemap=${sourcemap === true ? "external" : sourcemap}`);
567
+ if (sourcefile) flags.push(`--sourcefile=${sourcefile}`);
568
+ if (loader) flags.push(`--loader=${loader}`);
569
+ if (banner) flags.push(`--banner=${banner}`);
570
+ if (footer) flags.push(`--footer=${footer}`);
651
571
  return {
652
572
  flags,
653
573
  mangleCache: validateMangleCache(mangleCache)
@@ -687,8 +607,7 @@ function createChannel(streamIn) {
687
607
  };
688
608
  let afterClose = (error) => {
689
609
  closeData.didClose = true;
690
- if (error)
691
- closeData.reason = ": " + (error.message || error);
610
+ if (error) closeData.reason = ": " + (error.message || error);
692
611
  const text = "The service was stopped" + closeData.reason;
693
612
  for (let id in responseCallbacks) {
694
613
  responseCallbacks[id](text, null);
@@ -696,24 +615,20 @@ function createChannel(streamIn) {
696
615
  responseCallbacks = {};
697
616
  };
698
617
  let sendRequest = (refs, value, callback) => {
699
- if (closeData.didClose)
700
- return callback("The service is no longer running" + closeData.reason, null);
618
+ if (closeData.didClose) return callback("The service is no longer running" + closeData.reason, null);
701
619
  let id = nextRequestID++;
702
620
  responseCallbacks[id] = (error, response) => {
703
621
  try {
704
622
  callback(error, response);
705
623
  } finally {
706
- if (refs)
707
- refs.unref();
624
+ if (refs) refs.unref();
708
625
  }
709
626
  };
710
- if (refs)
711
- refs.ref();
627
+ if (refs) refs.ref();
712
628
  streamIn.writeToStdin(encodePacket({ id, isRequest: true, value }));
713
629
  };
714
630
  let sendResponse = (id, value) => {
715
- if (closeData.didClose)
716
- throw new Error("The service is no longer running" + closeData.reason);
631
+ if (closeData.didClose) throw new Error("The service is no longer running" + closeData.reason);
717
632
  streamIn.writeToStdin(encodePacket({ id, isRequest: false, value }));
718
633
  };
719
634
  let handleRequest = async (id, request) => {
@@ -747,8 +662,8 @@ function createChannel(streamIn) {
747
662
  if (isFirstPacket) {
748
663
  isFirstPacket = false;
749
664
  let binaryVersion = String.fromCharCode(...bytes);
750
- if (binaryVersion !== "0.20.0") {
751
- throw new Error(`Cannot start service: Host version "${"0.20.0"}" does not match binary version ${quote(binaryVersion)}`);
665
+ if (binaryVersion !== "0.24.0") {
666
+ throw new Error(`Cannot start service: Host version "${"0.24.0"}" does not match binary version ${quote(binaryVersion)}`);
752
667
  }
753
668
  return;
754
669
  }
@@ -758,10 +673,8 @@ function createChannel(streamIn) {
758
673
  } else {
759
674
  let callback = responseCallbacks[packet.id];
760
675
  delete responseCallbacks[packet.id];
761
- if (packet.value.error)
762
- callback(packet.value.error, {});
763
- else
764
- callback(null, packet.value);
676
+ if (packet.value.error) callback(packet.value.error, {});
677
+ else callback(null, packet.value);
765
678
  }
766
679
  };
767
680
  let buildOrContext = ({ callName, refs, options, isTTY: isTTY2, defaultWD: defaultWD2, callback }) => {
@@ -771,15 +684,13 @@ function createChannel(streamIn) {
771
684
  const buildRefs = {
772
685
  ref() {
773
686
  if (++refCount === 1) {
774
- if (refs)
775
- refs.ref();
687
+ if (refs) refs.ref();
776
688
  }
777
689
  },
778
690
  unref() {
779
691
  if (--refCount === 0) {
780
692
  delete requestCallbacksByKey[buildKey];
781
- if (refs)
782
- refs.unref();
693
+ if (refs) refs.unref();
783
694
  }
784
695
  }
785
696
  };
@@ -821,11 +732,9 @@ function createChannel(streamIn) {
821
732
  inputFS: inputPath !== null,
822
733
  input: inputPath !== null ? encodeUTF8(inputPath) : typeof input === "string" ? encodeUTF8(input) : input
823
734
  };
824
- if (mangleCache)
825
- request.mangleCache = mangleCache;
735
+ if (mangleCache) request.mangleCache = mangleCache;
826
736
  sendRequest(refs, request, (error, response) => {
827
- if (error)
828
- return callback(new Error(error), null);
737
+ if (error) return callback(new Error(error), null);
829
738
  let errors = replaceDetailsInMessages(response.errors, details);
830
739
  let warnings = replaceDetailsInMessages(response.warnings, details);
831
740
  let outstanding = 1;
@@ -838,15 +747,12 @@ function createChannel(streamIn) {
838
747
  mangleCache: void 0,
839
748
  legalComments: void 0
840
749
  };
841
- if ("legalComments" in response)
842
- result.legalComments = response == null ? void 0 : response.legalComments;
843
- if (response.mangleCache)
844
- result.mangleCache = response == null ? void 0 : response.mangleCache;
750
+ if ("legalComments" in response) result.legalComments = response == null ? void 0 : response.legalComments;
751
+ if (response.mangleCache) result.mangleCache = response == null ? void 0 : response.mangleCache;
845
752
  callback(null, result);
846
753
  }
847
754
  };
848
- if (errors.length > 0)
849
- return callback(failureErrorWithLog("Transform failed", errors, warnings), null);
755
+ if (errors.length > 0) return callback(failureErrorWithLog("Transform failed", errors, warnings), null);
850
756
  if (response.codeFS) {
851
757
  outstanding++;
852
758
  fs3.readFile(response.code, (err, contents) => {
@@ -891,35 +797,28 @@ function createChannel(streamIn) {
891
797
  start(null);
892
798
  };
893
799
  let formatMessages2 = ({ callName, refs, messages, options, callback }) => {
894
- if (!options)
895
- throw new Error(`Missing second argument in ${callName}() call`);
800
+ if (!options) throw new Error(`Missing second argument in ${callName}() call`);
896
801
  let keys = {};
897
802
  let kind = getFlag(options, keys, "kind", mustBeString);
898
803
  let color = getFlag(options, keys, "color", mustBeBoolean);
899
804
  let terminalWidth = getFlag(options, keys, "terminalWidth", mustBeInteger);
900
805
  checkForInvalidFlags(options, keys, `in ${callName}() call`);
901
- if (kind === void 0)
902
- throw new Error(`Missing "kind" in ${callName}() call`);
903
- if (kind !== "error" && kind !== "warning")
904
- throw new Error(`Expected "kind" to be "error" or "warning" in ${callName}() call`);
806
+ if (kind === void 0) throw new Error(`Missing "kind" in ${callName}() call`);
807
+ if (kind !== "error" && kind !== "warning") throw new Error(`Expected "kind" to be "error" or "warning" in ${callName}() call`);
905
808
  let request = {
906
809
  command: "format-msgs",
907
810
  messages: sanitizeMessages(messages, "messages", null, "", terminalWidth),
908
811
  isWarning: kind === "warning"
909
812
  };
910
- if (color !== void 0)
911
- request.color = color;
912
- if (terminalWidth !== void 0)
913
- request.terminalWidth = terminalWidth;
813
+ if (color !== void 0) request.color = color;
814
+ if (terminalWidth !== void 0) request.terminalWidth = terminalWidth;
914
815
  sendRequest(refs, request, (error, response) => {
915
- if (error)
916
- return callback(new Error(error), null);
816
+ if (error) return callback(new Error(error), null);
917
817
  callback(null, response.messages);
918
818
  });
919
819
  };
920
820
  let analyzeMetafile2 = ({ callName, refs, metafile, options, callback }) => {
921
- if (options === void 0)
922
- options = {};
821
+ if (options === void 0) options = {};
923
822
  let keys = {};
924
823
  let color = getFlag(options, keys, "color", mustBeBoolean);
925
824
  let verbose = getFlag(options, keys, "verbose", mustBeBoolean);
@@ -928,13 +827,10 @@ function createChannel(streamIn) {
928
827
  command: "analyze-metafile",
929
828
  metafile
930
829
  };
931
- if (color !== void 0)
932
- request.color = color;
933
- if (verbose !== void 0)
934
- request.verbose = verbose;
830
+ if (color !== void 0) request.color = color;
831
+ if (verbose !== void 0) request.verbose = verbose;
935
832
  sendRequest(refs, request, (error, response) => {
936
- if (error)
937
- return callback(new Error(error), null);
833
+ if (error) return callback(new Error(error), null);
938
834
  callback(null, response.result);
939
835
  });
940
836
  };
@@ -968,14 +864,12 @@ function buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs,
968
864
  if (typeof options === "object") {
969
865
  const value = options.plugins;
970
866
  if (value !== void 0) {
971
- if (!Array.isArray(value))
972
- return handleError(new Error(`"plugins" must be an array`), "");
867
+ if (!Array.isArray(value)) return handleError(new Error(`"plugins" must be an array`), "");
973
868
  plugins = value;
974
869
  }
975
870
  }
976
871
  if (plugins && plugins.length > 0) {
977
- if (streamIn.isSync)
978
- return handleError(new Error("Cannot use plugins in synchronous API calls"), "");
872
+ if (streamIn.isSync) return handleError(new Error("Cannot use plugins in synchronous API calls"), "");
979
873
  handlePlugins(
980
874
  buildKey,
981
875
  sendRequest,
@@ -988,8 +882,7 @@ function buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs,
988
882
  details
989
883
  ).then(
990
884
  (result) => {
991
- if (!result.ok)
992
- return handleError(result.error, result.pluginName);
885
+ if (!result.ok) return handleError(result.error, result.pluginName);
993
886
  try {
994
887
  buildOrContextContinue(result.requestPlugins, result.runOnEndCallbacks, result.scheduleOnDisposeCallbacks);
995
888
  } catch (e) {
@@ -1018,8 +911,7 @@ function buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs,
1018
911
  nodePaths,
1019
912
  mangleCache
1020
913
  } = flagsForBuildOptions(callName, options, isTTY2, buildLogLevelDefault, writeDefault);
1021
- if (write && !streamIn.hasFS)
1022
- throw new Error(`The "write" option is unavailable in this environment`);
914
+ if (write && !streamIn.hasFS) throw new Error(`The "write" option is unavailable in this environment`);
1023
915
  const request = {
1024
916
  command: "build",
1025
917
  key: buildKey,
@@ -1032,10 +924,8 @@ function buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs,
1032
924
  nodePaths,
1033
925
  context: isContext
1034
926
  };
1035
- if (requestPlugins)
1036
- request.plugins = requestPlugins;
1037
- if (mangleCache)
1038
- request.mangleCache = mangleCache;
927
+ if (requestPlugins) request.plugins = requestPlugins;
928
+ if (mangleCache) request.mangleCache = mangleCache;
1039
929
  const buildResponseToResult = (response, callback2) => {
1040
930
  const result = {
1041
931
  errors: replaceDetailsInMessages(response.errors, details),
@@ -1046,14 +936,10 @@ function buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs,
1046
936
  };
1047
937
  const originalErrors = result.errors.slice();
1048
938
  const originalWarnings = result.warnings.slice();
1049
- if (response.outputFiles)
1050
- result.outputFiles = response.outputFiles.map(convertOutputFiles);
1051
- if (response.metafile)
1052
- result.metafile = JSON.parse(response.metafile);
1053
- if (response.mangleCache)
1054
- result.mangleCache = response.mangleCache;
1055
- if (response.writeToStdout !== void 0)
1056
- console.log(decodeUTF8(response.writeToStdout).replace(/\n$/, ""));
939
+ if (response.outputFiles) result.outputFiles = response.outputFiles.map(convertOutputFiles);
940
+ if (response.metafile) result.metafile = JSON.parse(response.metafile);
941
+ if (response.mangleCache) result.mangleCache = response.mangleCache;
942
+ if (response.writeToStdout !== void 0) console.log(decodeUTF8(response.writeToStdout).replace(/\n$/, ""));
1057
943
  runOnEndCallbacks(result, (onEndErrors, onEndWarnings) => {
1058
944
  if (originalErrors.length > 0 || onEndErrors.length > 0) {
1059
945
  const error = failureErrorWithLog("Build failed", originalErrors.concat(onEndErrors), originalWarnings.concat(onEndWarnings));
@@ -1071,8 +957,7 @@ function buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs,
1071
957
  errors: onEndErrors,
1072
958
  warnings: onEndWarnings
1073
959
  };
1074
- if (provideLatestResult)
1075
- provideLatestResult(err, result);
960
+ if (provideLatestResult) provideLatestResult(err, result);
1076
961
  latestResultPromise = void 0;
1077
962
  provideLatestResult = void 0;
1078
963
  sendResponse(id, response);
@@ -1080,8 +965,7 @@ function buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs,
1080
965
  });
1081
966
  });
1082
967
  sendRequest(refs, request, (error, response) => {
1083
- if (error)
1084
- return callback(new Error(error), null);
968
+ if (error) return callback(new Error(error), null);
1085
969
  if (!isContext) {
1086
970
  return buildResponseToResult(response, (err, res) => {
1087
971
  scheduleOnDisposeCallbacks();
@@ -1094,35 +978,32 @@ function buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs,
1094
978
  let didDispose = false;
1095
979
  const result = {
1096
980
  rebuild: () => {
1097
- if (!latestResultPromise)
1098
- latestResultPromise = new Promise((resolve, reject) => {
1099
- let settlePromise;
1100
- provideLatestResult = (err, result2) => {
1101
- if (!settlePromise)
1102
- settlePromise = () => err ? reject(err) : resolve(result2);
981
+ if (!latestResultPromise) latestResultPromise = new Promise((resolve, reject) => {
982
+ let settlePromise;
983
+ provideLatestResult = (err, result2) => {
984
+ if (!settlePromise) settlePromise = () => err ? reject(err) : resolve(result2);
985
+ };
986
+ const triggerAnotherBuild = () => {
987
+ const request2 = {
988
+ command: "rebuild",
989
+ key: buildKey
1103
990
  };
1104
- const triggerAnotherBuild = () => {
1105
- const request2 = {
1106
- command: "rebuild",
1107
- key: buildKey
1108
- };
1109
- sendRequest(refs, request2, (error2, response2) => {
1110
- if (error2) {
1111
- reject(new Error(error2));
1112
- } else if (settlePromise) {
1113
- settlePromise();
1114
- } else {
1115
- triggerAnotherBuild();
1116
- }
1117
- });
1118
- };
1119
- triggerAnotherBuild();
1120
- });
991
+ sendRequest(refs, request2, (error2, response2) => {
992
+ if (error2) {
993
+ reject(new Error(error2));
994
+ } else if (settlePromise) {
995
+ settlePromise();
996
+ } else {
997
+ triggerAnotherBuild();
998
+ }
999
+ });
1000
+ };
1001
+ triggerAnotherBuild();
1002
+ });
1121
1003
  return latestResultPromise;
1122
1004
  },
1123
1005
  watch: (options2 = {}) => new Promise((resolve, reject) => {
1124
- if (!streamIn.hasFS)
1125
- throw new Error(`Cannot use the "watch" API in this environment`);
1006
+ if (!streamIn.hasFS) throw new Error(`Cannot use the "watch" API in this environment`);
1126
1007
  const keys = {};
1127
1008
  checkForInvalidFlags(options2, keys, `in watch() call`);
1128
1009
  const request2 = {
@@ -1130,15 +1011,12 @@ function buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs,
1130
1011
  key: buildKey
1131
1012
  };
1132
1013
  sendRequest(refs, request2, (error2) => {
1133
- if (error2)
1134
- reject(new Error(error2));
1135
- else
1136
- resolve(void 0);
1014
+ if (error2) reject(new Error(error2));
1015
+ else resolve(void 0);
1137
1016
  });
1138
1017
  }),
1139
1018
  serve: (options2 = {}) => new Promise((resolve, reject) => {
1140
- if (!streamIn.hasFS)
1141
- throw new Error(`Cannot use the "serve" API in this environment`);
1019
+ if (!streamIn.hasFS) throw new Error(`Cannot use the "serve" API in this environment`);
1142
1020
  const keys = {};
1143
1021
  const port = getFlag(options2, keys, "port", mustBeInteger);
1144
1022
  const host = getFlag(options2, keys, "host", mustBeString);
@@ -1153,21 +1031,14 @@ function buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs,
1153
1031
  key: buildKey,
1154
1032
  onRequest: !!onRequest
1155
1033
  };
1156
- if (port !== void 0)
1157
- request2.port = port;
1158
- if (host !== void 0)
1159
- request2.host = host;
1160
- if (servedir !== void 0)
1161
- request2.servedir = servedir;
1162
- if (keyfile !== void 0)
1163
- request2.keyfile = keyfile;
1164
- if (certfile !== void 0)
1165
- request2.certfile = certfile;
1166
- if (fallback !== void 0)
1167
- request2.fallback = fallback;
1034
+ if (port !== void 0) request2.port = port;
1035
+ if (host !== void 0) request2.host = host;
1036
+ if (servedir !== void 0) request2.servedir = servedir;
1037
+ if (keyfile !== void 0) request2.keyfile = keyfile;
1038
+ if (certfile !== void 0) request2.certfile = certfile;
1039
+ if (fallback !== void 0) request2.fallback = fallback;
1168
1040
  sendRequest(refs, request2, (error2, response2) => {
1169
- if (error2)
1170
- return reject(new Error(error2));
1041
+ if (error2) return reject(new Error(error2));
1171
1042
  if (onRequest) {
1172
1043
  requestCallbacks["serve-request"] = (id, request3) => {
1173
1044
  onRequest(request3.args);
@@ -1178,8 +1049,7 @@ function buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs,
1178
1049
  });
1179
1050
  }),
1180
1051
  cancel: () => new Promise((resolve) => {
1181
- if (didDispose)
1182
- return resolve();
1052
+ if (didDispose) return resolve();
1183
1053
  const request2 = {
1184
1054
  command: "cancel",
1185
1055
  key: buildKey
@@ -1189,8 +1059,7 @@ function buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs,
1189
1059
  });
1190
1060
  }),
1191
1061
  dispose: () => new Promise((resolve) => {
1192
- if (didDispose)
1193
- return resolve();
1062
+ if (didDispose) return resolve();
1194
1063
  didDispose = true;
1195
1064
  const request2 = {
1196
1065
  command: "dispose",
@@ -1221,15 +1090,12 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
1221
1090
  plugins = [...plugins];
1222
1091
  for (let item of plugins) {
1223
1092
  let keys = {};
1224
- if (typeof item !== "object")
1225
- throw new Error(`Plugin at index ${i} must be an object`);
1093
+ if (typeof item !== "object") throw new Error(`Plugin at index ${i} must be an object`);
1226
1094
  const name = getFlag(item, keys, "name", mustBeString);
1227
- if (typeof name !== "string" || name === "")
1228
- throw new Error(`Plugin at index ${i} is missing a name`);
1095
+ if (typeof name !== "string" || name === "") throw new Error(`Plugin at index ${i} is missing a name`);
1229
1096
  try {
1230
1097
  let setup = getFlag(item, keys, "setup", mustBeFunction);
1231
- if (typeof setup !== "function")
1232
- throw new Error(`Plugin is missing a setup function`);
1098
+ if (typeof setup !== "function") throw new Error(`Plugin is missing a setup function`);
1233
1099
  checkForInvalidFlags(item, keys, `on plugin ${quote(name)}`);
1234
1100
  let plugin = {
1235
1101
  name,
@@ -1240,10 +1106,8 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
1240
1106
  };
1241
1107
  i++;
1242
1108
  let resolve = (path3, options = {}) => {
1243
- if (!isSetupDone)
1244
- throw new Error('Cannot call "resolve" before plugin setup has completed');
1245
- if (typeof path3 !== "string")
1246
- throw new Error(`The path to resolve must be a string`);
1109
+ if (!isSetupDone) throw new Error('Cannot call "resolve" before plugin setup has completed');
1110
+ if (typeof path3 !== "string") throw new Error(`The path to resolve must be a string`);
1247
1111
  let keys2 = /* @__PURE__ */ Object.create(null);
1248
1112
  let pluginName = getFlag(options, keys2, "pluginName", mustBeString);
1249
1113
  let importer = getFlag(options, keys2, "importer", mustBeString);
@@ -1251,6 +1115,7 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
1251
1115
  let resolveDir = getFlag(options, keys2, "resolveDir", mustBeString);
1252
1116
  let kind = getFlag(options, keys2, "kind", mustBeString);
1253
1117
  let pluginData = getFlag(options, keys2, "pluginData", canBeAnything);
1118
+ let importAttributes = getFlag(options, keys2, "with", mustBeObject);
1254
1119
  checkForInvalidFlags(options, keys2, "in resolve() call");
1255
1120
  return new Promise((resolve2, reject) => {
1256
1121
  const request = {
@@ -1259,34 +1124,26 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
1259
1124
  key: buildKey,
1260
1125
  pluginName: name
1261
1126
  };
1262
- if (pluginName != null)
1263
- request.pluginName = pluginName;
1264
- if (importer != null)
1265
- request.importer = importer;
1266
- if (namespace != null)
1267
- request.namespace = namespace;
1268
- if (resolveDir != null)
1269
- request.resolveDir = resolveDir;
1270
- if (kind != null)
1271
- request.kind = kind;
1272
- else
1273
- throw new Error(`Must specify "kind" when calling "resolve"`);
1274
- if (pluginData != null)
1275
- request.pluginData = details.store(pluginData);
1127
+ if (pluginName != null) request.pluginName = pluginName;
1128
+ if (importer != null) request.importer = importer;
1129
+ if (namespace != null) request.namespace = namespace;
1130
+ if (resolveDir != null) request.resolveDir = resolveDir;
1131
+ if (kind != null) request.kind = kind;
1132
+ else throw new Error(`Must specify "kind" when calling "resolve"`);
1133
+ if (pluginData != null) request.pluginData = details.store(pluginData);
1134
+ if (importAttributes != null) request.with = sanitizeStringMap(importAttributes, "with");
1276
1135
  sendRequest(refs, request, (error, response) => {
1277
- if (error !== null)
1278
- reject(new Error(error));
1279
- else
1280
- resolve2({
1281
- errors: replaceDetailsInMessages(response.errors, details),
1282
- warnings: replaceDetailsInMessages(response.warnings, details),
1283
- path: response.path,
1284
- external: response.external,
1285
- sideEffects: response.sideEffects,
1286
- namespace: response.namespace,
1287
- suffix: response.suffix,
1288
- pluginData: details.load(response.pluginData)
1289
- });
1136
+ if (error !== null) reject(new Error(error));
1137
+ else resolve2({
1138
+ errors: replaceDetailsInMessages(response.errors, details),
1139
+ warnings: replaceDetailsInMessages(response.warnings, details),
1140
+ path: response.path,
1141
+ external: response.external,
1142
+ sideEffects: response.sideEffects,
1143
+ namespace: response.namespace,
1144
+ suffix: response.suffix,
1145
+ pluginData: details.load(response.pluginData)
1146
+ });
1290
1147
  });
1291
1148
  });
1292
1149
  };
@@ -1312,8 +1169,7 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
1312
1169
  let filter = getFlag(options, keys2, "filter", mustBeRegExp);
1313
1170
  let namespace = getFlag(options, keys2, "namespace", mustBeString);
1314
1171
  checkForInvalidFlags(options, keys2, `in onResolve() call for plugin ${quote(name)}`);
1315
- if (filter == null)
1316
- throw new Error(`onResolve() call is missing a filter`);
1172
+ if (filter == null) throw new Error(`onResolve() call is missing a filter`);
1317
1173
  let id = nextCallbackID++;
1318
1174
  onResolveCallbacks[id] = { name, callback, note: registeredNote };
1319
1175
  plugin.onResolve.push({ id, filter: filter.source, namespace: namespace || "" });
@@ -1325,8 +1181,7 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
1325
1181
  let filter = getFlag(options, keys2, "filter", mustBeRegExp);
1326
1182
  let namespace = getFlag(options, keys2, "namespace", mustBeString);
1327
1183
  checkForInvalidFlags(options, keys2, `in onLoad() call for plugin ${quote(name)}`);
1328
- if (filter == null)
1329
- throw new Error(`onLoad() call is missing a filter`);
1184
+ if (filter == null) throw new Error(`onLoad() call is missing a filter`);
1330
1185
  let id = nextCallbackID++;
1331
1186
  onLoadCallbacks[id] = { name, callback, note: registeredNote };
1332
1187
  plugin.onLoad.push({ id, filter: filter.source, namespace: namespace || "" });
@@ -1336,29 +1191,26 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
1336
1191
  },
1337
1192
  esbuild: streamIn.esbuild
1338
1193
  });
1339
- if (promise)
1340
- await promise;
1194
+ if (promise) await promise;
1341
1195
  requestPlugins.push(plugin);
1342
1196
  } catch (e) {
1343
1197
  return { ok: false, error: e, pluginName: name };
1344
1198
  }
1345
1199
  }
1346
1200
  requestCallbacks["on-start"] = async (id, request) => {
1201
+ details.clear();
1347
1202
  let response = { errors: [], warnings: [] };
1348
1203
  await Promise.all(onStartCallbacks.map(async ({ name, callback, note }) => {
1349
1204
  try {
1350
1205
  let result = await callback();
1351
1206
  if (result != null) {
1352
- if (typeof result !== "object")
1353
- throw new Error(`Expected onStart() callback in plugin ${quote(name)} to return an object`);
1207
+ if (typeof result !== "object") throw new Error(`Expected onStart() callback in plugin ${quote(name)} to return an object`);
1354
1208
  let keys = {};
1355
1209
  let errors = getFlag(result, keys, "errors", mustBeArray);
1356
1210
  let warnings = getFlag(result, keys, "warnings", mustBeArray);
1357
1211
  checkForInvalidFlags(result, keys, `from onStart() callback in plugin ${quote(name)}`);
1358
- if (errors != null)
1359
- response.errors.push(...sanitizeMessages(errors, "errors", details, name, void 0));
1360
- if (warnings != null)
1361
- response.warnings.push(...sanitizeMessages(warnings, "warnings", details, name, void 0));
1212
+ if (errors != null) response.errors.push(...sanitizeMessages(errors, "errors", details, name, void 0));
1213
+ if (warnings != null) response.warnings.push(...sanitizeMessages(warnings, "warnings", details, name, void 0));
1362
1214
  }
1363
1215
  } catch (e) {
1364
1216
  response.errors.push(extractErrorMessageV8(e, streamIn, details, note && note(), name));
@@ -1377,11 +1229,11 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
1377
1229
  namespace: request.namespace,
1378
1230
  resolveDir: request.resolveDir,
1379
1231
  kind: request.kind,
1380
- pluginData: details.load(request.pluginData)
1232
+ pluginData: details.load(request.pluginData),
1233
+ with: request.with
1381
1234
  });
1382
1235
  if (result != null) {
1383
- if (typeof result !== "object")
1384
- throw new Error(`Expected onResolve() callback in plugin ${quote(name)} to return an object`);
1236
+ if (typeof result !== "object") throw new Error(`Expected onResolve() callback in plugin ${quote(name)} to return an object`);
1385
1237
  let keys = {};
1386
1238
  let pluginName = getFlag(result, keys, "pluginName", mustBeString);
1387
1239
  let path3 = getFlag(result, keys, "path", mustBeString);
@@ -1396,28 +1248,17 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
1396
1248
  let watchDirs = getFlag(result, keys, "watchDirs", mustBeArray);
1397
1249
  checkForInvalidFlags(result, keys, `from onResolve() callback in plugin ${quote(name)}`);
1398
1250
  response.id = id2;
1399
- if (pluginName != null)
1400
- response.pluginName = pluginName;
1401
- if (path3 != null)
1402
- response.path = path3;
1403
- if (namespace != null)
1404
- response.namespace = namespace;
1405
- if (suffix != null)
1406
- response.suffix = suffix;
1407
- if (external != null)
1408
- response.external = external;
1409
- if (sideEffects != null)
1410
- response.sideEffects = sideEffects;
1411
- if (pluginData != null)
1412
- response.pluginData = details.store(pluginData);
1413
- if (errors != null)
1414
- response.errors = sanitizeMessages(errors, "errors", details, name, void 0);
1415
- if (warnings != null)
1416
- response.warnings = sanitizeMessages(warnings, "warnings", details, name, void 0);
1417
- if (watchFiles != null)
1418
- response.watchFiles = sanitizeStringArray(watchFiles, "watchFiles");
1419
- if (watchDirs != null)
1420
- response.watchDirs = sanitizeStringArray(watchDirs, "watchDirs");
1251
+ if (pluginName != null) response.pluginName = pluginName;
1252
+ if (path3 != null) response.path = path3;
1253
+ if (namespace != null) response.namespace = namespace;
1254
+ if (suffix != null) response.suffix = suffix;
1255
+ if (external != null) response.external = external;
1256
+ if (sideEffects != null) response.sideEffects = sideEffects;
1257
+ if (pluginData != null) response.pluginData = details.store(pluginData);
1258
+ if (errors != null) response.errors = sanitizeMessages(errors, "errors", details, name, void 0);
1259
+ if (warnings != null) response.warnings = sanitizeMessages(warnings, "warnings", details, name, void 0);
1260
+ if (watchFiles != null) response.watchFiles = sanitizeStringArray(watchFiles, "watchFiles");
1261
+ if (watchDirs != null) response.watchDirs = sanitizeStringArray(watchDirs, "watchDirs");
1421
1262
  break;
1422
1263
  }
1423
1264
  } catch (e) {
@@ -1440,8 +1281,7 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
1440
1281
  with: request.with
1441
1282
  });
1442
1283
  if (result != null) {
1443
- if (typeof result !== "object")
1444
- throw new Error(`Expected onLoad() callback in plugin ${quote(name)} to return an object`);
1284
+ if (typeof result !== "object") throw new Error(`Expected onLoad() callback in plugin ${quote(name)} to return an object`);
1445
1285
  let keys = {};
1446
1286
  let pluginName = getFlag(result, keys, "pluginName", mustBeString);
1447
1287
  let contents = getFlag(result, keys, "contents", mustBeStringOrUint8Array);
@@ -1454,26 +1294,16 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
1454
1294
  let watchDirs = getFlag(result, keys, "watchDirs", mustBeArray);
1455
1295
  checkForInvalidFlags(result, keys, `from onLoad() callback in plugin ${quote(name)}`);
1456
1296
  response.id = id2;
1457
- if (pluginName != null)
1458
- response.pluginName = pluginName;
1459
- if (contents instanceof Uint8Array)
1460
- response.contents = contents;
1461
- else if (contents != null)
1462
- response.contents = encodeUTF8(contents);
1463
- if (resolveDir != null)
1464
- response.resolveDir = resolveDir;
1465
- if (pluginData != null)
1466
- response.pluginData = details.store(pluginData);
1467
- if (loader != null)
1468
- response.loader = loader;
1469
- if (errors != null)
1470
- response.errors = sanitizeMessages(errors, "errors", details, name, void 0);
1471
- if (warnings != null)
1472
- response.warnings = sanitizeMessages(warnings, "warnings", details, name, void 0);
1473
- if (watchFiles != null)
1474
- response.watchFiles = sanitizeStringArray(watchFiles, "watchFiles");
1475
- if (watchDirs != null)
1476
- response.watchDirs = sanitizeStringArray(watchDirs, "watchDirs");
1297
+ if (pluginName != null) response.pluginName = pluginName;
1298
+ if (contents instanceof Uint8Array) response.contents = contents;
1299
+ else if (contents != null) response.contents = encodeUTF8(contents);
1300
+ if (resolveDir != null) response.resolveDir = resolveDir;
1301
+ if (pluginData != null) response.pluginData = details.store(pluginData);
1302
+ if (loader != null) response.loader = loader;
1303
+ if (errors != null) response.errors = sanitizeMessages(errors, "errors", details, name, void 0);
1304
+ if (warnings != null) response.warnings = sanitizeMessages(warnings, "warnings", details, name, void 0);
1305
+ if (watchFiles != null) response.watchFiles = sanitizeStringArray(watchFiles, "watchFiles");
1306
+ if (watchDirs != null) response.watchDirs = sanitizeStringArray(watchDirs, "watchDirs");
1477
1307
  break;
1478
1308
  }
1479
1309
  } catch (e) {
@@ -1495,16 +1325,13 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
1495
1325
  try {
1496
1326
  const value = await callback(result);
1497
1327
  if (value != null) {
1498
- if (typeof value !== "object")
1499
- throw new Error(`Expected onEnd() callback in plugin ${quote(name)} to return an object`);
1328
+ if (typeof value !== "object") throw new Error(`Expected onEnd() callback in plugin ${quote(name)} to return an object`);
1500
1329
  let keys = {};
1501
1330
  let errors = getFlag(value, keys, "errors", mustBeArray);
1502
1331
  let warnings = getFlag(value, keys, "warnings", mustBeArray);
1503
1332
  checkForInvalidFlags(value, keys, `from onEnd() callback in plugin ${quote(name)}`);
1504
- if (errors != null)
1505
- newErrors = sanitizeMessages(errors, "errors", details, name, void 0);
1506
- if (warnings != null)
1507
- newWarnings = sanitizeMessages(warnings, "warnings", details, name, void 0);
1333
+ if (errors != null) newErrors = sanitizeMessages(errors, "errors", details, name, void 0);
1334
+ if (warnings != null) newWarnings = sanitizeMessages(warnings, "warnings", details, name, void 0);
1508
1335
  }
1509
1336
  } catch (e) {
1510
1337
  newErrors = [extractErrorMessageV8(e, streamIn, details, note && note(), name)];
@@ -1545,12 +1372,14 @@ function createObjectStash() {
1545
1372
  const map = /* @__PURE__ */ new Map();
1546
1373
  let nextID = 0;
1547
1374
  return {
1375
+ clear() {
1376
+ map.clear();
1377
+ },
1548
1378
  load(id) {
1549
1379
  return map.get(id);
1550
1380
  },
1551
1381
  store(value) {
1552
- if (value === void 0)
1553
- return -1;
1382
+ if (value === void 0) return -1;
1554
1383
  const id = nextID++;
1555
1384
  map.set(id, value);
1556
1385
  return id;
@@ -1561,8 +1390,7 @@ function extractCallerV8(e, streamIn, ident) {
1561
1390
  let note;
1562
1391
  let tried = false;
1563
1392
  return () => {
1564
- if (tried)
1565
- return note;
1393
+ if (tried) return note;
1566
1394
  tried = true;
1567
1395
  try {
1568
1396
  let lines = (e.stack + "").split("\n");
@@ -1594,8 +1422,7 @@ function parseStackLinesV8(streamIn, lines, ident) {
1594
1422
  if (streamIn.readFileSync && !lines[0].startsWith(at) && lines[1].startsWith(at)) {
1595
1423
  for (let i = 1; i < lines.length; i++) {
1596
1424
  let line = lines[i];
1597
- if (!line.startsWith(at))
1598
- continue;
1425
+ if (!line.startsWith(at)) continue;
1599
1426
  line = line.slice(at.length);
1600
1427
  while (true) {
1601
1428
  let match = /^(?:new |async )?\S+ \((.*)\)$/.exec(line);
@@ -1638,10 +1465,8 @@ function parseStackLinesV8(streamIn, lines, ident) {
1638
1465
  function failureErrorWithLog(text, errors, warnings) {
1639
1466
  let limit = 5;
1640
1467
  text += errors.length < 1 ? "" : ` with ${errors.length} error${errors.length < 2 ? "" : "s"}:` + errors.slice(0, limit + 1).map((e, i) => {
1641
- if (i === limit)
1642
- return "\n...";
1643
- if (!e.location)
1644
- return `
1468
+ if (i === limit) return "\n...";
1469
+ if (!e.location) return `
1645
1470
  error: ${e.text}`;
1646
1471
  let { file, line, column } = e.location;
1647
1472
  let pluginText = e.pluginName ? `[plugin: ${e.pluginName}] ` : "";
@@ -1670,8 +1495,7 @@ function replaceDetailsInMessages(messages, stash) {
1670
1495
  return messages;
1671
1496
  }
1672
1497
  function sanitizeLocation(location, where, terminalWidth) {
1673
- if (location == null)
1674
- return null;
1498
+ if (location == null) return null;
1675
1499
  let keys = {};
1676
1500
  let file = getFlag(location, keys, "file", mustBeString);
1677
1501
  let namespace = getFlag(location, keys, "namespace", mustBeString);
@@ -1741,12 +1565,20 @@ function sanitizeMessages(messages, property, stash, fallbackPluginName, termina
1741
1565
  function sanitizeStringArray(values, property) {
1742
1566
  const result = [];
1743
1567
  for (const value of values) {
1744
- if (typeof value !== "string")
1745
- throw new Error(`${quote(property)} must be an array of strings`);
1568
+ if (typeof value !== "string") throw new Error(`${quote(property)} must be an array of strings`);
1746
1569
  result.push(value);
1747
1570
  }
1748
1571
  return result;
1749
1572
  }
1573
+ function sanitizeStringMap(map, property) {
1574
+ const result = /* @__PURE__ */ Object.create(null);
1575
+ for (const key in map) {
1576
+ const value = map[key];
1577
+ if (typeof value !== "string") throw new Error(`key ${quote(key)} in object ${quote(property)} must be a string`);
1578
+ result[key] = value;
1579
+ }
1580
+ return result;
1581
+ }
1750
1582
  function convertOutputFiles({ path: path3, contents, hash }) {
1751
1583
  let text = null;
1752
1584
  return {
@@ -1794,6 +1626,7 @@ var knownUnixlikePackages = {
1794
1626
  "linux x64 LE": "@esbuild/linux-x64",
1795
1627
  "linux loong64 LE": "@esbuild/linux-loong64",
1796
1628
  "netbsd x64 LE": "@esbuild/netbsd-x64",
1629
+ "openbsd arm64 LE": "@esbuild/openbsd-arm64",
1797
1630
  "openbsd x64 LE": "@esbuild/openbsd-x64",
1798
1631
  "sunos x64 LE": "@esbuild/sunos-x64"
1799
1632
  };
@@ -1828,16 +1661,14 @@ function pkgForSomeOtherPlatform() {
1828
1661
  for (const unixKey in knownUnixlikePackages) {
1829
1662
  try {
1830
1663
  const pkg = knownUnixlikePackages[unixKey];
1831
- if (fs.existsSync(path.join(nodeModulesDirectory, pkg)))
1832
- return pkg;
1664
+ if (fs.existsSync(path.join(nodeModulesDirectory, pkg))) return pkg;
1833
1665
  } catch {
1834
1666
  }
1835
1667
  }
1836
1668
  for (const windowsKey in knownWindowsPackages) {
1837
1669
  try {
1838
1670
  const pkg = knownWindowsPackages[windowsKey];
1839
- if (fs.existsSync(path.join(nodeModulesDirectory, pkg)))
1840
- return pkg;
1671
+ if (fs.existsSync(path.join(nodeModulesDirectory, pkg))) return pkg;
1841
1672
  } catch {
1842
1673
  }
1843
1674
  }
@@ -1941,7 +1772,7 @@ for your current platform.`);
1941
1772
  "node_modules",
1942
1773
  ".cache",
1943
1774
  "esbuild",
1944
- `pnpapi-${pkg.replace("/", "-")}-${"0.20.0"}-${path.basename(subpath)}`
1775
+ `pnpapi-${pkg.replace("/", "-")}-${"0.24.0"}-${path.basename(subpath)}`
1945
1776
  );
1946
1777
  if (!fs.existsSync(binTargetPath)) {
1947
1778
  fs.mkdirSync(path.dirname(binTargetPath), { recursive: true });
@@ -1976,7 +1807,7 @@ if (process.env.ESBUILD_WORKER_THREADS !== "0") {
1976
1807
  }
1977
1808
  }
1978
1809
  var _a;
1979
- var isInternalWorkerThread = ((_a = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a.esbuildVersion) === "0.20.0";
1810
+ var isInternalWorkerThread = ((_a = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a.esbuildVersion) === "0.24.0";
1980
1811
  var esbuildCommandAndArgs = () => {
1981
1812
  if ((!ESBUILD_BINARY_PATH || false) && (path2.basename(__filename) !== "main.js" || path2.basename(__dirname) !== "lib")) {
1982
1813
  throw new Error(
@@ -2043,7 +1874,7 @@ var fsAsync = {
2043
1874
  }
2044
1875
  }
2045
1876
  };
2046
- var version = "0.20.0";
1877
+ var version = "0.24.0";
2047
1878
  var build = (options) => ensureServiceIsRunning().build(options);
2048
1879
  var context = (buildOptions) => ensureServiceIsRunning().context(buildOptions);
2049
1880
  var transform = (input, options) => ensureServiceIsRunning().transform(input, options);
@@ -2051,8 +1882,7 @@ var formatMessages = (messages, options) => ensureServiceIsRunning().formatMessa
2051
1882
  var analyzeMetafile = (messages, options) => ensureServiceIsRunning().analyzeMetafile(messages, options);
2052
1883
  var buildSync = (options) => {
2053
1884
  if (worker_threads && !isInternalWorkerThread) {
2054
- if (!workerThreadService)
2055
- workerThreadService = startWorkerThreadService(worker_threads);
1885
+ if (!workerThreadService) workerThreadService = startWorkerThreadService(worker_threads);
2056
1886
  return workerThreadService.buildSync(options);
2057
1887
  }
2058
1888
  let result;
@@ -2063,8 +1893,7 @@ var buildSync = (options) => {
2063
1893
  isTTY: isTTY(),
2064
1894
  defaultWD,
2065
1895
  callback: (err, res) => {
2066
- if (err)
2067
- throw err;
1896
+ if (err) throw err;
2068
1897
  result = res;
2069
1898
  }
2070
1899
  }));
@@ -2072,8 +1901,7 @@ var buildSync = (options) => {
2072
1901
  };
2073
1902
  var transformSync = (input, options) => {
2074
1903
  if (worker_threads && !isInternalWorkerThread) {
2075
- if (!workerThreadService)
2076
- workerThreadService = startWorkerThreadService(worker_threads);
1904
+ if (!workerThreadService) workerThreadService = startWorkerThreadService(worker_threads);
2077
1905
  return workerThreadService.transformSync(input, options);
2078
1906
  }
2079
1907
  let result;
@@ -2085,8 +1913,7 @@ var transformSync = (input, options) => {
2085
1913
  isTTY: isTTY(),
2086
1914
  fs: fsSync,
2087
1915
  callback: (err, res) => {
2088
- if (err)
2089
- throw err;
1916
+ if (err) throw err;
2090
1917
  result = res;
2091
1918
  }
2092
1919
  }));
@@ -2094,8 +1921,7 @@ var transformSync = (input, options) => {
2094
1921
  };
2095
1922
  var formatMessagesSync = (messages, options) => {
2096
1923
  if (worker_threads && !isInternalWorkerThread) {
2097
- if (!workerThreadService)
2098
- workerThreadService = startWorkerThreadService(worker_threads);
1924
+ if (!workerThreadService) workerThreadService = startWorkerThreadService(worker_threads);
2099
1925
  return workerThreadService.formatMessagesSync(messages, options);
2100
1926
  }
2101
1927
  let result;
@@ -2105,8 +1931,7 @@ var formatMessagesSync = (messages, options) => {
2105
1931
  messages,
2106
1932
  options,
2107
1933
  callback: (err, res) => {
2108
- if (err)
2109
- throw err;
1934
+ if (err) throw err;
2110
1935
  result = res;
2111
1936
  }
2112
1937
  }));
@@ -2114,8 +1939,7 @@ var formatMessagesSync = (messages, options) => {
2114
1939
  };
2115
1940
  var analyzeMetafileSync = (metafile, options) => {
2116
1941
  if (worker_threads && !isInternalWorkerThread) {
2117
- if (!workerThreadService)
2118
- workerThreadService = startWorkerThreadService(worker_threads);
1942
+ if (!workerThreadService) workerThreadService = startWorkerThreadService(worker_threads);
2119
1943
  return workerThreadService.analyzeMetafileSync(metafile, options);
2120
1944
  }
2121
1945
  let result;
@@ -2125,31 +1949,24 @@ var analyzeMetafileSync = (metafile, options) => {
2125
1949
  metafile: typeof metafile === "string" ? metafile : JSON.stringify(metafile),
2126
1950
  options,
2127
1951
  callback: (err, res) => {
2128
- if (err)
2129
- throw err;
1952
+ if (err) throw err;
2130
1953
  result = res;
2131
1954
  }
2132
1955
  }));
2133
1956
  return result;
2134
1957
  };
2135
1958
  var stop = () => {
2136
- if (stopService)
2137
- stopService();
2138
- if (workerThreadService)
2139
- workerThreadService.stop();
1959
+ if (stopService) stopService();
1960
+ if (workerThreadService) workerThreadService.stop();
2140
1961
  return Promise.resolve();
2141
1962
  };
2142
1963
  var initializeWasCalled = false;
2143
1964
  var initialize = (options) => {
2144
1965
  options = validateInitializeOptions(options || {});
2145
- if (options.wasmURL)
2146
- throw new Error(`The "wasmURL" option only works in the browser`);
2147
- if (options.wasmModule)
2148
- throw new Error(`The "wasmModule" option only works in the browser`);
2149
- if (options.worker)
2150
- throw new Error(`The "worker" option only works in the browser`);
2151
- if (initializeWasCalled)
2152
- throw new Error('Cannot call "initialize" more than once');
1966
+ if (options.wasmURL) throw new Error(`The "wasmURL" option only works in the browser`);
1967
+ if (options.wasmModule) throw new Error(`The "wasmModule" option only works in the browser`);
1968
+ if (options.worker) throw new Error(`The "worker" option only works in the browser`);
1969
+ if (initializeWasCalled) throw new Error('Cannot call "initialize" more than once');
2153
1970
  ensureServiceIsRunning();
2154
1971
  initializeWasCalled = true;
2155
1972
  return Promise.resolve();
@@ -2158,10 +1975,9 @@ var defaultWD = process.cwd();
2158
1975
  var longLivedService;
2159
1976
  var stopService;
2160
1977
  var ensureServiceIsRunning = () => {
2161
- if (longLivedService)
2162
- return longLivedService;
1978
+ if (longLivedService) return longLivedService;
2163
1979
  let [command, args] = esbuildCommandAndArgs();
2164
- let child = child_process.spawn(command, args.concat(`--service=${"0.20.0"}`, "--ping"), {
1980
+ let child = child_process.spawn(command, args.concat(`--service=${"0.24.0"}`, "--ping"), {
2165
1981
  windowsHide: true,
2166
1982
  stdio: ["pipe", "pipe", "inherit"],
2167
1983
  cwd: defaultWD
@@ -2169,8 +1985,7 @@ var ensureServiceIsRunning = () => {
2169
1985
  let { readFromStdout, afterClose, service } = createChannel({
2170
1986
  writeToStdin(bytes) {
2171
1987
  child.stdin.write(bytes, (err) => {
2172
- if (err)
2173
- afterClose(err);
1988
+ if (err) afterClose(err);
2174
1989
  });
2175
1990
  },
2176
1991
  readFileSync: fs2.readFileSync,
@@ -2202,12 +2017,10 @@ var ensureServiceIsRunning = () => {
2202
2017
  }
2203
2018
  const refs = {
2204
2019
  ref() {
2205
- if (++refCount === 1)
2206
- child.ref();
2020
+ if (++refCount === 1) child.ref();
2207
2021
  },
2208
2022
  unref() {
2209
- if (--refCount === 0)
2210
- child.unref();
2023
+ if (--refCount === 0) child.unref();
2211
2024
  }
2212
2025
  };
2213
2026
  longLivedService = {
@@ -2260,8 +2073,7 @@ var runServiceSync = (callback) => {
2260
2073
  let stdin = new Uint8Array();
2261
2074
  let { readFromStdout, afterClose, service } = createChannel({
2262
2075
  writeToStdin(bytes) {
2263
- if (stdin.length !== 0)
2264
- throw new Error("Must run at most one command");
2076
+ if (stdin.length !== 0) throw new Error("Must run at most one command");
2265
2077
  stdin = bytes;
2266
2078
  },
2267
2079
  isSync: true,
@@ -2269,7 +2081,7 @@ var runServiceSync = (callback) => {
2269
2081
  esbuild: node_exports
2270
2082
  });
2271
2083
  callback(service);
2272
- let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.20.0"}`), {
2084
+ let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.24.0"}`), {
2273
2085
  cwd: defaultWD,
2274
2086
  windowsHide: true,
2275
2087
  input: stdin,
@@ -2289,7 +2101,7 @@ var workerThreadService = null;
2289
2101
  var startWorkerThreadService = (worker_threads2) => {
2290
2102
  let { port1: mainPort, port2: workerPort } = new worker_threads2.MessageChannel();
2291
2103
  let worker = new worker_threads2.Worker(__filename, {
2292
- workerData: { workerPort, defaultWD, esbuildVersion: "0.20.0" },
2104
+ workerData: { workerPort, defaultWD, esbuildVersion: "0.24.0" },
2293
2105
  transferList: [workerPort],
2294
2106
  // From node's documentation: https://nodejs.org/api/worker_threads.html
2295
2107
  //
@@ -2312,11 +2124,9 @@ error: ${text}`);
2312
2124
  return error;
2313
2125
  };
2314
2126
  let validateBuildSyncOptions = (options) => {
2315
- if (!options)
2316
- return;
2127
+ if (!options) return;
2317
2128
  let plugins = options.plugins;
2318
- if (plugins && plugins.length > 0)
2319
- throw fakeBuildError(`Cannot use plugins in synchronous API calls`);
2129
+ if (plugins && plugins.length > 0) throw fakeBuildError(`Cannot use plugins in synchronous API calls`);
2320
2130
  };
2321
2131
  let applyProperties = (object, properties) => {
2322
2132
  for (let key in properties) {
@@ -2330,11 +2140,9 @@ error: ${text}`);
2330
2140
  let msg = { sharedBuffer, id, command, args };
2331
2141
  worker.postMessage(msg);
2332
2142
  let status = Atomics.wait(sharedBufferView, 0, 0);
2333
- if (status !== "ok" && status !== "not-equal")
2334
- throw new Error("Internal error: Atomics.wait() failed: " + status);
2143
+ if (status !== "ok" && status !== "not-equal") throw new Error("Internal error: Atomics.wait() failed: " + status);
2335
2144
  let { message: { id: id2, resolve, reject, properties } } = worker_threads2.receiveMessageOnPort(mainPort);
2336
- if (id !== id2)
2337
- throw new Error(`Internal error: Expected id ${id} but got id ${id2}`);
2145
+ if (id !== id2) throw new Error(`Internal error: Expected id ${id} but got id ${id2}`);
2338
2146
  if (reject) {
2339
2147
  applyProperties(reject, properties);
2340
2148
  throw reject;