@valbuild/tanstack-build 0.145.1 → 0.148.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # @valbuild/tanstack-build
2
2
 
3
+ ## 0.148.0
4
+
5
+ ### Patch Changes
6
+
7
+ - [#886](https://github.com/valbuild/val/pull/886) [`4176757`](https://github.com/valbuild/val/commit/41767579b01849473a94779122fd39c07dd99234) Thanks [@freekh](https://github.com/freekh)! - Building a project's dependency layer takes one build per target again, instead
8
+ of falling back to building every dependency on its own. A dependency that
9
+ reaches a Node builtin from the browser side (`@valbuild/tanstack/server`,
10
+ `@valbuild/mcp`, `sharp`) or loads a native binary (`@tailwindcss/vite`) used
11
+ to fail the first build, and finding out which one did took two builds per
12
+ dependency. Now the first build finds them, and the layer is the same as
13
+ before.
14
+
15
+ The import check after each build also reads only a chunk's import
16
+ statements, found with `es-module-lexer`, instead of parsing the whole chunk:
17
+ Val's server chunk is 20 MB.
18
+
19
+ On the `template-tanstack` projects the two together took a layer build from
20
+ about 45 s and 2.8 GB to 8–12 s and 1.1–1.25 GB. Each server-only or skipped dependency is
21
+ now reported with the builtin or binary it reached and the module that asked
22
+ for it.
23
+
24
+ ## 0.146.0
25
+
26
+ ### Minor Changes
27
+
28
+ - [#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.
29
+
30
+ - **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.
31
+ - **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.
32
+ - Publish offers **Update from the site** whenever the site has moved under the proposal.
33
+
3
34
  ## 0.145.1
4
35
 
5
36
  ### Patch Changes
@@ -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";
@@ -92,8 +92,8 @@ export interface VendorLayer {
92
92
  * Specifiers built for the worker but not the browser.
93
93
  *
94
94
  * A server-only dependency is not a failure. `@valbuild/tanstack/server`
95
- * cannot build for a browser -- it reaches TanStack's SSR path, which lands
96
- * on `node:stream/web` -- and has no business in a client bundle either.
95
+ * cannot build for a browser -- it reaches Node's `path` through Val's
96
+ * server -- and has no business in a client bundle either.
97
97
  * Dropping it entirely would mean such a package can never be layered, so it
98
98
  * is layered for the side that can use it, and the builder rejects a client
99
99
  * import of it by name.
@@ -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
+ }>;
@@ -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.145.1",
1104
+ version: "0.148.0",
1105
1105
  sideEffects: false,
1106
1106
  main: "dist/valbuild-tanstack-build.cjs.js",
1107
1107
  module: "dist/valbuild-tanstack-build.esm.js",
@@ -1137,6 +1137,7 @@ var packageJson = {
1137
1137
  },
1138
1138
  dependencies: {
1139
1139
  "@rolldown/browser": "^1.2.5",
1140
+ "es-module-lexer": "^2.3.2",
1140
1141
  tailwindcss: "^4.3.3"
1141
1142
  },
1142
1143
  peerDependencies: {
@@ -4501,6 +4502,155 @@ function treeShaOfText(files) {
4501
4502
  })));
4502
4503
  }
4503
4504
 
