@valbuild/tanstack-build 0.144.4 → 0.146.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @valbuild/tanstack-build
2
2
 
3
+ ## 0.146.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#861](https://github.com/valbuild/val/pull/861) [`89b0fa8`](https://github.com/valbuild/val/commit/89b0fa82a3ae0d8ccd5d0282c1034f1f40cc4e26) Thanks [@freekh](https://github.com/freekh)! - Proposals can be brought up to date with the site, like a pull request.
8
+
9
+ - **Update from the site** merges what was published on the site since a proposal started into the proposal, field by field. Where the site and the proposal changed the same field, the Publish dialog shows both and asks which to keep.
10
+ - **With code:** a proposal that changes code, or a site whose code changed since the proposal started, is updated too. The Studio runs each version's schemas in the tab, and the merged code is built before it can be published.
11
+ - Publish offers **Update from the site** whenever the site has moved under the proposal.
12
+
13
+ ## 0.145.1
14
+
15
+ ### Patch Changes
16
+
17
+ - [#860](https://github.com/valbuild/val/pull/860) [`a45f595`](https://github.com/valbuild/val/commit/a45f595a5e20b009d4110bbef8ebdc08b2d731d7) Thanks [@freekh](https://github.com/freekh)! - `val publish` now refuses to build a site whose installed TanStack disagrees with the platform's. A project's CI builds its dependency layer from its own `node_modules`, and a lockfile two patches away from the platform's `@tanstack/*` used to publish fine and then fail on the first request that reached the mismatched code — typically signing in — with "does not provide an export named …". The build now stops with a message naming the package, the version the project resolved and the version the platform carries, and the fix is to pin the package to that version (with `pnpm.overrides` for a transitive one) and reinstall.
18
+
19
+ The same build also checks every import a dependency takes from the platform's React and TanStack against what the platform says those modules export, which until now ran only in the platform's own checkout.
20
+
21
+ Both checks use what the platform reports about itself, so they run once the platform does; until then `val publish` builds as before and says in its output that the check was skipped. They run in the `@valbuild/tanstack-build` the project has installed, so upgrade it alongside `@valbuild/cli`.
22
+
23
+ - [#860](https://github.com/valbuild/val/pull/860) [`a45f595`](https://github.com/valbuild/val/commit/a45f595a5e20b009d4110bbef8ebdc08b2d731d7) Thanks [@freekh](https://github.com/freekh)! - A server function's validator no longer ships to the browser. TanStack Start removes `createServerFn().validator(...)` and `.inputValidator(...)` from client code, because a validator only ever runs on the server; the Val build replaced the handler but left the validator in, so its code — and anything it imported — reached every visitor's bundle. Both spellings are handled: TanStack Start 1.169 removed `.inputValidator()`, and 1.168 has both.
24
+
3
25
  ## 0.144.4
4
26
 
5
27
  ### Patch Changes
@@ -83,6 +83,42 @@ export interface BuildTarget {
83
83
  modules: Record<string, string>;
84
84
  /** The same, for the react-server layer. Empty when RSC is not served. */
85
85
  rscModules: Record<string, string>;
86
+ /**
87
+ * Package -> the exact version this base layer was built from: every
88
+ * package a base specifier belongs to, and every `@tanstack/*` the
89
+ * platform carries.
90
+ *
91
+ * A layer build that bundles one of these at another version refuses,
92
+ * naming both. A project's own copy of a base package is never used for a
93
+ * base specifier, so a lockfile that disagrees here is either harmless or
94
+ * the skew PINS.md records -- and a build that is not running in the
95
+ * platform's own checkout cannot pin to the platform's copy, so it has to
96
+ * be told which is which.
97
+ *
98
+ * These are a property of the base SET, which is why they travel with
99
+ * `rev` rather than beside it: when a project chooses its base set, the
100
+ * answer for that set carries that set's versions, and nothing that reads
101
+ * this has to change.
102
+ *
103
+ * Absent from a loader that predates it. A build then skips the check
104
+ * rather than failing, and says so.
105
+ */
106
+ pins?: Record<string, string>;
107
+ /**
108
+ * Base chunk name -> the names it exports, per target: what a project
109
+ * chunk may import from `${baseFrom}${chunk}.js`.
110
+ *
111
+ * The export audit's facts for a build that has no built base layer on
112
+ * disk, which is every build but the platform's own. A chunk that is not
113
+ * listed is not checked -- the same "cannot be determined" a chunk ending
114
+ * in `export *` gets -- rather than refused.
115
+ *
116
+ * Absent from a loader that predates it, and the audit then skips.
117
+ */
118
+ exports?: {
119
+ worker: Record<string, Array<string>>;
120
+ browser: Record<string, Array<string>>;
121
+ };
86
122
  /** Where the chunks live, as seen from each kind of importer. */
87
123
  paths: {
88
124
  /** The base layer, from a project-layer chunk. */
@@ -33,3 +33,4 @@ export * from "./contract.js";
33
33
  export * from "./artifacts.js";
34
34
  export * from "./gitTree.js";
35
35
  export * from "./wire.js";
36
+ export { bundleValModules } from "./valModules.js";
@@ -11,7 +11,7 @@
11
11
  * Nothing in here is reachable from the package root. See
12
12
  * `noNodeFromBrowser.test.ts`.
13
13
  */
14
- export { BASE_PROVIDED, auditableImports, auditableSpecifiers, buildVendorLayer, chunkNameFor, collectDependencyCss, cssSpecifiersOf, layerDepsOf, packageOf, type VendorLayer, type VendorPlatform, } from "./vendorLayer.js";
14
+ export { BASE_PROVIDED, auditableImports, auditableSpecifiers, buildVendorLayer, chunkNameFor, collectDependencyCss, cssSpecifiersOf, layerDepsOf, packageOf, PinSkewError, type PinSkew, type VendorLayer, type VendorPlatform, } from "./vendorLayer.js";
15
15
  export { nodeShims, nodeShimSources, NODE_SHIMS, REEXPORT, SHIM_PREFIX, } from "./nodeShims.js";
16
16
  export { cssModuleLoader } from "./cssModules.js";
17
17
  export { routeSplitter } from "./routeSplitter.js";
@@ -48,11 +48,35 @@ export interface VendorPlatform {
48
48
  * not built them.
49
49
  *
50
50
  * Only the export audit reads it, and only to check a named import against
51
- * the chunk it will link to. Null means that check is skipped, which is the
52
- * honest answer rather than a refusal -- see `baseChunkExports`.
51
+ * the chunk it will link to. Null means the audit reads what the platform
52
+ * said instead (`base.exports`), and skips a chunk the platform said nothing
53
+ * about, which is the honest answer rather than a refusal -- see
54
+ * `baseChunkExports`.
53
55
  */
54
56
  baseLayerDir: string | null;
55
57
  }
58
+ /** A pinned package, bundled into the layer at a version the base set is not. */
59
+ export interface PinSkew {
60
+ name: string;
61
+ /** What the base set was built from: `BuildTarget.base.pins`. */
62
+ pinned: string;
63
+ /** What the project's own install resolved, and the layer would carry. */
64
+ found: string;
65
+ }
66
+ /**
67
+ * A layer that would carry a pinned package at another version.
68
+ *
69
+ * Its own class because it is the one failure `buildVendorLayer` must NOT
70
+ * absorb. Every other build error drops the dependency that caused it and
71
+ * carries on (see `skipped`), which is right for a Vite plugin nobody imports
72
+ * and wrong here: dropping `@valbuild/tanstack` because its TanStack disagrees
73
+ * with the platform's turns "your lockfile is out of step" into "this import
74
+ * is not available", which names the wrong thing to fix.
75
+ */
76
+ export declare class PinSkewError extends Error {
77
+ readonly skew: Array<PinSkew>;
78
+ constructor(skew: Array<PinSkew>, baseRev: string);
79
+ }
56
80
  export interface VendorLayer {
57
81
  rev: string;
58
82
  /**
@@ -0,0 +1,29 @@
1
+ import type { BuildTarget } from "./contract.js";
2
+ /**
3
+ * A project's `val.modules.ts`, bundled to run: every `.val.ts` it imports,
4
+ * the `val.config` they share and the `.val.json` entries they name, as ONE
5
+ * ES module -- so it can be imported from a `blob:` URL, which cannot resolve
6
+ * a relative chunk -- with every npm import pointing at the site's own
7
+ * vendor chunks, at absolute URLs under `origin`.
8
+ *
9
+ * What the builder tab evaluates to learn a tree's schemas: Update from the
10
+ * site with code (valbuild/home `docs/hosted-publishing.md` step 8.2, slice
11
+ * 1b). The project's own `@valbuild/*` and dependencies are what run, as the
12
+ * site runs them -- the browser half of its layer, from `/_pvendor/<rev>/`,
13
+ * and the base layer from `/_vendor/`. Whoever imports it should do so off
14
+ * the Studio's page: `@valbuild/tanstack` brings React and patches its JSX.
15
+ *
16
+ * Nothing else of a build happens here: no route splitting, no server
17
+ * functions, no CSS -- a `.val.ts` has none of it.
18
+ */
19
+ export declare function bundleValModules(input: {
20
+ /** The tree, by path from the project root. */
21
+ files: Record<string, string>;
22
+ target: BuildTarget;
23
+ /** The site's origin, where its vendor chunks are served. */
24
+ origin: string;
25
+ /** The entry; the project's `val.modules.ts` unless said otherwise. */
26
+ entry?: string;
27
+ }): Promise<{
28
+ code: string;
29
+ }>;
@@ -429,6 +429,16 @@ var assetModule = function assetModule(url) {
429
429
  return "export default ".concat(JSON.stringify(url), "\n");
430
430
  };
431
431
 
432
+ function _typeof(o) {
433
+ "@babel/helpers - typeof";
434
+
435
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
436
+ return typeof o;
437
+ } : function (o) {
438
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
439
+ }, _typeof(o);
440
+ }
441
+
432
442
  function _regeneratorValues(e) {
433
443
  if (null != e) {
434
444
  var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
@@ -447,4 +457,4 @@ function _regeneratorValues(e) {
447
457
  throw new TypeError(typeof e + " is not iterable");
448
458
  }
449
459
 
450
- export { ASSET_BASE as A, INLINE_LIMIT as I, _createForOfIteratorHelper as _, _asyncToGenerator as a, _regenerator as b, _toConsumableArray as c, _slicedToArray as d, _objectSpread2 as e, _defineProperty as f, _regeneratorValues as g, assetModule as h, isAsset as i, base64Bytes as j, resolveAsset as r, sha256Hex as s };
460
+ export { ASSET_BASE as A, INLINE_LIMIT as I, _createForOfIteratorHelper as _, _asyncToGenerator as a, _regenerator as b, _toConsumableArray as c, _slicedToArray as d, _typeof as e, _objectSpread2 as f, _defineProperty as g, _regeneratorValues as h, assetModule as i, isAsset as j, base64Bytes as k, _toPropertyKey as l, resolveAsset as r, sha256Hex as s };
@@ -431,6 +431,16 @@ var assetModule = function assetModule(url) {
431
431
  return "export default ".concat(JSON.stringify(url), "\n");
432
432
  };
433
433
 
434
+ function _typeof(o) {
435
+ "@babel/helpers - typeof";
436
+
437
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
438
+ return typeof o;
439
+ } : function (o) {
440
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
441
+ }, _typeof(o);
442
+ }
443
+
434
444
  function _regeneratorValues(e) {
435
445
  if (null != e) {
436
446
  var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
@@ -459,6 +469,8 @@ exports._regenerator = _regenerator;
459
469
  exports._regeneratorValues = _regeneratorValues;
460
470
  exports._slicedToArray = _slicedToArray;
461
471
  exports._toConsumableArray = _toConsumableArray;
472
+ exports._toPropertyKey = _toPropertyKey;
473
+ exports._typeof = _typeof;
462
474
  exports.assetModule = assetModule;
463
475
  exports.base64Bytes = base64Bytes;
464
476
  exports.isAsset = isAsset;
@@ -431,6 +431,16 @@ var assetModule = function assetModule(url) {
431
431
  return "export default ".concat(JSON.stringify(url), "\n");
432
432
  };
433
433
 
434
+ function _typeof(o) {
435
+ "@babel/helpers - typeof";
436
+
437
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
438
+ return typeof o;
439
+ } : function (o) {
440
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
441
+ }, _typeof(o);
442
+ }
443
+
434
444
  function _regeneratorValues(e) {
435
445
  if (null != e) {
436
446
  var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
@@ -459,6 +469,8 @@ exports._regenerator = _regenerator;
459
469
  exports._regeneratorValues = _regeneratorValues;
460
470
  exports._slicedToArray = _slicedToArray;
461
471
  exports._toConsumableArray = _toConsumableArray;
472
+ exports._toPropertyKey = _toPropertyKey;
473
+ exports._typeof = _typeof;
462
474
  exports.assetModule = assetModule;
463
475
  exports.base64Bytes = base64Bytes;
464
476
  exports.isAsset = isAsset;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var regeneratorValues = require('./regeneratorValues-5b6a1f70.cjs.dev.js');
5
+ var regeneratorValues = require('./regeneratorValues-f5d7ce8a.cjs.dev.js');
6
6
  var browser = require('@rolldown/browser');
7
7
  var projectPaths = require('./projectPaths-f222255a.cjs.dev.js');
8
8
  var parseAst = require('@rolldown/browser/parseAst');
@@ -201,6 +201,47 @@ function rscEntrySource(files) {
201
201
  var REGISTRY_REEXPORT = "\nexport { __serverFns } from ".concat(JSON.stringify(REGISTRY_ID), "\n");
202
202
  var SERVER_RPC = "@tanstack/react-start/server-rpc";
203
203
  var CLIENT_RPC = "@tanstack/react-start/client-rpc";
204
+ /**
205
+ * Both spellings, because both are supported while a supported version set
206
+ * has each: Start 1.169 removed `inputValidator` from its runtime, and 1.168
207
+ * has both. See `version-sets/` in valbuild/home.
208
+ */
209
+ var VALIDATOR_METHODS = new Set(["validator", "inputValidator"]);
210
+
211
+ /**
212
+ * The validator calls in a `createServerFn()` chain, which the CLIENT build
213
+ * drops as Start's `handleCreateServerFn` does (`stripMethodCall`).
214
+ *
215
+ * A validator is server code: it runs before the handler, on the server, and
216
+ * nothing in the browser calls it. Left in, it ships to every visitor along
217
+ * with whatever it imports -- the schema library at best, and a server-only
218
+ * module at worst. Only the handler used to be replaced, so for a long time
219
+ * this went to the browser unnoticed; `patterns-test.ts` in valbuild/home now
220
+ * asserts the validator's body is absent from the client bundle.
221
+ */
222
+ function validatorsOf(chain, moduleId) {
223
+ var found = [];
224
+ var current = chain;
225
+ while (current && current.type === "CallExpression") {
226
+ var _callee$property;
227
+ var callee = current.callee;
228
+ if ((callee === null || callee === void 0 ? void 0 : callee.type) !== "MemberExpression") break;
229
+ var name = (_callee$property = callee.property) === null || _callee$property === void 0 ? void 0 : _callee$property.name;
230
+ if (typeof name === "string" && VALIDATOR_METHODS.has(name)) {
231
+ var _current$arguments;
232
+ if (!((_current$arguments = current.arguments) !== null && _current$arguments !== void 0 && _current$arguments[0])) {
233
+ throw new Error("".concat(moduleId, ": createServerFn().").concat(name, "() must be called with a validator."));
234
+ }
235
+ found.push({
236
+ start: callee.object.end,
237
+ end: current.end
238
+ });
239
+ }
240
+ current = callee.object;
241
+ }
242
+ return found;
243
+ }
244
+
204
245
  /**
205
246
  * Ids must be identical across the two passes, since one produces the registry
206
247
  * key and the other the URL that looks it up. Derived from the module id and
@@ -241,11 +282,11 @@ function findSites(ast, moduleId, code, seen) {
241
282
  var sites = [];
242
283
  var names = new Set();
243
284
  walk(ast, function (node, stack) {
244
- var _callee$property, _node$arguments, _declarator$id;
285
+ var _callee$property2, _node$arguments, _declarator$id;
245
286
  if (node.type !== "CallExpression") return;
246
287
  var callee = node.callee;
247
288
  if ((callee === null || callee === void 0 ? void 0 : callee.type) !== "MemberExpression") return;
248
- if (((_callee$property = callee.property) === null || _callee$property === void 0 ? void 0 : _callee$property.name) !== "handler") return;
289
+ if (((_callee$property2 = callee.property) === null || _callee$property2 === void 0 ? void 0 : _callee$property2.name) !== "handler") return;
249
290
  if (!isCreateServerFnChain(callee.object)) return;
250
291
  var arg = (_node$arguments = node.arguments) === null || _node$arguments === void 0 ? void 0 : _node$arguments[0];
251
292
  if (!arg) {
@@ -283,7 +324,8 @@ function findSites(ast, moduleId, code, seen) {
283
324
  argStart: arg.start,
284
325
  argEnd: arg.end,
285
326
  declStart: statement.start,
286
- declEnd: statement.end
327
+ declEnd: statement.end,
328
+ validators: validatorsOf(callee.object, moduleId)
287
329
  });
288
330
  });
289
331
  return sites;
@@ -297,7 +339,7 @@ function transformServerFns(_x, _x2, _x3, _x4) {
297
339
  }
298
340
  function _transformServerFns() {
299
341
  _transformServerFns = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee(moduleId, code, target, seen) {
300
- var ast, sites, edits, _iterator, _step, site, meta, out, prelude;
342
+ var ast, sites, edits, _iterator, _step, site, meta, _iterator2, _step2, validator, out, prelude;
301
343
  return regeneratorValues._regenerator().w(function (_context) {
302
344
  while (1) switch (_context.n) {
303
345
  case 0:
@@ -353,6 +395,21 @@ function _transformServerFns() {
353
395
  end: site.argEnd,
354
396
  text: "__platformClientRpc(".concat(JSON.stringify(site.id), ")")
355
397
  });
398
+ _iterator2 = regeneratorValues._createForOfIteratorHelper(site.validators);
399
+ try {
400
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
401
+ validator = _step2.value;
402
+ edits.push({
403
+ start: validator.start,
404
+ end: validator.end,
405
+ text: ""
406
+ });
407
+ }
408
+ } catch (err) {
409
+ _iterator2.e(err);
410
+ } finally {
411
+ _iterator2.f();
412
+ }
356
413
  }
357
414
  }
358
415
  } catch (err) {
@@ -1035,16 +1092,6 @@ function _objectWithoutProperties(e, t) {
1035
1092
  return i;
1036
1093
  }
1037
1094
 
1038
- function _typeof(o) {
1039
- "@babel/helpers - typeof";
1040
-
1041
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
1042
- return typeof o;
1043
- } : function (o) {
1044
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
1045
- }, _typeof(o);
1046
- }
1047
-
1048
1095
  var packageJson = {
1049
1096
  name: "@valbuild/tanstack-build",
1050
1097
  "private": false,
@@ -1054,7 +1101,7 @@ var packageJson = {
1054
1101
  url: "git+https://github.com/valbuild/val.git"
1055
1102
  },
1056
1103
  license: "MIT",
1057
- version: "0.144.4",
1104
+ version: "0.146.0",
1058
1105
  sideEffects: false,
1059
1106
  main: "dist/valbuild-tanstack-build.cjs.js",
1060
1107
  module: "dist/valbuild-tanstack-build.esm.js",
@@ -1399,7 +1446,7 @@ function bakedGit(files) {
1399
1446
  if (!(match !== null && match !== void 0 && match[1]) || match[1] === "null") return undefined;
1400
1447
  try {
1401
1448
  var parsed = JSON.parse(match[1]);
1402
- if (_typeof(parsed) !== "object" || parsed === null) return undefined;
1449
+ if (regeneratorValues._typeof(parsed) !== "object" || parsed === null) return undefined;
1403
1450
  var _ref2 = parsed,
1404
1451
  commit = _ref2.commit,
1405
1452
  branch = _ref2.branch;
@@ -1704,7 +1751,7 @@ function _digests() {
1704
1751
  }
1705
1752
  function canonicalJson(value) {
1706
1753
  if (Array.isArray(value)) return "[".concat(value.map(canonicalJson).join(","), "]");
1707
- if (value !== null && _typeof(value) === "object") {
1754
+ if (value !== null && regeneratorValues._typeof(value) === "object") {
1708
1755
  var entries = Object.entries(value).filter(function (_ref) {
1709
1756
  var _ref2 = regeneratorValues._slicedToArray(_ref, 2),
1710
1757
  item = _ref2[1];
@@ -4454,6 +4501,155 @@ function treeShaOfText(files) {
4454
4501
  })));
4455
4502
  }
4456
4503
 
4504
+ /**
4505
+ * A project's `val.modules.ts`, bundled to run: every `.val.ts` it imports,
4506
+ * the `val.config` they share and the `.val.json` entries they name, as ONE
4507
+ * ES module -- so it can be imported from a `blob:` URL, which cannot resolve
4508
+ * a relative chunk -- with every npm import pointing at the site's own
4509
+ * vendor chunks, at absolute URLs under `origin`.
4510
+ *
4511
+ * What the builder tab evaluates to learn a tree's schemas: Update from the
4512
+ * site with code (valbuild/home `docs/hosted-publishing.md` step 8.2, slice
4513
+ * 1b). The project's own `@valbuild/*` and dependencies are what run, as the
4514
+ * site runs them -- the browser half of its layer, from `/_pvendor/<rev>/`,
4515
+ * and the base layer from `/_vendor/`. Whoever imports it should do so off
4516
+ * the Studio's page: `@valbuild/tanstack` brings React and patches its JSX.
4517
+ *
4518
+ * Nothing else of a build happens here: no route splitting, no server
4519
+ * functions, no CSS -- a `.val.ts` has none of it.
4520
+ */
4521
+ function bundleValModules(_x) {
4522
+ return _bundleValModules.apply(this, arguments);
4523
+ }
4524
+ function _bundleValModules() {
4525
+ _bundleValModules = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee(input) {
4526
+ var _input$entry;
4527
+ var files, target, origin, entry, warnings, aliases, base, project, resolveProjectPath, result, chunks, _t;
4528
+ return regeneratorValues._regenerator().w(function (_context) {
4529
+ while (1) switch (_context.p = _context.n) {
4530
+ case 0:
4531
+ files = input.files, target = input.target, origin = input.origin;
4532
+ entry = (_input$entry = input.entry) !== null && _input$entry !== void 0 ? _input$entry : ["val.modules.ts", "val.modules.js"].find(function (path) {
4533
+ return path in files;
4534
+ });
4535
+ if (!(entry === undefined || !(entry in files))) {
4536
+ _context.n = 1;
4537
+ break;
4538
+ }
4539
+ throw new Error("This project has no val.modules.ts, so its Val modules cannot be read.");
4540
+ case 1:
4541
+ warnings = [];
4542
+ aliases = aliasMap(files, function (message) {
4543
+ return warnings.push(message);
4544
+ });
4545
+ base = "".concat(origin, "/_vendor/");
4546
+ project = target.project.rev === null ? null : "".concat(origin, "/_pvendor/").concat(target.project.rev, "/");
4547
+ resolveProjectPath = function resolveProjectPath(path) {
4548
+ return resolveInFiles(path, files);
4549
+ };
4550
+ _context.p = 2;
4551
+ _context.n = 3;
4552
+ return browser.build({
4553
+ input: entry,
4554
+ // See `buildOnce`: required in the browser, inert here.
4555
+ cwd: "/",
4556
+ moduleTypes: {
4557
+ ".css": "empty"
4558
+ },
4559
+ plugins: [{
4560
+ name: "val:modules",
4561
+ resolveId: function resolveId(source, importer) {
4562
+ if (source.startsWith(".")) {
4563
+ return resolveProjectPath(resolve(dirname(importer !== null && importer !== void 0 ? importer : entry), source));
4564
+ }
4565
+ if (source in files) return source;
4566
+ var baseChunk = target.base.modules[source];
4567
+ if (baseChunk) {
4568
+ return {
4569
+ id: "".concat(base).concat(baseChunk, ".js"),
4570
+ external: true
4571
+ };
4572
+ }
4573
+ var projectChunk = target.project.modules[source];
4574
+ if (projectChunk && project !== null) {
4575
+ if (target.project.workerOnly.includes(source)) {
4576
+ throw new Error("'".concat(source, "' is server-only in this project's vendor layer, so a .val.ts importing it cannot be read in the browser."));
4577
+ }
4578
+ return {
4579
+ id: "".concat(project).concat(projectChunk, ".js"),
4580
+ external: true
4581
+ };
4582
+ }
4583
+ if (aliases) {
4584
+ var _iterator = regeneratorValues._createForOfIteratorHelper(aliases.candidates(source)),
4585
+ _step;
4586
+ try {
4587
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
4588
+ var candidate = _step.value;
4589
+ var _hit = resolveProjectPath(candidate);
4590
+ if (_hit) return _hit;
4591
+ }
4592
+ } catch (err) {
4593
+ _iterator.e(err);
4594
+ } finally {
4595
+ _iterator.f();
4596
+ }
4597
+ var fromBaseUrl = aliases.baseUrlCandidate(source);
4598
+ var hit = fromBaseUrl && resolveProjectPath(fromBaseUrl);
4599
+ if (hit) return hit;
4600
+ }
4601
+ // An error, not a warning: rolldown would otherwise leave the
4602
+ // specifier as it is, and it would fail when imported, unnamed.
4603
+ throw new Error("'".concat(source, "' is not an available dependency. Available: ").concat([].concat(regeneratorValues._toConsumableArray(Object.keys(target.base.modules)), regeneratorValues._toConsumableArray(Object.keys(target.project.modules))).join(", "), "."));
4604
+ },
4605
+ load: function load(id) {
4606
+ return id in files ? files[id] : null;
4607
+ }
4608
+ }],
4609
+ transform: {
4610
+ jsx: {
4611
+ runtime: "automatic",
4612
+ importSource: "react"
4613
+ }
4614
+ },
4615
+ output: {
4616
+ format: "esm",
4617
+ minify: false,
4618
+ // One module: `def: () => import("./x.val")` stays a dynamic import of
4619
+ // something already in the file.
4620
+ codeSplitting: false
4621
+ },
4622
+ write: false
4623
+ });
4624
+ case 3:
4625
+ result = _context.v;
4626
+ _context.n = 5;
4627
+ break;
4628
+ case 4:
4629
+ _context.p = 4;
4630
+ _t = _context.v;
4631
+ throw new Error(["The Val modules could not be bundled."].concat(warnings, [_t instanceof Error ? _t.message : String(_t)]).join("\n"), {
4632
+ cause: _t
4633
+ });
4634
+ case 5:
4635
+ chunks = result.output.filter(function (output) {
4636
+ return output.type === "chunk";
4637
+ });
4638
+ if (!(chunks.length !== 1)) {
4639
+ _context.n = 6;
4640
+ break;
4641
+ }
4642
+ throw new Error("Bundling the Val modules made ".concat(chunks.length, " chunks rather than one."));
4643
+ case 6:
4644
+ return _context.a(2, {
4645
+ code: chunks[0].code
4646
+ });
4647
+ }
4648
+ }, _callee, null, [[2, 4]]);
4649
+ }));
4650
+ return _bundleValModules.apply(this, arguments);
4651
+ }
4652
+
4457
4653
  exports.INLINE_LIMIT = regeneratorValues.INLINE_LIMIT;
4458
4654
  exports.base64Bytes = regeneratorValues.base64Bytes;
4459
4655
  exports.isAsset = regeneratorValues.isAsset;
@@ -4472,6 +4668,7 @@ exports.bakedJob = bakedJob;
4472
4668
  exports.blobSha = blobSha;
4473
4669
  exports.buildInputId = buildInputId;
4474
4670
  exports.buildUserApp = buildUserApp;
4671
+ exports.bundleValModules = bundleValModules;
4475
4672
  exports.fetchBuildTarget = fetchBuildTarget;
4476
4673
  exports.fetchBuildTargetRev = fetchBuildTargetRev;
4477
4674
  exports.isValProject = isValProject;