@valbuild/tanstack-build 0.148.3 → 0.148.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @valbuild/tanstack-build
2
2
 
3
+ ## 0.148.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#899](https://github.com/valbuild/val/pull/899) [`acc5fee`](https://github.com/valbuild/val/commit/acc5feef498edbb9a7d3e8715bfb516d26079669) Thanks [@freekh](https://github.com/freekh)! - A project's dependency layer no longer builds Val's server entry points for the browser. `@valbuild/tanstack/server` and `@valbuild/tanstack/demo` go in the worker half only, so the browser half stops carrying code nothing in the browser imports. `@valbuild/tanstack/demo` is about 15 MB: on the Val demo the browser half went from 20.2 to 4.8 million characters, and the whole layer from 40.8 to 25.4. Importing either from client code is still reported by name, as for any server-only dependency.
8
+
3
9
  ## 0.148.3
4
10
 
5
11
  ### Patch Changes
@@ -129,6 +129,22 @@ export interface VendorLayer {
129
129
  /** Browser chunks, served under `/_pvendor/<rev>/`. */
130
130
  browser: Record<string, string>;
131
131
  }
132
+ /**
133
+ * Val's own entry points that are server-only by contract, built for the
134
+ * worker and never for the browser.
135
+ *
136
+ * Without this a dependency goes in the browser half whenever it CAN be built
137
+ * for a browser, whether or not anything there imports it. `@valbuild/tanstack/demo`
138
+ * can: it is the demo's server half, and its 15.5 MB is the built Studio it
139
+ * serves, as strings. A project importing it from its API route got that
140
+ * twice, once in each half, and the browser copy was never loaded -- a third
141
+ * of the demo's layer, built, uploaded and stored for nothing.
142
+ *
143
+ * Only entries whose purpose is the server, named by the package that
144
+ * defines them. A client import of one is still caught, by name: the layer
145
+ * lists it in `workerOnly`, and the app build rejects it (`build.ts`).
146
+ */
147
+ export declare const SERVER_ONLY_ENTRIES: ReadonlyArray<string>;
132
148
  /**
133
149
  * Every import a project chunk emits has to resolve inside the isolate: into
134
150
  * the base layer, at a sibling chunk, or at a Node builtin the runtime
@@ -1101,7 +1101,7 @@ var packageJson = {
1101
1101
  url: "git+https://github.com/valbuild/val.git"
1102
1102
  },
1103
1103
  license: "MIT",
1104
- version: "0.148.3",
1104
+ version: "0.148.5",
1105
1105
  sideEffects: false,
1106
1106
  main: "dist/valbuild-tanstack-build.cjs.js",
1107
1107
  module: "dist/valbuild-tanstack-build.esm.js",
@@ -1101,7 +1101,7 @@ var packageJson = {
1101
1101
  url: "git+https://github.com/valbuild/val.git"
1102
1102
  },
1103
1103
  license: "MIT",
1104
- version: "0.148.3",
1104
+ version: "0.148.5",
1105
1105
  sideEffects: false,
1106
1106
  main: "dist/valbuild-tanstack-build.cjs.js",
1107
1107
  module: "dist/valbuild-tanstack-build.esm.js",
@@ -1100,7 +1100,7 @@ var packageJson = {
1100
1100
  url: "git+https://github.com/valbuild/val.git"
1101
1101
  },
1102
1102
  license: "MIT",
1103
- version: "0.148.3",
1103
+ version: "0.148.5",
1104
1104
  sideEffects: false,
1105
1105
  main: "dist/valbuild-tanstack-build.cjs.js",
1106
1106
  module: "dist/valbuild-tanstack-build.esm.js",
@@ -1155,6 +1155,24 @@ var PER_PROJECT_ENTRIES = ["#tanstack-router-entry", "#tanstack-start-entry"];
1155
1155
  * fails loudly at load rather than silently shipping a server bundle.
1156
1156
  */
1157
1157
  var SERVER_ENTRIES = ["@tanstack/react-start/server", "@tanstack/react-start-server", "@tanstack/start-server-core"];
1158
+
1159
+ /**
1160
+ * Val's own entry points that are server-only by contract, built for the
1161
+ * worker and never for the browser.
1162
+ *
1163
+ * Without this a dependency goes in the browser half whenever it CAN be built
1164
+ * for a browser, whether or not anything there imports it. `@valbuild/tanstack/demo`
1165
+ * can: it is the demo's server half, and its 15.5 MB is the built Studio it
1166
+ * serves, as strings. A project importing it from its API route got that
1167
+ * twice, once in each half, and the browser copy was never loaded -- a third
1168
+ * of the demo's layer, built, uploaded and stored for nothing.
1169
+ *
1170
+ * Only entries whose purpose is the server, named by the package that
1171
+ * defines them. A client import of one is still caught, by name: the layer
1172
+ * lists it in `workerOnly`, and the app build rejects it (`build.ts`).
1173
+ */
1174
+ var SERVER_ONLY_ENTRIES = ["@valbuild/tanstack/server", "@valbuild/tanstack/demo"];
1175
+ var SERVER_ONLY_REASON = "a server entry point: built for the worker only, by design";
1158
1176
  var SERVER_ENTRY_STUB = "\nthrow new Error(\n 'TanStack Start\\'s server entry is not available in the browser. A project ' +\n 'dependency reached it from client code; on this platform the shell owns ' +\n 'the server side. If this came from a server-only branch guarded by ' +\n 'try/catch, this is the failure it expects.',\n)\n";