4505
+ /**
4506
+ * A project's `val.modules.ts`, bundled to run: every `.val.ts` it imports,
4507
+ * the `val.config` they share and the `.val.json` entries they name, as ONE
4508
+ * ES module -- so it can be imported from a `blob:` URL, which cannot resolve
4509
+ * a relative chunk -- with every npm import pointing at the site's own
4510
+ * vendor chunks, at absolute URLs under `origin`.
4511
+ *
4512
+ * What the builder tab evaluates to learn a tree's schemas: Update from the
4513
+ * site with code (valbuild/home `docs/hosted-publishing.md` step 8.2, slice
4514
+ * 1b). The project's own `@valbuild/*` and dependencies are what run, as the
4515
+ * site runs them -- the browser half of its layer, from `/_pvendor/<rev>/`,
4516
+ * and the base layer from `/_vendor/`. Whoever imports it should do so off
4517
+ * the Studio's page: `@valbuild/tanstack` brings React and patches its JSX.
4518
+ *
4519
+ * Nothing else of a build happens here: no route splitting, no server
4520
+ * functions, no CSS -- a `.val.ts` has none of it.
4521
+ */
4522
+ function bundleValModules(_x) {
4523
+ return _bundleValModules.apply(this, arguments);
4524
+ }
4525
+ function _bundleValModules() {
4526
+ _bundleValModules = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee(input) {
4527
+ var _input$entry;
4528
+ var files, target, origin, entry, warnings, aliases, base, project, resolveProjectPath, result, chunks, _t;
4529
+ return regeneratorValues._regenerator().w(function (_context) {
4530
+ while (1) switch (_context.p = _context.n) {
4531
+ case 0:
4532
+ files = input.files, target = input.target, origin = input.origin;
4533
+ entry = (_input$entry = input.entry) !== null && _input$entry !== void 0 ? _input$entry : ["val.modules.ts", "val.modules.js"].find(function (path) {
4534
+ return path in files;
4535
+ });
4536
+ if (!(entry === undefined || !(entry in files))) {
4537
+ _context.n = 1;
4538
+ break;
4539
+ }
4540
+ throw new Error("This project has no val.modules.ts, so its Val modules cannot be read.");
4541
+ case 1:
4542
+ warnings = [];
4543
+ aliases = aliasMap(files, function (message) {
4544
+ return warnings.push(message);
4545
+ });
4546
+ base = "".concat(origin, "/_vendor/");
4547
+ project = target.project.rev === null ? null : "".concat(origin, "/_pvendor/").concat(target.project.rev, "/");
4548
+ resolveProjectPath = function resolveProjectPath(path) {
4549
+ return resolveInFiles(path, files);
4550
+ };
4551
+ _context.p = 2;
4552
+ _context.n = 3;
4553
+ return browser.build({
4554
+ input: entry,
4555
+ // See `buildOnce`: required in the browser, inert here.
4556
+ cwd: "/",
4557
+ moduleTypes: {
4558
+ ".css": "empty"
4559
+ },
4560
+ plugins: [{
4561
+ name: "val:modules",
4562
+ resolveId: function resolveId(source, importer) {
4563
+ if (source.startsWith(".")) {
4564
+ return resolveProjectPath(resolve(dirname(importer !== null && importer !== void 0 ? importer : entry), source));
4565
+ }
4566
+ if (source in files) return source;
4567
+ var baseChunk = target.base.modules[source];
4568
+ if (baseChunk) {
4569
+ return {
4570
+ id: "".concat(base).concat(baseChunk, ".js"),
4571
+ external: true
4572
+ };
4573
+ }
4574
+ var projectChunk = target.project.modules[source];
4575
+ if (projectChunk && project !== null) {
4576
+ if (target.project.workerOnly.includes(source)) {
4577
+ 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."));
4578
+ }
4579
+ return {
4580
+ id: "".concat(project).concat(projectChunk, ".js"),
4581
+ external: true
4582
+ };
4583
+ }
4584
+ if (aliases) {
4585
+ var _iterator = regeneratorValues._createForOfIteratorHelper(aliases.candidates(source)),
4586
+ _step;
4587
+ try {
4588
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
4589
+ var candidate = _step.value;
4590
+ var _hit = resolveProjectPath(candidate);
4591
+ if (_hit) return _hit;
4592
+ }
4593
+ } catch (err) {
4594
+ _iterator.e(err);
4595
+ } finally {
4596
+ _iterator.f();
4597
+ }
4598
+ var fromBaseUrl = aliases.baseUrlCandidate(source);
4599
+ var hit = fromBaseUrl && resolveProjectPath(fromBaseUrl);
4600
+ if (hit) return hit;
4601
+ }
4602
+ // An error, not a warning: rolldown would otherwise leave the
4603
+ // specifier as it is, and it would fail when imported, unnamed.
4604
+ 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(", "), "."));
4605
+ },
4606
+ load: function load(id) {
4607
+ return id in files ? files[id] : null;
4608
+ }
4609
+ }],
4610
+ transform: {
4611
+ jsx: {
4612
+ runtime: "automatic",
4613
+ importSource: "react"
4614
+ }
4615
+ },
4616
+ output: {
4617
+ format: "esm",
4618
+ minify: false,
4619
+ // One module: `def: () => import("./x.val")` stays a dynamic import of
4620
+ // something already in the file.
4621
+ codeSplitting: false
4622
+ },
4623
+ write: false
4624
+ });
4625
+ case 3:
4626
+ result = _context.v;
4627
+ _context.n = 5;
4628
+ break;
4629
+ case 4:
4630
+ _context.p = 4;
4631
+ _t = _context.v;
4632
+ throw new Error(["The Val modules could not be bundled."].concat(warnings, [_t instanceof Error ? _t.message : String(_t)]).join("\n"), {
4633
+ cause: _t
4634
+ });
4635
+ case 5:
4636
+ chunks = result.output.filter(function (output) {
4637
+ return output.type === "chunk";
4638
+ });
4639
+ if (!(chunks.length !== 1)) {
4640
+ _context.n = 6;
4641
+ break;
4642
+ }
4643
+ throw new Error("Bundling the Val modules made ".concat(chunks.length, " chunks rather than one."));
4644
+ case 6:
4645
+ return _context.a(2, {
4646
+ code: chunks[0].code
4647
+ });
4648
+ }
4649
+ }, _callee, null, [[2, 4]]);
4650
+ }));
4651
+ return _bundleValModules.apply(this, arguments);
4652
+ }
4653
+
4504
4654
  exports.INLINE_LIMIT = regeneratorValues.INLINE_LIMIT;
