@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
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import type { BuildTarget } from "../contract.js";
|
|
2
|
+
/**
|
|
3
|
+
* Packages the base layer already provides.
|
|
4
|
+
*
|
|
5
|
+
* A project declares these and must -- `packages/verify` fails a project that
|
|
6
|
+
* does not -- but they are supplied by the platform, so building them into a
|
|
7
|
+
* project layer would be the duplication described above.
|
|
8
|
+
*/
|
|
9
|
+
export declare const BASE_PROVIDED: Set<string>;
|
|
10
|
+
/**
|
|
11
|
+
* Chunk filename for a package.
|
|
12
|
+
*
|
|
13
|
+
* `@scope/name` becomes `scope__name`: a flat, filesystem-safe name, since
|
|
14
|
+
* these are module-map keys and URL segments. A package literally named
|
|
15
|
+
* `scope__name` would collide with a scoped one; that is unlikely enough to
|
|
16
|
+
* take, and it would be caught here as a duplicate rather than silently.
|
|
17
|
+
*/
|
|
18
|
+
export declare const chunkNameFor: (specifier: string) => string;
|
|
19
|
+
/**
|
|
20
|
+
* The platform a layer is built against, as facts rather than as imports.
|
|
21
|
+
*
|
|
22
|
+
* This module used to read `@valbuild/vendor/externals` and
|
|
23
|
+
* `@valbuild/vendor/resolve` directly, which is what kept it in the same
|
|
24
|
+
* repository as the vendor package -- the same knot `BuildTarget` untied for
|
|
25
|
+
* the browser builder, one level down. The facts have not changed and they are
|
|
26
|
+
* still the platform's; they now ARRIVE.
|
|
27
|
+
*
|
|
28
|
+
* The three are separate because they answer at different times.
|
|
29
|
+
* {@link base} crosses a wire, so it is data. The other two cannot: one
|
|
30
|
+
* resolves against a node_modules that only the platform's own checkout has,
|
|
31
|
+
* and the other is a directory in it. A host that has neither passes
|
|
32
|
+
* `() => null` and `null`, and says so by doing it.
|
|
33
|
+
*/
|
|
34
|
+
export interface VendorPlatform {
|
|
35
|
+
/** `BuildTarget.base`: the specifier map and the paths that read it. */
|
|
36
|
+
base: BuildTarget["base"];
|
|
37
|
+
/**
|
|
38
|
+
* Where the PLATFORM's own copy of `specifier` is, as opposed to a project's.
|
|
39
|
+
*
|
|
40
|
+
* Null is the ordinary answer and not a failure: a project depends on plenty
|
|
41
|
+
* the platform has never heard of, and those layer from the project's own
|
|
42
|
+
* node_modules. What it is FOR is the `@tanstack/*` set, which has to agree
|
|
43
|
+
* with the base layer version for version -- see `pinPlatformTanstack`.
|
|
44
|
+
*/
|
|
45
|
+
resolvePlatformModule: (specifier: string) => string | null;
|
|
46
|
+
/**
|
|
47
|
+
* Where the built base layer's chunks are, or null when this checkout has
|
|
48
|
+
* not built them.
|
|
49
|
+
*
|
|
50
|
+
* Only the export audit reads it, and only to check a named import against
|
|
51
|
+
* the chunk it will link to. Null means that check is skipped, which is the
|
|
52
|
+
* honest answer rather than a refusal -- see `baseChunkExports`.
|
|
53
|
+
*/
|
|
54
|
+
baseLayerDir: string | null;
|
|
55
|
+
}
|
|
56
|
+
export interface VendorLayer {
|
|
57
|
+
rev: string;
|
|
58
|
+
/**
|
|
59
|
+
* Stylesheets a dependency ships, keyed by the specifier that imports them.
|
|
60
|
+
*
|
|
61
|
+
* `import 'react-day-picker/style.css'` is a bare specifier pointing at a
|
|
62
|
+
* file in node_modules, and the browser build has no node_modules. Resolved
|
|
63
|
+
* and read here, where there is one, and carried across with the layer --
|
|
64
|
+
* the same trade as the code, and for the same reason.
|
|
65
|
+
*/
|
|
66
|
+
css: Record<string, string>;
|
|
67
|
+
/**
|
|
68
|
+
* Specifiers built for the worker but not the browser.
|
|
69
|
+
*
|
|
70
|
+
* A server-only dependency is not a failure. `@valbuild/tanstack/server`
|
|
71
|
+
* cannot build for a browser -- it reaches TanStack's SSR path, which lands
|
|
72
|
+
* on `node:stream/web` -- and has no business in a client bundle either.
|
|
73
|
+
* Dropping it entirely would mean such a package can never be layered, so it
|
|
74
|
+
* is layered for the side that can use it, and the builder rejects a client
|
|
75
|
+
* import of it by name.
|
|
76
|
+
*/
|
|
77
|
+
workerOnly: Array<string>;
|
|
78
|
+
/**
|
|
79
|
+
* Why each `workerOnly` specifier failed its browser build.
|
|
80
|
+
*
|
|
81
|
+
* Reporting only, and deliberately not part of what a publish sends: the
|
|
82
|
+
* builder needs to know a dependency is server-only, not why. But without
|
|
83
|
+
* this the diagnosis stopped at "it could not be built for the browser",
|
|
84
|
+
* which does not tell you whether to move the import or fix the package.
|
|
85
|
+
*/
|
|
86
|
+
workerOnlyReasons: Record<string, string>;
|
|
87
|
+
/**
|
|
88
|
+
* Specifiers that could not be built, with the reason.
|
|
89
|
+
*
|
|
90
|
+
* Dropped rather than fatal, because a manifest lists things the app never
|
|
91
|
+
* imports -- build plugins especially. `@tailwindcss/vite` is in the starter
|
|
92
|
+
* template's `dependencies` and pulls a native `.node` binary; failing the
|
|
93
|
+
* whole publish over a Vite plugin the isolate will never load would be
|
|
94
|
+
* wrong. Anything the app *does* import still fails, at the verify gate,
|
|
95
|
+
* naming the specifier.
|
|
96
|
+
*/
|
|
97
|
+
skipped: Array<{
|
|
98
|
+
specifier: string;
|
|
99
|
+
reason: string;
|
|
100
|
+
}>;
|
|
101
|
+
/** Specifier -> chunk name, which is what the builder resolves imports with. */
|
|
102
|
+
modules: Record<string, string>;
|
|
103
|
+
/** Module-map entries for the isolate, keyed `pvendor/<file>`. */
|
|
104
|
+
worker: Record<string, string>;
|
|
105
|
+
/** Browser chunks, served under `/_pvendor/<rev>/`. */
|
|
106
|
+
browser: Record<string, string>;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Every import a project chunk emits has to resolve inside the isolate: into
|
|
110
|
+
* the base layer, at a sibling chunk, or at a Node builtin the runtime
|
|
111
|
+
* provides. Anything else is a bare specifier with no module-map entry, and it
|
|
112
|
+
* fails at *startup* rather than at build time -- so it is checked here, where
|
|
113
|
+
* the cause is still in view.
|
|
114
|
+
*
|
|
115
|
+
* Parsed, not matched. This used to scan the emitted text with
|
|
116
|
+
* `/from\s*["']([^"']+)["']/`, which also matches inside string literals -- and
|
|
117
|
+
* TypeScript's diagnostic messages contain
|
|
118
|
+
* `Consider using 'import * as ns from "mod"'`. So bundling the TypeScript
|
|
119
|
+
* compiler was rejected for importing a package called `mod`, which does not
|
|
120
|
+
* exist and which nothing imported. `prettier` was rejected the same way. Both
|
|
121
|
+
* looked exactly like a genuine unresolvable dependency.
|
|
122
|
+
*/
|
|
123
|
+
interface AuditableImport {
|
|
124
|
+
/** The specifier, exactly as emitted. */
|
|
125
|
+
source: string;
|
|
126
|
+
/**
|
|
127
|
+
* The names taken from it, as the OTHER module has to export them.
|
|
128
|
+
*
|
|
129
|
+
* `import { a as b }` and `export { a as b } from` both want `a`. A default
|
|
130
|
+
* import wants `default`. A namespace import wants nothing in particular, so
|
|
131
|
+
* it contributes no names -- and `export * from` cannot be checked this way
|
|
132
|
+
* either, which is fine: neither can fail to link.
|
|
133
|
+
*/
|
|
134
|
+
names: Array<string>;
|
|
135
|
+
}
|
|
136
|
+
/** Every import and re-export a chunk emits, with the names it takes. */
|
|
137
|
+
export declare function auditableImports(code: string, file: string): Promise<Array<AuditableImport>>;
|
|
138
|
+
export declare function auditableSpecifiers(code: string, file: string): Promise<Array<string>>;
|
|
139
|
+
/** Bare specifiers that point at a stylesheet rather than a module. */
|
|
140
|
+
export declare function cssSpecifiersOf(files: Record<string, string>): string[];
|
|
141
|
+
/** The package a bare specifier belongs to. `@scope/pkg/sub` -> `@scope/pkg`. */
|
|
142
|
+
export declare function packageOf(specifier: string): string;
|
|
143
|
+
/**
|
|
144
|
+
* What the layer has to carry: every specifier the project imports, not every
|
|
145
|
+
* package it declares.
|
|
146
|
+
*
|
|
147
|
+
* Specifiers rather than package names, because a subpath is a different entry
|
|
148
|
+
* point with a different module graph -- the starter template imports
|
|
149
|
+
* `@valbuild/tanstack`, `@valbuild/tanstack/client` *and*
|
|
150
|
+
* `@valbuild/tanstack/server`, and a layer built from package names alone
|
|
151
|
+
* resolves one of the three.
|
|
152
|
+
*
|
|
153
|
+
* Intersected with the manifest, so a typo'd import does not silently become a
|
|
154
|
+
* layer entry and an undeclared dependency still fails the verify gate.
|
|
155
|
+
*/
|
|
156
|
+
export declare function layerDepsOf(manifest: {
|
|
157
|
+
dependencies?: Record<string, string>;
|
|
158
|
+
}, files?: Record<string, string>): Array<string>;
|
|
159
|
+
/**
|
|
160
|
+
* Builds the layer, from the dependencies installed in `dir`.
|
|
161
|
+
*
|
|
162
|
+
* Returns `null` when the project declares nothing beyond the base set, which
|
|
163
|
+
* is the same thing as having no layer -- not an empty one, because the head
|
|
164
|
+
* pointer distinguishes "no layer" from "a layer that is missing".
|
|
165
|
+
*/
|
|
166
|
+
/**
|
|
167
|
+
* Reads the stylesheets a project imports from its dependencies.
|
|
168
|
+
*
|
|
169
|
+
* Separate from the code build: these are not bundled, they are concatenated
|
|
170
|
+
* into the project's stylesheet by the builder's CSS pass. Resolution is the
|
|
171
|
+
* project's own, so the version matches whatever its lockfile pinned.
|
|
172
|
+
*/
|
|
173
|
+
export declare function collectDependencyCss(dir: string, specifiers: Array<string>): Promise<Record<string, string>>;
|
|
174
|
+
export declare function buildVendorLayer(dir: string, deps: Array<string>, css: Record<string, string>, platform: VendorPlatform): Promise<VendorLayer | null>;
|
|
175
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function dirname(path: string): string;
|
|
2
|
+
export declare function resolve(from: string, to: string): string;
|
|
3
|
+
/** Resolve a relative import against the in-memory file set. */
|
|
4
|
+
export declare function resolveInFiles(base: string, files: Record<string, string>): string | null;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paths the platform's contract fixes, in one place.
|
|
3
|
+
*
|
|
4
|
+
* These are not conventions this package chose -- `src/app.tsx` is the module
|
|
5
|
+
* the builder resolves as its entry, and `src/routeTree.gen.ts` is what
|
|
6
|
+
* TanStack's generator is configured to write. They are here so that a change
|
|
7
|
+
* on either side is one edit rather than a search for string literals.
|
|
8
|
+
*/
|
|
9
|
+
/** The module the builder uses as the project's entry. */
|
|
10
|
+
export declare const ENTRY = "src/app.tsx";
|
|
11
|
+
/** Where TanStack's generator writes the route tree. */
|
|
12
|
+
export declare const TREE = "src/routeTree.gen.ts";
|
|
13
|
+
/** Where a file-based project keeps its route files. */
|
|
14
|
+
export declare const ROUTES_DIR = "src/routes";
|
|
15
|
+
/**
|
|
16
|
+
* The one line the builder needs from a file-based project, as `src/app.tsx`.
|
|
17
|
+
*
|
|
18
|
+
* `src/app.tsx` is the entry the builder looks for, and a routes-as-data
|
|
19
|
+
* project writes it. A file-based project has no such file -- its entry IS
|
|
20
|
+
* the generated tree -- so every route generator adds this, and it is the
|
|
21
|
+
* same line wherever that runs (the `/node` entrypoint's `withRouteTree`, and
|
|
22
|
+
* the platform's browser generator, which reaches it through `/constants`).
|
|
23
|
+
*/
|
|
24
|
+
export declare const ENTRY_SHIM = "export { routeTree } from './routeTree.gen'\n";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface RouteSplitter {
|
|
2
|
+
/**
|
|
3
|
+
* Rewrites a route file to defer its split options.
|
|
4
|
+
*
|
|
5
|
+
* Returns null when the file has nothing to split, which is most of them.
|
|
6
|
+
*/
|
|
7
|
+
reference(id: string, code: string): {
|
|
8
|
+
code: string;
|
|
9
|
+
} | null;
|
|
10
|
+
/** Produces the deferred half, containing only `targets`. */
|
|
11
|
+
virtual(id: string, code: string, targets: Array<string>): {
|
|
12
|
+
code: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/** Query Start's splitter emits, e.g. `?tsr-split=component---errorComponent`. */
|
|
16
|
+
export declare const SPLIT_QUERY = "tsr-split";
|
|
17
|
+
/** Is this a route file, i.e. one the splitter should look at? */
|
|
18
|
+
export declare const isRouteFile: (path: string, routesDir?: string) => boolean;
|
|
19
|
+
export interface SplitRequest {
|
|
20
|
+
path: string;
|
|
21
|
+
targets: Array<string>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Reads `./posts.tsx?tsr-split=component---errorComponent`.
|
|
25
|
+
*
|
|
26
|
+
* Returns null for anything else, including a `?raw` or `?url` query, so the
|
|
27
|
+
* caller can fall through to its other handling.
|
|
28
|
+
*/
|
|
29
|
+
export declare function parseSplitRequest(source: string): SplitRequest | null;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { compile } from "tailwindcss";
|
|
2
|
+
/** Does this stylesheet ask for Tailwind at all? */
|
|
3
|
+
export declare const usesTailwind: (css: string) => boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Loads a JS module for `@plugin` / `@config`.
|
|
6
|
+
*
|
|
7
|
+
* Tailwind resolves and *executes* these while compiling CSS, which is the one
|
|
8
|
+
* thing this build cannot do on its own: there is no module resolution here,
|
|
9
|
+
* only a fixed set of externals. So it is a capability the caller supplies --
|
|
10
|
+
* `packages/publish` has a real filesystem and node_modules and passes one; a
|
|
11
|
+
* browser build has neither and does not.
|
|
12
|
+
*
|
|
13
|
+
* Absent, this throws rather than returning an empty plugin. A plugin that
|
|
14
|
+
* silently does nothing leaves a page subtly unstyled, which is much harder to
|
|
15
|
+
* diagnose than a build that stops and names the directive -- and it would make
|
|
16
|
+
* the same project build differently depending on where it was published.
|
|
17
|
+
*/
|
|
18
|
+
type CompileOptions = NonNullable<Parameters<typeof compile>[1]>;
|
|
19
|
+
/**
|
|
20
|
+
* Derived from Tailwind's own option rather than restated.
|
|
21
|
+
*
|
|
22
|
+
* It used to be restated -- `(id, base, hint: string) => Promise<{ module:
|
|
23
|
+
* unknown; base: string }>` -- and the restatement was WRONG: Tailwind also
|
|
24
|
+
* wants a `path`, and the loader in the CLI never sent one. Nothing caught it
|
|
25
|
+
* because the package this came from ran under `--experimental-strip-types`,
|
|
26
|
+
* which strips types without checking them, so the mismatch was invisible on
|
|
27
|
+
* both sides of the call.
|
|
28
|
+
*
|
|
29
|
+
* Derived, a Tailwind upgrade that changes the shape is a compile error here
|
|
30
|
+
* -- which is where it can be read -- rather than an `undefined` handed to
|
|
31
|
+
* someone else's code.
|
|
32
|
+
*/
|
|
33
|
+
export type CssModuleLoader = NonNullable<CompileOptions["loadModule"]>;
|
|
34
|
+
/** What a `@plugin` / `@config` module has to be, once it is loaded. */
|
|
35
|
+
export type LoadedCssModule = Awaited<ReturnType<CssModuleLoader>>["module"];
|
|
36
|
+
/**
|
|
37
|
+
* Candidates for `build()`, extracted from the project's own source.
|
|
38
|
+
*
|
|
39
|
+
* Every string in every module, not just JSX class attributes: a class name can
|
|
40
|
+
* be built anywhere -- a `cn()` helper, a lookup table, a constant in another
|
|
41
|
+
* file -- and Tailwind's own scanner makes the same choice for the same reason.
|
|
42
|
+
*/
|
|
43
|
+
export declare function scanCandidates(files: Record<string, string>): Array<string>;
|
|
44
|
+
export interface TailwindResult {
|
|
45
|
+
css: string;
|
|
46
|
+
/** Directives this build cannot honour, as messages for the caller. */
|
|
47
|
+
warnings: Array<string>;
|
|
48
|
+
candidates: number;
|
|
49
|
+
ms: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Runs the project's stylesheet through Tailwind.
|
|
53
|
+
*
|
|
54
|
+
* The input is the *already concatenated* project CSS, so a project's own rules
|
|
55
|
+
* and its `@import "tailwindcss"` are compiled together and the cascade order
|
|
56
|
+
* the CSS pass worked out is preserved.
|
|
57
|
+
*/
|
|
58
|
+
export declare function compileTailwind(css: string, files: Record<string, string>, loadModule?: CssModuleLoader): Promise<TailwindResult>;
|
|
59
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON with comments and trailing commas, which is what tsconfig.json is.
|
|
3
|
+
*
|
|
4
|
+
* Written as a scanner rather than a regex on purpose: `"url": "https://x"`
|
|
5
|
+
* contains `//`, and a regex that strips comments without tracking string state
|
|
6
|
+
* truncates the file there and throws a parse error pointing at the wrong line.
|
|
7
|
+
*/
|
|
8
|
+
export declare function parseJsonc(text: string): unknown;
|
|
9
|
+
export interface AliasMap {
|
|
10
|
+
/** Candidate paths for a specifier, best first. Empty when nothing matches. */
|
|
11
|
+
candidates: (specifier: string) => Array<string>;
|
|
12
|
+
/**
|
|
13
|
+
* The `baseUrl` fallback, tried after `candidates` and reported differently.
|
|
14
|
+
*
|
|
15
|
+
* TypeScript resolves a bare specifier against `baseUrl` even with no `paths`
|
|
16
|
+
* entry at all -- `"baseUrl": "src"` makes `import 'components/Button'` work.
|
|
17
|
+
* Verified against ts.resolveModuleName rather than assumed.
|
|
18
|
+
*
|
|
19
|
+
* Kept separate from `candidates` because a miss means something different:
|
|
20
|
+
* an unresolved `paths` match is a typo (PLATFORM405), but an unresolved baseUrl
|
|
21
|
+
* guess is almost always just an npm package that is not in the vendor set,
|
|
22
|
+
* and reporting *that* as a broken alias would be the wrong diagnosis.
|
|
23
|
+
*/
|
|
24
|
+
baseUrlCandidate: (specifier: string) => string | null;
|
|
25
|
+
/** The raw pattern list, for reporting a pattern that shadows a vendor package. */
|
|
26
|
+
patterns: Array<string>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Reads tsconfig.json out of the file record and builds the matcher.
|
|
30
|
+
*
|
|
31
|
+
* Returns null when the project configures no aliases, which is the common
|
|
32
|
+
* case and costs nothing.
|
|
33
|
+
*/
|
|
34
|
+
export declare function aliasMap(files: Record<string, string>, warn: (message: string) => void, entry?: string): AliasMap | null;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
export interface Change {
|
|
2
|
+
what: string;
|
|
3
|
+
why: string;
|
|
4
|
+
}
|
|
5
|
+
export interface WireResult {
|
|
6
|
+
files: Record<string, string>;
|
|
7
|
+
changes: Array<Change>;
|
|
8
|
+
/** Things that will bite later, reported rather than fixed. */
|
|
9
|
+
warnings: Array<string>;
|
|
10
|
+
}
|
|
11
|
+
export interface WireOptions {
|
|
12
|
+
/**
|
|
13
|
+
* The project id this record is wired for.
|
|
14
|
+
*
|
|
15
|
+
* No longer written into the generated file: it named the project a save's
|
|
16
|
+
* files were handed over under, and that hand-over is gone. Kept so a caller
|
|
17
|
+
* that identifies the project does not have to change with it.
|
|
18
|
+
*/
|
|
19
|
+
project: string;
|
|
20
|
+
/**
|
|
21
|
+
* The platform's control plane.
|
|
22
|
+
*
|
|
23
|
+
* No longer baked into the generated file -- a save posts to the sentinel
|
|
24
|
+
* host the platform intercepts, because an isolate cannot fetch the loader's
|
|
25
|
+
* real address. Kept because a caller still identifies the platform it is
|
|
26
|
+
* wiring for, and the next thing that needs it will want it here.
|
|
27
|
+
*/
|
|
28
|
+
loader: string;
|
|
29
|
+
/**
|
|
30
|
+
* The commit this source was read at, and the branch a publish commits to.
|
|
31
|
+
*
|
|
32
|
+
* Load bearing rather than bookkeeping. Val reads a project's content from
|
|
33
|
+
* the content service AT A COMMIT, so a build wired with the wrong one edits
|
|
34
|
+
* and renders a different version of its files than the code it is running.
|
|
35
|
+
*
|
|
36
|
+
* Absent for a source that came from no commit at all -- a record assembled
|
|
37
|
+
* in a tab, a fixture. Such a build serves its pages and cannot edit, which
|
|
38
|
+
* the generated file decides in one place rather than failing five ways.
|
|
39
|
+
*/
|
|
40
|
+
git?: {
|
|
41
|
+
commit: string;
|
|
42
|
+
branch: string;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Where a Val project keeps the module this replaces.
|
|
47
|
+
*
|
|
48
|
+
* Exported because a caller has to be able to rewrite JUST this file. The
|
|
49
|
+
* commit is baked into it (see `BUILT_FROM` in the template), and the files a save
|
|
50
|
+
* writes are the `.val.ts` ones it patched -- this is never among them, so a tab
|
|
51
|
+
* that laid a save over the project and rebuilt would compile the NEW content
|
|
52
|
+
* against the OLD commit and read the wrong version of it back. `rebakeGit` is
|
|
53
|
+
* what the Studio calls.
|
|
54
|
+
*/
|
|
55
|
+
export declare const VAL_SERVER_PATH = "src/val/val.server.ts";
|
|
56
|
+
/**
|
|
57
|
+
* The wired `val.server.ts`, on its own.
|
|
58
|
+
*
|
|
59
|
+
* {@link wireUp} does this and eight other things, which is right when a
|
|
60
|
+
* repository arrives and wrong every time a build is about to run: re-deriving
|
|
61
|
+
* a package.json and a route entry to change one baked-in sha would be a lot of
|
|
62
|
+
* machinery to get a one-line difference, and any of it not being idempotent
|
|
63
|
+
* would be a bug that only shows up on the second publish.
|
|
64
|
+
*/
|
|
65
|
+
export declare function wiredValServer(options: WireOptions): string;
|
|
66
|
+
export declare function bakedGit(files: Record<string, string>): {
|
|
67
|
+
commit: string;
|
|
68
|
+
branch: string;
|
|
69
|
+
} | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* The same record, wired at a different commit.
|
|
72
|
+
*
|
|
73
|
+
* The inverse of {@link bakedGit}, and the whole of what a rebuild has to
|
|
74
|
+
* change: `BUILT_FROM` is the only place the commit appears, and every other
|
|
75
|
+
* use in the generated file reads it.
|
|
76
|
+
*
|
|
77
|
+
* REWRITES one line rather than regenerating the file, and that is the point.
|
|
78
|
+
* `wiredValServer` needs the project id and the platform's address, which the
|
|
79
|
+
* publisher that has them is the tab; a Studio publishing from inside the
|
|
80
|
+
* deployment has neither, and reconstructing the file from what it could guess
|
|
81
|
+
* would throw away wiring it cannot see. Replacing the literal cannot.
|
|
82
|
+
*
|
|
83
|
+
* Returns the record unchanged when there is nothing to rewrite -- no
|
|
84
|
+
* `val.server.ts`, or one this does not recognise. Unchanged rather than
|
|
85
|
+
* thrown, because the caller's next step is a build, and a build of a record
|
|
86
|
+
* with no wired server is a project that was never wired: a real thing, which
|
|
87
|
+
* fails with its own message rather than this one.
|
|
88
|
+
*
|
|
89
|
+
* Non-destructive, like {@link wireUp}: the caller's record is what gets
|
|
90
|
+
* published back as source.
|
|
91
|
+
*/
|
|
92
|
+
export declare function rebakeGit(files: Record<string, string>, git: {
|
|
93
|
+
commit: string;
|
|
94
|
+
branch: string;
|
|
95
|
+
} | null): Record<string, string>;
|
|
96
|
+
/** Is this a Val project at all? */
|
|
97
|
+
export declare function isValProject(files: Record<string, string>): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Has this record already been wired up?
|
|
100
|
+
*
|
|
101
|
+
* {@link WIRED_MARKER} is the marker, or -- for a file generated before it
|
|
102
|
+
* existed -- the sentinel host that file posted its saves to. It used to be
|
|
103
|
+
* `platform:project-source` before that, which the generated file imported
|
|
104
|
+
* while Val was in memory mode.
|
|
105
|
+
*/
|
|
106
|
+
export declare function isWired(files: Record<string, string>): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Returns the record with the platform's wiring applied, and what it changed.
|
|
109
|
+
*
|
|
110
|
+
* Non-destructive, and that matters more than it looks: the caller's record is
|
|
111
|
+
* what an edit is applied to, and the source that gets published back.
|
|
112
|
+
*/
|
|
113
|
+
export declare function wireUp(files: Record<string, string>, options: WireOptions): WireResult;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paths the platform's contract fixes, in one place.
|
|
3
|
+
*
|
|
4
|
+
* These are not conventions this package chose -- `src/app.tsx` is the module
|
|
5
|
+
* the builder resolves as its entry, and `src/routeTree.gen.ts` is what
|
|
6
|
+
* TanStack's generator is configured to write. They are here so that a change
|
|
7
|
+
* on either side is one edit rather than a search for string literals.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** The module the builder uses as the project's entry. */
|
|
11
|
+
var ENTRY = "src/app.tsx";
|
|
12
|
+
|
|
13
|
+
/** Where TanStack's generator writes the route tree. */
|
|
14
|
+
var TREE = "src/routeTree.gen.ts";
|
|
15
|
+
|
|
16
|
+
/** Where a file-based project keeps its route files. */
|
|
17
|
+
var ROUTES_DIR = "src/routes";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The one line the builder needs from a file-based project, as `src/app.tsx`.
|
|
21
|
+
*
|
|
22
|
+
* `src/app.tsx` is the entry the builder looks for, and a routes-as-data
|
|
23
|
+
* project writes it. A file-based project has no such file -- its entry IS
|
|
24
|
+
* the generated tree -- so every route generator adds this, and it is the
|
|
25
|
+
* same line wherever that runs (the `/node` entrypoint's `withRouteTree`, and
|
|
26
|
+
* the platform's browser generator, which reaches it through `/constants`).
|
|
27
|
+
*/
|
|
28
|
+
var ENTRY_SHIM = "export { routeTree } from './routeTree.gen'\n";
|
|
29
|
+
|
|
30
|
+
export { ENTRY as E, ROUTES_DIR as R, TREE as T, ENTRY_SHIM as a };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Paths the platform's contract fixes, in one place.
|
|
5
|
+
*
|
|
6
|
+
* These are not conventions this package chose -- `src/app.tsx` is the module
|
|
7
|
+
* the builder resolves as its entry, and `src/routeTree.gen.ts` is what
|
|
8
|
+
* TanStack's generator is configured to write. They are here so that a change
|
|
9
|
+
* on either side is one edit rather than a search for string literals.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** The module the builder uses as the project's entry. */
|
|
13
|
+
var ENTRY = "src/app.tsx";
|
|
14
|
+
|
|
15
|
+
/** Where TanStack's generator writes the route tree. */
|
|
16
|
+
var TREE = "src/routeTree.gen.ts";
|
|
17
|
+
|
|
18
|
+
/** Where a file-based project keeps its route files. */
|
|
19
|
+
var ROUTES_DIR = "src/routes";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The one line the builder needs from a file-based project, as `src/app.tsx`.
|
|
23
|
+
*
|
|
24
|
+
* `src/app.tsx` is the entry the builder looks for, and a routes-as-data
|
|
25
|
+
* project writes it. A file-based project has no such file -- its entry IS
|
|
26
|
+
* the generated tree -- so every route generator adds this, and it is the
|
|
27
|
+
* same line wherever that runs (the `/node` entrypoint's `withRouteTree`, and
|
|
28
|
+
* the platform's browser generator, which reaches it through `/constants`).
|
|
29
|
+
*/
|
|
30
|
+
var ENTRY_SHIM = "export { routeTree } from './routeTree.gen'\n";
|
|
31
|
+
|
|
32
|
+
exports.ENTRY = ENTRY;
|
|
33
|
+
exports.ENTRY_SHIM = ENTRY_SHIM;
|
|
34
|
+
exports.ROUTES_DIR = ROUTES_DIR;
|
|
35
|
+
exports.TREE = TREE;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Paths the platform's contract fixes, in one place.
|
|
5
|
+
*
|
|
6
|
+
* These are not conventions this package chose -- `src/app.tsx` is the module
|
|
7
|
+
* the builder resolves as its entry, and `src/routeTree.gen.ts` is what
|
|
8
|
+
* TanStack's generator is configured to write. They are here so that a change
|
|
9
|
+
* on either side is one edit rather than a search for string literals.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** The module the builder uses as the project's entry. */
|
|
13
|
+
var ENTRY = "src/app.tsx";
|
|
14
|
+
|
|
15
|
+
/** Where TanStack's generator writes the route tree. */
|
|
16
|
+
var TREE = "src/routeTree.gen.ts";
|
|
17
|
+
|
|
18
|
+
/** Where a file-based project keeps its route files. */
|
|
19
|
+
var ROUTES_DIR = "src/routes";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The one line the builder needs from a file-based project, as `src/app.tsx`.
|
|
23
|
+
*
|
|
24
|
+
* `src/app.tsx` is the entry the builder looks for, and a routes-as-data
|
|
25
|
+
* project writes it. A file-based project has no such file -- its entry IS
|
|
26
|
+
* the generated tree -- so every route generator adds this, and it is the
|
|
27
|
+
* same line wherever that runs (the `/node` entrypoint's `withRouteTree`, and
|
|
28
|
+
* the platform's browser generator, which reaches it through `/constants`).
|
|
29
|
+
*/
|
|
30
|
+
var ENTRY_SHIM = "export { routeTree } from './routeTree.gen'\n";
|
|
31
|
+
|
|
32
|
+
exports.ENTRY = ENTRY;
|
|
33
|
+
exports.ENTRY_SHIM = ENTRY_SHIM;
|
|
34
|
+
exports.ROUTES_DIR = ROUTES_DIR;
|
|
35
|
+
exports.TREE = TREE;
|