@valbuild/tanstack-build 0.150.12 → 0.153.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,80 @@
1
1
  # @valbuild/tanstack-build
2
2
 
3
+ ## 0.153.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1016](https://github.com/valbuild/val/pull/1016) [`2e70d13`](https://github.com/valbuild/val/commit/2e70d13cf7ca25874900c9ea25227df2876727b9) Thanks [@freekh](https://github.com/freekh)! - Editing content in a proposal whose code changed, before the proposal is built again:
8
+
9
+ - **A module the proposal adds** can be edited and saved right away. Its content is read from the new file and saved. Before, those edits were dropped. If the module's content is made by code (not written out in the file), the save waits and says to build the proposal first.
10
+ - **A module whose schema moved because a file it imports changed** (for example a shared `src/schemas/*.ts`) is no longer read with the old schema. Pages keep showing the content as built until the proposal is built again.
11
+ - **Edits that no longer fit the schema** can be handed to the assistant. The banner that lists them has a **Have the assistant move it** button for each one. You still discard the held edit yourself afterwards.
12
+
13
+ For this, `@valbuild/tanstack-build` records which files each Val module imports, and the `val.server.ts` it generates passes that to Val as the new optional `moduleDependencies` option of `initValServer` and `initValContent`. You do not need to set it yourself. A site built before this has no `moduleDependencies` and works as before.
14
+
15
+ - [#1025](https://github.com/valbuild/val/pull/1025) [`45d5d49`](https://github.com/valbuild/val/commit/45d5d4991bddbe43ca74a245b3f1286bc3b38a3f) Thanks [@freekh](https://github.com/freekh)! - A hosted project's `PUBLIC_` variables are read when the page runs, not when it is built.
16
+
17
+ Variables set for a project in Val Build reach a published site without a rebuild, and `import.meta.env` reads them:
18
+
19
+ ```tsx
20
+ const api = import.meta.env.PUBLIC_API_URL; // on the server and in the browser
21
+ const token = process.env.STRIPE_KEY; // a secret: on the server only
22
+ ```
23
+
24
+ - In the browser, `import.meta.env` reads the `PUBLIC_` variables the platform writes into the page. On the server it reads them from `process.env`, at the top level of a module too.
25
+ - `import.meta.env` holds `PUBLIC_` names and Vite's built-ins, as in Vite. Other names are read with `process.env.NAME` on the server, and are `undefined` in the browser, where `process.env.NAME` no longer throws.
26
+ - Vite's built-ins (`MODE`, `DEV`, `PROD`, `SSR`, `BASE_URL`) are still inlined, so `import.meta.env.DEV && <Debug />` is still removed from a build.
27
+ - Values passed to `buildUserApp({ env })` are still inlined, and win over runtime values of the same name.
28
+
29
+ ## 0.151.0
30
+
31
+ ### Patch Changes
32
+
33
+ - [#1006](https://github.com/valbuild/val/pull/1006) [`04bae7e`](https://github.com/valbuild/val/commit/04bae7e54e6b191fc70f45e6f10bbce820b6069c) Thanks [@freekh](https://github.com/freekh)! - **No more "A new version has been deployed" dialog.** A Studio that is open
34
+ while the site is deployed no longer stops you with a dialog you can only
35
+ answer by reloading. Instead:
36
+
37
+ - **On Val's hosting**, the Studio takes the new build's fields in where you
38
+ are, without reloading: a field the deploy added can be filled in at once,
39
+ and the assistant's chat, the page you were on and your unsaved edits stay
40
+ as they were. Each build now carries its content schemas as a small file of
41
+ its own beside its scripts, which the Studio loads.
42
+ - **Anywhere else** (a Next.js site, or a TanStack Start site hosted
43
+ somewhere else), the Studio reloads itself a few seconds after the deploy,
44
+ once everything you typed has been saved. Nothing is lost: where you were is
45
+ in the address, and every edit is on the server.
46
+ - **In local development** nothing changes: your dev server's hot reload
47
+ brings the new fields, as before.
48
+
49
+ When a deploy upgrades Val itself, the Studio reloads itself the same way,
50
+ since its own code changed too.
51
+
52
+ - [#1006](https://github.com/valbuild/val/pull/1006) [`be276e7`](https://github.com/valbuild/val/commit/be276e76f5849fcc421398abdb7e114f3de4d3e8) Thanks [@freekh](https://github.com/freekh)! - In a proposal in code mode, an edit to a field the assistant has just added is
53
+ saved with the assistant's next change, without waiting for the proposal to be
54
+ built.
55
+
56
+ The Studio already let you type into a field that only the assistant's staged
57
+ code has. But the save that runs before the assistant's next change applied
58
+ your edit to the content as the proposal's last build had it -- without the new
59
+ field -- so it failed, and the assistant's next change was refused ("the
60
+ changes waiting to be saved could not be saved first") until someone pressed
61
+ Build.
62
+
63
+ Val's server at the proposal's address now learns which staged code the build
64
+ it runs was made of (the platform hands it over beside the build), and saves a
65
+ module whose code was staged after that build from the staged `.val.ts` itself.
66
+ A page at the address keeps reading such a module as its build has it until a
67
+ build of the new code serves it, so it never shows content made for code it
68
+ does not have.
69
+
70
+ When the server cannot read a staged module's content without running it --
71
+ its content is built by code, or it is a `.jsonValues()` record -- the edit is
72
+ kept, and the assistant's change is refused saying the proposal has to be built
73
+ first, rather than failing with no reason.
74
+
75
+ `@valbuild/tanstack-build` rewrites the proposal block of a `val.server.ts`
76
+ generated before this, so a site picks it up at its next build.
77
+
3
78
  ## 0.150.12
4
79
 
5
80
  ### Patch Changes
package/README.md CHANGED
@@ -20,6 +20,11 @@ package because they are one decision — what a published build IS.
20
20
  `BuildTarget` and produces the server, client and (optionally) RSC bundles,
21
21
  the CSS, the assets and the chunk map. It runs on `@rolldown/browser`, so it
22
22
  runs in a tab.
23
+ - **The build's Val modules, for an open Studio.** Beside its client chunks,
24
+ every build emits the project's `val.modules` as one ES module named after
25
+ the build (`val-modules-<build>.js`, `valModulesEntry`). The server running
26
+ the build names it on its manifest, and a Studio opened on an older build
27
+ imports it to take the new schemas in without reloading the page.
23
28
  - **The wiring.** `wireUp(files, options)` turns an imported checkout into
24
29
  something a host with no filesystem can serve: it writes the project's
25
30
  `src/val/val.server.ts` against `@valbuild/tanstack/server`. That file is the
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var projectPaths = require('../../dist/projectPaths-f222255a.cjs.dev.js');
5
+ var projectPaths = require('../../dist/projectPaths-cb474a60.cjs.dev.js');
6
6
  var artifactKeys = require('../../dist/artifactKeys-ad3e41fc.cjs.dev.js');
7
7
 
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var projectPaths = require('../../dist/projectPaths-9cbecebf.cjs.prod.js');
5
+ var projectPaths = require('../../dist/projectPaths-d08a9ea7.cjs.prod.js');
6
6
  var artifactKeys = require('../../dist/artifactKeys-700b9044.cjs.prod.js');
7
7
 
8
8
 
@@ -1,2 +1,2 @@
1
- export { E as ENTRY, a as ENTRY_SHIM, R as ROUTES_DIR, T as TREE } from '../../dist/projectPaths-5e4defea.esm.js';
1
+ export { E as ENTRY, a as ENTRY_SHIM, R as ROUTES_DIR, T as TREE } from '../../dist/projectPaths-521a37ed.esm.js';
2
2
  export { A as ARTIFACT_KEYS, a as ARTIFACT_PREFIXES } from '../../dist/artifactKeys-3a40f3a0.esm.js';
@@ -44,6 +44,11 @@ export declare const ENTRY_CHUNK = "app.js";
44
44
  * would be both a leak and, for a real app, enormous.
45
45
  */
46
46
  export declare const PROJECT_SOURCE = "platform:project-source";
47
+ /**
48
+ * The global the server build defines as each Val module's project
49
+ * dependencies (`valModulesEntry`), read by the generated `val.server.ts`.
50
+ */
51
+ export declare const MODULE_DEPENDENCIES_GLOBAL = "globalThis.__VAL_MODULE_DEPENDENCIES__";
47
52
  export declare const PUBLIC_PREFIX = "PUBLIC_";
48
53
  export interface BuildInput {
49
54
  /** Virtual file tree, keyed by posix path relative to the project root. */
@@ -61,7 +66,11 @@ export interface BuildInput {
61
66
  * `GET /v1/build-target` on content proxies it.
62
67
  */
63
68
  target: BuildTarget;
64
- /** Project env vars, inlined at build time. See PUBLIC_PREFIX. */
69
+ /**
70
+ * Env vars to inline at build time, which win over the runtime ones. A
71
+ * hosted project's are not passed here: they are read at runtime, see
72
+ * `envFor`. See also PUBLIC_PREFIX.
73
+ */
65
74
  env?: Record<string, string>;
66
75
  /**
67
76
  * Files under `public/`, base64-encoded, keyed by project-relative path.
@@ -22,3 +22,15 @@ export declare const ROUTES_DIR = "src/routes";
22
22
  * the platform's browser generator, which reaches it through `/constants`).
23
23
  */
24
24
  export declare const ENTRY_SHIM = "export { routeTree } from './routeTree.gen'\n";
25
+ /**
26
+ * The file a build's `val.modules` registry is emitted as, among its client
27
+ * chunks: served at `/_app/val-modules-<build>.js`, where a Studio opened
28
+ * on an older build imports it to take this build's code in without
29
+ * reloading the page. The server running the build names it on its
30
+ * manifest by the same name (`valModulesEntryPath` in
31
+ * `@valbuild/shared/internal`). Neither package depends on the other, so each
32
+ * pins the same literal, `val-modules-<build>.js`: `valModules.test.ts` here,
33
+ * `buildRegistry.test.ts` there. Not exported: the name is a contract
34
+ * between the two, not API. See `valModulesEntry`.
35
+ */
36
+ export declare function valModulesEntryFile(build: string): string;
@@ -26,4 +26,40 @@ export declare function bundleValModules(input: {
26
26
  entry?: string;
27
27
  }): Promise<{
28
28
  code: string;
29
+ /**
30
+ * For each module file, every project file it depends on, as this bundle
31
+ * resolved its imports: see {@link moduleDependenciesOf}.
32
+ */
33
+ dependencies: Record<string, string[]>;
34
+ }>;
35
+ /**
36
+ * A build's `val.modules` registry, as the build emits it beside its client
37
+ * chunks: `{ "val-modules-<build>.js": code }`, served at `/_app/` with
38
+ * them, its npm imports pointing at the site's vendor chunks on its own
39
+ * origin (`/_vendor/`, `/_pvendor/<rev>/`) as the client bundle's do.
40
+ *
41
+ * What a Studio opened on an older build imports, once the server's
42
+ * manifest names it (`registry`, from the build's name the platform hands
43
+ * the server: `VAL_BUILD`), to take this build's schemas in WITHOUT
44
+ * reloading the page: `HostStore.reloadCode` in `@valbuild/ui`, and phase 9
45
+ * of `docs/plans/one-content-model.md` in valbuild/val.
46
+ *
47
+ * Empty -- and the build goes on -- for a project with no `val.modules.ts`,
48
+ * or one whose Val modules cannot be bundled for the browser (a `.val.ts`
49
+ * importing something server-only): such a build has no entry, and a Studio
50
+ * that cannot import one reloads the page instead, as it did before. Said
51
+ * in the build's warnings.
52
+ */
53
+ export declare function valModulesEntry(input: {
54
+ files: Record<string, string>;
55
+ target: BuildTarget;
56
+ }, build: string, warnings: string[]): Promise<{
57
+ /** The entry, by its file name: none when it could not be made. */
58
+ files: Record<string, string>;
59
+ /**
60
+ * Each module file's project dependencies (see `moduleDependenciesOf`),
61
+ * or `null` when the modules could not be bundled: then nobody can say,
62
+ * and Val's server counts only staged module files.
63
+ */
64
+ dependencies: Record<string, string[]> | null;
29
65
  }>;
@@ -27,4 +27,19 @@ var ROUTES_DIR = "src/routes";
27
27
  */
28
28
  var ENTRY_SHIM = "export { routeTree } from './routeTree.gen'\n";
29
29
 
30
- export { ENTRY as E, ROUTES_DIR as R, TREE as T, ENTRY_SHIM as a };
30
+ /**
31
+ * The file a build's `val.modules` registry is emitted as, among its client
32
+ * chunks: served at `/_app/val-modules-<build>.js`, where a Studio opened
33
+ * on an older build imports it to take this build's code in without
34
+ * reloading the page. The server running the build names it on its
35
+ * manifest by the same name (`valModulesEntryPath` in
36
+ * `@valbuild/shared/internal`). Neither package depends on the other, so each
37
+ * pins the same literal, `val-modules-<build>.js`: `valModules.test.ts` here,
38
+ * `buildRegistry.test.ts` there. Not exported: the name is a contract
39
+ * between the two, not API. See `valModulesEntry`.
40
+ */
41
+ function valModulesEntryFile(build) {
42
+ return "val-modules-".concat(build, ".js");
43
+ }
44
+
45
+ export { ENTRY as E, ROUTES_DIR as R, TREE as T, ENTRY_SHIM as a, valModulesEntryFile as v };
@@ -29,7 +29,23 @@ var ROUTES_DIR = "src/routes";
29
29
  */
30
30
  var ENTRY_SHIM = "export { routeTree } from './routeTree.gen'\n";
31
31
 
32
+ /**
33
+ * The file a build's `val.modules` registry is emitted as, among its client
34
+ * chunks: served at `/_app/val-modules-<build>.js`, where a Studio opened
35
+ * on an older build imports it to take this build's code in without
36
+ * reloading the page. The server running the build names it on its
37
+ * manifest by the same name (`valModulesEntryPath` in
38
+ * `@valbuild/shared/internal`). Neither package depends on the other, so each
39
+ * pins the same literal, `val-modules-<build>.js`: `valModules.test.ts` here,
40
+ * `buildRegistry.test.ts` there. Not exported: the name is a contract
41
+ * between the two, not API. See `valModulesEntry`.
42
+ */
43
+ function valModulesEntryFile(build) {
44
+ return "val-modules-".concat(build, ".js");
45
+ }
46
+
32
47
  exports.ENTRY = ENTRY;
33
48
  exports.ENTRY_SHIM = ENTRY_SHIM;
34
49
  exports.ROUTES_DIR = ROUTES_DIR;
35
50
  exports.TREE = TREE;
51
+ exports.valModulesEntryFile = valModulesEntryFile;
@@ -29,7 +29,23 @@ var ROUTES_DIR = "src/routes";
29
29
  */
30
30
  var ENTRY_SHIM = "export { routeTree } from './routeTree.gen'\n";
31
31
 
32
+ /**
33
+ * The file a build's `val.modules` registry is emitted as, among its client
34
+ * chunks: served at `/_app/val-modules-<build>.js`, where a Studio opened
35
+ * on an older build imports it to take this build's code in without
36
+ * reloading the page. The server running the build names it on its
37
+ * manifest by the same name (`valModulesEntryPath` in
38
+ * `@valbuild/shared/internal`). Neither package depends on the other, so each
39
+ * pins the same literal, `val-modules-<build>.js`: `valModules.test.ts` here,
40
+ * `buildRegistry.test.ts` there. Not exported: the name is a contract
41
+ * between the two, not API. See `valModulesEntry`.
42
+ */
43
+ function valModulesEntryFile(build) {
44
+ return "val-modules-".concat(build, ".js");
45
+ }
46
+
32
47
  exports.ENTRY = ENTRY;
33
48
  exports.ENTRY_SHIM = ENTRY_SHIM;
34
49
  exports.ROUTES_DIR = ROUTES_DIR;
35
50
  exports.TREE = TREE;
51
+ exports.valModulesEntryFile = valModulesEntryFile;