@valbuild/tanstack-build 0.0.1-alpha.0 → 0.136.1
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 +97 -0
- package/constants/dist/valbuild-tanstack-build-constants.cjs.d.ts +2 -0
- package/constants/dist/valbuild-tanstack-build-constants.cjs.dev.js +15 -0
- package/constants/dist/valbuild-tanstack-build-constants.cjs.js +7 -0
- package/constants/dist/valbuild-tanstack-build-constants.cjs.prod.js +15 -0
- package/constants/dist/valbuild-tanstack-build-constants.esm.js +2 -0
- package/constants/package.json +4 -0
- package/dist/artifactKeys-3a40f3a0.esm.js +50 -0
- package/dist/artifactKeys-700b9044.cjs.prod.js +53 -0
- package/dist/artifactKeys-ad3e41fc.cjs.dev.js +53 -0
- package/dist/declarations/src/artifactKeys.d.ts +46 -0
- package/dist/declarations/src/artifacts.d.ts +72 -0
- package/dist/declarations/src/assets.d.ts +34 -0
- package/dist/declarations/src/build.d.ts +260 -0
- package/dist/declarations/src/buildTarget.d.ts +44 -0
- package/dist/declarations/src/constants/index.d.ts +19 -0
- package/dist/declarations/src/contract.d.ts +135 -0
- package/dist/declarations/src/gitTree.d.ts +20 -0
- package/dist/declarations/src/index.d.ts +34 -0
- package/dist/declarations/src/node/cssModules.d.ts +2 -0
- package/dist/declarations/src/node/index.d.ts +18 -0
- package/dist/declarations/src/node/nodeShims.d.ts +74 -0
- package/dist/declarations/src/node/routeSplitter.d.ts +14 -0
- package/dist/declarations/src/node/routes.d.ts +27 -0
- package/dist/declarations/src/node/vendorLayer.d.ts +175 -0
- package/dist/declarations/src/paths.d.ts +4 -0
- package/dist/declarations/src/projectPaths.d.ts +24 -0
- package/dist/declarations/src/routeSplit.d.ts +29 -0
- package/dist/declarations/src/tailwind.d.ts +59 -0
- package/dist/declarations/src/tsconfigPaths.d.ts +34 -0
- package/dist/declarations/src/wire.d.ts +113 -0
- package/dist/projectPaths-5e4defea.esm.js +30 -0
- package/dist/projectPaths-9cbecebf.cjs.prod.js +35 -0
- package/dist/projectPaths-f222255a.cjs.dev.js +35 -0
- package/dist/slicedToArray-12869836.cjs.dev.js +311 -0
- package/dist/slicedToArray-149a2518.cjs.prod.js +311 -0
- package/dist/slicedToArray-d71360f4.esm.js +303 -0
- package/dist/valbuild-tanstack-build.cjs.d.ts +2 -2
- package/dist/valbuild-tanstack-build.cjs.dev.js +3556 -0
- package/dist/valbuild-tanstack-build.cjs.js +6 -15
- package/dist/valbuild-tanstack-build.cjs.prod.js +3556 -0
- package/dist/valbuild-tanstack-build.esm.js +3525 -0
- package/node/dist/valbuild-tanstack-build-node.cjs.d.ts +2 -2
- package/node/dist/valbuild-tanstack-build-node.cjs.dev.js +2201 -0
- package/node/dist/valbuild-tanstack-build-node.cjs.js +6 -15
- package/node/dist/valbuild-tanstack-build-node.cjs.prod.js +2201 -0
- package/node/dist/valbuild-tanstack-build-node.esm.js +2162 -0
- package/package.json +12 -5
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# @valbuild/tanstack-build
|
|
2
|
+
|
|
3
|
+
## 0.136.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#716](https://github.com/valbuild/val/pull/716) [`4450be5`](https://github.com/valbuild/val/commit/4450be570ec3a66d7d98ba273c333ca2d2f163d9) Thanks [@freekh](https://github.com/freekh)! - `rebakeGit` rewires a project record to a different commit, and the Studio's publish proxy can now reach `/project-source`.
|
|
8
|
+
|
|
9
|
+
Both are groundwork for a publish that happens in the browser. `rebakeGit` replaces the one line in the generated `val.server.ts` that carries the commit, rather than regenerating the file: a publisher running inside the deployment does not know the project id or the platform's address, and reconstructing the file from what it could guess would throw away wiring it cannot see.
|
|
10
|
+
|
|
11
|
+
- [#716](https://github.com/valbuild/val/pull/716) [`d2f385a`](https://github.com/valbuild/val/commit/d2f385a04978992a5036379235e447ba7775faef) Thanks [@freekh](https://github.com/freekh)! - The Studio works again when served from the published package, and a managed project's publish now puts the saved edit on the site.
|
|
12
|
+
|
|
13
|
+
- **The Studio did not start in 0.136.0.** Its main bundle imports sibling chunks by relative path, and the Studio is served at `/api/val/static/<version>/app`, so those imports resolved to paths the handler did not know and came back as the HTML fallback — which a browser refuses as a module script. Preview was gone with it. The handler now serves those chunks, and the package build follows every import the bundle makes before it lets a release through.
|
|
14
|
+
- **The in-browser builder could not load.** The Studio's bundle carried rolldown's Node WASI binding, which throws `process is not defined` in a tab. It now uses the browser binding, and the build refuses a bundle that contains the Node one.
|
|
15
|
+
- **A managed publish builds what was just saved.** `/save` returns the source files the commit wrote, the Studio builds with them laid over the project's stored source, and publishes that source back with the build — so the next edit starts from this one rather than undoing it. The save's commit is also passed through to the build, which previously ran as though no commit had been made.
|
|
16
|
+
- **The bundler's WebAssembly is served from `content.val.build/v1/static`** (`DEFAULT_STATIC_HOST`), still addressed by its SHA-256. `globalThis.__VAL_ROLLDOWN_WASM_URL__` still overrides it.
|
|
17
|
+
- The `val.server.ts` that `@valbuild/tanstack-build` generates no longer hands a save's files to the platform (`platform.internal/__api/source`). A managed project's Studio builds in its own tab, and the platform has closed that door. `isWired` recognises files wired either way.
|
|
18
|
+
- `@valbuild/tanstack-build/constants` exports the contract paths and the artifact key namespace from an entrypoint that imports nothing else, for callers that must not load the bundler. The namespace gains a `source` key.
|
|
19
|
+
|
|
20
|
+
## 0.135.0
|
|
21
|
+
|
|
22
|
+
### Minor Changes
|
|
23
|
+
|
|
24
|
+
- [#712](https://github.com/valbuild/val/pull/712) [`8181db8`](https://github.com/valbuild/val/commit/8181db81050d94fe9080a7bc50c051e570165213) Thanks [@freekh](https://github.com/freekh)! - New package: `@valbuild/tanstack-build` builds a TanStack Start app from a Val
|
|
25
|
+
project's files — in the browser, and in Node.
|
|
26
|
+
|
|
27
|
+
It carries three things that were previously in the platform repository:
|
|
28
|
+
|
|
29
|
+
- **the build** — `buildUserApp(input)` produces the server, client and RSC
|
|
30
|
+
bundles, the CSS, the assets and the chunk map, on `@rolldown/browser`, so it
|
|
31
|
+
runs in a tab;
|
|
32
|
+
- **the wiring** — `wireUp(files, options)` writes a project's
|
|
33
|
+
`src/val/val.server.ts` against `@valbuild/tanstack/server`;
|
|
34
|
+
- **the contract** — `BuildTarget`, `UserApp`, `PublishManifest` and the rest of
|
|
35
|
+
the types a host and a build have to agree on.
|
|
36
|
+
|
|
37
|
+
The wiring is the reason for the move rather than a passenger of it. It writes
|
|
38
|
+
code against `initValServer`'s signature, and it used to do that from another
|
|
39
|
+
repository on another release train — so a change to that signature could not
|
|
40
|
+
break it until somebody published, which is to say a user found it. It is now
|
|
41
|
+
beside the function it calls.
|
|
42
|
+
|
|
43
|
+
Everything that needs Node is behind the `@valbuild/tanstack-build/node`
|
|
44
|
+
subpath: the project dependency layer, the route tree, Tailwind's `@plugin` and
|
|
45
|
+
`autoCodeSplitting`. The root entrypoint reaches none of it, and a test walks
|
|
46
|
+
the import graph to keep that true — a browser bundle that pulled in `rolldown`
|
|
47
|
+
or a `node:` builtin would fail in the consuming app's build rather than here.
|
|
48
|
+
`rolldown`, `@tanstack/router-generator` and `@tanstack/router-plugin` are
|
|
49
|
+
optional peer dependencies for the same reason: they are things a project asks
|
|
50
|
+
for.
|
|
51
|
+
|
|
52
|
+
Type-checking this code for the first time, and reviewing it once it was here,
|
|
53
|
+
found several things that had been invisible where it lived — that build strips
|
|
54
|
+
types rather than checking them, and its one check of the generated server file
|
|
55
|
+
runs `tsc --noResolve`, so it cannot see across an import at all.
|
|
56
|
+
|
|
57
|
+
The one that mattered most is about a rename that has gone both ways.
|
|
58
|
+
`ValHttpMode` took `gitCommit`/`gitBranch` up to 0.132, a nested `git` from
|
|
59
|
+
0.133.0, and is flat again here — and the generated `val.server.ts` is compiled
|
|
60
|
+
and run against whatever `@valbuild/tanstack` the PROJECT installed, which the
|
|
61
|
+
platform writing the file has no say in. Sending only the name this release
|
|
62
|
+
knows drops the commit for every app still on 0.133.x, silently: the publish
|
|
63
|
+
then produces no mirrored `.val.ts`, so a save commits and hands over nothing,
|
|
64
|
+
and the site keeps serving its old content with the patches already consumed.
|
|
65
|
+
The template now sends all three keys, and each version reads its own and
|
|
66
|
+
ignores the rest.
|
|
67
|
+
|
|
68
|
+
There is also a test that compiles the generated file against the real package,
|
|
69
|
+
with resolution — the platform's own check runs `tsc --noResolve`, so it cannot
|
|
70
|
+
see across an import at all. It is the right tool for a name that no longer
|
|
71
|
+
exists and the wrong one for this, and it says so: the compiler in this
|
|
72
|
+
repository is looking at a different version of `@valbuild/tanstack` than the
|
|
73
|
+
app is.
|
|
74
|
+
|
|
75
|
+
Two more, both of which changed behaviour:
|
|
76
|
+
|
|
77
|
+
- A split route's deferred half skipped every source transform, so
|
|
78
|
+
`<ClientOnly>` and `createIsomorphicFn()` in a route component were rewritten
|
|
79
|
+
when no splitter was supplied and left alone when one was. Splitting is
|
|
80
|
+
allowed to cost bytes and not to change behaviour.
|
|
81
|
+
- The project dependency-layer build re-audited chunks it had just dropped,
|
|
82
|
+
because its fast path and its retry shared an output directory that nothing
|
|
83
|
+
cleared — so the recovery failed for exactly the case it exists for.
|
|
84
|
+
|
|
85
|
+
And the four the compiler found on its own:
|
|
86
|
+
|
|
87
|
+
- Tailwind's `loadModule` contract was restated by hand and restated wrongly —
|
|
88
|
+
Tailwind also wants a `path`, and the CLI's loader had never sent one. The
|
|
89
|
+
type is now derived from Tailwind's own option, so an upgrade that changes the
|
|
90
|
+
shape is a compile error rather than an `undefined` handed to someone else's
|
|
91
|
+
code.
|
|
92
|
+
- The rolldown output filter was `(chunk: any) => chunk.type === 'chunk'`, which
|
|
93
|
+
does not narrow, so every `.code` read after it was unchecked.
|
|
94
|
+
- The route generator was handed `verboseFileRoutes: true`, a key that is not in
|
|
95
|
+
its config, its types, or anywhere in its dist — inert, behind an `as any`.
|
|
96
|
+
- The same cast was hiding a key the generator does require. Both are gone, and
|
|
97
|
+
so is the cast.
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export * from "../../dist/declarations/src/constants/index.js";
|
|
2
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsYnVpbGQtdGFuc3RhY2stYnVpbGQtY29uc3RhbnRzLmNqcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vZGlzdC9kZWNsYXJhdGlvbnMvc3JjL2NvbnN0YW50cy9pbmRleC5kLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBIn0=
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var projectPaths = require('../../dist/projectPaths-f222255a.cjs.dev.js');
|
|
6
|
+
var artifactKeys = require('../../dist/artifactKeys-ad3e41fc.cjs.dev.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.ENTRY = projectPaths.ENTRY;
|
|
11
|
+
exports.ENTRY_SHIM = projectPaths.ENTRY_SHIM;
|
|
12
|
+
exports.ROUTES_DIR = projectPaths.ROUTES_DIR;
|
|
13
|
+
exports.TREE = projectPaths.TREE;
|
|
14
|
+
exports.ARTIFACT_KEYS = artifactKeys.ARTIFACT_KEYS;
|
|
15
|
+
exports.ARTIFACT_PREFIXES = artifactKeys.ARTIFACT_PREFIXES;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var projectPaths = require('../../dist/projectPaths-9cbecebf.cjs.prod.js');
|
|
6
|
+
var artifactKeys = require('../../dist/artifactKeys-700b9044.cjs.prod.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.ENTRY = projectPaths.ENTRY;
|
|
11
|
+
exports.ENTRY_SHIM = projectPaths.ENTRY_SHIM;
|
|
12
|
+
exports.ROUTES_DIR = projectPaths.ROUTES_DIR;
|
|
13
|
+
exports.TREE = projectPaths.TREE;
|
|
14
|
+
exports.ARTIFACT_KEYS = artifactKeys.ARTIFACT_KEYS;
|
|
15
|
+
exports.ARTIFACT_PREFIXES = artifactKeys.ARTIFACT_PREFIXES;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The publish API's artifact key namespace: `server`, `chunk/client/<name>`,
|
|
3
|
+
* `public/<path>` and the rest. See `artifacts.ts` for why it is declared once
|
|
4
|
+
* and here.
|
|
5
|
+
*
|
|
6
|
+
* A module of its own, importing nothing, so it can be reached through
|
|
7
|
+
* `@valbuild/tanstack-build/constants` by a caller that must not load the
|
|
8
|
+
* builder -- content's `loaderPayload.ts` takes artifacts apart by these
|
|
9
|
+
* prefixes in a Node server that has no use for rolldown.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** The single-file keys, in the order a reader most wants to see them. */
|
|
13
|
+
var ARTIFACT_KEYS = {
|
|
14
|
+
server: "server",
|
|
15
|
+
client: "client",
|
|
16
|
+
css: "css",
|
|
17
|
+
rsc: "rsc",
|
|
18
|
+
/**
|
|
19
|
+
* The dependency layer: gzipped JSON, and NOT produced by a browser build.
|
|
20
|
+
*
|
|
21
|
+
* Named here because it is part of the namespace a reader is trying to
|
|
22
|
+
* understand, not because {@link publishArtifacts} ever emits it -- building
|
|
23
|
+
* a layer is a rolldown pass over `node_modules`, which a tab does not have.
|
|
24
|
+
* A publisher without one sends `layerRev` instead; see `DeclareBody`.
|
|
25
|
+
*/
|
|
26
|
+
layer: "layer",
|
|
27
|
+
/**
|
|
28
|
+
* The project's own files, as JSON, exactly as this build was made from
|
|
29
|
+
* them -- what the loader stores as the project's source.
|
|
30
|
+
*
|
|
31
|
+
* It has to travel WITH the build: it is what the next publisher starts
|
|
32
|
+
* from, and a managed project's Studio edits one `.val.ts` and rebuilds, so
|
|
33
|
+
* a build published without it leaves the stored source one edit behind --
|
|
34
|
+
* and the edit after that is built on top of the stale copy and silently
|
|
35
|
+
* undoes this one. The generated route tree is never in it; see
|
|
36
|
+
* `projectSource` on `BuildInput`.
|
|
37
|
+
*/
|
|
38
|
+
source: "source"
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/** The prefixes, and which {@link BuildOutput} record fills each. */
|
|
42
|
+
var ARTIFACT_PREFIXES = {
|
|
43
|
+
serverChunks: "chunk/server/",
|
|
44
|
+
clientChunks: "chunk/client/",
|
|
45
|
+
rscChunks: "chunk/rsc/",
|
|
46
|
+
assetFiles: "asset/",
|
|
47
|
+
publicFiles: "public/"
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export { ARTIFACT_KEYS as A, ARTIFACT_PREFIXES as a };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The publish API's artifact key namespace: `server`, `chunk/client/<name>`,
|
|
5
|
+
* `public/<path>` and the rest. See `artifacts.ts` for why it is declared once
|
|
6
|
+
* and here.
|
|
7
|
+
*
|
|
8
|
+
* A module of its own, importing nothing, so it can be reached through
|
|
9
|
+
* `@valbuild/tanstack-build/constants` by a caller that must not load the
|
|
10
|
+
* builder -- content's `loaderPayload.ts` takes artifacts apart by these
|
|
11
|
+
* prefixes in a Node server that has no use for rolldown.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** The single-file keys, in the order a reader most wants to see them. */
|
|
15
|
+
var ARTIFACT_KEYS = {
|
|
16
|
+
server: "server",
|
|
17
|
+
client: "client",
|
|
18
|
+
css: "css",
|
|
19
|
+
rsc: "rsc",
|
|
20
|
+
/**
|
|
21
|
+
* The dependency layer: gzipped JSON, and NOT produced by a browser build.
|
|
22
|
+
*
|
|
23
|
+
* Named here because it is part of the namespace a reader is trying to
|
|
24
|
+
* understand, not because {@link publishArtifacts} ever emits it -- building
|
|
25
|
+
* a layer is a rolldown pass over `node_modules`, which a tab does not have.
|
|
26
|
+
* A publisher without one sends `layerRev` instead; see `DeclareBody`.
|
|
27
|
+
*/
|
|
28
|
+
layer: "layer",
|
|
29
|
+
/**
|
|
30
|
+
* The project's own files, as JSON, exactly as this build was made from
|
|
31
|
+
* them -- what the loader stores as the project's source.
|
|
32
|
+
*
|
|
33
|
+
* It has to travel WITH the build: it is what the next publisher starts
|
|
34
|
+
* from, and a managed project's Studio edits one `.val.ts` and rebuilds, so
|
|
35
|
+
* a build published without it leaves the stored source one edit behind --
|
|
36
|
+
* and the edit after that is built on top of the stale copy and silently
|
|
37
|
+
* undoes this one. The generated route tree is never in it; see
|
|
38
|
+
* `projectSource` on `BuildInput`.
|
|
39
|
+
*/
|
|
40
|
+
source: "source"
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** The prefixes, and which {@link BuildOutput} record fills each. */
|
|
44
|
+
var ARTIFACT_PREFIXES = {
|
|
45
|
+
serverChunks: "chunk/server/",
|
|
46
|
+
clientChunks: "chunk/client/",
|
|
47
|
+
rscChunks: "chunk/rsc/",
|
|
48
|
+
assetFiles: "asset/",
|
|
49
|
+
publicFiles: "public/"
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
exports.ARTIFACT_KEYS = ARTIFACT_KEYS;
|
|
53
|
+
exports.ARTIFACT_PREFIXES = ARTIFACT_PREFIXES;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The publish API's artifact key namespace: `server`, `chunk/client/<name>`,
|
|
5
|
+
* `public/<path>` and the rest. See `artifacts.ts` for why it is declared once
|
|
6
|
+
* and here.
|
|
7
|
+
*
|
|
8
|
+
* A module of its own, importing nothing, so it can be reached through
|
|
9
|
+
* `@valbuild/tanstack-build/constants` by a caller that must not load the
|
|
10
|
+
* builder -- content's `loaderPayload.ts` takes artifacts apart by these
|
|
11
|
+
* prefixes in a Node server that has no use for rolldown.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** The single-file keys, in the order a reader most wants to see them. */
|
|
15
|
+
var ARTIFACT_KEYS = {
|
|
16
|
+
server: "server",
|
|
17
|
+
client: "client",
|
|
18
|
+
css: "css",
|
|
19
|
+
rsc: "rsc",
|
|
20
|
+
/**
|
|
21
|
+
* The dependency layer: gzipped JSON, and NOT produced by a browser build.
|
|
22
|
+
*
|
|
23
|
+
* Named here because it is part of the namespace a reader is trying to
|
|
24
|
+
* understand, not because {@link publishArtifacts} ever emits it -- building
|
|
25
|
+
* a layer is a rolldown pass over `node_modules`, which a tab does not have.
|
|
26
|
+
* A publisher without one sends `layerRev` instead; see `DeclareBody`.
|
|
27
|
+
*/
|
|
28
|
+
layer: "layer",
|
|
29
|
+
/**
|
|
30
|
+
* The project's own files, as JSON, exactly as this build was made from
|
|
31
|
+
* them -- what the loader stores as the project's source.
|
|
32
|
+
*
|
|
33
|
+
* It has to travel WITH the build: it is what the next publisher starts
|
|
34
|
+
* from, and a managed project's Studio edits one `.val.ts` and rebuilds, so
|
|
35
|
+
* a build published without it leaves the stored source one edit behind --
|
|
36
|
+
* and the edit after that is built on top of the stale copy and silently
|
|
37
|
+
* undoes this one. The generated route tree is never in it; see
|
|
38
|
+
* `projectSource` on `BuildInput`.
|
|
39
|
+
*/
|
|
40
|
+
source: "source"
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** The prefixes, and which {@link BuildOutput} record fills each. */
|
|
44
|
+
var ARTIFACT_PREFIXES = {
|
|
45
|
+
serverChunks: "chunk/server/",
|
|
46
|
+
clientChunks: "chunk/client/",
|
|
47
|
+
rscChunks: "chunk/rsc/",
|
|
48
|
+
assetFiles: "asset/",
|
|
49
|
+
publicFiles: "public/"
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
exports.ARTIFACT_KEYS = ARTIFACT_KEYS;
|
|
53
|
+
exports.ARTIFACT_PREFIXES = ARTIFACT_PREFIXES;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The publish API's artifact key namespace: `server`, `chunk/client/<name>`,
|
|
3
|
+
* `public/<path>` and the rest. See `artifacts.ts` for why it is declared once
|
|
4
|
+
* and here.
|
|
5
|
+
*
|
|
6
|
+
* A module of its own, importing nothing, so it can be reached through
|
|
7
|
+
* `@valbuild/tanstack-build/constants` by a caller that must not load the
|
|
8
|
+
* builder -- content's `loaderPayload.ts` takes artifacts apart by these
|
|
9
|
+
* prefixes in a Node server that has no use for rolldown.
|
|
10
|
+
*/
|
|
11
|
+
/** The single-file keys, in the order a reader most wants to see them. */
|
|
12
|
+
export declare const ARTIFACT_KEYS: {
|
|
13
|
+
readonly server: "server";
|
|
14
|
+
readonly client: "client";
|
|
15
|
+
readonly css: "css";
|
|
16
|
+
readonly rsc: "rsc";
|
|
17
|
+
/**
|
|
18
|
+
* The dependency layer: gzipped JSON, and NOT produced by a browser build.
|
|
19
|
+
*
|
|
20
|
+
* Named here because it is part of the namespace a reader is trying to
|
|
21
|
+
* understand, not because {@link publishArtifacts} ever emits it -- building
|
|
22
|
+
* a layer is a rolldown pass over `node_modules`, which a tab does not have.
|
|
23
|
+
* A publisher without one sends `layerRev` instead; see `DeclareBody`.
|
|
24
|
+
*/
|
|
25
|
+
readonly layer: "layer";
|
|
26
|
+
/**
|
|
27
|
+
* The project's own files, as JSON, exactly as this build was made from
|
|
28
|
+
* them -- what the loader stores as the project's source.
|
|
29
|
+
*
|
|
30
|
+
* It has to travel WITH the build: it is what the next publisher starts
|
|
31
|
+
* from, and a managed project's Studio edits one `.val.ts` and rebuilds, so
|
|
32
|
+
* a build published without it leaves the stored source one edit behind --
|
|
33
|
+
* and the edit after that is built on top of the stale copy and silently
|
|
34
|
+
* undoes this one. The generated route tree is never in it; see
|
|
35
|
+
* `projectSource` on `BuildInput`.
|
|
36
|
+
*/
|
|
37
|
+
readonly source: "source";
|
|
38
|
+
};
|
|
39
|
+
/** The prefixes, and which {@link BuildOutput} record fills each. */
|
|
40
|
+
export declare const ARTIFACT_PREFIXES: {
|
|
41
|
+
readonly serverChunks: "chunk/server/";
|
|
42
|
+
readonly clientChunks: "chunk/client/";
|
|
43
|
+
readonly rscChunks: "chunk/rsc/";
|
|
44
|
+
readonly assetFiles: "asset/";
|
|
45
|
+
readonly publicFiles: "public/";
|
|
46
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A build, as the flat set of artifacts a publisher declares.
|
|
3
|
+
*
|
|
4
|
+
* ## Why this is here and not in three places
|
|
5
|
+
*
|
|
6
|
+
* The publish API addresses every artifact by a STRING KEY -- `server`,
|
|
7
|
+
* `chunk/client/<name>`, `public/<path>` -- because a key that is just a string
|
|
8
|
+
* is what lets one mechanism declare, upload and confirm all of them by hash.
|
|
9
|
+
* That namespace was restated three times: content's `loaderPayload.ts` matched
|
|
10
|
+
* the prefixes to take them apart, `val publish` reproduced them as a directory
|
|
11
|
+
* layout to read, and whatever built the project had to lay that directory out.
|
|
12
|
+
* Three copies of a mapping whose failure mode is silent -- a chunk filed under
|
|
13
|
+
* the wrong target does not fail at publish, it fails at isolate startup with a
|
|
14
|
+
* missing export naming neither package nor version.
|
|
15
|
+
*
|
|
16
|
+
* So the namespace is declared once, HERE, beside the {@link BuildOutput} it
|
|
17
|
+
* describes. Val owns it because Val produces it.
|
|
18
|
+
*
|
|
19
|
+
* ## What is deliberately NOT here
|
|
20
|
+
*
|
|
21
|
+
* The loader's payload shape -- `serverCode`, `clientChunks`, `publicFiles` --
|
|
22
|
+
* stays content's own, and `loaderPayload.ts` says why: it is a platform
|
|
23
|
+
* internal, and a publisher that had to learn it would be coupled to the
|
|
24
|
+
* platform, which is exactly what a project token publishing from somebody's CI
|
|
25
|
+
* must not be. The KEYS are the public contract; the payload assembled from
|
|
26
|
+
* them is not. This exports the first and says nothing about the second.
|
|
27
|
+
*
|
|
28
|
+
* ## Everything is text
|
|
29
|
+
*
|
|
30
|
+
* Including assets and public files, which {@link BuildOutput} carries base64
|
|
31
|
+
* encoded. That is the existing wire contract rather than a choice made here:
|
|
32
|
+
* the loader stores what it is given and `decodeBase64`s it on the way out, so
|
|
33
|
+
* the artifact's bytes ARE the base64 text. Sending the raw bytes instead would
|
|
34
|
+
* be smaller and would corrupt every image in the isolate.
|
|
35
|
+
*/
|
|
36
|
+
import type { BuildOutput } from "./build.js";
|
|
37
|
+
import { ARTIFACT_KEYS, ARTIFACT_PREFIXES } from "./artifactKeys.js";
|
|
38
|
+
export { ARTIFACT_KEYS, ARTIFACT_PREFIXES };
|
|
39
|
+
/** One artifact, ready to declare and to upload. */
|
|
40
|
+
export type PublishArtifact = {
|
|
41
|
+
key: string;
|
|
42
|
+
/** The exact bytes, as text. See the note on encoding above. */
|
|
43
|
+
body: string;
|
|
44
|
+
sha256: string;
|
|
45
|
+
/**
|
|
46
|
+
* The byte length, which is NOT `body.length`.
|
|
47
|
+
*
|
|
48
|
+
* Content compares this against what object storage received. A string's
|
|
49
|
+
* length counts UTF-16 code units, so any non-ASCII character -- one accented
|
|
50
|
+
* word in a page's markup is enough -- makes it disagree with the number of
|
|
51
|
+
* bytes actually sent, and the publish is refused for a size mismatch that
|
|
52
|
+
* names no file.
|
|
53
|
+
*/
|
|
54
|
+
bytes: number;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Every artifact a build publishes, by key.
|
|
58
|
+
*
|
|
59
|
+
* Async because the hashes are, and the hashes are because `crypto.subtle` is
|
|
60
|
+
* the one digest available both in a tab and in Node -- see `hash.ts`.
|
|
61
|
+
*
|
|
62
|
+
* An empty stylesheet is omitted rather than uploaded as an empty artifact: a
|
|
63
|
+
* project with no CSS has no `css` key, which is what `loaderPayload.ts` reads
|
|
64
|
+
* `text("css") !== undefined` to decide.
|
|
65
|
+
*/
|
|
66
|
+
export declare function publishArtifacts(build: BuildOutput, options?: {
|
|
67
|
+
/**
|
|
68
|
+
* The project's own files, published as the `source` artifact. See
|
|
69
|
+
* `ARTIFACT_KEYS.source`. Omitted, the stored source is left as it was.
|
|
70
|
+
*/
|
|
71
|
+
projectSource?: Record<string, string>;
|
|
72
|
+
}): Promise<PublishArtifact[]>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare const extensionOf: (path: string) => string;
|
|
2
|
+
export declare const isAsset: (path: string) => boolean;
|
|
3
|
+
export declare const mimeOf: (path: string) => string;
|
|
4
|
+
/**
|
|
5
|
+
* Below this many decoded bytes, an asset is inlined as a data URI.
|
|
6
|
+
*
|
|
7
|
+
* 4 kB, matching Vite's `assetsInlineLimit` default. The trade is the same one
|
|
8
|
+
* Vite is making: an extra request costs more than 4 kB of base64 does, and
|
|
9
|
+
* above that it stops being true.
|
|
10
|
+
*/
|
|
11
|
+
export declare const INLINE_LIMIT = 4096;
|
|
12
|
+
/** Decoded byte length of base64, without decoding it. */
|
|
13
|
+
export declare function base64Bytes(base64: string): number;
|
|
14
|
+
export interface ResolvedAsset {
|
|
15
|
+
/** What the importing module's default export becomes. */
|
|
16
|
+
url: string;
|
|
17
|
+
/** Set when the asset needs publishing; absent when it was inlined. */
|
|
18
|
+
file?: {
|
|
19
|
+
name: string;
|
|
20
|
+
base64: string;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Where an asset import resolves to, for one target.
|
|
25
|
+
*
|
|
26
|
+
* Server and client get the *same* URL. An asset is a URL in both, and SSR has
|
|
27
|
+
* to emit the same `src` the browser will hydrate against -- a server bundle
|
|
28
|
+
* with a different URL would be a hydration mismatch on every image.
|
|
29
|
+
*/
|
|
30
|
+
export declare function resolveAsset(path: string, base64: string): Promise<ResolvedAsset>;
|
|
31
|
+
/** Where published assets are served from. Matched by the loader. */
|
|
32
|
+
export declare const ASSET_BASE = "/_app/a/";
|
|
33
|
+
/** The module a resolved asset import becomes. */
|
|
34
|
+
export declare const assetModule: (url: string) => string;
|