4505
4655
  exports.base64Bytes = regeneratorValues.base64Bytes;
4506
4656
  exports.isAsset = regeneratorValues.isAsset;
@@ -4519,6 +4669,7 @@ exports.bakedJob = bakedJob;
4519
4669
  exports.blobSha = blobSha;
4520
4670
  exports.buildInputId = buildInputId;
4521
4671
  exports.buildUserApp = buildUserApp;
4672
+ exports.bundleValModules = bundleValModules;
4522
4673
  exports.fetchBuildTarget = fetchBuildTarget;
4523
4674
  exports.fetchBuildTargetRev = fetchBuildTargetRev;
4524
4675
  exports.isValProject = isValProject;
@@ -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.145.1",
1104
+ version: "0.148.0",
1105
1105
  sideEffects: false,
1106
1106
  main: "dist/valbuild-tanstack-build.cjs.js",
1107
1107
  module: "dist/valbuild-tanstack-build.esm.js",
@@ -1137,6 +1137,7 @@ var packageJson = {
1137
1137
  },
1138
1138
  dependencies: {
1139
1139
  "@rolldown/browser": "^1.2.5",
1140
+ "es-module-lexer": "^2.3.2",
1140
1141
  tailwindcss: "^4.3.3"
1141
1142
  },
1142
1143
  peerDependencies: {
@@ -4501,6 +4502,155 @@ function treeShaOfText(files) {
4501
4502
  })));
4502
4503
  }
4503
4504
 
