@valbuild/tanstack-build 0.149.2 → 0.150.9

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,22 @@
1
1
  # @valbuild/tanstack-build
2
2
 
3
+ ## 0.150.9
4
+
5
+ ### Patch Changes
6
+
7
+ - [#971](https://github.com/valbuild/val/pull/971) [`fdb0280`](https://github.com/valbuild/val/commit/fdb02809830355e595127814c8e8676fdb0d5279) Thanks [@freekh](https://github.com/freekh)! - The Studio's files now also ship as plain files, so a host can serve them itself instead of from your app's server.
8
+
9
+ - `@valbuild/ui` includes `static/`: every Studio file, plus a `manifest.json` that says which request path under `/api/val/static` serves which file. Binary files are copied byte for byte. `@valbuild/ui/server` is unchanged, and so is every host that uses it.
10
+ - `@valbuild/tanstack-build` uses it on Val Build's hosting. When the platform says it serves build assets, the site's dependency layer leaves out the Studio copy embedded in `@valbuild/ui/server` and carries the Studio's files as build assets instead. The site's server then loads about 18 MB less JavaScript and uses roughly 80-100 MB less memory. That margin is what kept a Studio from loading on a hosted site: its server ran out of memory and was restarted on almost every request.
11
+
12
+ ## 0.150.1
13
+
14
+ ### Patch Changes
15
+
16
+ - [#942](https://github.com/valbuild/val/pull/942) [`fd9ee2a`](https://github.com/valbuild/val/commit/fd9ee2ad76ef45bc6c4801aaccaae6e183960f11) Thanks [@freekh](https://github.com/freekh)! - `val publish` builds with native `rolldown` instead of rolldown's WebAssembly build. A site whose lockfile resolved `@napi-rs/wasm-runtime` 1.2.6 (released 2026-10-25) could no longer publish: `@rolldown/browser` 1.2.15 accepts that version but does not load with it, and `val publish` failed with "@valbuild/tanstack-build and rolldown … could not be loaded: Cannot set properties of undefined (setting 'initWorker')". Native `rolldown` does not use `@napi-rs/wasm-runtime` at all, so the site's version of it no longer matters. The Studio still builds in the browser with `@rolldown/browser`, from Val's own pinned versions.
17
+
18
+ New: `val check-build-tools` loads what `val publish` builds with and builds a one-line module with it, without asking content anything, and fails when it could not. Val Build runs it on an upgrade's install before a project whose CI publishes it can publish the upgrade.
19
+
3
20
  ## 0.149.2
4
21
 
5
22
  ### Patch Changes
@@ -119,6 +119,21 @@ export interface BuildTarget {
119
119
  worker: Record<string, Array<string>>;
120
120
  browser: Record<string, Array<string>>;
121
121
  };
122
+ /**
123
+ * Whether this platform serves BUILD ASSETS: files a build names by
124
+ * content hash ({@link BuildAssets}), uploaded once and served by the
125
+ * platform itself rather than by the site's server.
126
+ *
127
+ * What a layer build reads it for is the Studio. `@valbuild/ui/server`
128
+ * carries every Studio file base64-embedded, which costs a server that
129
+ * loads it some 80-100 MB of heap -- inside a 128 MB isolate, too much.
130
+ * Where this is true the layer is built without that copy and carries the
131
+ * Studio's files as assets instead.
132
+ *
133
+ * Absent from a platform that predates it, and a layer is then built as
134
+ * it always was: a Studio without its files is worse than a heavy one.
135
+ */
136
+ buildAssets?: boolean;
122
137
  /** Where the chunks live, as seen from each kind of importer. */
123
138
  paths: {
124
139
  /** The base layer, from a project-layer chunk. */
@@ -169,3 +184,34 @@ export interface BuildTargetRev {
169
184
  rev: string | null;
170
185
  };
171
186
  }
187
+ /**
188
+ * One file a build names, by content: the platform stores it once, under its
189
+ * sha256, and serves it at every path a build maps to it.
190
+ */
191
+ export interface BuildAsset {
192
+ /** Lower-case hex sha256 of the bytes. Also the file's name in the store. */
193
+ sha256: string;
194
+ contentType: string;
195
+ cacheControl: string;
196
+ }
197
+ /**
198
+ * Files a build has the platform serve for it, by request path, before the
199
+ * request reaches the site's server.
200
+ *
201
+ * GENERIC on purpose. The Studio is the first thing served this way (see
202
+ * {@link BuildTarget}'s `base.buildAssets`), and the platform knows nothing
203
+ * of it: it follows this map. Anything else a build would rather not carry in
204
+ * its server -- a dependency's fonts, a site's own large files -- can be
205
+ * served the same way without the platform learning anything new.
206
+ */
207
+ export interface BuildAssets {
208
+ /** Request path (`/api/val/static/0.150.8/app`) -> the file served there. */
209
+ paths: Record<string, BuildAsset>;
210
+ /**
211
+ * What a path under `prefix` that is not in {@link paths} is answered with:
212
+ * a single-page app's index page. The longest matching prefix wins.
213
+ */
214
+ fallbacks: Array<BuildAsset & {
215
+ prefix: string;
216
+ }>;
217
+ }
@@ -34,3 +34,4 @@ export * from "./artifacts.js";
34
34
  export * from "./gitTree.js";
35
35
  export * from "./wire.js";
36
36
  export { bundleValModules } from "./valModules.js";
37
+ export { loadRolldown, useRolldown, type Rolldown } from "./rolldown.js";
@@ -16,3 +16,4 @@ export { nodeShims, nodeShimSources, NODE_SHIMS, REEXPORT, SHIM_PREFIX, } from "
16
16
  export { cssModuleLoader } from "./cssModules.js";
17
17
  export { routeSplitter } from "./routeSplitter.js";
18
18
  export { generateRouteTree, isFileBased } from "./routes.js";
19
+ export { nativeRolldown } from "./rolldown.js";
@@ -0,0 +1,6 @@
1
+ import type { Rolldown } from "../rolldown.js";
2
+ /**
3
+ * Native rolldown, for `useRolldown` in Node: the build without the
4
+ * WebAssembly glue a site's lockfile can break (see `../rolldown.ts`).
5
+ */
6
+ export declare const nativeRolldown: Rolldown;
@@ -1,4 +1,4 @@
1
- import type { BuildTarget } from "../contract.js";
1
+ import type { BuildAssets, BuildTarget } from "../contract.js";
2
2
  /**
3
3
  * Packages the base layer already provides.
4
4
  *
@@ -128,6 +128,20 @@ export interface VendorLayer {
128
128
  worker: Record<string, string>;
129
129
  /** Browser chunks, served under `/_pvendor/<rev>/`. */
130
130
  browser: Record<string, string>;
131
+ /**
132
+ * Files the platform serves for this layer, by request path: the Studio,
133
+ * where the platform serves build assets (`base.buildAssets`) and the
134
+ * project's `@valbuild/ui` ships its files (see `studioAssets.ts`). Absent
135
+ * otherwise.
136
+ */
137
+ assets?: BuildAssets;
138
+ /**
139
+ * The bytes {@link assets} names, base64, by sha256: for the publisher to
140
+ * upload, and never stored with the layer. The platform keeps each file
141
+ * once, by its hash, so a publisher asks which it is missing and sends
142
+ * only those.
143
+ */
144
+ assetBytes?: Record<string, string>;
131
145
  }
132
146
  /**
133
147
  * Val's own entry points that are server-only by contract, built for the
@@ -0,0 +1,38 @@
1
+ import type { build } from "@rolldown/browser";
2
+ import type { parseAstAsync } from "@rolldown/browser/parseAst";
3
+ /**
4
+ * The bundler the build runs on, chosen by where it runs.
5
+ *
6
+ * The build is the same code in a browser tab and in Node, and rolldown comes
7
+ * in two builds with one API: `@rolldown/browser`, compiled to WebAssembly,
8
+ * and `rolldown`, the native one. A tab can only have the first. Node should
9
+ * not load it: it reaches its WebAssembly through `@napi-rs/wasm-runtime`, a
10
+ * dependency whose version the SITE'S lockfile picks, and rolldown's own
11
+ * ranges have let a release in that does not load (2026-10-26, below). The
12
+ * native one has no such glue. So nothing in this package imports either
13
+ * statically: Node is handed the native one (`useRolldown`, with
14
+ * `nativeRolldown` from `@valbuild/tanstack-build/node`), and anything not
15
+ * handed one gets the browser build, imported on first use.
16
+ *
17
+ * Why not just the browser build in both, as it was until 2026-10-26:
18
+ * `@rolldown/browser` 1.2.15 pins `@emnapi/core` 2.0.0-alpha.5 and asks for
19
+ * `@napi-rs/wasm-runtime` `~1.2.5`, and wasm-runtime 1.2.6 (2026-10-25) only
20
+ * works with `@emnapi/core` 1.x or 2.0.0-beta.2 -- loading it throws
21
+ * "Cannot set properties of undefined (setting 'initWorker')". Any site whose
22
+ * lockfile was resolved after that release (an upgrade, a `pnpm update`)
23
+ * could no longer `val publish`. The Studio's tab and Val Build's upgrade page
24
+ * are not exposed to it: they bundle the browser build from their own
25
+ * lockfiles, where the builder tab's end-to-end specs load it before a
26
+ * release.
27
+ */
28
+ export interface Rolldown {
29
+ build: typeof build;
30
+ parseAstAsync: typeof parseAstAsync;
31
+ }
32
+ /** Build on `rolldown` from now on. Node calls it with `nativeRolldown`. */
33
+ export declare function useRolldown(rolldown: Rolldown): void;
34
+ /**
35
+ * The bundler, loading the browser build if nobody chose one. Called early by
36
+ * a tab that wants the WebAssembly compiled before the first build needs it.
37
+ */
38
+ export declare function loadRolldown(): Promise<Rolldown>;
@@ -457,4 +457,4 @@ function _regeneratorValues(e) {
457
457
  throw new TypeError(typeof e + " is not iterable");
458
458
  }
459
459
 
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 };
460
+ export { ASSET_BASE as A, INLINE_LIMIT as I, _slicedToArray as _, _createForOfIteratorHelper as a, _asyncToGenerator as b, _regenerator as c, _toConsumableArray 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 };
@@ -3,12 +3,85 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var regeneratorValues = require('./regeneratorValues-f5d7ce8a.cjs.dev.js');
6
- var browser = require('@rolldown/browser');
7
6
  var projectPaths = require('./projectPaths-f222255a.cjs.dev.js');
