@valbuild/tanstack-build 0.145.1 → 0.148.0

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.
@@ -5,6 +5,7 @@ import { createRequire } from 'node:module';
5
5
  import { readFile, rm, writeFile, mkdir, readdir, stat } from 'node:fs/promises';
6
6
  import { join, resolve, extname, dirname, isAbsolute } from 'node:path';
7
7
  import { parseAstAsync } from 'rolldown/parseAst';
8
+ import { parse, ImportType, init } from 'es-module-lexer';
8
9
  import { pathToFileURL } from 'node:url';
9
10
  import { a as ENTRY_SHIM } from '../../dist/projectPaths-5e4defea.esm.js';
10
11
 
@@ -503,10 +504,10 @@ function owningPackage(_x, _x2) {
503
504
  * it is the package that caused the incident this exists for.
504
505
  */
505
506
  function _owningPackage() {
506
- _owningPackage = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(id, cache) {
507
- var visited, dir, found, cached, manifest, parent, _i3, _visited, each;
508
- return _regenerator().w(function (_context2) {
509
- while (1) switch (_context2.n) {
507
+ _owningPackage = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(id, cache) {
508
+ var visited, dir, found, cached, manifest, parent, _i4, _visited, each;
509
+ return _regenerator().w(function (_context4) {
510
+ while (1) switch (_context4.n) {
510
511
  case 0:
511
512
  visited = [];
512
513
  dir = dirname(id);
@@ -514,50 +515,50 @@ function _owningPackage() {
514
515
  case 1:
515
516
  cached = cache.get(dir);
516
517
  if (!(cached !== undefined)) {
517
- _context2.n = 2;
518
+ _context4.n = 2;
518
519
  break;
519
520
  }
520
521
  found = cached;
521
- return _context2.a(3, 7);
522
+ return _context4.a(3, 7);
522
523
  case 2:
523
524
  visited.push(dir);
524
- _context2.n = 3;
525
+ _context4.n = 3;
525
526
  return readFile(join(dir, "package.json"), "utf8").then(function (text) {
526
527
  return JSON.parse(text);
527
528
  })["catch"](function () {
528
529
  return null;
529
530
  });
530
531
  case 3:
531
- manifest = _context2.v;
532
+ manifest = _context4.v;
532
533
  if (!(_typeof(manifest) === "object" && manifest !== null && "name" in manifest && "version" in manifest && typeof manifest.name === "string" && typeof manifest.version === "string")) {
533
- _context2.n = 4;
534
+ _context4.n = 4;
534
535
  break;
535
536
  }
536
537
  found = {
537
538
  name: manifest.name,
538
539
  version: manifest.version
539
540
  };
540
- return _context2.a(3, 7);
541
+ return _context4.a(3, 7);
541
542
  case 4:
542
543
  parent = dirname(dir);
543
544
  if (!(parent === dir)) {
544
- _context2.n = 5;
545
+ _context4.n = 5;
545
546
  break;
546
547
  }
547
- return _context2.a(3, 7);
548
+ return _context4.a(3, 7);
548
549
  case 5:
549
550
  dir = parent;
550
551
  case 6:
551
- _context2.n = 1;
552
+ _context4.n = 1;
552
553
  break;
553
554
  case 7:
554
- for (_i3 = 0, _visited = visited; _i3 < _visited.length; _i3++) {
555
- each = _visited[_i3];
555
+ for (_i4 = 0, _visited = visited; _i4 < _visited.length; _i4++) {
556
+ each = _visited[_i4];
556
557
  cache.set(each, found);
557
558
  }
558
- return _context2.a(2, found);
559
+ return _context4.a(2, found);
559
560
  }
560
- }, _callee2);
561
+ }, _callee4);
561
562
  }));
562
563
  return _owningPackage.apply(this, arguments);
563
564
  }
@@ -575,63 +576,63 @@ function pinSkewOf(_x3, _x4, _x5) {
575
576
  * here: it is a URL this package mints, not a path the platform owns.
576
577
  */
577
578
  function _pinSkewOf() {
578
- _pinSkewOf = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(moduleIds, pins, cache) {
579
- var found, _iterator9, _step9, _found$get, id, owner, pinned, versions, _t;
580
- return _regenerator().w(function (_context3) {
581
- while (1) switch (_context3.p = _context3.n) {
579
+ _pinSkewOf = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(moduleIds, pins, cache) {
580
+ var found, _iterator1, _step1, _found$get, id, owner, pinned, versions, _t;
581
+ return _regenerator().w(function (_context5) {
582
+ while (1) switch (_context5.p = _context5.n) {
582
583
  case 0:
583
584
  found = new Map();
584
- _iterator9 = _createForOfIteratorHelper(moduleIds);
585
- _context3.p = 1;
586
- _iterator9.s();
585
+ _iterator1 = _createForOfIteratorHelper(moduleIds);
586
+ _context5.p = 1;
587
+ _iterator1.s();
587
588
  case 2:
588
- if ((_step9 = _iterator9.n()).done) {
589
- _context3.n = 8;
589
+ if ((_step1 = _iterator1.n()).done) {
590
+ _context5.n = 8;
590
591
  break;
591
592
  }
592
- id = _step9.value;
593
+ id = _step1.value;
593
594
  if (isAbsolute(id)) {
594
- _context3.n = 3;
595
+ _context5.n = 3;
595
596
  break;
596
597
  }
597
- return _context3.a(3, 7);
598
+ return _context5.a(3, 7);
598
599
  case 3:
599
- _context3.n = 4;
600
+ _context5.n = 4;
600
601
  return owningPackage(id, cache);
601
602
  case 4:
602
- owner = _context3.v;
603
+ owner = _context5.v;
603
604
  if (owner) {
604
- _context3.n = 5;
605
+ _context5.n = 5;
605
606
  break;
606
607
  }
607
- return _context3.a(3, 7);
608
+ return _context5.a(3, 7);
608
609
  case 5:
609
610
  pinned = pins[owner.name];
610
611
  if (!(pinned === undefined || owner.version === pinned)) {
611
- _context3.n = 6;
612
+ _context5.n = 6;
612
613
  break;
613
614
  }
614
- return _context3.a(3, 7);
615
+ return _context5.a(3, 7);
615
616
  case 6:
616
617
  versions = (_found$get = found.get(owner.name)) !== null && _found$get !== void 0 ? _found$get : new Set();
617
618
  versions.add(owner.version);
618
619
  found.set(owner.name, versions);
619
620
  case 7:
620
- _context3.n = 2;
621
+ _context5.n = 2;
621
622
  break;
622
623
  case 8:
623
- _context3.n = 10;
624
+ _context5.n = 10;
624
625
  break;
625
626
  case 9:
626
- _context3.p = 9;
627
- _t = _context3.v;
628
- _iterator9.e(_t);
627
+ _context5.p = 9;
628
+ _t = _context5.v;
629
+ _iterator1.e(_t);
629
630
  case 10:
630
- _context3.p = 10;
631
- _iterator9.f();
632
- return _context3.f(10);
631
+ _context5.p = 10;
632
+ _iterator1.f();
633
+ return _context5.f(10);
633
634
  case 11:
634
- return _context3.a(2, _toConsumableArray(found.entries()).sort(function (_ref4, _ref5) {
635
+ return _context5.a(2, _toConsumableArray(found.entries()).sort(function (_ref4, _ref5) {
635
636
  var _ref6 = _slicedToArray(_ref4, 1),
636
637
  a = _ref6[0];
637
638
  var _ref7 = _slicedToArray(_ref5, 1),
@@ -650,7 +651,7 @@ function _pinSkewOf() {
650
651
  });
651
652
  }));
652
653
  }
653
- }, _callee3, null, [[1, 9, 10, 11]]);
654
+ }, _callee5, null, [[1, 9, 10, 11]]);
654
655
  }));
655
656
  return _pinSkewOf.apply(this, arguments);
656
657
  }
@@ -708,34 +709,35 @@ var firstLine = function firstLine(message) {
708
709
  };
709
710
 
710
711
  /**
711
- * A throwaway build, used only to find out whether a set of entries compiles.
712
- *
713
- * Worker target only: it is the stricter of the two (neutral platform, workerd
714
- * conditions), so anything that survives it is very unlikely to fail the
715
- * browser build for a reason worth attributing separately.
712
+ * Builds the given entries for each target, audits what came out, and digests
713
+ * it.
714
+ *
715
+ * Each target can take two passes. The first finds the entries that cannot be
716
+ * bundled for it (see `stubUnbundlable`); when there are any, the second
717
+ * builds the rest, and those are reported -- in `unusable` when they cannot be
718
+ * layered at all, in `serverOnly` when only the browser cannot have them --
719
+ * rather than failing the build. Either way each target ends with exactly one
720
+ * build that is audited and shipped.
716
721
  */
717
722
  function buildTargets(_x6, _x7, _x8, _x9, _x0) {
718
723
  return _buildTargets.apply(this, arguments);
719
724
  }
720
725
  /**
721
- * Start's per-project `imports` subpaths, stubbed for the project layer.
722
- *
723
- * `@tanstack/start-server-core` dynamically imports the app's router and server
724
- * entry through these, and Start's Vite plugin fills them in per project. It is
725
- * not in the base layer -- the shell needs its own copy, with those resolved
726
- * for real -- so a project dependency that merely *reaches* start-server-core
727
- * has nothing to resolve them to and cannot be built at all.
728
- *
729
- * Stubbed here rather than left unresolved, because the dependency almost
730
- * certainly wants a request helper or the storage context, not a second Start
731
- * handler. If one really does create a handler, this throws with a message
732
- * saying so instead of failing the layer build with a bare specifier.
726
+ * The entries of a stubbed build that load a stub, and why.
727
+ *
728
+ * An entry loads what its own chunk holds and what that chunk statically
729
+ * imports, transitively; a stub found there runs, and throws, when the entry is
730
+ * imported. A builtin stub reached only through `import()` does not count: that
731
+ * import rejects into whatever the package does about it, exactly as an
732
+ * unresolvable `import()` would. A native one does, either way, because an
733
+ * unstubbed build cannot load the binary at all -- which is what dropped the
734
+ * dependency before there were stubs.
733
735
  */
734
736
  function _buildTargets() {
735
- _buildTargets = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(names, input, outRoot, quiet, platform) {
736
- var out, digest, packages, _iterator0, _step0, target, forTarget, dir, shims, result, pins, skew, _iterator1, _step1, file, code, _t2, _t3, _t4;
737
- return _regenerator().w(function (_context4) {
738
- while (1) switch (_context4.p = _context4.n) {
737
+ _buildTargets = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(names, input, outRoot, quiet, platform) {
738
+ var out, digest, packages, serverOnly, unusable, _iterator10, _step10, target, forTarget, dir, stubs, _loop3, _ret, _t4;
739
+ return _regenerator().w(function (_context7) {
740
+ while (1) switch (_context7.p = _context7.n) {
739
741
  case 0:
740
742
  out = {
741
743
  worker: {},
@@ -744,222 +746,363 @@ function _buildTargets() {
744
746
  digest = createHash("sha256");
745
747
  /** Directory -> the package it belongs to, for the pin check. */
746
748
  packages = new Map();
747
- _iterator0 = _createForOfIteratorHelper(targetsFor(platform));
748
- _context4.p = 1;
749
- _iterator0.s();
749
+ /** Entry -> why it cannot be built for a browser. */
750
+ serverOnly = {};
751
+ /** Entry -> why it cannot be built at all. */
752
+ unusable = {};
753
+ _iterator10 = _createForOfIteratorHelper(targetsFor(platform));
754
+ _context7.p = 1;
755
+ _iterator10.s();
750
756
  case 2:
751
- if ((_step0 = _iterator0.n()).done) {
752
- _context4.n = 19;
753
- break;
754
- }
755
- target = _step0.value;
756
- forTarget = Array.isArray(names) ? names : names[target.name]; // Nothing for this side: a dependency can be server-only, and building an
757
- // empty bundle is both pointless and an error.
758
- if (!(forTarget.length === 0)) {
759
- _context4.n = 3;
757
+ if ((_step10 = _iterator10.n()).done) {
758
+ _context7.n = 8;
760
759
  break;
761
760
  }
762
- return _context4.a(3, 18);
763
- case 3:
761
+ target = _step10.value;
762
+ forTarget = (Array.isArray(names) ? names : names[target.name]).filter(
763
+ // The worker goes first: what it cannot bundle, neither side has.
764
+ function (name) {
765
+ return !(name in unusable);
766
+ });
764
767
  dir = join(outRoot, target.name);
765
- /*
766
- * Cleared first, because this function EMITS WHATEVER IT FINDS HERE.
767
- *
768
- * `buildVendorLayer` calls it twice against the same directory: once with
769
- * every dependency, and again with the survivors when that fails and the
770
- * per-dependency probe has worked out which to drop. rolldown writes
771
- * before the import audit runs, so a first pass that fails IN THE AUDIT
772
- * has already left chunks on disk -- including the chunk for the
773
- * dependency about to be dropped.
774
- *
775
- * Left in place, the `readdir` below picks that chunk up again, so the
776
- * retry re-audits the very thing it exists to exclude and fails the same
777
- * way; and where the first pass failed for some other reason, the dropped
778
- * dependency's code is shipped and folded into `rev`. rolldown has no
779
- * `emptyOutDir`, so nothing else clears it.
768
+ /**
769
+ * The builtins the first pass stubbed, each with the module that asked for
770
+ * it. Null on the second pass, which stubs nothing.
780
771
  */
781
- _context4.n = 4;
782
- return rm(dir, {
783
- recursive: true,
784
- force: true
772
+ stubs = new Map();
773
+ _loop3 = /*#__PURE__*/_regenerator().m(function _loop3() {
774
+ var shims, result, found, stubbed, _i5, _Object$entries3, _Object$entries3$_i, name, _Object$entries3$_i$, _native, reason, pins, skew, _iterator11, _step11, file, code, _t2, _t3;
775
+ return _regenerator().w(function (_context6) {
776
+ while (1) switch (_context6.p = _context6.n) {
777
+ case 0:
778
+ if (!(forTarget.length === 0)) {
779
+ _context6.n = 2;
780
+ break;
781
+ }
782
+ _context6.n = 1;
783
+ return rm(dir, {
784
+ recursive: true,
785
+ force: true
786
+ });
787
+ case 1:
788
+ return _context6.a(2, 0);
789
+ case 2:
790
+ _context6.n = 3;
791
+ return rm(dir, {
792
+ recursive: true,
793
+ force: true
794
+ });
795
+ case 3:
796
+ _context6.n = 4;
797
+ return nodeShims(target.name === "worker");
798
+ case 4:
799
+ shims = _context6.v;
800
+ _context6.n = 5;
801
+ return build({
802
+ input: Object.fromEntries(forTarget.map(function (name) {
803
+ return [name, input[name]];
804
+ })),
805
+ platform: target.platform,
806
+ plugins: [externaliseBase(target.baseFrom, platform), pinPlatformTanstack(platform), stubStartEntries(), stubServerEntries(target.name === "browser")].concat(_toConsumableArray(stubs ? [stubUnbundlable(target.name === "browser", stubs)] : []), [
807
+ // Worker only: a browser has no Node builtins to bridge to, and a
808
+ // package reaching for one there is a real error rather than a missing
809
+ // runtime.
810
+ shims]),
811
+ transform: {
812
+ define: _objectSpread2({
813
+ "process.env.NODE_ENV": JSON.stringify("production")
814
+ }, target.name === "worker" ? {
815
+ __filename: JSON.stringify("/worker.js"),
816
+ __dirname: JSON.stringify("/"),
817
+ "import.meta.url": JSON.stringify("file:///worker.js"),
818
+ /*
819
+ * There is no disk in here, and Val is the one dependency that
820
+ * assumes there is.
821
+ *
822
+ * It picks its storage mode by inference -- a content service
823
+ * when it finds an api key, the local filesystem otherwise --
824
+ * and the third mode, where the HOST hands over the source,
825
+ * cannot be inferred at all: it is chosen by passing
826
+ * `sourceFiles`, which only the app's own server file can do.
827
+ * `wireUp` writes that file, so a project the platform wired is
828
+ * already in the right mode.
829
+ *
830
+ * A project that brings its OWN server file is not, and the
831
+ * failure was `patch-error /bundle/.val/patches.lock: EPERM` --
832
+ * the isolate's read-only filesystem, named two layers below
833
+ * the decision that led there.
834
+ *
835
+ * So this says where the code is running and lets Val decide
836
+ * what that implies, rather than naming a Val mode. Which mode
837
+ * an isolate with no disk needs is Val's to know; that it IS an
838
+ * isolate with no disk is the only part the platform can
839
+ * actually vouch for, and the part that stays true if the modes
840
+ * are ever renamed or split. Harmless to every other
841
+ * dependency, and to a Val too old to look.
842
+ */
843
+ "process.env.VAL_ENV": JSON.stringify("app")
844
+ } : {})
845
+ },
846
+ resolve: _objectSpread2({
847
+ conditionNames: target.conditions
848
+ }, "mainFields" in target ? {
849
+ mainFields: target.mainFields
850
+ } : {}),
851
+ output: {
852
+ dir: dir,
853
+ format: "esm",
854
+ entryFileNames: "[name].js",
855
+ chunkFileNames: "_p-[hash].js",
856
+ minify: true
857
+ },
858
+ onLog: function onLog(level, log, handler) {
859
+ // Quiet during the attribution probes: they are *expected* to fail, and
860
+ // the failures are reported afterwards with the specifier attached.
861
+ if (quiet) return;
862
+ // `__ns.default ?? __ns` warns for every package with no default
863
+ // export, which is the case the fallback exists for -- see stubSource.
864
+ if (log.code === "IMPORT_IS_UNDEFINED") return;
865
+ /*
866
+ * "use client" in a package being bundled for the worker.
867
+ *
868
+ * Every React package that ships the directive warns, once per module,
869
+ * and TanStack's router alone accounts for a dozen. They are expected
870
+ * and they are not actionable: this build has no client boundary to
871
+ * preserve, the shell owns that split, and nothing here reads the
872
+ * directive.
873
+ *
874
+ * Silenced because the noise did real harm. A successful publish ended
875
+ * with twenty of these and the reader took it for a failed one -- the
876
+ * line that says `published <project> @ <hash>` was the last of about
877
+ * two hundred, and everything above it looked like an error.
878
+ */
879
+ if (log.code === "MODULE_LEVEL_DIRECTIVE") return;
880
+ /*
881
+ * NOT silenced: UNRESOLVED_IMPORT. rolldown downgrades it to a warning
882
+ * and externalises the specifier, which is how an unresolvable bare
883
+ * import reaches the isolate and refuses to start. The audit below is
884
+ * what turns it into an error, and the warning is worth seeing.
885
+ */
886
+ handler(level, log);
887
+ }
888
+ });
889
+ case 5:
890
+ result = _context6.v;
891
+ if (!stubs) {
892
+ _context6.n = 6;
893
+ break;
894
+ }
895
+ found = stubbedEntries(result.output, stubs);
896
+ stubbed = result.output.some(function (item) {
897
+ return item.type === "chunk" && item.moduleIds.some(function (id) {
898
+ return id.startsWith(BROWSER_BUILTIN) || isNativeBinary(id);
899
+ });
900
+ });
901
+ stubs = null;
902
+ for (_i5 = 0, _Object$entries3 = Object.entries(found); _i5 < _Object$entries3.length; _i5++) {
903
+ _Object$entries3$_i = _slicedToArray(_Object$entries3[_i5], 2), name = _Object$entries3$_i[0], _Object$entries3$_i$ = _Object$entries3$_i[1], _native = _Object$entries3$_i$["native"], reason = _Object$entries3$_i$.reason;
904
+ if (_native && target.name === "worker") unusable[name] = reason;else serverOnly[name] = reason;
905
+ }
906
+ // Nothing reached a stub, so this pass is the build: no second one.
907
+ // When something did -- even only a builtin behind an `import()`,
908
+ // which leaves every entry usable -- the output carries stubs and is
909
+ // built again without them, so what ships is what an unstubbed build
910
+ // makes.
911
+ if (!stubbed) {
912
+ _context6.n = 6;
913
+ break;
914
+ }
915
+ forTarget = forTarget.filter(function (name) {
916
+ return !(name in found);
917
+ });
918
+ return _context6.a(2, 1);
919
+ case 6:
920
+ // Before the import audit, which would otherwise report the same skew as
921
+ // a missing export -- true, and one step removed from the cause.
922
+ pins = platform.base.pins;
923
+ if (!pins) {
924
+ _context6.n = 8;
925
+ break;
926
+ }
927
+ _context6.n = 7;
928
+ return pinSkewOf(result.output.flatMap(function (item) {
929
+ return item.type === "chunk" ? item.moduleIds : [];
930
+ }), pins, packages);
931
+ case 7:
932
+ skew = _context6.v;
933
+ if (!skew.length) {
934
+ _context6.n = 8;
935
+ break;
936
+ }
937
+ throw new PinSkewError(skew, platform.base.rev);
938
+ case 8:
939
+ _t2 = _createForOfIteratorHelper;
940
+ _context6.n = 9;
941
+ return readdir(dir);
942
+ case 9:
943
+ _iterator11 = _t2(_context6.v.sort());
944
+ _context6.p = 10;
945
+ _iterator11.s();
946
+ case 11:
947
+ if ((_step11 = _iterator11.n()).done) {
948
+ _context6.n = 15;
949
+ break;
950
+ }
951
+ file = _step11.value;
952
+ _context6.n = 12;
953
+ return readFile(join(dir, file), "utf8");
954
+ case 12:
955
+ code = _context6.v;
956
+ _context6.n = 13;
957
+ return auditImports(target, file, code, platform);
958
+ case 13:
959
+ // Worker entries are module-map keys and carry the directory; browser
960
+ // entries are served under `/_pvendor/<rev>/` and do not.
961
+ out[target.name][target.name === "worker" ? "pvendor/".concat(file) : file] = code;
962
+ digest.update("".concat(target.name, "/").concat(file));
963
+ digest.update(code);
964
+ case 14:
965
+ _context6.n = 11;
966
+ break;
967
+ case 15:
968
+ _context6.n = 17;
969
+ break;
970
+ case 16:
971
+ _context6.p = 16;
972
+ _t3 = _context6.v;
973
+ _iterator11.e(_t3);
974
+ case 17:
975
+ _context6.p = 17;
976
+ _iterator11.f();
977
+ return _context6.f(17);
978
+ case 18:
979
+ return _context6.a(2, 0);
980
+ }
981
+ }, _loop3, null, [[10, 16, 17, 18]]);
785
982
  });
983
+ case 3:
984
+ return _context7.d(_regeneratorValues(_loop3()), 4);
786
985
  case 4:
787
- _context4.n = 5;
788
- return nodeShims(target.name === "worker");
789
- case 5:
790
- shims = _context4.v;
791
- _context4.n = 6;
792
- return build({
793
- input: Object.fromEntries(forTarget.map(function (name) {
794
- return [name, input[name]];
795
- })),
796
- platform: target.platform,
797
- plugins: [externaliseBase(target.baseFrom, platform), pinPlatformTanstack(platform), stubStartEntries(), stubServerEntries(target.name === "browser"),
798
- // Worker only: a browser has no Node builtins to bridge to, and a
799
- // package reaching for one there is a real error rather than a missing
800
- // runtime.
801
- shims],
802
- transform: {
803
- define: _objectSpread2({
804
- "process.env.NODE_ENV": JSON.stringify("production")
805
- }, target.name === "worker" ? {
806
- __filename: JSON.stringify("/worker.js"),
807
- __dirname: JSON.stringify("/"),
808
- "import.meta.url": JSON.stringify("file:///worker.js"),
809
- /*
810
- * There is no disk in here, and Val is the one dependency that
811
- * assumes there is.
812
- *
813
- * It picks its storage mode by inference -- a content service
814
- * when it finds an api key, the local filesystem otherwise --
815
- * and the third mode, where the HOST hands over the source,
816
- * cannot be inferred at all: it is chosen by passing
817
- * `sourceFiles`, which only the app's own server file can do.
818
- * `wireUp` writes that file, so a project the platform wired is
819
- * already in the right mode.
820
- *
821
- * A project that brings its OWN server file is not, and the
822
- * failure was `patch-error /bundle/.val/patches.lock: EPERM` --
823
- * the isolate's read-only filesystem, named two layers below
824
- * the decision that led there.
825
- *
826
- * So this says where the code is running and lets Val decide
827
- * what that implies, rather than naming a Val mode. Which mode
828
- * an isolate with no disk needs is Val's to know; that it IS an
829
- * isolate with no disk is the only part the platform can
830
- * actually vouch for, and the part that stays true if the modes
831
- * are ever renamed or split. Harmless to every other
832
- * dependency, and to a Val too old to look.
833
- */
834
- "process.env.VAL_ENV": JSON.stringify("app")
835
- } : {})
836
- },
837
- resolve: _objectSpread2({
838
- conditionNames: target.conditions
839
- }, "mainFields" in target ? {
840
- mainFields: target.mainFields
841
- } : {}),
842
- output: {
843
- dir: dir,
844
- format: "esm",
845
- entryFileNames: "[name].js",
846
- chunkFileNames: "_p-[hash].js",
847
- minify: true
848
- },
849
- onLog: function onLog(level, log, handler) {
850
- // Quiet during the attribution probes: they are *expected* to fail, and
851
- // the failures are reported afterwards with the specifier attached.
852
- if (quiet) return;
853
- // `__ns.default ?? __ns` warns for every package with no default
854
- // export, which is the case the fallback exists for -- see stubSource.
855
- if (log.code === "IMPORT_IS_UNDEFINED") return;
856
- /*
857
- * "use client" in a package being bundled for the worker.
858
- *
859
- * Every React package that ships the directive warns, once per module,
860
- * and TanStack's router alone accounts for a dozen. They are expected
861
- * and they are not actionable: this build has no client boundary to
862
- * preserve, the shell owns that split, and nothing here reads the
863
- * directive.
864
- *
865
- * Silenced because the noise did real harm. A successful publish ended
866
- * with twenty of these and the reader took it for a failed one -- the
867
- * line that says `published <project> @ <hash>` was the last of about
868
- * two hundred, and everything above it looked like an error.
869
- */
870
- if (log.code === "MODULE_LEVEL_DIRECTIVE") return;
871
- /*
872
- * NOT silenced: UNRESOLVED_IMPORT. rolldown downgrades it to a warning
873
- * and externalises the specifier, which is how an unresolvable bare
874
- * import reaches the isolate and refuses to start. The audit below is
875
- * what turns it into an error, and the warning is worth seeing.
876
- */
877
- handler(level, log);
878
- }
879
- });
880
- case 6:
881
- result = _context4.v;
882
- // Before the import audit, which would otherwise report the same skew as
883
- // a missing export -- true, and one step removed from the cause.
884
- pins = platform.base.pins;
885
- if (!pins) {
886
- _context4.n = 8;
986
+ _ret = _context7.v;
987
+ if (!(_ret === 0)) {
988
+ _context7.n = 5;
887
989
  break;
888
990
  }
889
- _context4.n = 7;
890
- return pinSkewOf(result.output.flatMap(function (item) {
891
- return item.type === "chunk" ? item.moduleIds : [];
892
- }), pins, packages);
893
- case 7:
894
- skew = _context4.v;
895
- if (!skew.length) {
896
- _context4.n = 8;
897
- break;
898
- }
899
- throw new PinSkewError(skew, platform.base.rev);
900
- case 8:
901
- _t2 = _createForOfIteratorHelper;
902
- _context4.n = 9;
903
- return readdir(dir);
904
- case 9:
905
- _iterator1 = _t2(_context4.v.sort());
906
- _context4.p = 10;
907
- _iterator1.s();
908
- case 11:
909
- if ((_step1 = _iterator1.n()).done) {
910
- _context4.n = 15;
991
+ return _context7.a(3, 7);
992
+ case 5:
993
+ if (!(_ret === 1)) {
994
+ _context7.n = 6;
911
995
  break;
912
996
  }
913
- file = _step1.value;
914
- _context4.n = 12;
915
- return readFile(join(dir, file), "utf8");
916
- case 12:
917
- code = _context4.v;
918
- _context4.n = 13;
919
- return auditImports(target, file, code, platform);
920
- case 13:
921
- // Worker entries are module-map keys and carry the directory; browser
922
- // entries are served under `/_pvendor/<rev>/` and do not.
923
- out[target.name][target.name === "worker" ? "pvendor/".concat(file) : file] = code;
924
- digest.update("".concat(target.name, "/").concat(file));
925
- digest.update(code);
926
- case 14:
927
- _context4.n = 11;
928
- break;
929
- case 15:
930
- _context4.n = 17;
997
+ return _context7.a(3, 6);
998
+ case 6:
999
+ _context7.n = 3;
931
1000
  break;
932
- case 16:
933
- _context4.p = 16;
934
- _t3 = _context4.v;
935
- _iterator1.e(_t3);
936
- case 17:
937
- _context4.p = 17;
938
- _iterator1.f();
939
- return _context4.f(17);
940
- case 18:
941
- _context4.n = 2;
1001
+ case 7:
1002
+ _context7.n = 2;
942
1003
  break;
943
- case 19:
944
- _context4.n = 21;
1004
+ case 8:
1005
+ _context7.n = 10;
945
1006
  break;
946
- case 20:
947
- _context4.p = 20;
948
- _t4 = _context4.v;
949
- _iterator0.e(_t4);
950
- case 21:
951
- _context4.p = 21;
952
- _iterator0.f();
953
- return _context4.f(21);
954
- case 22:
955
- return _context4.a(2, _objectSpread2(_objectSpread2({}, out), {}, {
1007
+ case 9:
1008
+ _context7.p = 9;
1009
+ _t4 = _context7.v;
1010
+ _iterator10.e(_t4);
1011
+ case 10:
1012
+ _context7.p = 10;
1013
+ _iterator10.f();
1014
+ return _context7.f(10);
1015
+ case 11:
1016
+ return _context7.a(2, _objectSpread2(_objectSpread2({}, out), {}, {
1017
+ serverOnly: serverOnly,
1018
+ unusable: unusable,
956
1019
  rev: digest.digest("hex").slice(0, 16)
957
1020
  }));
958
1021
  }
959
- }, _callee4, null, [[10, 16, 17, 18], [1, 20, 21, 22]]);
1022
+ }, _callee6, null, [[1, 9, 10, 11]]);
960
1023
  }));
961
1024
  return _buildTargets.apply(this, arguments);
962
1025
  }
1026
+ function stubbedEntries(output, builtins) {
1027
+ var chunks = new Map();
1028
+ var _iterator2 = _createForOfIteratorHelper(output),
1029
+ _step2;
1030
+ try {
1031
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
1032
+ var item = _step2.value;
1033
+ if (item.type === "chunk") chunks.set(item.fileName, item);
1034
+ }
1035
+ } catch (err) {
1036
+ _iterator2.e(err);
1037
+ } finally {
1038
+ _iterator2.f();
1039
+ }
1040
+ var reach = function reach(entry, dynamic) {
1041
+ var seen = new Set([entry.fileName]);
1042
+ var queue = [entry];
1043
+ var ids = [];
1044
+ for (var chunk = queue.shift(); chunk; chunk = queue.shift()) {
1045
+ ids.push.apply(ids, _toConsumableArray(chunk.moduleIds));
1046
+ for (var _i = 0, _arr = [].concat(_toConsumableArray(chunk.imports), _toConsumableArray(dynamic ? chunk.dynamicImports : [])); _i < _arr.length; _i++) {
1047
+ var file = _arr[_i];
1048
+ var next = chunks.get(file);
1049
+ if (next && !seen.has(file)) {
1050
+ seen.add(file);
1051
+ queue.push(next);
1052
+ }
1053
+ }
1054
+ }
1055
+ return ids;
1056
+ };
1057
+ var found = {};
1058
+ var _iterator3 = _createForOfIteratorHelper(chunks.values()),
1059
+ _step3;
1060
+ try {
1061
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
1062
+ var entry = _step3.value;
1063
+ if (!entry.isEntry) continue;
1064
+ var binary = reach(entry, true).filter(isNativeBinary).sort()[0];
1065
+ if (binary !== undefined) {
1066
+ found[entry.name] = {
1067
+ "native": true,
1068
+ reason: "loads the native binary ".concat(packagePathOf(binary), ", which cannot be bundled")
1069
+ };
1070
+ continue;
1071
+ }
1072
+ var builtin = reach(entry, false).filter(function (id) {
1073
+ return id.startsWith(BROWSER_BUILTIN);
1074
+ }).map(function (id) {
1075
+ return id.slice(BROWSER_BUILTIN.length);
1076
+ }).sort()[0];
1077
+ if (builtin === undefined) continue;
1078
+ var importer = builtins.get(builtin);
1079
+ found[entry.name] = {
1080
+ "native": false,
1081
+ reason: "reaches Node's '".concat(builtin, "'") + (importer ? " (imported by ".concat(importer, ")") : "") + ", which a browser does not have"
1082
+ };
1083
+ }
1084
+ } catch (err) {
1085
+ _iterator3.e(err);
1086
+ } finally {
1087
+ _iterator3.f();
1088
+ }
1089
+ return found;
1090
+ }
1091
+
1092
+ /**
1093
+ * Start's per-project `imports` subpaths, stubbed for the project layer.
1094
+ *
1095
+ * `@tanstack/start-server-core` dynamically imports the app's router and server
1096
+ * entry through these, and Start's Vite plugin fills them in per project. It is
1097
+ * not in the base layer -- the shell needs its own copy, with those resolved
1098
+ * for real -- so a project dependency that merely *reaches* start-server-core
1099
+ * has nothing to resolve them to and cannot be built at all.
1100
+ *
1101
+ * Stubbed here rather than left unresolved, because the dependency almost
1102
+ * certainly wants a request helper or the storage context, not a second Start
1103
+ * handler. If one really does create a handler, this throws with a message
1104
+ * saying so instead of failing the layer build with a bare specifier.
1105
+ */
963
1106
  var START_ENTRY_STUB = "\nexport function getRouter() {\n throw new Error(\n 'A project dependency tried to create a TanStack Start handler. The platform ' +\n 'shell is the handler here, so a dependency cannot create a second one.',\n )\n}\nexport default { getRouter }\n";
964
1107
  var PER_PROJECT_ENTRIES = ["#tanstack-router-entry", "#tanstack-start-entry"];
965
1108
 
@@ -1004,6 +1147,139 @@ function stubServerEntries(browser) {
1004
1147
  }
1005
1148
  };
1006
1149
  }
1150
+
1151
+ /**
1152
+ * What a first pass stubs, so that it builds: a module that throws, in place
1153
+ * of an import that cannot be bundled.
1154
+ *
1155
+ * - **Node builtins, on the browser side.** A server-only dependency is the
1156
+ * usual case, not the odd one: `@valbuild/tanstack/server` and
1157
+ * `@valbuild/mcp` reach `path` through Val's server, and `sharp` reaches
1158
+ * `node:util`.
1159
+ * - **Native binaries (`.node`), on both.** `@tailwindcss/vite` is in every
1160
+ * template's `dependencies` and loads one; nothing can bundle it.
1161
+ *
1162
+ * Left alone, any one of these failed the layer's single build, and since a
1163
+ * failed build does not say which entry pulled the file in, every dependency
1164
+ * was then built on its own for both targets to find out: twenty-six builds
1165
+ * where two would do, re-bundling Val's server once per entry that shares it,
1166
+ * at 3.2 GB.
1167
+ *
1168
+ * Stubbed, the build succeeds, and its output says which entries load a stub
1169
+ * (`stubbedEntries`): those are server-only, or for a binary, not layered at
1170
+ * all, each named with the reason. Then the target is built again without
1171
+ * them, unstubbed, so what ships is what an unstubbed build of the rest makes.
1172
+ *
1173
+ * A bare name is only a builtin when nothing resolves it. `events`, `buffer`
1174
+ * and `util` are also npm packages that exist to be bundled for a browser, and
1175
+ * a project that has one installed gets that package, as it always did. The
1176
+ * `node:` scheme is never a package.
1177
+ */
1178
+ var BROWSER_BUILTIN = "\0platform:browser-builtin:";
1179
+ var isNativeBinary = function isNativeBinary(id) {
1180
+ return id.endsWith(".node");
1181
+ };
1182
+ function stubUnbundlable(browser, reached) {
1183
+ return {
1184
+ name: "platform:unbundlable",
1185
+ resolveId: function resolveId(source, importer) {
1186
+ var _this2 = this;
1187
+ return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
1188
+ var installed, by, before;
1189
+ return _regenerator().w(function (_context) {
1190
+ while (1) switch (_context.n) {
1191
+ case 0:
1192
+ if (browser) {
1193
+ _context.n = 1;
1194
+ break;
1195
+ }
1196
+ return _context.a(2, null);
1197
+ case 1:
1198
+ if (source.startsWith("node:")) {
1199
+ _context.n = 4;
1200
+ break;
1201
+ }
1202
+ if (isRuntimeBuiltin(source)) {
1203
+ _context.n = 2;
1204
+ break;
1205
+ }
1206
+ return _context.a(2, null);
1207
+ case 2:
1208
+ _context.n = 3;
1209
+ return _this2.resolve(source, importer, {
1210
+ skipSelf: true
1211
+ });
1212
+ case 3:
1213
+ installed = _context.v;
1214
+ if (!(installed && !installed.external)) {
1215
+ _context.n = 4;
1216
+ break;
1217
+ }
1218
+ return _context.a(2, null);
1219
+ case 4:
1220
+ by = importer ? packagePathOf(importer) : "";
1221
+ before = reached.get(source); // The smallest, so the reason reads the same however resolution was
1222
+ // scheduled.
1223
+ if (before === undefined || by && by < before) reached.set(source, by);
1224
+ return _context.a(2, BROWSER_BUILTIN + source);
1225
+ }
1226
+ }, _callee);
1227
+ }))();
1228
+ },
1229
+ /*
1230
+ * Throws when evaluated, and exports every name the real builtin has.
1231
+ * The names are what keep this pass a build: `import { randomUUID } from
1232
+ * 'node:crypto'` against a stub with no exports is a MISSING_EXPORT, which
1233
+ * fails the build and sent the layer down the per-dependency path anyway.
1234
+ * The throw comes LAST: rolldown drops what follows a top-level throw as
1235
+ * unreachable, exports included, and the names are missing again.
1236
+ */
1237
+ load: function load(id) {
1238
+ return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
1239
+ var builtin, real, names;
1240
+ return _regenerator().w(function (_context2) {
1241
+ while (1) switch (_context2.n) {
1242
+ case 0:
1243
+ if (!isNativeBinary(id)) {
1244
+ _context2.n = 1;
1245
+ break;
1246
+ }
1247
+ return _context2.a(2, {
1248
+ code: "throw new Error(".concat(JSON.stringify("".concat(packagePathOf(id), " is a native binary, which cannot be bundled.")), ");"),
1249
+ moduleType: "js"
1250
+ });
1251
+ case 1:
1252
+ if (id.startsWith(BROWSER_BUILTIN)) {
1253
+ _context2.n = 2;
1254
+ break;
1255
+ }
1256
+ return _context2.a(2, null);
1257
+ case 2:
1258
+ builtin = id.slice(BROWSER_BUILTIN.length);
1259
+ _context2.n = 3;
1260
+ return import("node:".concat(builtin.replace(/^node:/, "")))["catch"](function () {
1261
+ return {};
1262
+ });
1263
+ case 3:
1264
+ real = _context2.v;
1265
+ names = Object.keys(real).filter(function (key) {
1266
+ return key !== "default" && /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key);
1267
+ });
1268
+ return _context2.a(2, ["const none = undefined;", "export { ".concat(["none as default"].concat(_toConsumableArray(names.map(function (name) {
1269
+ return "none as ".concat(name);
1270
+ }))).join(", "), " };"), "throw new Error(".concat(JSON.stringify("Node's '".concat(builtin, "' is not available in a browser.")), ");")].join("\n"));
1271
+ }
1272
+ }, _callee2);
1273
+ }))();
1274
+ }
1275
+ };
1276
+ }
1277
+
1278
+ /** `…/node_modules/.pnpm/x/node_modules/@scope/pkg/dist/a.js` -> `@scope/pkg/dist/a.js`. */
1279
+ var packagePathOf = function packagePathOf(id) {
1280
+ var at = id.lastIndexOf("node_modules/");
1281
+ return at === -1 ? id : id.slice(at + "node_modules/".length);
1282
+ };
1007
1283
  function stubStartEntries() {
1008
1284
  var prefix = "\0platform:start-entry:";
1009
1285
  return {
@@ -1157,66 +1433,132 @@ var nameOf = function nameOf(node) {
1157
1433
  node.value : null;
1158
1434
  };
1159
1435
  var parseModule = /*#__PURE__*/function () {
1160
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(code, file) {
1161
- return _regenerator().w(function (_context) {
1162
- while (1) switch (_context.n) {
1436
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(code, file) {
1437
+ return _regenerator().w(function (_context3) {
1438
+ while (1) switch (_context3.n) {
1163
1439
  case 0:
1164
- _context.n = 1;
1440
+ _context3.n = 1;
1165
1441
  return parseAstAsync(code, {
1166
1442
  lang: "js"
1167
1443
  }, file);
1168
1444
  case 1:
1169
- return _context.a(2, _context.v);
1445
+ return _context3.a(2, _context3.v);
1170
1446
  }
1171
- }, _callee);
1447
+ }, _callee3);
1172
1448
  }));
1173
1449
  return function parseModule(_x1, _x10) {
1174
1450
  return _ref3.apply(this, arguments);
1175
1451
  };
1176
1452
  }();
1177
1453
 
1454
+ /**
1455
+ * The text of every import and re-export statement in a chunk, and nothing
1456
+ * else, as one small module.
1457
+ *
1458
+ * A lexer finds them and the parser below reads only them. Parsing the whole
1459
+ * chunk was the most expensive thing left in a layer build: Val's server chunk
1460
+ * is 20 MB, and its syntax tree cost about 650 MB and 4 s to learn the dozen
1461
+ * statements at its top. The lexer knows strings, comments, template literals
1462
+ * and regular expressions, so a `from "mod"` inside a string is not a
1463
+ * statement -- which is the reason this is not a regular expression (see
1464
+ * above).
1465
+ *
1466
+ * Null when the lexer cannot read the chunk, and the caller parses all of it,
1467
+ * as it did before.
1468
+ */
1469
+ function importStatementsOf(_x11) {
1470
+ return _importStatementsOf.apply(this, arguments);
1471
+ }
1178
1472
  /** Every import and re-export a chunk emits, with the names it takes. */
1179
- function auditableImports(_x11, _x12) {
1473
+ function _importStatementsOf() {
1474
+ _importStatementsOf = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(code) {
1475
+ var _lexModule, _lexModule2, imports;
1476
+ return _regenerator().w(function (_context8) {
1477
+ while (1) switch (_context8.p = _context8.n) {
1478
+ case 0:
1479
+ _context8.n = 1;
1480
+ return init;
1481
+ case 1:
1482
+ _context8.p = 1;
1483
+ _lexModule = parse(code), _lexModule2 = _slicedToArray(_lexModule, 1), imports = _lexModule2[0];
1484
+ return _context8.a(2, imports.filter(function (entry) {
1485
+ return entry.t === ImportType.Static;
1486
+ }).map(function (entry) {
1487
+ return code.slice(entry.ss, entry.se);
1488
+ }).join(";\n"));
1489
+ case 2:
1490
+ _context8.p = 2;
1491
+ _context8.v;
1492
+ return _context8.a(2, null);
1493
+ }
1494
+ }, _callee7, null, [[1, 2]]);
1495
+ }));
1496
+ return _importStatementsOf.apply(this, arguments);
1497
+ }
1498
+ function auditableImports(_x12, _x13) {
1180
1499
  return _auditableImports.apply(this, arguments);
1181
1500
  }
1182
1501
  function _auditableImports() {
1183
- _auditableImports = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(code, file) {
1184
- var ast, imports, _iterator10, _step10, _statement$source, _statement$specifiers, statement, source, names, _iterator11, _step11, specifier, name, _name, _t5;
1185
- return _regenerator().w(function (_context5) {
1186
- while (1) switch (_context5.p = _context5.n) {
1502
+ _auditableImports = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(code, file) {
1503
+ var _yield$importStatemen;
1504
+ var ast, imports, _iterator12, _step12, _statement$source, _statement$specifiers, statement, source, names, _iterator13, _step13, specifier, name, _name, _t6, _t7, _t8, _t9, _t0;
1505
+ return _regenerator().w(function (_context9) {
1506
+ while (1) switch (_context9.p = _context9.n) {
1187
1507
  case 0:
1188
- _context5.n = 1;
1189
- return parseModule(code, file);
1508
+ _t6 = parseModule;
1509
+ _context9.n = 1;
1510
+ return importStatementsOf(code);
1190
1511
  case 1:
1191
- ast = _context5.v;
1192
- imports = [];
1193
- _iterator10 = _createForOfIteratorHelper(ast.body);
1194
- _context5.p = 2;
1195
- _iterator10.s();
1512
+ _t8 = _yield$importStatemen = _context9.v;
1513
+ _t7 = _t8 !== null;
1514
+ if (!_t7) {
1515
+ _context9.n = 2;
1516
+ break;
1517
+ }
1518
+ _t7 = _yield$importStatemen !== void 0;
1519
+ case 2:
1520
+ if (!_t7) {
1521
+ _context9.n = 3;
1522
+ break;
1523
+ }
1524
+ _t9 = _yield$importStatemen;
1525
+ _context9.n = 4;
1526
+ break;
1196
1527
  case 3:
1197
- if ((_step10 = _iterator10.n()).done) {
1198
- _context5.n = 7;
1528
+ _t9 = code;
1529
+ case 4:
1530
+ _context9.n = 5;
1531
+ return _t6(_t9, file);
1532
+ case 5:
1533
+ ast = _context9.v;
1534
+ imports = [];
1535
+ _iterator12 = _createForOfIteratorHelper(ast.body);
1536
+ _context9.p = 6;
1537
+ _iterator12.s();
1538
+ case 7:
1539
+ if ((_step12 = _iterator12.n()).done) {
1540
+ _context9.n = 11;
1199
1541
  break;
1200
1542
  }
1201
- statement = _step10.value;
1543
+ statement = _step12.value;
1202
1544
  if (!(statement.type !== "ImportDeclaration" && statement.type !== "ExportNamedDeclaration" && statement.type !== "ExportAllDeclaration")) {
1203
- _context5.n = 4;
1545
+ _context9.n = 8;
1204
1546
  break;
1205
1547
  }
1206
- return _context5.a(3, 6);
1207
- case 4:
1548
+ return _context9.a(3, 10);
1549
+ case 8:
1208
1550
  source = (_statement$source = statement.source) === null || _statement$source === void 0 ? void 0 : _statement$source.value;
1209
1551
  if (!(typeof source !== "string")) {
1210
- _context5.n = 5;
1552
+ _context9.n = 9;
1211
1553
  break;
1212
1554
  }
1213
- return _context5.a(3, 6);
1214
- case 5:
1555
+ return _context9.a(3, 10);
1556
+ case 9:
1215
1557
  names = [];
1216
- _iterator11 = _createForOfIteratorHelper((_statement$specifiers = statement.specifiers) !== null && _statement$specifiers !== void 0 ? _statement$specifiers : []);
1558
+ _iterator13 = _createForOfIteratorHelper((_statement$specifiers = statement.specifiers) !== null && _statement$specifiers !== void 0 ? _statement$specifiers : []);
1217
1559
  try {
1218
- for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
1219
- specifier = _step11.value;
1560
+ for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
1561
+ specifier = _step13.value;
1220
1562
  if (specifier.type === "ImportDefaultSpecifier") names.push("default");else if (specifier.type === "ImportSpecifier") {
1221
1563
  name = nameOf(specifier.imported);
1222
1564
  if (name) names.push(name);
@@ -1229,36 +1571,36 @@ function _auditableImports() {
1229
1571
  // whatever is there.
1230
1572
  }
1231
1573
  } catch (err) {
1232
- _iterator11.e(err);
1574
+ _iterator13.e(err);
1233
1575
  } finally {
1234
- _iterator11.f();
1576
+ _iterator13.f();
1235
1577
  }
1236
1578
  imports.push({
1237
1579
  source: source,
1238
1580
  names: names
1239
1581
  });
1240
- case 6:
1241
- _context5.n = 3;
1582
+ case 10:
1583
+ _context9.n = 7;
1242
1584
  break;
1243
- case 7:
1244
- _context5.n = 9;
1585
+ case 11:
1586
+ _context9.n = 13;
1245
1587
  break;
1246
- case 8:
1247
- _context5.p = 8;
1248
- _t5 = _context5.v;
1249
- _iterator10.e(_t5);
1250
- case 9:
1251
- _context5.p = 9;
1252
- _iterator10.f();
1253
- return _context5.f(9);
1254
- case 10:
1255
- return _context5.a(2, imports);
1588
+ case 12:
1589
+ _context9.p = 12;
1590
+ _t0 = _context9.v;
1591
+ _iterator12.e(_t0);
1592
+ case 13:
1593
+ _context9.p = 13;
1594
+ _iterator12.f();
1595
+ return _context9.f(13);
1596
+ case 14:
1597
+ return _context9.a(2, imports);
1256
1598
  }
1257
- }, _callee5, null, [[2, 8, 9, 10]]);
1599
+ }, _callee8, null, [[6, 12, 13, 14]]);
1258
1600
  }));
1259
1601
  return _auditableImports.apply(this, arguments);
1260
1602
  }
1261
- function auditableSpecifiers(_x13, _x14) {
1603
+ function auditableSpecifiers(_x14, _x15) {
1262
1604
  return _auditableSpecifiers.apply(this, arguments);
1263
1605
  }
1264
1606
 
@@ -1278,138 +1620,138 @@ function auditableSpecifiers(_x13, _x14) {
1278
1620
  * platform's.
1279
1621
  */
1280
1622
  function _auditableSpecifiers() {
1281
- _auditableSpecifiers = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(code, file) {
1282
- return _regenerator().w(function (_context6) {
1283
- while (1) switch (_context6.n) {
1623
+ _auditableSpecifiers = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(code, file) {
1624
+ return _regenerator().w(function (_context0) {
1625
+ while (1) switch (_context0.n) {
1284
1626
  case 0:
1285
- _context6.n = 1;
1627
+ _context0.n = 1;
1286
1628
  return auditableImports(code, file);
1287
1629
  case 1:
1288
- return _context6.a(2, _context6.v.map(function (entry) {
1630
+ return _context0.a(2, _context0.v.map(function (entry) {
1289
1631
  return entry.source;
1290
1632
  }));
1291
1633
  }
1292
- }, _callee6);
1634
+ }, _callee9);
1293
1635
  }));
1294
1636
  return _auditableSpecifiers.apply(this, arguments);
1295
1637
  }
1296
- function baseChunkExports(_x15, _x16, _x17) {
1638
+ function baseChunkExports(_x16, _x17, _x18) {
1297
1639
  return _baseChunkExports.apply(this, arguments);
1298
1640
  }
1299
1641
  function _baseChunkExports() {
1300
- _baseChunkExports = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(target, specifier, platform) {
1301
- var dist, _platform$base$export, chunk, chunks, listed, file, code, ast, exported, _iterator12, _step12, _declaration$id, _statement$specifiers2, _declaration$declarat, statement, _iterator13, _step13, specifierNode, name, declaration, _iterator14, _step14, _declarator$id, declarator, _t7;
1302
- return _regenerator().w(function (_context7) {
1303
- while (1) switch (_context7.p = _context7.n) {
1642
+ _baseChunkExports = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(target, specifier, platform) {
1643
+ var dist, _platform$base$export, chunk, chunks, listed, file, code, ast, exported, _iterator14, _step14, _declaration$id, _statement$specifiers2, _declaration$declarat, statement, _iterator15, _step15, specifierNode, name, declaration, _iterator16, _step16, _declarator$id, declarator, _t10;
1644
+ return _regenerator().w(function (_context1) {
1645
+ while (1) switch (_context1.p = _context1.n) {
1304
1646
  case 0:
1305
1647
  dist = platform.baseLayerDir;
1306
1648
  if (dist) {
1307
- _context7.n = 1;
1649
+ _context1.n = 1;
1308
1650
  break;
1309
1651
  }
1310
1652
  chunk = specifier.slice(target.baseFrom.length).replace(/\.js$/, "");
1311
1653
  chunks = (_platform$base$export = platform.base.exports) === null || _platform$base$export === void 0 ? void 0 : _platform$base$export[target.name]; // Own keys only: a chunk named like an Object.prototype member must not
1312
1654
  // read back a function.
1313
1655
  listed = chunks && Object.hasOwn(chunks, chunk) ? chunks[chunk] : undefined;
1314
- return _context7.a(2, listed ? new Set(listed) : null);
1656
+ return _context1.a(2, listed ? new Set(listed) : null);
1315
1657
  case 1:
1316
1658
  file = join(dist, target.name, "vendor", specifier.slice(target.baseFrom.length));
1317
- _context7.p = 2;
1318
- _context7.n = 3;
1659
+ _context1.p = 2;
1660
+ _context1.n = 3;
1319
1661
  return readFile(file, "utf8");
1320
1662
  case 3:
1321
- code = _context7.v;
1322
- _context7.n = 5;
1663
+ code = _context1.v;
1664
+ _context1.n = 5;
1323
1665
  break;
1324
1666
  case 4:
1325
- _context7.p = 4;
1326
- _context7.v;
1327
- return _context7.a(2, null);
1667
+ _context1.p = 4;
1668
+ _context1.v;
1669
+ return _context1.a(2, null);
1328
1670
  case 5:
1329
- _context7.n = 6;
1671
+ _context1.n = 6;
1330
1672
  return parseModule(code, file);
1331
1673
  case 6:
1332
- ast = _context7.v;
1674
+ ast = _context1.v;
1333
1675
  exported = new Set();
1334
- _iterator12 = _createForOfIteratorHelper(ast.body);
1335
- _context7.p = 7;
1336
- _iterator12.s();
1676
+ _iterator14 = _createForOfIteratorHelper(ast.body);
1677
+ _context1.p = 7;
1678
+ _iterator14.s();
1337
1679
  case 8:
1338
- if ((_step12 = _iterator12.n()).done) {
1339
- _context7.n = 13;
1680
+ if ((_step14 = _iterator14.n()).done) {
1681
+ _context1.n = 13;
1340
1682
  break;
1341
1683
  }
1342
- statement = _step12.value;
1684
+ statement = _step14.value;
1343
1685
  if (!(statement.type === "ExportAllDeclaration")) {
1344
- _context7.n = 9;
1686
+ _context1.n = 9;
1345
1687
  break;
1346
1688
  }
1347
- return _context7.a(2, null);
1689
+ return _context1.a(2, null);
1348
1690
  case 9:
1349
1691
  if (!(statement.type === "ExportDefaultDeclaration")) {
1350
- _context7.n = 10;
1692
+ _context1.n = 10;
1351
1693
  break;
1352
1694
  }
1353
1695
  exported.add("default");
1354
- return _context7.a(3, 12);
1696
+ return _context1.a(3, 12);
1355
1697
  case 10:
1356
1698
  if (!(statement.type !== "ExportNamedDeclaration")) {
1357
- _context7.n = 11;
1699
+ _context1.n = 11;
1358
1700
  break;
1359
1701
  }
1360
- return _context7.a(3, 12);
1702
+ return _context1.a(3, 12);
1361
1703
  case 11:
1362
- _iterator13 = _createForOfIteratorHelper((_statement$specifiers2 = statement.specifiers) !== null && _statement$specifiers2 !== void 0 ? _statement$specifiers2 : []);
1704
+ _iterator15 = _createForOfIteratorHelper((_statement$specifiers2 = statement.specifiers) !== null && _statement$specifiers2 !== void 0 ? _statement$specifiers2 : []);
1363
1705
  try {
1364
- for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
1365
- specifierNode = _step13.value;
1706
+ for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
1707
+ specifierNode = _step15.value;
1366
1708
  name = nameOf(specifierNode.exported);
1367
1709
  if (name) exported.add(name);
1368
1710
  }
1369
1711
  // `export const x = ...` / `export function x() {}`, which a hand-written
1370
1712
  // chunk can carry even though a bundled one usually does not.
1371
1713
  } catch (err) {
1372
- _iterator13.e(err);
1714
+ _iterator15.e(err);
1373
1715
  } finally {
1374
- _iterator13.f();
1716
+ _iterator15.f();
1375
1717
  }
1376
1718
  declaration = statement.declaration;
1377
1719
  if (declaration !== null && declaration !== void 0 && (_declaration$id = declaration.id) !== null && _declaration$id !== void 0 && _declaration$id.name) exported.add(declaration.id.name);
1378
- _iterator14 = _createForOfIteratorHelper((_declaration$declarat = declaration === null || declaration === void 0 ? void 0 : declaration.declarations) !== null && _declaration$declarat !== void 0 ? _declaration$declarat : []);
1720
+ _iterator16 = _createForOfIteratorHelper((_declaration$declarat = declaration === null || declaration === void 0 ? void 0 : declaration.declarations) !== null && _declaration$declarat !== void 0 ? _declaration$declarat : []);
1379
1721
  try {
1380
- for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
1381
- declarator = _step14.value;
1722
+ for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
1723
+ declarator = _step16.value;
1382
1724
  if (((_declarator$id = declarator.id) === null || _declarator$id === void 0 ? void 0 : _declarator$id.type) === "Identifier" && declarator.id.name) {
1383
1725
  exported.add(declarator.id.name);
1384
1726
  }
1385
1727
  }
1386
1728
  } catch (err) {
1387
- _iterator14.e(err);
1729
+ _iterator16.e(err);
1388
1730
  } finally {
1389
- _iterator14.f();
1731
+ _iterator16.f();
1390
1732
  }
1391
1733
  case 12:
1392
- _context7.n = 8;
1734
+ _context1.n = 8;
1393
1735
  break;
1394
1736
  case 13:
1395
- _context7.n = 15;
1737
+ _context1.n = 15;
1396
1738
  break;
1397
1739
  case 14:
1398
- _context7.p = 14;
1399
- _t7 = _context7.v;
1400
- _iterator12.e(_t7);
1740
+ _context1.p = 14;
1741
+ _t10 = _context1.v;
1742
+ _iterator14.e(_t10);
1401
1743
  case 15:
1402
- _context7.p = 15;
1403
- _iterator12.f();
1404
- return _context7.f(15);
1744
+ _context1.p = 15;
1745
+ _iterator14.f();
1746
+ return _context1.f(15);
1405
1747
  case 16:
1406
- return _context7.a(2, exported);
1748
+ return _context1.a(2, exported);
1407
1749
  }
1408
- }, _callee7, null, [[7, 14, 15, 16], [2, 4]]);
1750
+ }, _callee0, null, [[7, 14, 15, 16], [2, 4]]);
1409
1751
  }));
1410
1752
  return _baseChunkExports.apply(this, arguments);
1411
1753
  }
1412
- function auditImports(_x18, _x19, _x20, _x21) {
1754
+ function auditImports(_x19, _x20, _x21, _x22) {
1413
1755
  return _auditImports.apply(this, arguments);
1414
1756
  }
1415
1757
  /**
@@ -1439,62 +1781,62 @@ function auditImports(_x18, _x19, _x20, _x21) {
1439
1781
  * endpoint answers 500 forever.
1440
1782
  */
1441
1783
  function _auditImports() {
1442
- _auditImports = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(target, file, code, platform) {
1443
- var _iterator15, _step15, _step15$value, specifier, names, intoBase, intoSelf, builtin, _t8, _t9;
1444
- return _regenerator().w(function (_context8) {
1445
- while (1) switch (_context8.p = _context8.n) {
1784
+ _auditImports = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(target, file, code, platform) {
1785
+ var _iterator17, _step17, _step17$value, specifier, names, intoBase, intoSelf, builtin, _t11, _t12;
1786
+ return _regenerator().w(function (_context10) {
1787
+ while (1) switch (_context10.p = _context10.n) {
1446
1788
  case 0:
1447
- _t8 = _createForOfIteratorHelper;
1448
- _context8.n = 1;
1789
+ _t11 = _createForOfIteratorHelper;
1790
+ _context10.n = 1;
1449
1791
  return auditableImports(code, file);
1450
1792
  case 1:
1451
- _iterator15 = _t8(_context8.v);
1452
- _context8.p = 2;
1453
- _iterator15.s();
1793
+ _iterator17 = _t11(_context10.v);
1794
+ _context10.p = 2;
1795
+ _iterator17.s();
1454
1796
  case 3:
1455
- if ((_step15 = _iterator15.n()).done) {
1456
- _context8.n = 6;
1797
+ if ((_step17 = _iterator17.n()).done) {
1798
+ _context10.n = 6;
1457
1799
  break;
1458
1800
  }
1459
- _step15$value = _step15.value, specifier = _step15$value.source, names = _step15$value.names;
1801
+ _step17$value = _step17.value, specifier = _step17$value.source, names = _step17$value.names;
1460
1802
  intoBase = specifier.startsWith(target.baseFrom);
1461
1803
  intoSelf = specifier.startsWith("./") || specifier.startsWith("../pvendor/"); // Only the worker target: a browser has no Node builtins, and a chunk that
1462
1804
  // reached for one there is a genuine error rather than a runtime import.
1463
1805
  builtin = target.name === "worker" && isRuntimeBuiltin(specifier);
1464
1806
  if (!(!intoBase && !intoSelf && !builtin)) {
1465
- _context8.n = 4;
1807
+ _context10.n = 4;
1466
1808
  break;
1467
1809
  }
1468
1810
  throw new Error("".concat(target.name, "/").concat(file, " imports '").concat(specifier, "', which is neither a base-layer chunk, ") + "a sibling, nor a Node builtin the runtime provides. It would be an unresolvable " + "bare specifier in the isolate.");
1469
1811
  case 4:
1470
1812
  if (!(intoBase && names.length)) {
1471
- _context8.n = 5;
1813
+ _context10.n = 5;
1472
1814
  break;
1473
1815
  }
1474
- _context8.n = 5;
1816
+ _context10.n = 5;
1475
1817
  return auditBaseExports(target, file, specifier, names, platform);
1476
1818
  case 5:
1477
- _context8.n = 3;
1819
+ _context10.n = 3;
1478
1820
  break;
1479
1821
  case 6:
1480
- _context8.n = 8;
1822
+ _context10.n = 8;
1481
1823
  break;
1482
1824
  case 7:
1483
- _context8.p = 7;
1484
- _t9 = _context8.v;
1485
- _iterator15.e(_t9);
1825
+ _context10.p = 7;
1826
+ _t12 = _context10.v;
1827
+ _iterator17.e(_t12);
1486
1828
  case 8:
1487
- _context8.p = 8;
1488
- _iterator15.f();
1489
- return _context8.f(8);
1829
+ _context10.p = 8;
1830
+ _iterator17.f();
1831
+ return _context10.f(8);
1490
1832
  case 9:
1491
- return _context8.a(2);
1833
+ return _context10.a(2);
1492
1834
  }
1493
- }, _callee8, null, [[2, 7, 8, 9]]);
1835
+ }, _callee1, null, [[2, 7, 8, 9]]);
1494
1836
  }));
1495
1837
  return _auditImports.apply(this, arguments);
1496
1838
  }
1497
- function auditBaseExports(_x22, _x23, _x24, _x25, _x26) {
1839
+ function auditBaseExports(_x23, _x24, _x25, _x26, _x27) {
1498
1840
  return _auditBaseExports.apply(this, arguments);
1499
1841
  }
1500
1842
  /**
@@ -1506,48 +1848,48 @@ function auditBaseExports(_x22, _x23, _x24, _x25, _x26) {
1506
1848
  * pull a package in.
1507
1849
  */
1508
1850
  function _auditBaseExports() {
1509
- _auditBaseExports = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(target, file, specifier, names, platform) {
1851
+ _auditBaseExports = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(target, file, specifier, names, platform) {
1510
1852
  var exported, missing;
1511
- return _regenerator().w(function (_context9) {
1512
- while (1) switch (_context9.n) {
1853
+ return _regenerator().w(function (_context11) {
1854
+ while (1) switch (_context11.n) {
1513
1855
  case 0:
1514
- _context9.n = 1;
1856
+ _context11.n = 1;
1515
1857
  return baseChunkExports(target, specifier, platform);
1516
1858
  case 1:
1517
- exported = _context9.v;
1859
+ exported = _context11.v;
1518
1860
  if (exported) {
1519
- _context9.n = 2;
1861
+ _context11.n = 2;
1520
1862
  break;
1521
1863
  }
1522
- return _context9.a(2);
1864
+ return _context11.a(2);
1523
1865
  case 2:
1524
1866
  missing = names.filter(function (name) {
1525
1867
  return !exported.has(name);
1526
1868
  });
1527
1869
  if (!(missing.length === 0)) {
1528
- _context9.n = 3;
1870
+ _context11.n = 3;
1529
1871
  break;
1530
1872
  }
1531
- return _context9.a(2);
1873
+ return _context11.a(2);
1532
1874
  case 3:
1533
1875
  throw new Error("".concat(target.name, "/").concat(file, " imports ").concat(missing.map(function (name) {
1534
1876
  return "'".concat(name, "'");
1535
1877
  }).join(", "), " from ") + "'".concat(specifier, "', which the base layer does not export. The base layer is built from the ") + "platform's pinned versions (packages/vendor/package.json, and PINS.md for why they are " + "exact), so this is a project resolving a version of that package which disagrees with " + "the platform's. It would link in the isolate only until something imported it, and then " + "throw \"does not provide an export named '".concat(missing[0], "'\"."));
1536
1878
  case 4:
1537
- return _context9.a(2);
1879
+ return _context11.a(2);
1538
1880
  }
1539
- }, _callee9);
1881
+ }, _callee10);
1540
1882
  }));
1541
1883
  return _auditBaseExports.apply(this, arguments);
1542
1884
  }
1543
1885
  function cssImportSpecifiersOf(css) {
1544
1886
  var found = [];
1545
1887
  var code = css.replace(/\/\*[\s\S]*?\*\//g, "");
1546
- var _iterator2 = _createForOfIteratorHelper(code.matchAll(/@import\s+(?:url\(\s*)?(["'])([^"']+)\1/g)),
1547
- _step2;
1888
+ var _iterator4 = _createForOfIteratorHelper(code.matchAll(/@import\s+(?:url\(\s*)?(["'])([^"']+)\1/g)),
1889
+ _step4;
1548
1890
  try {
1549
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
1550
- var match = _step2.value;
1891
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
1892
+ var match = _step4.value;
1551
1893
  var specifier = match[2];
1552
1894
  if (/^[./]/.test(specifier)) continue;
1553
1895
  if (/^tailwindcss(\/|$)/.test(specifier)) continue;
@@ -1555,9 +1897,9 @@ function cssImportSpecifiersOf(css) {
1555
1897
  found.push(specifier);
1556
1898
  }
1557
1899
  } catch (err) {
1558
- _iterator2.e(err);
1900
+ _iterator4.e(err);
1559
1901
  } finally {
1560
- _iterator2.f();
1902
+ _iterator4.f();
1561
1903
  }
1562
1904
  return found;
1563
1905
  }
@@ -1568,37 +1910,37 @@ function cssImportSpecifiersOf(css) {
1568
1910
  */
1569
1911
  function cssSpecifiersOf(files) {
1570
1912
  var found = new Set();
1571
- for (var _i = 0, _Object$entries = Object.entries(files); _i < _Object$entries.length; _i++) {
1572
- var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
1913
+ for (var _i2 = 0, _Object$entries = Object.entries(files); _i2 < _Object$entries.length; _i2++) {
1914
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i2], 2),
1573
1915
  path = _Object$entries$_i[0],
1574
1916
  code = _Object$entries$_i[1];
1575
1917
  if (/\.css$/.test(path)) {
1576
- var _iterator3 = _createForOfIteratorHelper(cssImportSpecifiersOf(code)),
1577
- _step3;
1918
+ var _iterator5 = _createForOfIteratorHelper(cssImportSpecifiersOf(code)),
1919
+ _step5;
1578
1920
  try {
1579
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
1580
- var specifier = _step3.value;
1921
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
1922
+ var specifier = _step5.value;
1581
1923
  found.add(specifier);
1582
1924
  }
1583
1925
  } catch (err) {
1584
- _iterator3.e(err);
1926
+ _iterator5.e(err);
1585
1927
  } finally {
1586
- _iterator3.f();
1928
+ _iterator5.f();
1587
1929
  }
1588
1930
  continue;
1589
1931
  }
1590
1932
  if (!/\.(tsx?|jsx?|mjs|cjs)$/.test(path)) continue;
1591
- var _iterator4 = _createForOfIteratorHelper(code.matchAll(/(?:from|import)\s*["']([^"'.][^"']*\.css)["']/g)),
1592
- _step4;
1933
+ var _iterator6 = _createForOfIteratorHelper(code.matchAll(/(?:from|import)\s*["']([^"'.][^"']*\.css)["']/g)),
1934
+ _step6;
1593
1935
  try {
1594
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
1595
- var match = _step4.value;
1936
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
1937
+ var match = _step6.value;
1596
1938
  found.add(match[1]);
1597
1939
  }
1598
1940
  } catch (err) {
1599
- _iterator4.e(err);
1941
+ _iterator6.e(err);
1600
1942
  } finally {
1601
- _iterator4.f();
1943
+ _iterator6.f();
1602
1944
  }
1603
1945
  }
1604
1946
  return _toConsumableArray(found);
@@ -1618,24 +1960,24 @@ function importedSpecifiers(files) {
1618
1960
  // positive costs one unused chunk; the builder's own resolver is what
1619
1961
  // actually decides, and it reports anything this missed.
1620
1962
  var IMPORT = /(?:from|import)\s*["']([^"'.][^"']*)["']|import\s*\(\s*["']([^"'.][^"']*)["']/g;
1621
- for (var _i2 = 0, _Object$entries2 = Object.entries(files); _i2 < _Object$entries2.length; _i2++) {
1622
- var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
1963
+ for (var _i3 = 0, _Object$entries2 = Object.entries(files); _i3 < _Object$entries2.length; _i3++) {
1964
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i3], 2),
1623
1965
  path = _Object$entries2$_i[0],
1624
1966
  code = _Object$entries2$_i[1];
1625
1967
  if (!/\.(tsx?|jsx?|mjs|cjs)$/.test(path)) continue;
1626
- var _iterator5 = _createForOfIteratorHelper(code.matchAll(IMPORT)),
1627
- _step5;
1968
+ var _iterator7 = _createForOfIteratorHelper(code.matchAll(IMPORT)),
1969
+ _step7;
1628
1970
  try {
1629
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
1971
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
1630
1972
  var _match$;
1631
- var match = _step5.value;
1973
+ var match = _step7.value;
1632
1974
  var specifier = (_match$ = match[1]) !== null && _match$ !== void 0 ? _match$ : match[2];
1633
1975
  if (specifier && !specifier.startsWith("#")) found.add(specifier);
1634
1976
  }
1635
1977
  } catch (err) {
1636
- _iterator5.e(err);
1978
+ _iterator7.e(err);
1637
1979
  } finally {
1638
- _iterator5.f();
1980
+ _iterator7.f();
1639
1981
  }
1640
1982
  }
1641
1983
  return found;
@@ -1667,11 +2009,11 @@ function layerDepsOf(manifest) {
1667
2009
  // collectDependencyCss; building them as code entries fails, because a
1668
2010
  // package like that may have no JS entry point at all.
1669
2011
  var cssOnly = new Set();
1670
- var _iterator6 = _createForOfIteratorHelper(importedSpecifiers(files)),
1671
- _step6;
2012
+ var _iterator8 = _createForOfIteratorHelper(importedSpecifiers(files)),
2013
+ _step8;
1672
2014
  try {
1673
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
1674
- var specifier = _step6.value;
2015
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
2016
+ var specifier = _step8.value;
1675
2017
  var pkg = packageOf(specifier);
1676
2018
  if (!declared.has(pkg) || BASE_PROVIDED.has(pkg)) continue;
1677
2019
  if (specifier.endsWith(".css")) {
@@ -1684,48 +2026,48 @@ function layerDepsOf(manifest) {
1684
2026
  // and its files, with no JS entry to build. Left in, it is built as code,
1685
2027
  // fails, and is reported as skipped on every publish.
1686
2028
  } catch (err) {
1687
- _iterator6.e(err);
2029
+ _iterator8.e(err);
1688
2030
  } finally {
1689
- _iterator6.f();
2031
+ _iterator8.f();
1690
2032
  }
1691
- var _iterator7 = _createForOfIteratorHelper(cssSpecifiersOf(files)),
1692
- _step7;
2033
+ var _iterator9 = _createForOfIteratorHelper(cssSpecifiersOf(files)),
2034
+ _step9;
1693
2035
  try {
1694
2036
  var _loop = function _loop() {
1695
- var specifier = _step7.value;
2037
+ var specifier = _step9.value;
1696
2038
  var pkg = packageOf(specifier);
1697
2039
  if (declared.has(pkg) && !_toConsumableArray(specifiers).some(function (s) {
1698
2040
  return packageOf(s) === pkg;
1699
2041
  })) cssOnly.add(pkg);
1700
2042
  };
1701
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
2043
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
1702
2044
  _loop();
1703
2045
  }
1704
2046
 
1705
2047
  // A declared dependency nothing imports still gets an entry, so that a
1706
2048
  // project can add one and import it from the studio without a CI round-trip.
1707
2049
  } catch (err) {
1708
- _iterator7.e(err);
2050
+ _iterator9.e(err);
1709
2051
  } finally {
1710
- _iterator7.f();
2052
+ _iterator9.f();
1711
2053
  }
1712
- var _iterator8 = _createForOfIteratorHelper(declared),
1713
- _step8;
2054
+ var _iterator0 = _createForOfIteratorHelper(declared),
2055
+ _step0;
1714
2056
  try {
1715
2057
  var _loop2 = function _loop2() {
1716
- var name = _step8.value;
2058
+ var name = _step0.value;
1717
2059
  if (cssOnly.has(name)) return 1; // continue
1718
2060
  if (!_toConsumableArray(specifiers).some(function (specifier) {
1719
2061
  return packageOf(specifier) === name;
1720
2062
  })) specifiers.add(name);
1721
2063
  };
1722
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
2064
+ for (_iterator0.s(); !(_step0 = _iterator0.n()).done;) {
1723
2065
  if (_loop2()) continue;
1724
2066
  }
1725
2067
  } catch (err) {
1726
- _iterator8.e(err);
2068
+ _iterator0.e(err);
1727
2069
  } finally {
1728
- _iterator8.f();
2070
+ _iterator0.f();
1729
2071
  }
1730
2072
  return _toConsumableArray(specifiers).sort();
1731
2073
  }
@@ -1756,13 +2098,13 @@ var STUB_DIR = ".platform-vendor-stubs";
1756
2098
  * into the project's stylesheet by the builder's CSS pass. Resolution is the
1757
2099
  * project's own, so the version matches whatever its lockfile pinned.
1758
2100
  */
1759
- function collectDependencyCss(_x27, _x28, _x29) {
2101
+ function collectDependencyCss(_x28, _x29, _x30) {
1760
2102
  return _collectDependencyCss.apply(this, arguments);
1761
2103
  }
1762
2104
 
1763
2105
  /** `url(...)` with a relative target, quoted or not. */
1764
2106
  function _collectDependencyCss() {
1765
- _collectDependencyCss = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(dir, specifiers,
2107
+ _collectDependencyCss = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(dir, specifiers,
1766
2108
  /**
1767
2109
  * Where the files a stylesheet points at with `url(...)` go, base64, keyed
1768
2110
  * by the content-addressed name the rewritten `url()` now uses. Pass it to
@@ -1772,65 +2114,65 @@ function _collectDependencyCss() {
1772
2114
  * in one -- every font package's -- points at nothing once it is served.
1773
2115
  */
1774
2116
  assets) {
1775
- var require, css, _iterator16, _step16, specifier, file, _t1;
1776
- return _regenerator().w(function (_context0) {
1777
- while (1) switch (_context0.p = _context0.n) {
2117
+ var require, css, _iterator18, _step18, specifier, file, _t14;
2118
+ return _regenerator().w(function (_context12) {
2119
+ while (1) switch (_context12.p = _context12.n) {
1778
2120
  case 0:
1779
2121
  if (!(specifiers.length === 0)) {
1780
- _context0.n = 1;
2122
+ _context12.n = 1;
1781
2123
  break;
1782
2124
  }
1783
- return _context0.a(2, {});
2125
+ return _context12.a(2, {});
1784
2126
  case 1:
1785
2127
  require = createRequire(join(resolve(dir), "package.json"));
1786
2128
  css = {};
1787
- _iterator16 = _createForOfIteratorHelper(specifiers);
1788
- _context0.p = 2;
1789
- _iterator16.s();
2129
+ _iterator18 = _createForOfIteratorHelper(specifiers);
2130
+ _context12.p = 2;
2131
+ _iterator18.s();
1790
2132
  case 3:
1791
- if ((_step16 = _iterator16.n()).done) {
1792
- _context0.n = 10;
2133
+ if ((_step18 = _iterator18.n()).done) {
2134
+ _context12.n = 10;
1793
2135
  break;
1794
2136
  }
1795
- specifier = _step16.value;
2137
+ specifier = _step18.value;
1796
2138
  file = void 0;
1797
- _context0.p = 4;
2139
+ _context12.p = 4;
1798
2140
  file = require.resolve(specifier);
1799
- _context0.n = 6;
2141
+ _context12.n = 6;
1800
2142
  break;
1801
2143
  case 5:
1802
- _context0.p = 5;
1803
- _context0.v;
1804
- return _context0.a(3, 9);
2144
+ _context12.p = 5;
2145
+ _context12.v;
2146
+ return _context12.a(3, 9);
1805
2147
  case 6:
1806
2148
  if (file.endsWith(".css")) {
1807
- _context0.n = 7;
2149
+ _context12.n = 7;
1808
2150
  break;
1809
2151
  }
1810
- return _context0.a(3, 9);
2152
+ return _context12.a(3, 9);
1811
2153
  case 7:
1812
- _context0.n = 8;
2154
+ _context12.n = 8;
1813
2155
  return readDependencyStylesheet(file, assets, new Set());
1814
2156
  case 8:
1815
- css[specifier] = _context0.v;
2157
+ css[specifier] = _context12.v;
1816
2158
  case 9:
1817
- _context0.n = 3;
2159
+ _context12.n = 3;
1818
2160
  break;
1819
2161
  case 10:
1820
- _context0.n = 12;
2162
+ _context12.n = 12;
1821
2163
  break;
1822
2164
  case 11:
1823
- _context0.p = 11;
1824
- _t1 = _context0.v;
1825
- _iterator16.e(_t1);
2165
+ _context12.p = 11;
2166
+ _t14 = _context12.v;
2167
+ _iterator18.e(_t14);
1826
2168
  case 12:
1827
- _context0.p = 12;
1828
- _iterator16.f();
1829
- return _context0.f(12);
2169
+ _context12.p = 12;
2170
+ _iterator18.f();
2171
+ return _context12.f(12);
1830
2172
  case 13:
1831
- return _context0.a(2, css);
2173
+ return _context12.a(2, css);
1832
2174
  }
1833
- }, _callee0, null, [[4, 5], [2, 11, 12, 13]]);
2175
+ }, _callee11, null, [[4, 5], [2, 11, 12, 13]]);
1834
2176
  }));
1835
2177
  return _collectDependencyCss.apply(this, arguments);
1836
2178
  }
@@ -1845,150 +2187,150 @@ var RELATIVE_URL = /url\(\s*(["']?)(?![a-z]+:|\/|#)([^"')]+)\1\s*\)/gi;
1845
2187
  * Names follow `resolveAsset`'s: the first 16 hex of the base64's SHA-256, and
1846
2188
  * the file's own extension.
1847
2189
  */
1848
- function readDependencyStylesheet(_x30, _x31, _x32) {
2190
+ function readDependencyStylesheet(_x31, _x32, _x33) {
1849
2191
  return _readDependencyStylesheet.apply(this, arguments);
1850
2192
  }
1851
2193
  function _readDependencyStylesheet() {
1852
- _readDependencyStylesheet = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(file, assets, seen) {
1853
- var base, css, imports, _iterator17, _step17, match, target, inlined, rewrites, _iterator18, _step18, _match, reference, path, base64, hash, name, _t10, _t11, _t13;
1854
- return _regenerator().w(function (_context1) {
1855
- while (1) switch (_context1.p = _context1.n) {
2194
+ _readDependencyStylesheet = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(file, assets, seen) {
2195
+ var base, css, imports, _iterator19, _step19, match, target, inlined, rewrites, _iterator20, _step20, _match, reference, path, base64, hash, name, _t15, _t16, _t18;
2196
+ return _regenerator().w(function (_context13) {
2197
+ while (1) switch (_context13.p = _context13.n) {
1856
2198
  case 0:
1857
2199
  seen.add(file);
1858
2200
  base = dirname(file);
1859
- _context1.n = 1;
2201
+ _context13.n = 1;
1860
2202
  return readFile(file, "utf8");
1861
2203
  case 1:
1862
- css = _context1.v;
2204
+ css = _context13.v;
1863
2205
  imports = _toConsumableArray(css.matchAll(/@import\s+(?:url\(\s*)?(["'])(\.{1,2}\/[^"']+)\1[^;]*;/g));
1864
- _iterator17 = _createForOfIteratorHelper(imports);
1865
- _context1.p = 2;
1866
- _iterator17.s();
2206
+ _iterator19 = _createForOfIteratorHelper(imports);
2207
+ _context13.p = 2;
2208
+ _iterator19.s();
1867
2209
  case 3:
1868
- if ((_step17 = _iterator17.n()).done) {
1869
- _context1.n = 8;
2210
+ if ((_step19 = _iterator19.n()).done) {
2211
+ _context13.n = 8;
1870
2212
  break;
1871
2213
  }
1872
- match = _step17.value;
2214
+ match = _step19.value;
1873
2215
  target = join(base, match[2]);
1874
2216
  if (!seen.has(target)) {
1875
- _context1.n = 4;
2217
+ _context13.n = 4;
1876
2218
  break;
1877
2219
  }
1878
- _t10 = "";
1879
- _context1.n = 6;
2220
+ _t15 = "";
2221
+ _context13.n = 6;
1880
2222
  break;
1881
2223
  case 4:
1882
- _context1.n = 5;
2224
+ _context13.n = 5;
1883
2225
  return readDependencyStylesheet(target, assets, seen)["catch"](function () {
1884
2226
  return null;
1885
2227
  });
1886
2228
  case 5:
1887
- _t10 = _context1.v;
2229
+ _t15 = _context13.v;
1888
2230
  case 6:
1889
- inlined = _t10;
2231
+ inlined = _t15;
1890
2232
  // A missing file stays an import, so the builder names it.
1891
2233
  if (inlined !== null) css = css.replace(match[0], inlined);
1892
2234
  case 7:
1893
- _context1.n = 3;
2235
+ _context13.n = 3;
1894
2236
  break;
1895
2237
  case 8:
1896
- _context1.n = 10;
2238
+ _context13.n = 10;
1897
2239
  break;
1898
2240
  case 9:
1899
- _context1.p = 9;
1900
- _t11 = _context1.v;
1901
- _iterator17.e(_t11);
2241
+ _context13.p = 9;
2242
+ _t16 = _context13.v;
2243
+ _iterator19.e(_t16);
1902
2244
  case 10:
1903
- _context1.p = 10;
1904
- _iterator17.f();
1905
- return _context1.f(10);
2245
+ _context13.p = 10;
2246
+ _iterator19.f();
2247
+ return _context13.f(10);
1906
2248
  case 11:
1907
2249
  if (assets) {
1908
- _context1.n = 12;
2250
+ _context13.n = 12;
1909
2251
  break;
1910
2252
  }
1911
- return _context1.a(2, css);
2253
+ return _context13.a(2, css);
1912
2254
  case 12:
1913
2255
  rewrites = new Map();
1914
- _iterator18 = _createForOfIteratorHelper(css.matchAll(RELATIVE_URL));
1915
- _context1.p = 13;
1916
- _iterator18.s();
2256
+ _iterator20 = _createForOfIteratorHelper(css.matchAll(RELATIVE_URL));
2257
+ _context13.p = 13;
2258
+ _iterator20.s();
1917
2259
  case 14:
1918
- if ((_step18 = _iterator18.n()).done) {
1919
- _context1.n = 21;
2260
+ if ((_step20 = _iterator20.n()).done) {
2261
+ _context13.n = 21;
1920
2262
  break;
1921
2263
  }
1922
- _match = _step18.value;
2264
+ _match = _step20.value;
1923
2265
  reference = _match[2].trim();
1924
2266
  if (!rewrites.has(reference)) {
1925
- _context1.n = 15;
2267
+ _context13.n = 15;
1926
2268
  break;
1927
2269
  }
1928
- return _context1.a(3, 20);
2270
+ return _context13.a(3, 20);
1929
2271
  case 15:
1930
2272
  path = join(base, reference.split(/[?#]/)[0]);
1931
2273
  base64 = void 0;
1932
- _context1.p = 16;
1933
- _context1.n = 17;
2274
+ _context13.p = 16;
2275
+ _context13.n = 17;
1934
2276
  return readFile(path);
1935
2277
  case 17:
1936
- base64 = _context1.v.toString("base64");
1937
- _context1.n = 19;
2278
+ base64 = _context13.v.toString("base64");
2279
+ _context13.n = 19;
1938
2280
  break;
1939
2281
  case 18:
1940
- _context1.p = 18;
1941
- _context1.v;
1942
- return _context1.a(3, 20);
2282
+ _context13.p = 18;
2283
+ _context13.v;
2284
+ return _context13.a(3, 20);
1943
2285
  case 19:
1944
2286
  hash = createHash("sha256").update(base64).digest("hex").slice(0, 16);
1945
2287
  name = "".concat(hash).concat(extname(path).toLowerCase());
1946
2288
  assets[name] = base64;
1947
2289
  rewrites.set(reference, "".concat(ASSET_BASE).concat(name));
1948
2290
  case 20:
1949
- _context1.n = 14;
2291
+ _context13.n = 14;
1950
2292
  break;
1951
2293
  case 21:
1952
- _context1.n = 23;
2294
+ _context13.n = 23;
1953
2295
  break;
1954
2296
  case 22:
1955
- _context1.p = 22;
1956
- _t13 = _context1.v;
1957
- _iterator18.e(_t13);
2297
+ _context13.p = 22;
2298
+ _t18 = _context13.v;
2299
+ _iterator20.e(_t18);
1958
2300
  case 23:
1959
- _context1.p = 23;
1960
- _iterator18.f();
1961
- return _context1.f(23);
2301
+ _context13.p = 23;
2302
+ _iterator20.f();
2303
+ return _context13.f(23);
1962
2304
  case 24:
1963
- return _context1.a(2, css.replace(RELATIVE_URL, function (whole, _quote, reference) {
2305
+ return _context13.a(2, css.replace(RELATIVE_URL, function (whole, _quote, reference) {
1964
2306
  var url = rewrites.get(reference.trim());
1965
2307
  return url ? "url(".concat(url, ")") : whole;
1966
2308
  }));
1967
2309
  }
1968
- }, _callee1, null, [[16, 18], [13, 22, 23, 24], [2, 9, 10, 11]]);
2310
+ }, _callee12, null, [[16, 18], [13, 22, 23, 24], [2, 9, 10, 11]]);
1969
2311
  }));
1970
2312
  return _readDependencyStylesheet.apply(this, arguments);
1971
2313
  }
1972
- function buildVendorLayer(_x33, _x34, _x35, _x36) {
2314
+ function buildVendorLayer(_x34, _x35, _x36, _x37) {
1973
2315
  return _buildVendorLayer.apply(this, arguments);
1974
2316
  }
1975
2317
  function _buildVendorLayer() {
1976
- _buildVendorLayer = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(dir, deps, css, platform) {
1977
- var modules, _iterator19, _step19, _loop3, stubs, input, _i4, _Object$entries3, _Object$entries3$_i, specifier, name, file, skipped, workerOnly, workerOnlyReasons, specifierOf, usable, built, _i5, _Object$values, _name2, worked, reasons, _iterator20, _step20, target, _message, _reasons$, _i6, _Object$entries4, _Object$entries4$_i, _specifier, _name3, _t14, _t15, _t16;
1978
- return _regenerator().w(function (_context11) {
1979
- while (1) switch (_context11.p = _context11.n) {
2318
+ _buildVendorLayer = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(dir, deps, css, platform) {
2319
+ var modules, _iterator21, _step21, _loop4, stubs, input, _i6, _Object$entries4, _Object$entries4$_i, specifier, name, file, skipped, workerOnly, workerOnlyReasons, specifierOf, usable, built, _i7, _Object$values, _name2, worked, reasons, _iterator22, _step22, target, _probe$unusable$_name, probe, unbundlable, _message, _reasons$, _i8, _Object$entries5, _Object$entries5$_i, _specifier, _name3, _i9, _Object$entries6, _Object$entries6$_i, _specifier2, _name4, reason, _i0, _Object$entries7, _Object$entries7$_i, _specifier3, _name5, _reason, _t19, _t20, _t21;
2320
+ return _regenerator().w(function (_context15) {
2321
+ while (1) switch (_context15.p = _context15.n) {
1980
2322
  case 0:
1981
2323
  if (!(deps.length === 0 && Object.keys(css).length === 0)) {
1982
- _context11.n = 1;
2324
+ _context15.n = 1;
1983
2325
  break;
1984
2326
  }
1985
- return _context11.a(2, null);
2327
+ return _context15.a(2, null);
1986
2328
  case 1:
1987
2329
  if (!(deps.length === 0)) {
1988
- _context11.n = 2;
2330
+ _context15.n = 2;
1989
2331
  break;
1990
2332
  }
1991
- return _context11.a(2, {
2333
+ return _context15.a(2, {
1992
2334
  rev: cssRev(css),
1993
2335
  modules: {},
1994
2336
  worker: {},
@@ -2000,14 +2342,14 @@ function _buildVendorLayer() {
2000
2342
  });
2001
2343
  case 2:
2002
2344
  modules = {};
2003
- _iterator19 = _createForOfIteratorHelper(deps);
2004
- _context11.p = 3;
2005
- _loop3 = /*#__PURE__*/_regenerator().m(function _loop3() {
2345
+ _iterator21 = _createForOfIteratorHelper(deps);
2346
+ _context15.p = 3;
2347
+ _loop4 = /*#__PURE__*/_regenerator().m(function _loop4() {
2006
2348
  var specifier, name, clash;
2007
- return _regenerator().w(function (_context10) {
2008
- while (1) switch (_context10.n) {
2349
+ return _regenerator().w(function (_context14) {
2350
+ while (1) switch (_context14.n) {
2009
2351
  case 0:
2010
- specifier = _step19.value;
2352
+ specifier = _step21.value;
2011
2353
  name = chunkNameFor(specifier);
2012
2354
  clash = Object.entries(modules).find(function (_ref10) {
2013
2355
  var _ref11 = _slicedToArray(_ref10, 2),
@@ -2015,38 +2357,38 @@ function _buildVendorLayer() {
2015
2357
  return existing === name;
2016
2358
  });
2017
2359
  if (!clash) {
2018
- _context10.n = 1;
2360
+ _context14.n = 1;
2019
2361
  break;
2020
2362
  }
2021
2363
  throw new Error("'".concat(specifier, "' and '").concat(clash[0], "' both map to the chunk name '").concat(name, "'. ") + "Rename is not an option, so this needs chunkNameFor to disambiguate.");
2022
2364
  case 1:
2023
2365
  modules[specifier] = name;
2024
2366
  case 2:
2025
- return _context10.a(2);
2367
+ return _context14.a(2);
2026
2368
  }
2027
- }, _loop3);
2369
+ }, _loop4);
2028
2370
  });
2029
- _iterator19.s();
2371
+ _iterator21.s();
2030
2372
  case 4:
2031
- if ((_step19 = _iterator19.n()).done) {
2032
- _context11.n = 6;
2373
+ if ((_step21 = _iterator21.n()).done) {
2374
+ _context15.n = 6;
2033
2375
  break;
2034
2376
  }
2035
- return _context11.d(_regeneratorValues(_loop3()), 5);
2377
+ return _context15.d(_regeneratorValues(_loop4()), 5);
2036
2378
  case 5:
2037
- _context11.n = 4;
2379
+ _context15.n = 4;
2038
2380
  break;
2039
2381
  case 6:
2040
- _context11.n = 8;
2382
+ _context15.n = 8;
2041
2383
  break;
2042
2384
  case 7:
2043
- _context11.p = 7;
2044
- _t14 = _context11.v;
2045
- _iterator19.e(_t14);
2385
+ _context15.p = 7;
2386
+ _t19 = _context15.v;
2387
+ _iterator21.e(_t19);
2046
2388
  case 8:
2047
- _context11.p = 8;
2048
- _iterator19.f();
2049
- return _context11.f(8);
2389
+ _context15.p = 8;
2390
+ _iterator21.f();
2391
+ return _context15.f(8);
2050
2392
  case 9:
2051
2393
  // `resolve` rather than `join`, and the CLI's own default argument is why.
2052
2394
  //
@@ -2063,40 +2405,42 @@ function _buildVendorLayer() {
2063
2405
  // path: the suites all build in a mkdtemp. The one caller that does not is
2064
2406
  // the one a person uses.
2065
2407
  stubs = join(resolve(dir), STUB_DIR);
2066
- _context11.n = 10;
2408
+ _context15.n = 10;
2067
2409
  return rm(stubs, {
2068
2410
  recursive: true,
2069
2411
  force: true
2070
2412
  });
2071
2413
  case 10:
2072
- _context11.n = 11;
2414
+ _context15.n = 11;
2073
2415
  return mkdir(stubs, {
2074
2416
  recursive: true
2075
2417
  });
2076
2418
  case 11:
2077
- _context11.p = 11;
2419
+ _context15.p = 11;
2078
2420
  input = {};
2079
- _i4 = 0, _Object$entries3 = Object.entries(modules);
2421
+ _i6 = 0, _Object$entries4 = Object.entries(modules);
2080
2422
  case 12:
2081
- if (!(_i4 < _Object$entries3.length)) {
2082
- _context11.n = 15;
2423
+ if (!(_i6 < _Object$entries4.length)) {
2424
+ _context15.n = 15;
2083
2425
  break;
2084
2426
  }
2085
- _Object$entries3$_i = _slicedToArray(_Object$entries3[_i4], 2), specifier = _Object$entries3$_i[0], name = _Object$entries3$_i[1];
2427
+ _Object$entries4$_i = _slicedToArray(_Object$entries4[_i6], 2), specifier = _Object$entries4$_i[0], name = _Object$entries4$_i[1];
2086
2428
  file = join(stubs, "".concat(name, ".js"));
2087
- _context11.n = 13;
2429
+ _context15.n = 13;
2088
2430
  return writeFile(file, stubSource(specifier));
2089
2431
  case 13:
2090
2432
  input[name] = file;
2091
2433
  case 14:
2092
- _i4++;
2093
- _context11.n = 12;
2434
+ _i6++;
2435
+ _context15.n = 12;
2094
2436
  break;
2095
2437
  case 15:
2096
- // Fast path: one build with every entry, so shared code is shared. When it
2097
- // fails, rolldown reports against a file deep inside a package rather than
2098
- // against the entry that pulled it in, so the only way to learn *which*
2099
- // dependency is at fault is to try them one at a time.
2438
+ // Fast path: one build with every entry, so shared code is shared, and the
2439
+ // usual answer: a server-only dependency, or one that loads a native
2440
+ // binary, does not fail it (see `stubUnbundlable`). When something else does, rolldown reports
2441
+ // against a file deep inside a package rather than against the entry that
2442
+ // pulled it in, so the only way to learn *which* dependency is at fault is
2443
+ // to try them one at a time.
2100
2444
  skipped = [];
2101
2445
  /** Built for the worker but not the browser: server-only dependencies. */
2102
2446
  workerOnly = [];
@@ -2110,79 +2454,79 @@ function _buildVendorLayer() {
2110
2454
  })[0];
2111
2455
  };
2112
2456
  usable = Object.values(modules);
2113
- _context11.n = 16;
2457
+ _context15.n = 16;
2114
2458
  return buildTargets(usable, input, join(stubs, "out"), false, platform)["catch"](function (error) {
2115
2459
  if (error instanceof PinSkewError) throw error;
2116
2460
  return null;
2117
2461
  });
2118
2462
  case 16:
2119
- built = _context11.v;
2463
+ built = _context15.v;
2120
2464
  if (built) {
2121
- _context11.n = 33;
2465
+ _context15.n = 33;
2122
2466
  break;
2123
2467
  }
2124
2468
  usable = [];
2125
- _i5 = 0, _Object$values = Object.values(modules);
2469
+ _i7 = 0, _Object$values = Object.values(modules);
2126
2470
  case 17:
2127
- if (!(_i5 < _Object$values.length)) {
2128
- _context11.n = 30;
2471
+ if (!(_i7 < _Object$values.length)) {
2472
+ _context15.n = 30;
2129
2473
  break;
2130
2474
  }
2131
- _name2 = _Object$values[_i5];
2475
+ _name2 = _Object$values[_i7];
2132
2476
  // Probed per target, because the two sides are not the same question.
2133
- // `@valbuild/tanstack/server` cannot build for a browser -- it reaches
2134
- // TanStack's SSR path, which lands on `node:stream/web` -- and it has no
2135
- // business being in a browser bundle either. Failing it outright would
2136
- // mean a server-only dependency can never be layered at all, so a
2137
- // package that builds for the worker and not the browser is kept as
2477
+ // A package that builds for the worker and not the browser is kept as
2138
2478
  // server-only, and importing it from client code is rejected later by
2139
- // the builder, naming it.
2479
+ // the builder, naming it. Reaching a Node builtin is not a failure here
2480
+ // any more than in the first build: `buildTargets` reports it.
2140
2481
  worked = {};
2141
2482
  reasons = [];
2142
- _iterator20 = _createForOfIteratorHelper(targetsFor(platform));
2143
- _context11.p = 18;
2144
- _iterator20.s();
2483
+ _iterator22 = _createForOfIteratorHelper(targetsFor(platform));
2484
+ _context15.p = 18;
2485
+ _iterator22.s();
2145
2486
  case 19:
2146
- if ((_step20 = _iterator20.n()).done) {
2147
- _context11.n = 25;
2487
+ if ((_step22 = _iterator22.n()).done) {
2488
+ _context15.n = 25;
2148
2489
  break;
2149
2490
  }
2150
- target = _step20.value;
2151
- _context11.p = 20;
2152
- _context11.n = 21;
2491
+ target = _step22.value;
2492
+ _context15.p = 20;
2493
+ _context15.n = 21;
2153
2494
  return buildTargets({
2154
2495
  worker: target.name === "worker" ? [_name2] : [],
2155
2496
  browser: target.name === "browser" ? [_name2] : []
2156
2497
  }, input, join(stubs, "probe", target.name, _name2), true, platform);
2157
2498
  case 21:
2158
- worked[target.name] = true;
2159
- _context11.n = 24;
2499
+ probe = _context15.v;
2500
+ unbundlable = (_probe$unusable$_name = probe.unusable[_name2]) !== null && _probe$unusable$_name !== void 0 ? _probe$unusable$_name : probe.serverOnly[_name2];
2501
+ worked[target.name] = unbundlable === undefined;
2502
+ if (unbundlable !== undefined) reasons.push(unbundlable);
2503
+ _context15.n = 24;
2160
2504
  break;
2161
2505
  case 22:
2162
- _context11.p = 22;
2163
- _t15 = _context11.v;
2164
- if (!(_t15 instanceof PinSkewError)) {
2165
- _context11.n = 23;
2506
+ _context15.p = 22;
2507
+ _t20 = _context15.v;
2508
+ if (!(_t20 instanceof PinSkewError)) {
2509
+ _context15.n = 23;
2166
2510
  break;
2167
2511
  }
2168
- throw _t15;
2512
+ throw _t20;
2169
2513
  case 23:
2170
2514
  worked[target.name] = false;
2171
- reasons.push(firstLine(String((_message = _t15 === null || _t15 === void 0 ? void 0 : _t15.message) !== null && _message !== void 0 ? _message : _t15)));
2515
+ reasons.push(firstLine(String((_message = _t20 === null || _t20 === void 0 ? void 0 : _t20.message) !== null && _message !== void 0 ? _message : _t20)));
2172
2516
  case 24:
2173
- _context11.n = 19;
2517
+ _context15.n = 19;
2174
2518
  break;
2175
2519
  case 25:
2176
- _context11.n = 27;
2520
+ _context15.n = 27;
2177
2521
  break;
2178
2522
  case 26:
2179
- _context11.p = 26;
2180
- _t16 = _context11.v;
2181
- _iterator20.e(_t16);
2523
+ _context15.p = 26;
2524
+ _t21 = _context15.v;
2525
+ _iterator22.e(_t21);
2182
2526
  case 27:
2183
- _context11.p = 27;
2184
- _iterator20.f();
2185
- return _context11.f(27);
2527
+ _context15.p = 27;
2528
+ _iterator22.f();
2529
+ return _context15.f(27);
2186
2530
  case 28:
2187
2531
  if (worked.worker && worked.browser) usable.push(_name2);else if (worked.worker) {
2188
2532
  usable.push(_name2);
@@ -2201,21 +2545,21 @@ function _buildVendorLayer() {
2201
2545
  });
2202
2546
  }
2203
2547
  case 29:
2204
- _i5++;
2205
- _context11.n = 17;
2548
+ _i7++;
2549
+ _context15.n = 17;
2206
2550
  break;
2207
2551
  case 30:
2208
- for (_i6 = 0, _Object$entries4 = Object.entries(modules); _i6 < _Object$entries4.length; _i6++) {
2209
- _Object$entries4$_i = _slicedToArray(_Object$entries4[_i6], 2), _specifier = _Object$entries4$_i[0], _name3 = _Object$entries4$_i[1];
2552
+ for (_i8 = 0, _Object$entries5 = Object.entries(modules); _i8 < _Object$entries5.length; _i8++) {
2553
+ _Object$entries5$_i = _slicedToArray(_Object$entries5[_i8], 2), _specifier = _Object$entries5$_i[0], _name3 = _Object$entries5$_i[1];
2210
2554
  if (!usable.includes(_name3)) delete modules[_specifier];
2211
2555
  }
2212
2556
  // Everything failed: a layer with no entries is the same as no layer, and
2213
2557
  // the skip list is what the caller reports.
2214
2558
  if (!(usable.length === 0)) {
2215
- _context11.n = 31;
2559
+ _context15.n = 31;
2216
2560
  break;
2217
2561
  }
2218
- return _context11.a(2, {
2562
+ return _context15.a(2, {
2219
2563
  rev: "none",
2220
2564
  modules: {},
2221
2565
  worker: {},
@@ -2226,7 +2570,7 @@ function _buildVendorLayer() {
2226
2570
  workerOnlyReasons: workerOnlyReasons
2227
2571
  });
2228
2572
  case 31:
2229
- _context11.n = 32;
2573
+ _context15.n = 32;
2230
2574
  return buildTargets({
2231
2575
  worker: usable,
2232
2576
  browser: usable.filter(function (name) {
@@ -2234,9 +2578,54 @@ function _buildVendorLayer() {
2234
2578
  })
2235
2579
  }, input, join(stubs, "out"), false, platform);
2236
2580
  case 32:
2237
- built = _context11.v;
2581
+ built = _context15.v;
2238
2582
  case 33:
2239
- return _context11.a(2, {
2583
+ _i9 = 0, _Object$entries6 = Object.entries(modules);
2584
+ case 34:
2585
+ if (!(_i9 < _Object$entries6.length)) {
2586
+ _context15.n = 37;
2587
+ break;
2588
+ }
2589
+ _Object$entries6$_i = _slicedToArray(_Object$entries6[_i9], 2), _specifier2 = _Object$entries6$_i[0], _name4 = _Object$entries6$_i[1];
2590
+ reason = built.unusable[_name4];
2591
+ if (!(reason === undefined)) {
2592
+ _context15.n = 35;
2593
+ break;
2594
+ }
2595
+ return _context15.a(3, 36);
2596
+ case 35:
2597
+ skipped.push({
2598
+ specifier: _specifier2,
2599
+ reason: reason
2600
+ });
2601
+ delete modules[_specifier2];
2602
+ case 36:
2603
+ _i9++;
2604
+ _context15.n = 34;
2605
+ break;
2606
+ case 37:
2607
+ _i0 = 0, _Object$entries7 = Object.entries(modules);
2608
+ case 38:
2609
+ if (!(_i0 < _Object$entries7.length)) {
2610
+ _context15.n = 41;
2611
+ break;
2612
+ }
2613
+ _Object$entries7$_i = _slicedToArray(_Object$entries7[_i0], 2), _specifier3 = _Object$entries7$_i[0], _name5 = _Object$entries7$_i[1];
2614
+ _reason = built.serverOnly[_name5];
2615
+ if (!(_reason === undefined || workerOnly.includes(_specifier3))) {
2616
+ _context15.n = 39;
2617
+ break;
2618
+ }
2619
+ return _context15.a(3, 40);
2620
+ case 39:
2621
+ workerOnly.push(_specifier3);
2622
+ workerOnlyReasons[_specifier3] = _reason;
2623
+ case 40:
2624
+ _i0++;
2625
+ _context15.n = 38;
2626
+ break;
2627
+ case 41:
2628
+ return _context15.a(2, {
2240
2629
  rev: "".concat(built.rev).concat(cssRev(css) ? "-".concat(cssRev(css)) : ""),
2241
2630
  modules: modules,
2242
2631
  worker: built.worker,
@@ -2246,19 +2635,19 @@ function _buildVendorLayer() {
2246
2635
  workerOnly: workerOnly,
2247
2636
  workerOnlyReasons: workerOnlyReasons
2248
2637
  });
2249
- case 34:
2250
- _context11.p = 34;
2251
- _context11.n = 35;
2638
+ case 42:
2639
+ _context15.p = 42;
2640
+ _context15.n = 43;
2252
2641
  return rm(stubs, {
2253
2642
  recursive: true,
2254
2643
  force: true
2255
2644
  });
2256
- case 35:
2257
- return _context11.f(34);
2258
- case 36:
2259
- return _context11.a(2);
2645
+ case 43:
2646
+ return _context15.f(42);
2647
+ case 44:
2648
+ return _context15.a(2);
2260
2649
  }
2261
- }, _callee10, null, [[20, 22], [18, 26, 27, 28], [11,, 34, 36], [3, 7, 8, 9]]);
2650
+ }, _callee13, null, [[20, 22], [18, 26, 27, 28], [11,, 42, 44], [3, 7, 8, 9]]);
2262
2651
  }));
2263
2652
  return _buildVendorLayer.apply(this, arguments);
2264
2653
  }