4505
+ /**
4506
+ * A project's `val.modules.ts`, bundled to run: every `.val.ts` it imports,
4507
+ * the `val.config` they share and the `.val.json` entries they name, as ONE
4508
+ * ES module -- so it can be imported from a `blob:` URL, which cannot resolve
4509
+ * a relative chunk -- with every npm import pointing at the site's own
4510
+ * vendor chunks, at absolute URLs under `origin`.
4511
+ *
4512
+ * What the builder tab evaluates to learn a tree's schemas: Update from the
4513
+ * site with code (valbuild/home `docs/hosted-publishing.md` step 8.2, slice
4514
+ * 1b). The project's own `@valbuild/*` and dependencies are what run, as the
4515
+ * site runs them -- the browser half of its layer, from `/_pvendor/<rev>/`,
4516
+ * and the base layer from `/_vendor/`. Whoever imports it should do so off
4517
+ * the Studio's page: `@valbuild/tanstack` brings React and patches its JSX.
4518
+ *
4519
+ * Nothing else of a build happens here: no route splitting, no server
4520
+ * functions, no CSS -- a `.val.ts` has none of it.
4521
+ */
4522
+ function bundleValModules(_x) {
4523
+ return _bundleValModules.apply(this, arguments);
4524
+ }
4525
+ function _bundleValModules() {
4526
+ _bundleValModules = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee(input) {
4527
+ var _input$entry;
4528
+ var files, target, origin, entry, warnings, aliases, base, project, resolveProjectPath, result, chunks, _t;
4529
+ return regeneratorValues._regenerator().w(function (_context) {
4530
+ while (1) switch (_context.p = _context.n) {
4531
+ case 0:
4532
+ files = input.files, target = input.target, origin = input.origin;
4533
+ entry = (_input$entry = input.entry) !== null && _input$entry !== void 0 ? _input$entry : ["val.modules.ts", "val.modules.js"].find(function (path) {
4534
+ return path in files;
4535
+ });
4536
+ if (!(entry === undefined || !(entry in files))) {
4537
+ _context.n = 1;
4538
+ break;
4539
+ }
4540
+ throw new Error("This project has no val.modules.ts, so its Val modules cannot be read.");
4541
+ case 1:
4542
+ warnings = [];
4543
+ aliases = aliasMap(files, function (message) {
4544
+ return warnings.push(message);
4545
+ });
4546
+ base = "".concat(origin, "/_vendor/");
4547
+ project = target.project.rev === null ? null : "".concat(origin, "/_pvendor/").concat(target.project.rev, "/");
4548
+ resolveProjectPath = function resolveProjectPath(path) {
4549
+ return resolveInFiles(path, files);
4550
+ };
4551
+ _context.p = 2;
4552
+ _context.n = 3;
4553
+ return browser.build({
4554
+ input: entry,
4555
+ // See `buildOnce`: required in the browser, inert here.
4556
+ cwd: "/",
4557
+ moduleTypes: {
4558
+ ".css": "empty"
4559
+ },
4560
+ plugins: [{
4561
+ name: "val:modules",
4562
+ resolveId: function resolveId(source, importer) {
4563
+ if (source.startsWith(".")) {
4564
+ return resolveProjectPath(resolve(dirname(importer !== null && importer !== void 0 ? importer : entry), source));
4565
+ }
4566
+ if (source in files) return source;
4567
+ var baseChunk = target.base.modules[source];
4568
+ if (baseChunk) {
4569
+ return {
4570
+ id: "".concat(base).concat(baseChunk, ".js"),
4571
+ external: true
4572
+ };
4573
+ }
4574
+ var projectChunk = target.project.modules[source];
4575
+ if (projectChunk && project !== null) {
4576
+ if (target.project.workerOnly.includes(source)) {
4577
+ 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."));
4578
+ }
4579
+ return {
4580
+ id: "".concat(project).concat(projectChunk, ".js"),
4581
+ external: true
4582
+ };
4583
+ }
4584
+ if (aliases) {
4585
+ var _iterator = regeneratorValues._createForOfIteratorHelper(aliases.candidates(source)),
4586
+ _step;
4587
+ try {
4588
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
4589
+ var candidate = _step.value;
4590
+ var _hit = resolveProjectPath(candidate);
4591
+ if (_hit) return _hit;
4592
+ }
4593
+ } catch (err) {
4594
+ _iterator.e(err);
4595
+ } finally {
4596
+ _iterator.f();
4597
+ }
4598
+ var fromBaseUrl = aliases.baseUrlCandidate(source);
4599
+ var hit = fromBaseUrl && resolveProjectPath(fromBaseUrl);
4600
+ if (hit) return hit;
4601
+ }
4602
+ // An error, not a warning: rolldown would otherwise leave the
4603
+ // specifier as it is, and it would fail when imported, unnamed.
4604
+ 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(", "), "."));
4605
+ },
4606
+ load: function load(id) {
4607
+ return id in files ? files[id] : null;
4608
+ }
4609
+ }],
4610
+ transform: {
4611
+ jsx: {
4612
+ runtime: "automatic",
4613
+ importSource: "react"
4614
+ }
4615
+ },
4616
+ output: {
4617
+ format: "esm",
4618
+ minify: false,
4619
+ // One module: `def: () => import("./x.val")` stays a dynamic import of
4620
+ // something already in the file.
4621
+ codeSplitting: false
4622
+ },
4623
+ write: false
4624
+ });
4625
+ case 3:
4626
+ result = _context.v;
4627
+ _context.n = 5;
4628
+ break;
4629
+ case 4:
4630
+ _context.p = 4;
4631
+ _t = _context.v;
4632
+ throw new Error(["The Val modules could not be bundled."].concat(warnings, [_t instanceof Error ? _t.message : String(_t)]).join("\n"), {
4633
+ cause: _t
4634
+ });
4635
+ case 5:
4636
+ chunks = result.output.filter(function (output) {
4637
+ return output.type === "chunk";
4638
+ });
4639
+ if (!(chunks.length !== 1)) {
4640
+ _context.n = 6;
4641
+ break;
4642
+ }
4643
+ throw new Error("Bundling the Val modules made ".concat(chunks.length, " chunks rather than one."));
4644
+ case 6:
4645
+ return _context.a(2, {
4646
+ code: chunks[0].code
4647
+ });
4648
+ }
4649
+ }, _callee, null, [[2, 4]]);
4650
+ }));
4651
+ return _bundleValModules.apply(this, arguments);
4652
+ }
4653
+
4504
4654
  exports.INLINE_LIMIT = regeneratorValues.INLINE_LIMIT;