8
- var parseAst = require('@rolldown/browser/parseAst');
9
7
  var tailwindcss = require('tailwindcss');
10
8
  var artifactKeys = require('./artifactKeys-ad3e41fc.cjs.dev.js');
11
9
 
10
+ function _interopNamespace(e) {
11
+ if (e && e.__esModule) return e;
12
+ var n = Object.create(null);
13
+ if (e) {
14
+ Object.keys(e).forEach(function (k) {
15
+ if (k !== 'default') {
16
+ var d = Object.getOwnPropertyDescriptor(e, k);
17
+ Object.defineProperty(n, k, d.get ? d : {
18
+ enumerable: true,
19
+ get: function () { return e[k]; }
20
+ });
21
+ }
22
+ });
23
+ }
24
+ n["default"] = e;
25
+ return Object.freeze(n);
26
+ }
27
+
28
+ /**
29
+ * The bundler the build runs on, chosen by where it runs.
30
+ *
31
+ * The build is the same code in a browser tab and in Node, and rolldown comes
32
+ * in two builds with one API: `@rolldown/browser`, compiled to WebAssembly,
33
+ * and `rolldown`, the native one. A tab can only have the first. Node should
34
+ * not load it: it reaches its WebAssembly through `@napi-rs/wasm-runtime`, a
35
+ * dependency whose version the SITE'S lockfile picks, and rolldown's own
36
+ * ranges have let a release in that does not load (2026-10-26, below). The
37
+ * native one has no such glue. So nothing in this package imports either
38
+ * statically: Node is handed the native one (`useRolldown`, with
39
+ * `nativeRolldown` from `@valbuild/tanstack-build/node`), and anything not
40
+ * handed one gets the browser build, imported on first use.
41
+ *
42
+ * Why not just the browser build in both, as it was until 2026-10-26:
43
+ * `@rolldown/browser` 1.2.15 pins `@emnapi/core` 2.0.0-alpha.5 and asks for
44
+ * `@napi-rs/wasm-runtime` `~1.2.5`, and wasm-runtime 1.2.6 (2026-10-25) only
45
+ * works with `@emnapi/core` 1.x or 2.0.0-beta.2 -- loading it throws
46
+ * "Cannot set properties of undefined (setting 'initWorker')". Any site whose
47
+ * lockfile was resolved after that release (an upgrade, a `pnpm update`)
48
+ * could no longer `val publish`. The Studio's tab and Val Build's upgrade page
49
+ * are not exposed to it: they bundle the browser build from their own
50
+ * lockfiles, where the builder tab's end-to-end specs load it before a
51
+ * release.
52
+ */
53
+
54
+ var chosen = null;
55
+
56
+ /** Build on `rolldown` from now on. Node calls it with `nativeRolldown`. */
57
+ function useRolldown(rolldown) {
58
+ chosen = Promise.resolve(rolldown);
59
+ }
60
+
61
+ /**
62
+ * The bundler, loading the browser build if nobody chose one. Called early by
63
+ * a tab that wants the WebAssembly compiled before the first build needs it.
64
+ */
65
+ function loadRolldown() {
66
+ if (chosen === null) {
67
+ var loading = Promise.all([Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@rolldown/browser')); }), Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@rolldown/browser/parseAst')); })]).then(function (_ref) {
68
+ var _ref2 = regeneratorValues._slicedToArray(_ref, 2),
69
+ bundler = _ref2[0],
70
+ parser = _ref2[1];
71
+ return {
72
+ build: bundler.build,
73
+ parseAstAsync: parser.parseAstAsync
74
+ };
75
+ });
76
+ // A load that failed is tried again by the next caller, not kept.
77
+ loading["catch"](function () {
78
+ if (chosen === loading) chosen = null;
79
+ });
80
+ chosen = loading;
81
+ }
82
+ return chosen;
83
+ }
84
+
12
85
  // A minimal posix path resolver. The builder runs in the browser, so node:path
