@valbuild/tanstack-build 0.151.0 → 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,31 @@
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
+
3
29
  ## 0.151.0
4
30
 
5
31
  ### Patch Changes
@@ -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.
@@ -26,6 +26,11 @@ 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[]>;
29
34
  }>;
30
35
  /**
31
36
  * A build's `val.modules` registry, as the build emits it beside its client
@@ -48,4 +53,13 @@ export declare function bundleValModules(input: {
48
53
  export declare function valModulesEntry(input: {
49
54
  files: Record<string, string>;
50
55
  target: BuildTarget;
51
- }, build: string, warnings: string[]): Promise<Record<string, string>>;
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;
65
+ }>;