4505
4655
  exports.base64Bytes = regeneratorValues.base64Bytes;
4506
4656
  exports.isAsset = regeneratorValues.isAsset;
@@ -4519,6 +4669,7 @@ exports.bakedJob = bakedJob;
4519
4669
  exports.blobSha = blobSha;
4520
4670
  exports.buildInputId = buildInputId;
4521
4671
  exports.buildUserApp = buildUserApp;
4672
+ exports.bundleValModules = bundleValModules;
4522
4673
  exports.fetchBuildTarget = fetchBuildTarget;
4523
4674
  exports.fetchBuildTargetRev = fetchBuildTargetRev;
4524
4675
  exports.isValProject = isValProject;
@@ -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.145.1",
1103
+ version: "0.148.0",
1104
1104
  sideEffects: false,
1105
1105
  main: "dist/valbuild-tanstack-build.cjs.js",
1106
1106
  module: "dist/valbuild-tanstack-build.esm.js",
@@ -1136,6 +1136,7 @@ var packageJson = {
1136
1136
  },
1137
1137
  dependencies: {
1138
1138
  "@rolldown/browser": "^1.2.5",
1139
+ "es-module-lexer": "^2.3.2",
1139
1140
  tailwindcss: "^4.3.3"
1140
1141
  },
1141
1142
  peerDependencies: {
@@ -4500,4 +4501,153 @@ function treeShaOfText(files) {
4500
4501
  })));
4501
4502
  }
4502
4503
 
4503
- 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 };
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 = _asyncToGenerator(/*#__PURE__*/_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 _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 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 = _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(_toConsumableArray(Object.keys(target.base.modules)), _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
+
4653
+ 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 };