@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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var regeneratorValues = require('./regeneratorValues-295cad22.cjs.prod.js');
5
+ var regeneratorValues = require('./regeneratorValues-eb61e1b2.cjs.prod.js');
6
6
  var browser = require('@rolldown/browser');
7
7
  var projectPaths = require('./projectPaths-9cbecebf.cjs.prod.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;
@@ -1,5 +1,5 @@
1
- import { _ as _createForOfIteratorHelper, a as _asyncToGenerator, b as _regenerator, c as _toConsumableArray, d as _slicedToArray, s as sha256Hex, e as _objectSpread2, f as _defineProperty, g as _regeneratorValues, r as resolveAsset, h as assetModule, i as isAsset } from './regeneratorValues-4fe49970.esm.js';
2
- export { I as INLINE_LIMIT, j as base64Bytes, i as isAsset } from './regeneratorValues-4fe49970.esm.js';
1
+ import { _ as _createForOfIteratorHelper, a as _asyncToGenerator, b as _regenerator, c as _toConsumableArray, d as _slicedToArray, s as sha256Hex, e as _typeof, f as _objectSpread2, g as _defineProperty, h as _regeneratorValues, r as resolveAsset, i as assetModule, j as isAsset } from './regeneratorValues-77cb8c45.esm.js';
2
+ export { I as INLINE_LIMIT, k as base64Bytes, j as isAsset } from './regeneratorValues-77cb8c45.esm.js';
3
3
  import { build } from '@rolldown/browser';
4
4
  import { T as TREE, E as ENTRY } from './projectPaths-5e4defea.esm.js';
5
5
  export { E as ENTRY, R as ROUTES_DIR, T as TREE } from './projectPaths-5e4defea.esm.js';
@@ -200,6 +200,47 @@ function rscEntrySource(files) {
200
200
  var REGISTRY_REEXPORT = "\nexport { __serverFns } from ".concat(JSON.stringify(REGISTRY_ID), "\n");
201
201
  var SERVER_RPC = "@tanstack/react-start/server-rpc";
202
202
  var CLIENT_RPC = "@tanstack/react-start/client-rpc";
203
+ /**
204
+ * Both spellings, because both are supported while a supported version set
205
+ * has each: Start 1.169 removed `inputValidator` from its runtime, and 1.168
206
+ * has both. See `version-sets/` in valbuild/home.
207
+ */
208
+ var VALIDATOR_METHODS = new Set(["validator", "inputValidator"]);
209
+
210
+ /**
211
+ * The validator calls in a `createServerFn()` chain, which the CLIENT build
212
+ * drops as Start's `handleCreateServerFn` does (`stripMethodCall`).
213
+ *
214
+ * A validator is server code: it runs before the handler, on the server, and
215
+ * nothing in the browser calls it. Left in, it ships to every visitor along
216
+ * with whatever it imports -- the schema library at best, and a server-only
217
+ * module at worst. Only the handler used to be replaced, so for a long time
218
+ * this went to the browser unnoticed; `patterns-test.ts` in valbuild/home now
219
+ * asserts the validator's body is absent from the client bundle.
220
+ */
221
+ function validatorsOf(chain, moduleId) {
222
+ var found = [];
223
+ var current = chain;
224
+ while (current && current.type === "CallExpression") {
225
+ var _callee$property;
226
+ var callee = current.callee;
227
+ if ((callee === null || callee === void 0 ? void 0 : callee.type) !== "MemberExpression") break;
228
+ var name = (_callee$property = callee.property) === null || _callee$property === void 0 ? void 0 : _callee$property.name;
229
+ if (typeof name === "string" && VALIDATOR_METHODS.has(name)) {
230
+ var _current$arguments;
231
+ if (!((_current$arguments = current.arguments) !== null && _current$arguments !== void 0 && _current$arguments[0])) {
232
+ throw new Error("".concat(moduleId, ": createServerFn().").concat(name, "() must be called with a validator."));
233
+ }
234
+ found.push({
235
+ start: callee.object.end,
236
+ end: current.end
237
+ });
238
+ }
239
+ current = callee.object;
240
+ }
241
+ return found;
242
+ }
243
+
203
244
  /**
204
245
  * Ids must be identical across the two passes, since one produces the registry
205
246
  * key and the other the URL that looks it up. Derived from the module id and
@@ -240,11 +281,11 @@ function findSites(ast, moduleId, code, seen) {
240
281
  var sites = [];
241
282
  var names = new Set();
242
283
  walk(ast, function (node, stack) {
243
- var _callee$property, _node$arguments, _declarator$id;
284
+ var _callee$property2, _node$arguments, _declarator$id;
244
285
  if (node.type !== "CallExpression") return;
245
286
  var callee = node.callee;
246
287
  if ((callee === null || callee === void 0 ? void 0 : callee.type) !== "MemberExpression") return;
247
- if (((_callee$property = callee.property) === null || _callee$property === void 0 ? void 0 : _callee$property.name) !== "handler") return;
288
+ if (((_callee$property2 = callee.property) === null || _callee$property2 === void 0 ? void 0 : _callee$property2.name) !== "handler") return;
248
289
  if (!isCreateServerFnChain(callee.object)) return;
249
290
  var arg = (_node$arguments = node.arguments) === null || _node$arguments === void 0 ? void 0 : _node$arguments[0];
250
291
  if (!arg) {
@@ -282,7 +323,8 @@ function findSites(ast, moduleId, code, seen) {
282
323
  argStart: arg.start,
283
324
  argEnd: arg.end,
284
325
  declStart: statement.start,
285
- declEnd: statement.end
326
+ declEnd: statement.end,
327
+ validators: validatorsOf(callee.object, moduleId)
286
328
  });
287
329
  });
288
330
  return sites;
@@ -296,7 +338,7 @@ function transformServerFns(_x, _x2, _x3, _x4) {
296
338
  }
297
339
  function _transformServerFns() {
298
340
  _transformServerFns = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(moduleId, code, target, seen) {
299
- var ast, sites, edits, _iterator, _step, site, meta, out, prelude;
341
+ var ast, sites, edits, _iterator, _step, site, meta, _iterator2, _step2, validator, out, prelude;
300
342
  return _regenerator().w(function (_context) {
301
343
  while (1) switch (_context.n) {
302
344
  case 0:
@@ -352,6 +394,21 @@ function _transformServerFns() {
352
394
  end: site.argEnd,
353
395
  text: "__platformClientRpc(".concat(JSON.stringify(site.id), ")")
354
396
  });
397
+ _iterator2 = _createForOfIteratorHelper(site.validators);
398
+ try {
399
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
400
+ validator = _step2.value;
401
+ edits.push({
402
+ start: validator.start,
403
+ end: validator.end,
404
+ text: ""
405
+ });
406
+ }
407
+ } catch (err) {
408
+ _iterator2.e(err);
409
+ } finally {
410
+ _iterator2.f();
411
+ }
355
412
  }
356
413
  }
357
414
  } catch (err) {
@@ -1034,16 +1091,6 @@ function _objectWithoutProperties(e, t) {
1034
1091
  return i;
1035
1092
  }
1036
1093
 
1037
- function _typeof(o) {
1038
- "@babel/helpers - typeof";
1039
-
1040
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
1041
- return typeof o;
1042
- } : function (o) {
1043
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
1044
- }, _typeof(o);
1045
- }
1046
-
1047
1094
  var packageJson = {
1048
1095
  name: "@valbuild/tanstack-build",
1049
1096
  "private": false,
@@ -1053,7 +1100,7 @@ var packageJson = {
1053
1100
  url: "git+https://github.com/valbuild/val.git"
1054
1101
  },
1055
1102
  license: "MIT",
1056
- version: "0.144.4",
1103
+ version: "0.146.0",
1057
1104
  sideEffects: false,
1058
1105
  main: "dist/valbuild-tanstack-build.cjs.js",
1059
1106
  module: "dist/valbuild-tanstack-build.esm.js",
@@ -4453,4 +4500,153 @@ function treeShaOfText(files) {
4453
4500
  })));
4454
4501
  }
4455
4502
 
4456
- export { ENTRY_CHUNK, PROJECT_SOURCE, PUBLIC_PREFIX, VAL_SERVER_PATH, aliasMap, bakedGit, bakedJob, blobSha, buildInputId, buildUserApp, fetchBuildTarget, fetchBuildTargetRev, isValProject, isWired, publishArtifacts, publishPayload, rebakeGit, resolveInFiles, scanCandidates, treeSha, treeShaOfText, usesTailwind, wireUp, wiredValServer, withoutBakedJob };
4503
+ /**
4504
+ * A project's `val.modules.ts`, bundled to run: every `.val.ts` it imports,
4505
+ * the `val.config` they share and the `.val.json` entries they name, as ONE
4506
+ * ES module -- so it can be imported from a `blob:` URL, which cannot resolve
4507
+ * a relative chunk -- with every npm import pointing at the site's own
4508
+ * vendor chunks, at absolute URLs under `origin`.
4509
+ *
4510
+ * What the builder tab evaluates to learn a tree's schemas: Update from the
4511
+ * site with code (valbuild/home `docs/hosted-publishing.md` step 8.2, slice
4512
+ * 1b). The project's own `@valbuild/*` and dependencies are what run, as the
4513
+ * site runs them -- the browser half of its layer, from `/_pvendor/<rev>/`,
4514
+ * and the base layer from `/_vendor/`. Whoever imports it should do so off
4515
+ * the Studio's page: `@valbuild/tanstack` brings React and patches its JSX.
4516
+ *
4517
+ * Nothing else of a build happens here: no route splitting, no server
4518
+ * functions, no CSS -- a `.val.ts` has none of it.
4519
+ */
4520
+ function bundleValModules(_x) {
4521
+ return _bundleValModules.apply(this, arguments);
4522
+ }
4523
+ function _bundleValModules() {
4524
+ _bundleValModules = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(input) {
4525
+ var _input$entry;
4526
+ var files, target, origin, entry, warnings, aliases, base, project, resolveProjectPath, result, chunks, _t;
4527
+ return _regenerator().w(function (_context) {
4528
+ while (1) switch (_context.p = _context.n) {
4529
+ case 0:
4530
+ files = input.files, target = input.target, origin = input.origin;
4531
+ entry = (_input$entry = input.entry) !== null && _input$entry !== void 0 ? _input$entry : ["val.modules.ts", "val.modules.js"].find(function (path) {
4532
+ return path in files;
4533
+ });
4534
+ if (!(entry === undefined || !(entry in files))) {
4535
+ _context.n = 1;
4536
+ break;
4537
+ }
4538
+ throw new Error("This project has no val.modules.ts, so its Val modules cannot be read.");
4539
+ case 1:
4540
+ warnings = [];
4541
+ aliases = aliasMap(files, function (message) {
4542
+ return warnings.push(message);
4543
+ });
4544
+ base = "".concat(origin, "/_vendor/");
4545
+ project = target.project.rev === null ? null : "".concat(origin, "/_pvendor/").concat(target.project.rev, "/");
4546
+ resolveProjectPath = function resolveProjectPath(path) {
4547
+ return resolveInFiles(path, files);
4548
+ };
4549
+ _context.p = 2;
4550
+ _context.n = 3;
4551
+ return build({
4552
+ input: entry,
4553
+ // See `buildOnce`: required in the browser, inert here.
4554
+ cwd: "/",
4555
+ moduleTypes: {
4556
+ ".css": "empty"
4557
+ },
4558
+ plugins: [{
4559
+ name: "val:modules",
4560
+ resolveId: function resolveId(source, importer) {
4561
+ if (source.startsWith(".")) {
4562
+ return resolveProjectPath(resolve(dirname(importer !== null && importer !== void 0 ? importer : entry), source));
4563
+ }
4564
+ if (source in files) return source;
4565
+ var baseChunk = target.base.modules[source];
4566
+ if (baseChunk) {
4567
+ return {
4568
+ id: "".concat(base).concat(baseChunk, ".js"),
4569
+ external: true
4570
+ };
4571
+ }
4572
+ var projectChunk = target.project.modules[source];
4573
+ if (projectChunk && project !== null) {
4574
+ if (target.project.workerOnly.includes(source)) {
4575
+ 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."));
4576
+ }
4577
+ return {
4578
+ id: "".concat(project).concat(projectChunk, ".js"),
4579
+ external: true
4580
+ };
4581
+ }
4582
+ if (aliases) {
4583
+ var _iterator = _createForOfIteratorHelper(aliases.candidates(source)),
4584
+ _step;
4585
+ try {
4586
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
4587
+ var candidate = _step.value;
4588
+ var _hit = resolveProjectPath(candidate);
4589
+ if (_hit) return _hit;
4590
+ }
4591
+ } catch (err) {
4592
+ _iterator.e(err);
4593
+ } finally {
4594
+ _iterator.f();
4595
+ }
4596
+ var fromBaseUrl = aliases.baseUrlCandidate(source);
4597
+ var hit = fromBaseUrl && resolveProjectPath(fromBaseUrl);
4598
+ if (hit) return hit;
4599
+ }
4600
+ // An error, not a warning: rolldown would otherwise leave the
4601
+ // specifier as it is, and it would fail when imported, unnamed.
4602
+ throw new Error("'".concat(source, "' is not an available dependency. Available: ").concat([].concat(_toConsumableArray(Object.keys(target.base.modules)), _toConsumableArray(Object.keys(target.project.modules))).join(", "), "."));
4603
+ },
4604
+ load: function load(id) {
4605
+ return id in files ? files[id] : null;
4606
+ }
4607
+ }],
4608
+ transform: {
4609
+ jsx: {
4610
+ runtime: "automatic",
4611
+ importSource: "react"
4612
+ }
4613
+ },
4614
+ output: {
4615
+ format: "esm",
4616
+ minify: false,
4617
+ // One module: `def: () => import("./x.val")` stays a dynamic import of
4618
+ // something already in the file.
4619
+ codeSplitting: false
4620
+ },
4621
+ write: false
4622
+ });
4623
+ case 3:
4624
+ result = _context.v;
4625
+ _context.n = 5;
4626
+ break;
4627
+ case 4:
4628
+ _context.p = 4;
4629
+ _t = _context.v;
4630
+ throw new Error(["The Val modules could not be bundled."].concat(warnings, [_t instanceof Error ? _t.message : String(_t)]).join("\n"), {
4631
+ cause: _t
4632
+ });
4633
+ case 5:
4634
+ chunks = result.output.filter(function (output) {
4635
+ return output.type === "chunk";
4636
+ });
4637
+ if (!(chunks.length !== 1)) {
4638
+ _context.n = 6;
4639
+ break;
4640
+ }
4641
+ throw new Error("Bundling the Val modules made ".concat(chunks.length, " chunks rather than one."));
4642
+ case 6:
4643
+ return _context.a(2, {
4644
+ code: chunks[0].code
4645
+ });
4646
+ }
4647
+ }, _callee, null, [[2, 4]]);
4648
+ }));
4649
+ return _bundleValModules.apply(this, arguments);
4650
+ }
4651
+
4652
+ export { ENTRY_CHUNK, PROJECT_SOURCE, PUBLIC_PREFIX, VAL_SERVER_PATH, aliasMap, bakedGit, bakedJob, blobSha, buildInputId, buildUserApp, bundleValModules, fetchBuildTarget, fetchBuildTargetRev, isValProject, isWired, publishArtifacts, publishPayload, rebakeGit, resolveInFiles, scanCandidates, treeSha, treeShaOfText, usesTailwind, wireUp, wiredValServer, withoutBakedJob };