13
86
  // is unavailable, and pulling a polyfill in for two functions is not worth it.
14
87
 
@@ -63,14 +136,20 @@ function parse(_x, _x2) {
63
136
  /** Depth-first walk carrying a parent stack, nearest parent last. */
64
137
  function _parse() {
65
138
  _parse = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee(path, code) {
139
+ var _yield$loadRolldown, parseAstAsync;
66
140
  return regeneratorValues._regenerator().w(function (_context) {
67
141
  while (1) switch (_context.n) {
68
142
  case 0:
69
143
  _context.n = 1;
70
- return parseAst.parseAstAsync(code, {
144
+ return loadRolldown();
145
+ case 1:
146
+ _yield$loadRolldown = _context.v;
147
+ parseAstAsync = _yield$loadRolldown.parseAstAsync;
148
+ _context.n = 2;
149
+ return parseAstAsync(code, {
71
150
  lang: langOf(path)
72
151
  }, path);
73
- case 1:
152
+ case 2:
74
153
  return _context.a(2, _context.v);
75
154
  }
76
155
  }, _callee);
@@ -620,16 +699,21 @@ function importsOf(_x, _x2) {
620
699
  }
621
700
  function _importsOf() {
622
701
  _importsOf = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee(path, code) {
623
- var lang, ast, sources, _iterator, _step, statement, source;
702
+ var lang, _yield$loadRolldown, parseAstAsync, ast, sources, _iterator, _step, statement, source;
624
703
  return regeneratorValues._regenerator().w(function (_context) {
625
704
  while (1) switch (_context.n) {
626
705
  case 0:
627
706
  lang = path.endsWith(".tsx") || path.endsWith(".jsx") ? "tsx" : "ts";
628
707
  _context.n = 1;
629
- return parseAst.parseAstAsync(code, {
708
+ return loadRolldown();
709
+ case 1:
710
+ _yield$loadRolldown = _context.v;
711
+ parseAstAsync = _yield$loadRolldown.parseAstAsync;
712
+ _context.n = 2;
713
+ return parseAstAsync(code, {
630
714
  lang: lang
631
715
  }, path);
632
- case 1:
716
+ case 2:
633
717
  ast = _context.v;
634
718
  sources = [];
635
719
  _iterator = regeneratorValues._createForOfIteratorHelper(ast.body);
@@ -1101,7 +1185,7 @@ var packageJson = {
1101
1185
  url: "git+https://github.com/valbuild/val.git"
1102
1186
  },
1103
1187
  license: "MIT",
1104
- version: "0.149.2",
1188
+ version: "0.150.9",
1105
1189
  sideEffects: false,
1106
1190
  main: "dist/valbuild-tanstack-build.cjs.js",
1107
1191
  module: "dist/valbuild-tanstack-build.esm.js",
@@ -1166,7 +1250,7 @@ var packageJson = {
1166
1250
  "@types/jest": "^30.0.0",
1167
1251
  "@types/node": "^26.4.0",
1168
1252
  "@types/react": "^19.2.18",
1169
- rolldown: "^1.2.5",
1253
+ rolldown: "1.2.9",
1170
1254
  tsx: "^4.23.12",
1171
1255
  typescript: "^6.0.3"
1172
1256
  },
@@ -3773,6 +3857,8 @@ function _buildOnce() {
3773
3857
  aliases,
3774
3858
  vendor,
3775
3859
  projectVendor,
3860
+ _yield$loadRolldown,
3861
+ build,
3776
3862
  result,
3777
3863
  chunks,
3778
3864
  entry,
@@ -3806,7 +3892,12 @@ function _buildOnce() {
3806
3892
  // it runs on the server, so server-only code stays and client-only code goes.
3807
3893
  // Only the vendor layer differs.
3808
3894
  _context2.n = 1;
3809
- return browser.build({
3895
+ return loadRolldown();
3896
+ case 1:
3897
+ _yield$loadRolldown = _context2.v;
3898
+ build = _yield$loadRolldown.build;
3899
+ _context2.n = 2;
3900
+ return build({
3810
3901
  input: isRsc ? RSC_ENTRY_ID : projectPaths.ENTRY,
3811
3902
  // Required in the browser. rolldown computes `cwd: inputOptions.cwd ??
3812
3903
  // process.cwd()` unguarded, so omitting this throws "process is not
@@ -3842,7 +3933,7 @@ function _buildOnce() {
3842
3933
  },
3843
3934
  write: false
3844
3935
  });
3845
- case 1:
3936
+ case 2:
3846
3937
  result = _context2.v;
3847
3938
  // A type predicate rather than `(chunk: any)`, which is how this read until
3848
3939
  // the package moved into a repository that type-checks it: an `any`
@@ -3857,13 +3948,13 @@ function _buildOnce() {
3857
3948
  return chunk.fileName === ENTRY_CHUNK;
3858
3949
  });
3859
3950
  if (entry) {
3860
- _context2.n = 2;
3951
+ _context2.n = 3;
3861
3952
  break;
3862
3953
  }
3863
3954
  throw new Error("The build produced no ".concat(ENTRY_CHUNK, ". Chunks: ").concat(chunks.map(function (c) {
3864
3955
  return c.fileName;
3865
3956
  }).join(", "), "."));
3866
- case 2:
3957
+ case 3:
3867
3958
  // Chunk-to-chunk imports come out relative (`./c-abc.js`), which is exactly
3868
3959
  // what both sides need and why neither gets a base path here: relative to
3869
3960
  // `app.js` in the module map, relative to `/_app/app.js` as a URL.
@@ -4537,7 +4628,7 @@ function bundleValModules(_x) {
4537
4628
  function _bundleValModules() {
4538
4629
  _bundleValModules = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee(input) {
4539
4630
  var _input$entry;
4540
- var files, target, origin, entry, warnings, aliases, base, project, resolveProjectPath, result, chunks, _t;
4631
+ var files, target, origin, entry, warnings, aliases, base, project, resolveProjectPath, _yield$loadRolldown, build, result, chunks, _t;
4541
4632
  return regeneratorValues._regenerator().w(function (_context) {
4542
4633
  while (1) switch (_context.p = _context.n) {
4543
4634
  case 0:
@@ -4560,9 +4651,14 @@ function _bundleValModules() {
4560
4651
  resolveProjectPath = function resolveProjectPath(path) {
4561
4652
  return resolveInFiles(path, files);
4562
4653
  };
4563
- _context.p = 2;
4564
- _context.n = 3;
4565
- return browser.build({
4654
+ _context.n = 2;
4655
+ return loadRolldown();
4656
+ case 2:
4657
+ _yield$loadRolldown = _context.v;
4658
+ build = _yield$loadRolldown.build;
4659
+ _context.p = 3;
4660
+ _context.n = 4;
4661
+ return build({
4566
4662
  input: entry,
4567
4663
  // See `buildOnce`: required in the browser, inert here.
4568
4664
  cwd: "/",
@@ -4634,31 +4730,31 @@ function _bundleValModules() {
4634
4730
  },
4635
4731
  write: false
4636
4732
  });
4637
- case 3:
4733
+ case 4:
4638
4734
  result = _context.v;
4639
- _context.n = 5;
4735
+ _context.n = 6;
4640
4736
  break;
4641
- case 4:
4642
- _context.p = 4;
4737
+ case 5:
4738
+ _context.p = 5;
4643
4739
  _t = _context.v;
4644
4740
  throw new Error(["The Val modules could not be bundled."].concat(warnings, [_t instanceof Error ? _t.message : String(_t)]).join("\n"), {
4645
4741
  cause: _t
4646
4742
  });
4647
- case 5:
4743
+ case 6:
4648
4744
  chunks = result.output.filter(function (output) {
4649
4745
  return output.type === "chunk";
4650
4746
  });
4651
4747
  if (!(chunks.length !== 1)) {
4652
- _context.n = 6;
4748
+ _context.n = 7;
4653
4749
  break;
4654
4750
  }
4655
4751
  throw new Error("Bundling the Val modules made ".concat(chunks.length, " chunks rather than one."));
4656
- case 6:
4752
+ case 7:
4657
4753
  return _context.a(2, {
4658
4754
  code: chunks[0].code
4659
4755
  });
4660
4756
  }
4661
- }, _callee, null, [[2, 4]]);
4757
+ }, _callee, null, [[3, 5]]);
4662
4758
  }));
4663
4759
  return _bundleValModules.apply(this, arguments);
4664
4760
  }
@@ -4686,6 +4782,7 @@ exports.fetchBuildTarget = fetchBuildTarget;
4686
4782
  exports.fetchBuildTargetRev = fetchBuildTargetRev;
4687
4783
  exports.isValProject = isValProject;
4688
4784
  exports.isWired = isWired;
4785
+ exports.loadRolldown = loadRolldown;
4689
4786
  exports.publishArtifacts = publishArtifacts;
4690
4787
  exports.publishPayload = publishPayload;
4691
4788
  exports.rebakeGit = rebakeGit;
@@ -4693,6 +4790,7 @@ exports.resolveInFiles = resolveInFiles;
4693
4790
  exports.scanCandidates = scanCandidates;
4694
4791
  exports.treeSha = treeSha;
4695
4792
  exports.treeShaOfText = treeShaOfText;
4793
+ exports.useRolldown = useRolldown;
4696
4794
  exports.usesTailwind = usesTailwind;
4697
4795
  exports.wireUp = wireUp;
4698
4796
  exports.wiredValServer = wiredValServer;