1159
1177
  function stubServerEntries(browser) {
1160
1178
  var prefix = "\0platform:server-entry:";
@@ -2338,7 +2356,7 @@ function buildVendorLayer(_x34, _x35, _x36, _x37) {
2338
2356
  }
2339
2357
  function _buildVendorLayer() {
2340
2358
  _buildVendorLayer = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee13(dir, deps, css, platform) {
2341
- 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;
2359
+ var modules, _iterator21, _step21, _loop4, stubs, input, _i6, _Object$entries4, _Object$entries4$_i, specifier, name, file, skipped, workerOnly, workerOnlyReasons, specifierOf, _i7, _Object$keys, _specifier, forBrowser, forgetUncarried, usable, built, _i9, _Object$values, _name2, worked, reasons, serverOnlyByContract, _iterator22, _step22, target, _probe$unusable$_name, probe, unbundlable, _message, _reasons$, _i0, _Object$entries5, _Object$entries5$_i, _specifier3, _name3, _i1, _Object$entries6, _Object$entries6$_i, _specifier4, _name4, reason, _i10, _Object$entries7, _Object$entries7$_i, _specifier5, _name5, _reason, _t19, _t20, _t21;
2342
2360
  return regeneratorValues._regenerator().w(function (_context15) {
2343
2361
  while (1) switch (_context15.p = _context15.n) {
2344
2362
  case 0:
@@ -2475,26 +2493,63 @@ function _buildVendorLayer() {
2475
2493
  return name === chunk;
2476
2494
  })[0];
2477
2495
  };
2478
- usable = Object.values(modules);
2496
+ _i7 = 0, _Object$keys = Object.keys(modules);
2497
+ case 16:
2498
+ if (!(_i7 < _Object$keys.length)) {
2499
+ _context15.n = 19;
2500
+ break;
2501
+ }
2502
+ _specifier = _Object$keys[_i7];
2503
+ if (SERVER_ONLY_ENTRIES.includes(_specifier)) {
2504
+ _context15.n = 17;
2505
+ break;
2506
+ }
2507
+ return _context15.a(3, 18);
2508
+ case 17:
2509
+ workerOnly.push(_specifier);
2510
+ workerOnlyReasons[_specifier] = SERVER_ONLY_REASON;
2511
+ case 18:
2512
+ _i7++;
2479
2513
  _context15.n = 16;
2480
- return buildTargets(usable, input, node_path.join(stubs, "out"), false, platform)["catch"](function (error) {
2514
+ break;
2515
+ case 19:
2516
+ forBrowser = function forBrowser(names) {
2517
+ return names.filter(function (name) {
2518
+ return !workerOnly.includes(specifierOf(name));
2519
+ });
2520
+ }; // Those are listed before the first build, so one that then could not be
2521
+ // built at all is in `skipped`, and is no longer reported as server-only.
2522
+ forgetUncarried = function forgetUncarried() {
2523
+ for (var _i8 = 0, _arr2 = [].concat(workerOnly); _i8 < _arr2.length; _i8++) {
2524
+ var _specifier2 = _arr2[_i8];
2525
+ if (_specifier2 in modules) continue;
2526
+ workerOnly.splice(workerOnly.indexOf(_specifier2), 1);
2527
+ delete workerOnlyReasons[_specifier2];
2528
+ }
2529
+ };
2530
+ usable = Object.values(modules);
2531
+ _context15.n = 20;
2532
+ return buildTargets({
2533
+ worker: usable,
2534
+ browser: forBrowser(usable)
2535
+ }, input, node_path.join(stubs, "out"), false, platform)["catch"](function (error) {
2481
2536
  if (error instanceof PinSkewError) throw error;
2482
2537
  return null;
2483
2538
  });
2484
- case 16:
2539
+ case 20:
2485
2540
  built = _context15.v;
2486
2541
  if (built) {
2487
- _context15.n = 33;
2542
+ _context15.n = 40;
2488
2543
  break;
2489
2544
  }
2490
2545
  usable = [];
2491
- _i7 = 0, _Object$values = Object.values(modules);
2492
- case 17:
2493
- if (!(_i7 < _Object$values.length)) {
2494
- _context15.n = 30;
2546
+ _i9 = 0, _Object$values = Object.values(modules);
2547
+ case 21:
2548
+ if (!(_i9 < _Object$values.length)) {
2549
+ _context15.n = 37;
2495
2550
  break;
2496
2551
  }
2497
- _name2 = _Object$values[_i7];
2552
+ _name2 = _Object$values[_i9];
2498
2553
  // Probed per target, because the two sides are not the same question.
2499
2554
  // A package that builds for the worker and not the browser is kept as
2500
2555
  // server-only, and importing it from client code is rejected later by
@@ -2502,85 +2557,113 @@ function _buildVendorLayer() {
2502
2557
  // any more than in the first build: `buildTargets` reports it.
2503
2558
  worked = {};
2504
2559
  reasons = [];
2560
+ serverOnlyByContract = SERVER_ONLY_ENTRIES.includes(specifierOf(_name2));
2505
2561
  _iterator22 = regeneratorValues._createForOfIteratorHelper(targetsFor(platform));
2506
- _context15.p = 18;
2562
+ _context15.p = 22;
2507
2563
  _iterator22.s();
2508
- case 19:
2564
+ case 23:
2509
2565
  if ((_step22 = _iterator22.n()).done) {
2510
- _context15.n = 25;
2566
+ _context15.n = 29;
2511
2567
  break;
2512
2568
  }
2513
2569
  target = _step22.value;
2514
- _context15.p = 20;
2515
- _context15.n = 21;
2570
+ if (!(target.name === "browser" && serverOnlyByContract)) {
2571
+ _context15.n = 24;
2572
+ break;
2573
+ }
2574
+ worked.browser = false;
2575
+ return _context15.a(3, 28);
2576
+ case 24:
2577
+ _context15.p = 24;
2578
+ _context15.n = 25;
2516
2579
  return buildTargets({
2517
2580
  worker: target.name === "worker" ? [_name2] : [],
2518
2581
  browser: target.name === "browser" ? [_name2] : []
2519
2582
  }, input, node_path.join(stubs, "probe", target.name, _name2), true, platform);
2520
- case 21:
2583
+ case 25:
2521
2584
  probe = _context15.v;
2522
2585
  unbundlable = (_probe$unusable$_name = probe.unusable[_name2]) !== null && _probe$unusable$_name !== void 0 ? _probe$unusable$_name : probe.serverOnly[_name2];
2523
2586
  worked[target.name] = unbundlable === undefined;
2524
2587
  if (unbundlable !== undefined) reasons.push(unbundlable);
2525
- _context15.n = 24;
2588
+ _context15.n = 28;
2526
2589
  break;
2527
- case 22:
2528
- _context15.p = 22;
2590
+ case 26:
2591
+ _context15.p = 26;
2529
2592
  _t20 = _context15.v;
2530
2593
  if (!(_t20 instanceof PinSkewError)) {
2531
- _context15.n = 23;
2594
+ _context15.n = 27;
2532
2595
  break;
2533
2596
  }
2534
2597
  throw _t20;
2535
- case 23:
2598
+ case 27:
2536
2599
  worked[target.name] = false;
2537
2600
  reasons.push(firstLine(String((_message = _t20 === null || _t20 === void 0 ? void 0 : _t20.message) !== null && _message !== void 0 ? _message : _t20)));
2538
- case 24:
2539
- _context15.n = 19;
2601
+ case 28:
2602
+ _context15.n = 23;
2540
2603
  break;
2541
- case 25:
2542
- _context15.n = 27;
2604
+ case 29:
2605
+ _context15.n = 31;
2543
2606
  break;
2544
- case 26:
2545
- _context15.p = 26;
2607
+ case 30:
2608
+ _context15.p = 30;
2546
2609
  _t21 = _context15.v;
2547
2610
  _iterator22.e(_t21);
2548
- case 27:
2549
- _context15.p = 27;
2611
+ case 31:
2612
+ _context15.p = 31;
2550
2613
  _iterator22.f();
2551
- return _context15.f(27);
2552
- case 28:
2553
- if (worked.worker && worked.browser) usable.push(_name2);else if (worked.worker) {
2554
- usable.push(_name2);
2555
- workerOnly.push(specifierOf(_name2));
2556
- // Kept, because throwing it away is what made this class of failure
2557
- // undebuggable. `workerOnly` says a dependency is server-only and
2558
- // PLATFORM404 says importing it from a component is an error, and
2559
- // between them they never said WHY it could not be built for a
2560
- // browser -- which is the only thing that tells you whether to change
2561
- // the import or fix the package.
2562
- if (reasons[0]) workerOnlyReasons[specifierOf(_name2)] = reasons[0];
2563
- } else {
2564
- skipped.push({
2565
- specifier: specifierOf(_name2),
2566
- reason: (_reasons$ = reasons[0]) !== null && _reasons$ !== void 0 ? _reasons$ : "build failed"
2567
- });
2614
+ return _context15.f(31);
2615
+ case 32:
2616
+ if (!(worked.worker && worked.browser)) {
2617
+ _context15.n = 33;
2618
+ break;
2568
2619
  }
2569
- case 29:
2570
- _i7++;
2571
- _context15.n = 17;
2620
+ usable.push(_name2);
2621
+ _context15.n = 36;
2572
2622
  break;
2573
- case 30:
2574
- for (_i8 = 0, _Object$entries5 = Object.entries(modules); _i8 < _Object$entries5.length; _i8++) {
2575
- _Object$entries5$_i = regeneratorValues._slicedToArray(_Object$entries5[_i8], 2), _specifier = _Object$entries5$_i[0], _name3 = _Object$entries5$_i[1];
2576
- if (!usable.includes(_name3)) delete modules[_specifier];
2623
+ case 33:
2624
+ if (!worked.worker) {
2625
+ _context15.n = 35;
2626
+ break;
2627
+ }
2628
+ usable.push(_name2);
2629
+ if (!serverOnlyByContract) {
2630
+ _context15.n = 34;
2631
+ break;
2632
+ }
2633
+ return _context15.a(3, 36);
2634
+ case 34:
2635
+ // listed before the first build
2636
+ workerOnly.push(specifierOf(_name2));
2637
+ // Kept, because throwing it away is what made this class of failure
2638
+ // undebuggable. `workerOnly` says a dependency is server-only and
2639
+ // PLATFORM404 says importing it from a component is an error, and
2640
+ // between them they never said WHY it could not be built for a
2641
+ // browser -- which is the only thing that tells you whether to change
2642
+ // the import or fix the package.
2643
+ if (reasons[0]) workerOnlyReasons[specifierOf(_name2)] = reasons[0];
2644
+ _context15.n = 36;
2645
+ break;
2646
+ case 35:
2647
+ skipped.push({
2648
+ specifier: specifierOf(_name2),
2649
+ reason: (_reasons$ = reasons[0]) !== null && _reasons$ !== void 0 ? _reasons$ : "build failed"
2650
+ });
2651
+ case 36:
2652
+ _i9++;
2653
+ _context15.n = 21;
2654
+ break;
2655
+ case 37:
2656
+ for (_i0 = 0, _Object$entries5 = Object.entries(modules); _i0 < _Object$entries5.length; _i0++) {
2657
+ _Object$entries5$_i = regeneratorValues._slicedToArray(_Object$entries5[_i0], 2), _specifier3 = _Object$entries5$_i[0], _name3 = _Object$entries5$_i[1];
2658
+ if (!usable.includes(_name3)) delete modules[_specifier3];
2577
2659
  }
2578
2660
  // Everything failed: a layer with no entries is the same as no layer, and
2579
2661
  // the skip list is what the caller reports.
2580
2662
  if (!(usable.length === 0)) {
2581
- _context15.n = 31;
2663
+ _context15.n = 38;
2582
2664
  break;
2583
2665
  }
2666
+ forgetUncarried();
2584
2667
  return _context15.a(2, {
2585
2668
  rev: "none",
2586
2669
  modules: {},
@@ -2591,62 +2674,65 @@ function _buildVendorLayer() {
2591
2674
  workerOnly: workerOnly,
2592
2675
  workerOnlyReasons: workerOnlyReasons
2593
2676
  });
2594
- case 31:
2595
- _context15.n = 32;
2677
+ case 38:
2678
+ _context15.n = 39;
2596
2679
  return buildTargets({
2597
2680
  worker: usable,
2598
- browser: usable.filter(function (name) {
2599
- return !workerOnly.includes(specifierOf(name));
2600
- })
2681
+ browser: forBrowser(usable)
2601
2682
  }, input, node_path.join(stubs, "out"), false, platform);
2602
- case 32:
2683
+ case 39:
2603
2684
  built = _context15.v;
2604
- case 33:
2605
- _i9 = 0, _Object$entries6 = Object.entries(modules);
2606
- case 34:
2607
- if (!(_i9 < _Object$entries6.length)) {
2608
- _context15.n = 37;
2685
+ case 40:
2686
+ _i1 = 0, _Object$entries6 = Object.entries(modules);
2687
+ case 41:
2688
+ if (!(_i1 < _Object$entries6.length)) {
2689
+ _context15.n = 44;
2609
2690
  break;
2610
2691
  }
2611
- _Object$entries6$_i = regeneratorValues._slicedToArray(_Object$entries6[_i9], 2), _specifier2 = _Object$entries6$_i[0], _name4 = _Object$entries6$_i[1];
2692
+ _Object$entries6$_i = regeneratorValues._slicedToArray(_Object$entries6[_i1], 2), _specifier4 = _Object$entries6$_i[0], _name4 = _Object$entries6$_i[1];
2612
2693
  reason = built.unusable[_name4];
2613
2694
  if (!(reason === undefined)) {
2614
- _context15.n = 35;
2695
+ _context15.n = 42;
2615
2696
  break;
2616
2697
  }
2617
- return _context15.a(3, 36);
2618
- case 35:
2698
+ return _context15.a(3, 43);
2699
+ case 42:
2619
2700
  skipped.push({
2620
- specifier: _specifier2,
2701
+ specifier: _specifier4,
2621
2702
  reason: reason
2622
2703
  });
2623
- delete modules[_specifier2];
2624
- case 36:
2625
- _i9++;
2626
- _context15.n = 34;
2704
+ delete modules[_specifier4];
2705
+ case 43:
2706
+ _i1++;
2707
+ _context15.n = 41;
2627
2708
  break;
2628
- case 37:
2629
- _i0 = 0, _Object$entries7 = Object.entries(modules);
2630
- case 38:
2631
- if (!(_i0 < _Object$entries7.length)) {
2632
- _context15.n = 41;
2709
+ case 44:
2710
+ _i10 = 0, _Object$entries7 = Object.entries(modules);
2711
+ case 45:
2712
+ if (!(_i10 < _Object$entries7.length)) {
2713
+ _context15.n = 48;
2633
2714
  break;
2634
2715
  }
2635
- _Object$entries7$_i = regeneratorValues._slicedToArray(_Object$entries7[_i0], 2), _specifier3 = _Object$entries7$_i[0], _name5 = _Object$entries7$_i[1];
2716
+ _Object$entries7$_i = regeneratorValues._slicedToArray(_Object$entries7[_i10], 2), _specifier5 = _Object$entries7$_i[0], _name5 = _Object$entries7$_i[1];
2636
2717
  _reason = built.serverOnly[_name5];
2637
- if (!(_reason === undefined || workerOnly.includes(_specifier3))) {
2638
- _context15.n = 39;
2718
+ if (!(_reason === undefined || workerOnly.includes(_specifier5))) {
2719
+ _context15.n = 46;
2639
2720
  break;
2640
2721
  }
2641
- return _context15.a(3, 40);
2642
- case 39:
2643
- workerOnly.push(_specifier3);
2644
- workerOnlyReasons[_specifier3] = _reason;
2645
- case 40:
2646
- _i0++;
2647
- _context15.n = 38;
2722
+ return _context15.a(3, 47);
2723
+ case 46:
2724
+ workerOnly.push(_specifier5);
2725
+ workerOnlyReasons[_specifier5] = _reason;
2726
+ case 47:
2727
+ _i10++;
2728
+ _context15.n = 45;
2648
2729
  break;
2649
- case 41:
2730
+ case 48:
2731
+ forgetUncarried();
2732
+
2733
+ // The revision covers the stylesheets too: changing one is a different
2734
+ // dependency set, and the build hash folds in the revision rather than the
2735
+ // contents.
2650
2736
  return _context15.a(2, {
2651
2737
  rev: "".concat(built.rev).concat(cssRev(css) ? "-".concat(cssRev(css)) : ""),
2652
2738
  modules: modules,
@@ -2657,19 +2743,19 @@ function _buildVendorLayer() {
2657
2743
  workerOnly: workerOnly,
2658
2744
  workerOnlyReasons: workerOnlyReasons
2659
2745
  });
2660
- case 42:
2661
- _context15.p = 42;
2662
- _context15.n = 43;
2746
+ case 49:
2747
+ _context15.p = 49;
2748
+ _context15.n = 50;
2663
2749
  return promises.rm(stubs, {
2664
2750
  recursive: true,
2665
2751
  force: true
2666
2752
  });
2667
- case 43:
2668
- return _context15.f(42);
2669
- case 44:
2753
+ case 50:
2754
+ return _context15.f(49);
2755
+ case 51:
2670
2756
  return _context15.a(2);
2671
2757
  }
2672
- }, _callee13, null, [[20, 22], [18, 26, 27, 28], [11,, 42, 44], [3, 7, 8, 9]]);
2758
+ }, _callee13, null, [[24, 26], [22, 30, 31, 32], [11,, 49, 51], [3, 7, 8, 9]]);
2673
2759
  }));
2674
2760
  return _buildVendorLayer.apply(this, arguments);
2675
2761
  }
@@ -1155,6 +1155,24 @@ var PER_PROJECT_ENTRIES = ["#tanstack-router-entry", "#tanstack-start-entry"];
1155
1155
  * fails loudly at load rather than silently shipping a server bundle.
1156
1156
  */
1157
1157
  var SERVER_ENTRIES = ["@tanstack/react-start/server", "@tanstack/react-start-server", "@tanstack/start-server-core"];
1158
+
1159
+ /**
1160
+ * Val's own entry points that are server-only by contract, built for the
1161
+ * worker and never for the browser.
1162
+ *
1163
+ * Without this a dependency goes in the browser half whenever it CAN be built
1164
+ * for a browser, whether or not anything there imports it. `@valbuild/tanstack/demo`
1165
+ * can: it is the demo's server half, and its 15.5 MB is the built Studio it
1166
+ * serves, as strings. A project importing it from its API route got that
1167
+ * twice, once in each half, and the browser copy was never loaded -- a third
1168
+ * of the demo's layer, built, uploaded and stored for nothing.
1169
+ *
1170
+ * Only entries whose purpose is the server, named by the package that
1171
+ * defines them. A client import of one is still caught, by name: the layer
1172
+ * lists it in `workerOnly`, and the app build rejects it (`build.ts`).
1173
+ */
1174
+ var SERVER_ONLY_ENTRIES = ["@valbuild/tanstack/server", "@valbuild/tanstack/demo"];
1175
+ var SERVER_ONLY_REASON = "a server entry point: built for the worker only, by design";
1158
1176
  var SERVER_ENTRY_STUB = "\nthrow new Error(\n 'TanStack Start\\'s server entry is not available in the browser. A project ' +\n 'dependency reached it from client code; on this platform the shell owns ' +\n 'the server side. If this came from a server-only branch guarded by ' +\n 'try/catch, this is the failure it expects.',\n)\n";
1159
1177
  function stubServerEntries(browser) {
1160
1178
  var prefix = "\0platform:server-entry:";
@@ -2338,7 +2356,7 @@ function buildVendorLayer(_x34, _x35, _x36, _x37) {
2338
2356
  }
2339
2357
  function _buildVendorLayer() {
2340
2358
  _buildVendorLayer = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee13(dir, deps, css, platform) {
2341
- 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;
2359
+ var modules, _iterator21, _step21, _loop4, stubs, input, _i6, _Object$entries4, _Object$entries4$_i, specifier, name, file, skipped, workerOnly, workerOnlyReasons, specifierOf, _i7, _Object$keys, _specifier, forBrowser, forgetUncarried, usable, built, _i9, _Object$values, _name2, worked, reasons, serverOnlyByContract, _iterator22, _step22, target, _probe$unusable$_name, probe, unbundlable, _message, _reasons$, _i0, _Object$entries5, _Object$entries5$_i, _specifier3, _name3, _i1, _Object$entries6, _Object$entries6$_i, _specifier4, _name4, reason, _i10, _Object$entries7, _Object$entries7$_i, _specifier5, _name5, _reason, _t19, _t20, _t21;
2342
2360
  return regeneratorValues._regenerator().w(function (_context15) {
2343
2361
  while (1) switch (_context15.p = _context15.n) {
2344
2362
  case 0:
@@ -2475,26 +2493,63 @@ function _buildVendorLayer() {
2475
2493
  return name === chunk;
2476
2494
  })[0];
2477
2495
  };
2478
- usable = Object.values(modules);
2496
+ _i7 = 0, _Object$keys = Object.keys(modules);
2497
+ case 16:
2498
+ if (!(_i7 < _Object$keys.length)) {
2499
+ _context15.n = 19;
2500
+ break;
2501
+ }
2502
+ _specifier = _Object$keys[_i7];
2503
+ if (SERVER_ONLY_ENTRIES.includes(_specifier)) {
2504
+ _context15.n = 17;
2505
+ break;
2506
+ }
2507
+ return _context15.a(3, 18);
2508
+ case 17:
2509
+ workerOnly.push(_specifier);
2510
+ workerOnlyReasons[_specifier] = SERVER_ONLY_REASON;
2511
+ case 18:
2512
+ _i7++;
2479
2513
  _context15.n = 16;
2480
- return buildTargets(usable, input, node_path.join(stubs, "out"), false, platform)["catch"](function (error) {
2514
+ break;
2515
+ case 19:
2516
+ forBrowser = function forBrowser(names) {
2517
+ return names.filter(function (name) {
2518
+ return !workerOnly.includes(specifierOf(name));
2519
+ });
2520
+ }; // Those are listed before the first build, so one that then could not be
2521
+ // built at all is in `skipped`, and is no longer reported as server-only.
2522
+ forgetUncarried = function forgetUncarried() {
2523
+ for (var _i8 = 0, _arr2 = [].concat(workerOnly); _i8 < _arr2.length; _i8++) {
2524
+ var _specifier2 = _arr2[_i8];
2525
+ if (_specifier2 in modules) continue;
2526
+ workerOnly.splice(workerOnly.indexOf(_specifier2), 1);
2527
+ delete workerOnlyReasons[_specifier2];
2528
+ }
2529
+ };
2530
+ usable = Object.values(modules);
2531
+ _context15.n = 20;
2532
+ return buildTargets({
2533
+ worker: usable,
2534
+ browser: forBrowser(usable)
2535
+ }, input, node_path.join(stubs, "out"), false, platform)["catch"](function (error) {
2481
2536
  if (error instanceof PinSkewError) throw error;
2482
2537
  return null;
2483
2538
  });
2484
- case 16:
2539
+ case 20:
2485
2540
  built = _context15.v;
2486
2541
  if (built) {
2487
- _context15.n = 33;
2542
+ _context15.n = 40;
2488
2543
  break;
2489
2544
  }
2490
2545
  usable = [];
2491
- _i7 = 0, _Object$values = Object.values(modules);
2492
- case 17:
2493
- if (!(_i7 < _Object$values.length)) {
2494
- _context15.n = 30;
2546
+ _i9 = 0, _Object$values = Object.values(modules);
2547
+ case 21:
2548
+ if (!(_i9 < _Object$values.length)) {
2549
+ _context15.n = 37;
2495
2550
  break;
2496
2551
  }
2497
- _name2 = _Object$values[_i7];
2552
+ _name2 = _Object$values[_i9];
2498
2553
  // Probed per target, because the two sides are not the same question.
2499
2554
  // A package that builds for the worker and not the browser is kept as
2500
2555
  // server-only, and importing it from client code is rejected later by
@@ -2502,85 +2557,113 @@ function _buildVendorLayer() {
2502
2557
  // any more than in the first build: `buildTargets` reports it.
2503
2558
  worked = {};
2504
2559
  reasons = [];
2560
+ serverOnlyByContract = SERVER_ONLY_ENTRIES.includes(specifierOf(_name2));
2505
2561
  _iterator22 = regeneratorValues._createForOfIteratorHelper(targetsFor(platform));
2506
- _context15.p = 18;
2562
+ _context15.p = 22;
2507
2563
  _iterator22.s();
2508
- case 19:
2564
+ case 23:
2509
2565
  if ((_step22 = _iterator22.n()).done) {
2510
- _context15.n = 25;
2566
+ _context15.n = 29;
2511
2567
  break;
2512
2568
  }
2513
2569
  target = _step22.value;
2514
- _context15.p = 20;
2515
- _context15.n = 21;
2570
+ if (!(target.name === "browser" && serverOnlyByContract)) {
2571
+ _context15.n = 24;
2572
+ break;
2573
+ }
2574
+ worked.browser = false;
2575
+ return _context15.a(3, 28);
2576
+ case 24:
2577
+ _context15.p = 24;
2578
+ _context15.n = 25;
2516
2579
  return buildTargets({
2517
2580
  worker: target.name === "worker" ? [_name2] : [],
2518
2581
  browser: target.name === "browser" ? [_name2] : []
2519
2582
  }, input, node_path.join(stubs, "probe", target.name, _name2), true, platform);
2520
- case 21:
2583
+ case 25:
2521
2584
  probe = _context15.v;
2522
2585
  unbundlable = (_probe$unusable$_name = probe.unusable[_name2]) !== null && _probe$unusable$_name !== void 0 ? _probe$unusable$_name : probe.serverOnly[_name2];
2523
2586
  worked[target.name] = unbundlable === undefined;
2524
2587
  if (unbundlable !== undefined) reasons.push(unbundlable);
2525
- _context15.n = 24;
2588
+ _context15.n = 28;
2526
2589
  break;
2527
- case 22:
2528
- _context15.p = 22;
2590
+ case 26:
2591
+ _context15.p = 26;
2529
2592
  _t20 = _context15.v;
2530
2593
  if (!(_t20 instanceof PinSkewError)) {
2531
- _context15.n = 23;
2594
+ _context15.n = 27;
2532
2595
  break;
2533
2596
  }
2534
2597
  throw _t20;
2535
- case 23:
2598
+ case 27:
2536
2599
  worked[target.name] = false;
2537
2600
  reasons.push(firstLine(String((_message = _t20 === null || _t20 === void 0 ? void 0 : _t20.message) !== null && _message !== void 0 ? _message : _t20)));
2538
- case 24:
2539
- _context15.n = 19;
2601
+ case 28:
2602
+ _context15.n = 23;
2540
2603
  break;
2541
- case 25:
2542
- _context15.n = 27;
2604
+ case 29:
2605
+ _context15.n = 31;
2543
2606
  break;
2544
- case 26:
2545
- _context15.p = 26;
2607
+ case 30:
2608
+ _context15.p = 30;
2546
2609
  _t21 = _context15.v;
2547
2610
  _iterator22.e(_t21);
2548
- case 27:
2549
- _context15.p = 27;
2611
+ case 31:
2612
+ _context15.p = 31;
2550
2613
  _iterator22.f();
2551
- return _context15.f(27);
2552
- case 28:
2553
- if (worked.worker && worked.browser) usable.push(_name2);else if (worked.worker) {
2554
- usable.push(_name2);
2555
- workerOnly.push(specifierOf(_name2));
2556
- // Kept, because throwing it away is what made this class of failure
2557
- // undebuggable. `workerOnly` says a dependency is server-only and
2558
- // PLATFORM404 says importing it from a component is an error, and
2559
- // between them they never said WHY it could not be built for a
2560
- // browser -- which is the only thing that tells you whether to change
2561
- // the import or fix the package.
2562
- if (reasons[0]) workerOnlyReasons[specifierOf(_name2)] = reasons[0];
2563
- } else {
2564
- skipped.push({
2565
- specifier: specifierOf(_name2),
2566
- reason: (_reasons$ = reasons[0]) !== null && _reasons$ !== void 0 ? _reasons$ : "build failed"
2567
- });
2614
+ return _context15.f(31);
2615
+ case 32:
2616
+ if (!(worked.worker && worked.browser)) {
2617
+ _context15.n = 33;
2618
+ break;
2568
2619
  }
2569
- case 29:
2570
- _i7++;
2571
- _context15.n = 17;
2620
+ usable.push(_name2);
2621
+ _context15.n = 36;
2572
2622
  break;
2573
- case 30:
2574
- for (_i8 = 0, _Object$entries5 = Object.entries(modules); _i8 < _Object$entries5.length; _i8++) {
2575
- _Object$entries5$_i = regeneratorValues._slicedToArray(_Object$entries5[_i8], 2), _specifier = _Object$entries5$_i[0], _name3 = _Object$entries5$_i[1];
2576
- if (!usable.includes(_name3)) delete modules[_specifier];
2623
+ case 33:
2624
+ if (!worked.worker) {
2625
+ _context15.n = 35;
2626
+ break;
2627
+ }
2628
+ usable.push(_name2);
2629
+ if (!serverOnlyByContract) {
2630
+ _context15.n = 34;
2631
+ break;
2632
+ }
2633
+ return _context15.a(3, 36);
2634
+ case 34:
2635
+ // listed before the first build
2636
+ workerOnly.push(specifierOf(_name2));
2637
+ // Kept, because throwing it away is what made this class of failure
2638
+ // undebuggable. `workerOnly` says a dependency is server-only and
2639
+ // PLATFORM404 says importing it from a component is an error, and
2640
+ // between them they never said WHY it could not be built for a
2641
+ // browser -- which is the only thing that tells you whether to change
2642
+ // the import or fix the package.
2643
+ if (reasons[0]) workerOnlyReasons[specifierOf(_name2)] = reasons[0];
2644
+ _context15.n = 36;
2645
+ break;
2646
+ case 35:
2647
+ skipped.push({
2648
+ specifier: specifierOf(_name2),
2649
+ reason: (_reasons$ = reasons[0]) !== null && _reasons$ !== void 0 ? _reasons$ : "build failed"
2650
+ });
2651
+ case 36:
2652
+ _i9++;
2653
+ _context15.n = 21;
2654
+ break;
2655
+ case 37:
2656
+ for (_i0 = 0, _Object$entries5 = Object.entries(modules); _i0 < _Object$entries5.length; _i0++) {
2657
+ _Object$entries5$_i = regeneratorValues._slicedToArray(_Object$entries5[_i0], 2), _specifier3 = _Object$entries5$_i[0], _name3 = _Object$entries5$_i[1];
2658
+ if (!usable.includes(_name3)) delete modules[_specifier3];
2577
2659
  }
2578
2660
  // Everything failed: a layer with no entries is the same as no layer, and
2579
2661
  // the skip list is what the caller reports.
2580
2662
  if (!(usable.length === 0)) {
2581
- _context15.n = 31;
2663
+ _context15.n = 38;
2582
2664
  break;
2583
2665
  }
2666
+ forgetUncarried();
2584
2667
  return _context15.a(2, {
2585
2668
  rev: "none",
2586
2669
  modules: {},
@@ -2591,62 +2674,65 @@ function _buildVendorLayer() {
2591
2674
  workerOnly: workerOnly,
2592
2675
  workerOnlyReasons: workerOnlyReasons
2593
2676
  });
2594
- case 31:
2595
- _context15.n = 32;
2677
+ case 38:
2678
+ _context15.n = 39;
2596
2679
  return buildTargets({
2597
2680
  worker: usable,
2598
- browser: usable.filter(function (name) {
2599
- return !workerOnly.includes(specifierOf(name));
2600
- })
2681
+ browser: forBrowser(usable)
2601
2682
  }, input, node_path.join(stubs, "out"), false, platform);
2602
- case 32:
2683
+ case 39:
2603
2684
  built = _context15.v;
2604
- case 33:
2605
- _i9 = 0, _Object$entries6 = Object.entries(modules);
2606
- case 34:
2607
- if (!(_i9 < _Object$entries6.length)) {
2608
- _context15.n = 37;
2685
+ case 40:
2686
+ _i1 = 0, _Object$entries6 = Object.entries(modules);
2687
+ case 41:
2688
+ if (!(_i1 < _Object$entries6.length)) {
2689
+ _context15.n = 44;
2609
2690
  break;
2610
2691
  }
2611
- _Object$entries6$_i = regeneratorValues._slicedToArray(_Object$entries6[_i9], 2), _specifier2 = _Object$entries6$_i[0], _name4 = _Object$entries6$_i[1];
2692
+ _Object$entries6$_i = regeneratorValues._slicedToArray(_Object$entries6[_i1], 2), _specifier4 = _Object$entries6$_i[0], _name4 = _Object$entries6$_i[1];
2612
2693
  reason = built.unusable[_name4];
2613
2694
  if (!(reason === undefined)) {
2614
- _context15.n = 35;
2695
+ _context15.n = 42;
2615
2696
  break;
2616
2697
  }
2617
- return _context15.a(3, 36);
2618
- case 35:
2698
+ return _context15.a(3, 43);
2699
+ case 42:
2619
2700
  skipped.push({
2620
- specifier: _specifier2,
2701
+ specifier: _specifier4,
2621
2702
  reason: reason
2622
2703
  });
2623
- delete modules[_specifier2];
2624
- case 36:
2625
- _i9++;
2626
- _context15.n = 34;
2704
+ delete modules[_specifier4];
2705
+ case 43:
2706
+ _i1++;
2707
+ _context15.n = 41;
2627
2708
  break;
2628
- case 37:
2629
- _i0 = 0, _Object$entries7 = Object.entries(modules);
2630
- case 38:
2631
- if (!(_i0 < _Object$entries7.length)) {
2632
- _context15.n = 41;
2709
+ case 44:
2710
+ _i10 = 0, _Object$entries7 = Object.entries(modules);
2711
+ case 45:
2712
+ if (!(_i10 < _Object$entries7.length)) {
2713
+ _context15.n = 48;
2633
2714
  break;
2634
2715
  }
2635
- _Object$entries7$_i = regeneratorValues._slicedToArray(_Object$entries7[_i0], 2), _specifier3 = _Object$entries7$_i[0], _name5 = _Object$entries7$_i[1];
2716
+ _Object$entries7$_i = regeneratorValues._slicedToArray(_Object$entries7[_i10], 2), _specifier5 = _Object$entries7$_i[0], _name5 = _Object$entries7$_i[1];
2636
2717
  _reason = built.serverOnly[_name5];
2637
- if (!(_reason === undefined || workerOnly.includes(_specifier3))) {
2638
- _context15.n = 39;
2718
+ if (!(_reason === undefined || workerOnly.includes(_specifier5))) {
2719
+ _context15.n = 46;
2639
2720
  break;
2640
2721
  }
2641
- return _context15.a(3, 40);
2642
- case 39:
2643
- workerOnly.push(_specifier3);
2644
- workerOnlyReasons[_specifier3] = _reason;
2645
- case 40:
2646
- _i0++;
2647
- _context15.n = 38;
2722
+ return _context15.a(3, 47);
2723
+ case 46:
2724
+ workerOnly.push(_specifier5);
2725
+ workerOnlyReasons[_specifier5] = _reason;
2726
+ case 47:
2727
+ _i10++;
2728
+ _context15.n = 45;
2648
2729
  break;
2649
- case 41:
2730
+ case 48:
2731
+ forgetUncarried();
2732
+
2733
+ // The revision covers the stylesheets too: changing one is a different
2734
+ // dependency set, and the build hash folds in the revision rather than the
2735
+ // contents.
2650
2736
  return _context15.a(2, {
2651
2737
  rev: "".concat(built.rev).concat(cssRev(css) ? "-".concat(cssRev(css)) : ""),
2652
2738
  modules: modules,
@@ -2657,19 +2743,19 @@ function _buildVendorLayer() {
2657
2743
  workerOnly: workerOnly,
2658
2744
  workerOnlyReasons: workerOnlyReasons
2659
2745
  });
2660
- case 42:
2661
- _context15.p = 42;
2662
- _context15.n = 43;
2746
+ case 49:
2747
+ _context15.p = 49;
2748
+ _context15.n = 50;
2663
2749
  return promises.rm(stubs, {
2664
2750
  recursive: true,
2665
2751
  force: true
2666
2752
  });
2667
- case 43:
2668
- return _context15.f(42);
2669
- case 44:
2753
+ case 50:
2754
+ return _context15.f(49);
2755
+ case 51:
2670
2756
  return _context15.a(2);
2671
2757
  }
2672
- }, _callee13, null, [[20, 22], [18, 26, 27, 28], [11,, 42, 44], [3, 7, 8, 9]]);
2758
+ }, _callee13, null, [[24, 26], [22, 30, 31, 32], [11,, 49, 51], [3, 7, 8, 9]]);
2673
2759
  }));
2674
2760
  return _buildVendorLayer.apply(this, arguments);
2675
2761
  }
@@ -1133,6 +1133,24 @@ var PER_PROJECT_ENTRIES = ["#tanstack-router-entry", "#tanstack-start-entry"];
1133
1133
  * fails loudly at load rather than silently shipping a server bundle.
1134
1134
  */
1135
1135
  var SERVER_ENTRIES = ["@tanstack/react-start/server", "@tanstack/react-start-server", "@tanstack/start-server-core"];
1136
+
1137
+ /**
1138
+ * Val's own entry points that are server-only by contract, built for the
1139
+ * worker and never for the browser.
1140
+ *
1141
+ * Without this a dependency goes in the browser half whenever it CAN be built
1142
+ * for a browser, whether or not anything there imports it. `@valbuild/tanstack/demo`
1143
+ * can: it is the demo's server half, and its 15.5 MB is the built Studio it
1144
+ * serves, as strings. A project importing it from its API route got that
1145
+ * twice, once in each half, and the browser copy was never loaded -- a third
1146
+ * of the demo's layer, built, uploaded and stored for nothing.
1147
+ *
1148
+ * Only entries whose purpose is the server, named by the package that
1149
+ * defines them. A client import of one is still caught, by name: the layer
1150
+ * lists it in `workerOnly`, and the app build rejects it (`build.ts`).
1151
+ */
1152
+ var SERVER_ONLY_ENTRIES = ["@valbuild/tanstack/server", "@valbuild/tanstack/demo"];
1153
+ var SERVER_ONLY_REASON = "a server entry point: built for the worker only, by design";
1136
1154
  var SERVER_ENTRY_STUB = "\nthrow new Error(\n 'TanStack Start\\'s server entry is not available in the browser. A project ' +\n 'dependency reached it from client code; on this platform the shell owns ' +\n 'the server side. If this came from a server-only branch guarded by ' +\n 'try/catch, this is the failure it expects.',\n)\n";
1137
1155
  function stubServerEntries(browser) {
1138
1156
  var prefix = "\0platform:server-entry:";
@@ -2316,7 +2334,7 @@ function buildVendorLayer(_x34, _x35, _x36, _x37) {
2316
2334
  }
2317
2335
  function _buildVendorLayer() {
2318
2336
  _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;
2337
+ var modules, _iterator21, _step21, _loop4, stubs, input, _i6, _Object$entries4, _Object$entries4$_i, specifier, name, file, skipped, workerOnly, workerOnlyReasons, specifierOf, _i7, _Object$keys, _specifier, forBrowser, forgetUncarried, usable, built, _i9, _Object$values, _name2, worked, reasons, serverOnlyByContract, _iterator22, _step22, target, _probe$unusable$_name, probe, unbundlable, _message, _reasons$, _i0, _Object$entries5, _Object$entries5$_i, _specifier3, _name3, _i1, _Object$entries6, _Object$entries6$_i, _specifier4, _name4, reason, _i10, _Object$entries7, _Object$entries7$_i, _specifier5, _name5, _reason, _t19, _t20, _t21;
2320
2338
  return _regenerator().w(function (_context15) {
2321
2339
  while (1) switch (_context15.p = _context15.n) {
2322
2340
  case 0:
@@ -2453,26 +2471,63 @@ function _buildVendorLayer() {
2453
2471
  return name === chunk;
2454
2472
  })[0];
2455
2473
  };
2456
- usable = Object.values(modules);
2474
+ _i7 = 0, _Object$keys = Object.keys(modules);
2475
+ case 16:
2476
+ if (!(_i7 < _Object$keys.length)) {
2477
+ _context15.n = 19;
2478
+ break;
2479
+ }
2480
+ _specifier = _Object$keys[_i7];
2481
+ if (SERVER_ONLY_ENTRIES.includes(_specifier)) {
2482
+ _context15.n = 17;
2483
+ break;
2484
+ }
2485
+ return _context15.a(3, 18);
2486
+ case 17:
2487
+ workerOnly.push(_specifier);
2488
+ workerOnlyReasons[_specifier] = SERVER_ONLY_REASON;
2489
+ case 18:
2490
+ _i7++;
2457
2491
  _context15.n = 16;
2458
- return buildTargets(usable, input, join(stubs, "out"), false, platform)["catch"](function (error) {
2492
+ break;
2493
+ case 19:
2494
+ forBrowser = function forBrowser(names) {
2495
+ return names.filter(function (name) {
2496
+ return !workerOnly.includes(specifierOf(name));
2497
+ });
2498
+ }; // Those are listed before the first build, so one that then could not be
2499
+ // built at all is in `skipped`, and is no longer reported as server-only.
2500
+ forgetUncarried = function forgetUncarried() {
2501
+ for (var _i8 = 0, _arr2 = [].concat(workerOnly); _i8 < _arr2.length; _i8++) {
2502
+ var _specifier2 = _arr2[_i8];
2503
+ if (_specifier2 in modules) continue;
2504
+ workerOnly.splice(workerOnly.indexOf(_specifier2), 1);
2505
+ delete workerOnlyReasons[_specifier2];
2506
+ }
2507
+ };
2508
+ usable = Object.values(modules);
2509
+ _context15.n = 20;
2510
+ return buildTargets({
2511
+ worker: usable,
2512
+ browser: forBrowser(usable)
2513
+ }, input, join(stubs, "out"), false, platform)["catch"](function (error) {
2459
2514
  if (error instanceof PinSkewError) throw error;
2460
2515
  return null;
2461
2516
  });
2462
- case 16:
2517
+ case 20:
2463
2518
  built = _context15.v;
2464
2519
  if (built) {
2465
- _context15.n = 33;
2520
+ _context15.n = 40;
2466
2521
  break;
2467
2522
  }
2468
2523
  usable = [];
2469
- _i7 = 0, _Object$values = Object.values(modules);
2470
- case 17:
2471
- if (!(_i7 < _Object$values.length)) {
2472
- _context15.n = 30;
2524
+ _i9 = 0, _Object$values = Object.values(modules);
2525
+ case 21:
2526
+ if (!(_i9 < _Object$values.length)) {
2527
+ _context15.n = 37;
2473
2528
  break;
2474
2529
  }
2475
- _name2 = _Object$values[_i7];
2530
+ _name2 = _Object$values[_i9];
2476
2531
  // Probed per target, because the two sides are not the same question.
2477
2532
  // A package that builds for the worker and not the browser is kept as
2478
2533
  // server-only, and importing it from client code is rejected later by
@@ -2480,85 +2535,113 @@ function _buildVendorLayer() {
2480
2535
  // any more than in the first build: `buildTargets` reports it.
2481
2536
  worked = {};
2482
2537
  reasons = [];
2538
+ serverOnlyByContract = SERVER_ONLY_ENTRIES.includes(specifierOf(_name2));
2483
2539
  _iterator22 = _createForOfIteratorHelper(targetsFor(platform));
2484
- _context15.p = 18;
2540
+ _context15.p = 22;
2485
2541
  _iterator22.s();
2486
- case 19:
2542
+ case 23:
2487
2543
  if ((_step22 = _iterator22.n()).done) {
2488
- _context15.n = 25;
2544
+ _context15.n = 29;
2489
2545
  break;
2490
2546
  }
2491
2547
  target = _step22.value;
2492
- _context15.p = 20;
2493
- _context15.n = 21;
2548
+ if (!(target.name === "browser" && serverOnlyByContract)) {
2549
+ _context15.n = 24;
2550
+ break;
2551
+ }
2552
+ worked.browser = false;
2553
+ return _context15.a(3, 28);
2554
+ case 24:
2555
+ _context15.p = 24;
2556
+ _context15.n = 25;
2494
2557
  return buildTargets({
2495
2558
  worker: target.name === "worker" ? [_name2] : [],
2496
2559
  browser: target.name === "browser" ? [_name2] : []
2497
2560
  }, input, join(stubs, "probe", target.name, _name2), true, platform);
2498
- case 21:
2561
+ case 25:
2499
2562
  probe = _context15.v;
2500
2563
  unbundlable = (_probe$unusable$_name = probe.unusable[_name2]) !== null && _probe$unusable$_name !== void 0 ? _probe$unusable$_name : probe.serverOnly[_name2];
2501
2564
  worked[target.name] = unbundlable === undefined;
2502
2565
  if (unbundlable !== undefined) reasons.push(unbundlable);
2503
- _context15.n = 24;
2566
+ _context15.n = 28;
2504
2567
  break;
2505
- case 22:
2506
- _context15.p = 22;
2568
+ case 26:
2569
+ _context15.p = 26;
2507
2570
  _t20 = _context15.v;
2508
2571
  if (!(_t20 instanceof PinSkewError)) {
2509
- _context15.n = 23;
2572
+ _context15.n = 27;
2510
2573
  break;
2511
2574
  }
2512
2575
  throw _t20;
2513
- case 23:
2576
+ case 27:
2514
2577
  worked[target.name] = false;
2515
2578
  reasons.push(firstLine(String((_message = _t20 === null || _t20 === void 0 ? void 0 : _t20.message) !== null && _message !== void 0 ? _message : _t20)));
2516
- case 24:
2517
- _context15.n = 19;
2579
+ case 28:
2580
+ _context15.n = 23;
2518
2581
  break;
2519
- case 25:
2520
- _context15.n = 27;
2582
+ case 29:
2583
+ _context15.n = 31;
2521
2584
  break;
2522
- case 26:
2523
- _context15.p = 26;
2585
+ case 30:
2586
+ _context15.p = 30;
2524
2587
  _t21 = _context15.v;
2525
2588
  _iterator22.e(_t21);
2526
- case 27:
2527
- _context15.p = 27;
2589
+ case 31:
2590
+ _context15.p = 31;
2528
2591
  _iterator22.f();
2529
- return _context15.f(27);
2530
- case 28:
2531
- if (worked.worker && worked.browser) usable.push(_name2);else if (worked.worker) {
2532
- usable.push(_name2);
2533
- workerOnly.push(specifierOf(_name2));
2534
- // Kept, because throwing it away is what made this class of failure
2535
- // undebuggable. `workerOnly` says a dependency is server-only and
2536
- // PLATFORM404 says importing it from a component is an error, and
2537
- // between them they never said WHY it could not be built for a
2538
- // browser -- which is the only thing that tells you whether to change
2539
- // the import or fix the package.
2540
- if (reasons[0]) workerOnlyReasons[specifierOf(_name2)] = reasons[0];
2541
- } else {
2542
- skipped.push({
2543
- specifier: specifierOf(_name2),
2544
- reason: (_reasons$ = reasons[0]) !== null && _reasons$ !== void 0 ? _reasons$ : "build failed"
2545
- });
2592
+ return _context15.f(31);
2593
+ case 32:
2594
+ if (!(worked.worker && worked.browser)) {
2595
+ _context15.n = 33;
2596
+ break;
2546
2597
  }
2547
- case 29:
2548
- _i7++;
2549
- _context15.n = 17;
2598
+ usable.push(_name2);
2599
+ _context15.n = 36;
2550
2600
  break;
2551
- case 30:
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];
2554
- if (!usable.includes(_name3)) delete modules[_specifier];
2601
+ case 33:
2602
+ if (!worked.worker) {
2603
+ _context15.n = 35;
2604
+ break;
2605
+ }
2606
+ usable.push(_name2);
2607
+ if (!serverOnlyByContract) {
2608
+ _context15.n = 34;
2609
+ break;
2610
+ }
2611
+ return _context15.a(3, 36);
2612
+ case 34:
2613
+ // listed before the first build
2614
+ workerOnly.push(specifierOf(_name2));
2615
+ // Kept, because throwing it away is what made this class of failure
2616
+ // undebuggable. `workerOnly` says a dependency is server-only and
2617
+ // PLATFORM404 says importing it from a component is an error, and
2618
+ // between them they never said WHY it could not be built for a
2619
+ // browser -- which is the only thing that tells you whether to change
2620
+ // the import or fix the package.
2621
+ if (reasons[0]) workerOnlyReasons[specifierOf(_name2)] = reasons[0];
2622
+ _context15.n = 36;
2623
+ break;
2624
+ case 35:
2625
+ skipped.push({
2626
+ specifier: specifierOf(_name2),
2627
+ reason: (_reasons$ = reasons[0]) !== null && _reasons$ !== void 0 ? _reasons$ : "build failed"
2628
+ });
2629
+ case 36:
2630
+ _i9++;
2631
+ _context15.n = 21;
2632
+ break;
2633
+ case 37:
2634
+ for (_i0 = 0, _Object$entries5 = Object.entries(modules); _i0 < _Object$entries5.length; _i0++) {
2635
+ _Object$entries5$_i = _slicedToArray(_Object$entries5[_i0], 2), _specifier3 = _Object$entries5$_i[0], _name3 = _Object$entries5$_i[1];
2636
+ if (!usable.includes(_name3)) delete modules[_specifier3];
2555
2637
  }
2556
2638
  // Everything failed: a layer with no entries is the same as no layer, and
2557
2639
  // the skip list is what the caller reports.
2558
2640
  if (!(usable.length === 0)) {
2559
- _context15.n = 31;
2641
+ _context15.n = 38;
2560
2642
  break;
2561
2643
  }
2644
+ forgetUncarried();
2562
2645
  return _context15.a(2, {
2563
2646
  rev: "none",
2564
2647
  modules: {},
@@ -2569,62 +2652,65 @@ function _buildVendorLayer() {
2569
2652
  workerOnly: workerOnly,
2570
2653
  workerOnlyReasons: workerOnlyReasons
2571
2654
  });
2572
- case 31:
2573
- _context15.n = 32;
2655
+ case 38:
2656
+ _context15.n = 39;
2574
2657
  return buildTargets({
2575
2658
  worker: usable,
2576
- browser: usable.filter(function (name) {
2577
- return !workerOnly.includes(specifierOf(name));
2578
- })
2659
+ browser: forBrowser(usable)
2579
2660
  }, input, join(stubs, "out"), false, platform);
2580
- case 32:
2661
+ case 39:
2581
2662
  built = _context15.v;
2582
- case 33:
2583
- _i9 = 0, _Object$entries6 = Object.entries(modules);
2584
- case 34:
2585
- if (!(_i9 < _Object$entries6.length)) {
2586
- _context15.n = 37;
2663
+ case 40:
2664
+ _i1 = 0, _Object$entries6 = Object.entries(modules);
2665
+ case 41:
2666
+ if (!(_i1 < _Object$entries6.length)) {
2667
+ _context15.n = 44;
2587
2668
  break;
2588
2669
  }
2589
- _Object$entries6$_i = _slicedToArray(_Object$entries6[_i9], 2), _specifier2 = _Object$entries6$_i[0], _name4 = _Object$entries6$_i[1];
2670
+ _Object$entries6$_i = _slicedToArray(_Object$entries6[_i1], 2), _specifier4 = _Object$entries6$_i[0], _name4 = _Object$entries6$_i[1];
2590
2671
  reason = built.unusable[_name4];
2591
2672
  if (!(reason === undefined)) {
2592
- _context15.n = 35;
2673
+ _context15.n = 42;
2593
2674
  break;
2594
2675
  }
2595
- return _context15.a(3, 36);
2596
- case 35:
2676
+ return _context15.a(3, 43);
2677
+ case 42:
2597
2678
  skipped.push({
2598
- specifier: _specifier2,
2679
+ specifier: _specifier4,
2599
2680
  reason: reason
2600
2681
  });
2601
- delete modules[_specifier2];
2602
- case 36:
2603
- _i9++;
2604
- _context15.n = 34;
2682
+ delete modules[_specifier4];
2683
+ case 43:
2684
+ _i1++;
2685
+ _context15.n = 41;
2605
2686
  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;
2687
+ case 44:
2688
+ _i10 = 0, _Object$entries7 = Object.entries(modules);
2689
+ case 45:
2690
+ if (!(_i10 < _Object$entries7.length)) {
2691
+ _context15.n = 48;
2611
2692
  break;
2612
2693
  }
2613
- _Object$entries7$_i = _slicedToArray(_Object$entries7[_i0], 2), _specifier3 = _Object$entries7$_i[0], _name5 = _Object$entries7$_i[1];
2694
+ _Object$entries7$_i = _slicedToArray(_Object$entries7[_i10], 2), _specifier5 = _Object$entries7$_i[0], _name5 = _Object$entries7$_i[1];
2614
2695
  _reason = built.serverOnly[_name5];
2615
- if (!(_reason === undefined || workerOnly.includes(_specifier3))) {
2616
- _context15.n = 39;
2696
+ if (!(_reason === undefined || workerOnly.includes(_specifier5))) {
2697
+ _context15.n = 46;
2617
2698
  break;
2618
2699
  }
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;
2700
+ return _context15.a(3, 47);
2701
+ case 46:
2702
+ workerOnly.push(_specifier5);
2703
+ workerOnlyReasons[_specifier5] = _reason;
2704
+ case 47:
2705
+ _i10++;
2706
+ _context15.n = 45;
2626
2707
  break;
2627
- case 41:
2708
+ case 48:
2709
+ forgetUncarried();
2710
+
2711
+ // The revision covers the stylesheets too: changing one is a different
2712
+ // dependency set, and the build hash folds in the revision rather than the
2713
+ // contents.
2628
2714
  return _context15.a(2, {
2629
2715
  rev: "".concat(built.rev).concat(cssRev(css) ? "-".concat(cssRev(css)) : ""),
2630
2716
  modules: modules,
@@ -2635,19 +2721,19 @@ function _buildVendorLayer() {
2635
2721
  workerOnly: workerOnly,
2636
2722
  workerOnlyReasons: workerOnlyReasons
2637
2723
  });
2638
- case 42:
2639
- _context15.p = 42;
2640
- _context15.n = 43;
2724
+ case 49:
2725
+ _context15.p = 49;
2726
+ _context15.n = 50;
2641
2727
  return rm(stubs, {
2642
2728
  recursive: true,
2643
2729
  force: true
2644
2730
  });
2645
- case 43:
2646
- return _context15.f(42);
2647
- case 44:
2731
+ case 50:
2732
+ return _context15.f(49);
2733
+ case 51:
2648
2734
  return _context15.a(2);
2649
2735
  }
2650
- }, _callee13, null, [[20, 22], [18, 26, 27, 28], [11,, 42, 44], [3, 7, 8, 9]]);
2736
+ }, _callee13, null, [[24, 26], [22, 30, 31, 32], [11,, 49, 51], [3, 7, 8, 9]]);
2651
2737
  }));
2652
2738
  return _buildVendorLayer.apply(this, arguments);
2653
2739
  }
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "url": "git+https://github.com/valbuild/val.git"
8
8
  },
9
9
  "license": "MIT",
10
- "version": "0.148.3",
10
+ "version": "0.148.5",
11
11
  "sideEffects": false,
12
12
  "main": "dist/valbuild-tanstack-build.cjs.js",
13
13
  "module": "dist/valbuild-tanstack-build.esm.js",