@valbuild/tanstack-build 0.151.0 → 0.154.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 +39 -0
- package/dist/declarations/src/build.d.ts +10 -1
- package/dist/declarations/src/valModules.d.ts +15 -1
- package/dist/valbuild-tanstack-build.cjs.dev.js +331 -109
- package/dist/valbuild-tanstack-build.cjs.prod.js +331 -109
- package/dist/valbuild-tanstack-build.esm.js +331 -110
- package/package.json +1 -1
|
@@ -1191,7 +1191,7 @@ var packageJson = {
|
|
|
1191
1191
|
url: "git+https://github.com/valbuild/val.git"
|
|
1192
1192
|
},
|
|
1193
1193
|
license: "MIT",
|
|
1194
|
-
version: "0.
|
|
1194
|
+
version: "0.154.0",
|
|
1195
1195
|
sideEffects: false,
|
|
1196
1196
|
main: "dist/valbuild-tanstack-build.cjs.js",
|
|
1197
1197
|
module: "dist/valbuild-tanstack-build.esm.js",
|
|
@@ -1370,6 +1370,16 @@ var PROPOSAL_BLOCK_V1 = "/*\n * THE PROPOSAL this isolate serves the address of,
|
|
|
1370
1370
|
* arrives in files wired before it the same way: {@link rebakeContent}.
|
|
1371
1371
|
*/
|
|
1372
1372
|
var CONTENT_BLOCK = "/*\n * THE CONTENT VERSION the site serves, when the platform says it differs from\n * the one this build bundles (`VAL_CONTENT`: its id, the publish that made\n * it, and the Source and Val files that differ). Val reads that Source instead\n * of the bundle's and names that publish as its position. valbuild/home\n * `docs/hosted-publishing.md`, step 2.\n *\n * Parsed here, like the proposal above, because this file is compiled against\n * whatever @valbuild/tanstack the PROJECT installed. One from before content\n * versions ignores the `contentVersion` key below and serves the bundle --\n * and never says it applied the version, which is how the platform knows not\n * to serve this build a version it does not bundle. A version that does not\n * parse is thrown, not served as the bundle.\n *\n * A version too large for one variable names others under `refs`\n * (`\"env://VAL_CONTENT_1\"`), each holding one module's Source or one file's\n * text. Only `refs` is resolved, never a string inside Source, and only\n * `VAL_CONTENT_<n>` is read: Source is text editors write, and resolving a\n * reference in there would read `VAL_SECRET` into a page. The same rules as\n * `contentFromEnv` in @valbuild/server.\n */\nconst contentVersion = (() => {\n const handed = secret(\"VAL_CONTENT\");\n if (!handed) return undefined;\n const isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n const parsed: unknown = JSON.parse(handed);\n if (!isRecord(parsed)) throw new Error(\"Val: VAL_CONTENT is not an object\");\n const id = parsed.id;\n if (typeof id !== \"string\" || id === \"\") {\n throw new Error(\"Val: VAL_CONTENT has no id\");\n }\n const where = \"Val: content version \" + id;\n const nullableString = (key: string): string | null => {\n const value = parsed[key] ?? null;\n if (value !== null && typeof value !== \"string\") {\n throw new Error(where + \": \" + key + \" must be a string or null\");\n }\n return value;\n };\n const record = (value: unknown, name: string): Record<string, unknown> => {\n const found = value ?? {};\n if (!isRecord(found)) throw new Error(where + \": \" + name + \" must be an object\");\n return found;\n };\n const job = nullableString(\"job\");\n const commit = nullableString(\"commit\");\n const modules: Record<string, unknown> = { ...record(parsed.modules, \"modules\") };\n const filesIn = record(parsed.files, \"files\");\n const files: Record<string, string> = {};\n for (const [path, text] of Object.entries(filesIn)) {\n if (typeof text === \"string\") files[path] = text;\n }\n const refs = record(parsed.refs, \"refs\");\n const read = (kind: string, path: string, ref: unknown): string => {\n const at = where + \": refs.\" + kind + \"[\" + path + \"]\";\n if (typeof ref !== \"string\" || !ref.startsWith(\"env://\")) {\n throw new Error(at + \" is \" + String(ref) + \": only env://VAL_CONTENT_<n> is read\");\n }\n const name = ref.slice(\"env://\".length);\n if (!/^VAL_CONTENT_[0-9]+$/.test(name)) {\n throw new Error(at + \" names \" + name + \": only VAL_CONTENT_<n> is read\");\n }\n const value = secret(name);\n if (value === undefined) {\n throw new Error(at + \" names \" + name + \", which is not set\");\n }\n return value;\n };\n for (const [path, ref] of Object.entries(record(refs.modules, \"refs.modules\"))) {\n if (Object.prototype.hasOwnProperty.call(modules, path)) {\n throw new Error(where + \": \" + path + \" is in modules and refs.modules\");\n }\n modules[path] = JSON.parse(read(\"modules\", path, ref));\n }\n for (const [path, ref] of Object.entries(record(refs.files, \"refs.files\"))) {\n if (Object.prototype.hasOwnProperty.call(filesIn, path)) {\n throw new Error(where + \": \" + path + \" is in files and refs.files\");\n }\n files[path] = read(\"files\", path, ref);\n }\n if (job === null && commit === null) {\n throw new Error(where + \" must name a job or a commit, or it would be placed at the build it runs in\");\n }\n return { id, job, commit, modules, files };\n})();\n";
|
|
1373
|
+
/**
|
|
1374
|
+
* What each Val module depends on, as the build resolved its imports
|
|
1375
|
+
* (`valModulesEntry` in this package): the build defines it as a global
|
|
1376
|
+
* (`MODULE_DEPENDENCIES_GLOBAL`), and this hands it to Val's server as
|
|
1377
|
+
* `moduleDependencies`. After {@link CONTENT_BLOCK}, where a rebake puts it
|
|
1378
|
+
* in a file wired before it.
|
|
1379
|
+
*/
|
|
1380
|
+
var DEPENDENCIES_BLOCK = "/*\n * WHAT EACH VAL MODULE DEPENDS ON, as this build resolved its imports.\n *\n * At a proposal's address it is how Val knows that a module whose own file\n * is not staged is still of code this build was not made of, through a file\n * it imports. Defined by the build; `undefined` from a builder that\n * predates it, and then only staged module files count.\n */\nconst MODULE_DEPENDENCIES = globalThis.__VAL_MODULE_DEPENDENCIES__;\n\n";
|
|
1381
|
+
/** And the option that hands it to Val, after the content version's. */
|
|
1382
|
+
var DEPENDENCIES_OPTION = " ...(MODULE_DEPENDENCIES !== undefined\n ? { moduleDependencies: MODULE_DEPENDENCIES }\n : {}),\n";
|
|
1373
1383
|
/** Where {@link PROPOSAL_BLOCK} goes: right after this line. */
|
|
1374
1384
|
var SERVED_BUILD_LINE = 'const servedBuild = secret("VAL_BUILD");\n';
|
|
1375
1385
|
/** And the option that hands it to Val, after the build's. */
|
|
@@ -1379,7 +1389,7 @@ var CONTENT_OPTION = " ...(contentVersion !== undefined ? { contentVersio
|
|
|
1379
1389
|
var PUBLISH_BUILD_OPTION = " ...(servedBuild !== undefined ? { publishBuild: servedBuild } : {}),\n";
|
|
1380
1390
|
var valServerSource = function valServerSource(_ref) {
|
|
1381
1391
|
var git = _ref.git;
|
|
1382
|
-
return "".concat(WIRED_MARKER, "\nimport {\n initValContent,\n initValServer,\n} from \"@valbuild/tanstack/server\";\nimport { config } from \"../../val.config\";\nimport valModules from \"../../val.modules\";\n/*\n * This build's own source, which a publish patches. A project with no\n * repository has no other copy of its `.val.ts` text: content keeps its\n * content as data. Ignored by a @valbuild/tanstack that predates it.\n */\nimport { FILES } from \"platform:project-source\";\n\n/**\n * A secret, as the platform hands it over at RUNTIME.\n *\n * Preferred over `process.env`, which the builder inlines as a literal into\n * this bundle: that puts the value in storage inside the code, copies it into\n * every isolate that loads it, and makes rotating it a republish.\n *\n * Falls back to the build-time value, so an app published before secrets\n * existed keeps working.\n */\nfunction secret(name: string): string | undefined {\n return (globalThis.__PLATFORM_SECRETS ?? {})[name] ?? process.env[name];\n}\n\n/**\n * The commit this build was made from, and the branch it commits to.\n *\n * Baked in rather than handed over at runtime, unlike a secret, because it is\n * not configuration -- it is a property OF THIS BUILD. Every read of a\n * `.val.ts` in http mode fetches that path from the content service at this\n * sha, so a build served with somebody else's commit renders and edits a\n * version of its files it was not compiled from. A secret can be rotated under\n * a running build; this cannot, and publishing again is how it changes.\n *\n * WHAT THIS IS NOT. It is not every read: a committed render reads the source\n * bundled into this build and asks the content service nothing. It is the\n * PUBLISH path -- turning pending patches into new `.val.ts` text means\n * fetching the current text to patch, and that is the read that happens at\n * this sha. The docblock used to say \"every read\", which sent readers looking\n * for a content call on the serving path that is not there.\n *\n * `null` when the source came from no commit -- a record assembled in a tab,\n * a fixture, or ANY build this platform makes, which is the common case rather\n * than the exception. Such a build has no repository to mirror commits into,\n * and does not need one: the content service is the store of record for\n * content and mints its own commit shas. Val is in http mode on credentials\n * alone.\n */\nconst BUILT_FROM = ").concat(git ? JSON.stringify(git) : "null", ";\n\n/**\n * The publish job this build was made for, when a Studio built it in a tab.\n *\n * A tab's build has no commit to bake -- the job's is minted at the seal, after\n * the build -- so this is how it says where it sits in the content service's\n * chain. Without it the service places it at whatever build is live, which is\n * a different build for a request this one is still serving when the pointer\n * moves. Set by the Studio (`rebakeGit`), `null` for any other build.\n */\nconst BUILT_FOR_JOB = null;\n\n/**\n * What puts Val in http mode: its content service owns the content.\n *\n * The same three things any deployed Val app is configured with. Note what is\n * NOT here: no `sourceFiles`, so patches are relayed to the content service\n * instead of being kept by this platform, and the browser uploads an image\n * straight there on a presigned URL instead of streaming it through here.\n *\n * `undefined` when a credential or the commit is missing, and deliberately not\n * a throw at module scope: that would take the isolate down with it, page\n * renders included. Val is left to refuse the request and name what it wanted\n * -- `VAL_ENV=app` is set on this build precisely so that a missing credential\n * is an error instead of a fall-through to `fs` mode, looking for a working\n * tree that is not in here.\n */\nconst apiKey = secret(\"VAL_API_KEY\");\nconst valSecret = secret(\"VAL_SECRET\");\n/*\n * Which content service, for a project that is not pointed at the real one.\n *\n * A secret rather than a baked literal, because unlike the commit this IS\n * configuration: the same build should be servable against a stand-in and\n * against production. It is what makes the editing path testable at all --\n * Val's own `e2e/mock-content-host` implements this wire protocol with no git\n * repository behind it -- and without it a build could only ever talk to\n * content.val.build.\n *\n * It does NOT redirect everything, and the gap is in Val rather than here:\n * `getSettings`, which remote FILES use, reads `process.env.VAL_CONTENT_URL`\n * at module scope inside @valbuild/server. This platform bundles its\n * dependencies separately from the app, so nothing it sets reaches that read --\n * the same reason `apiKey` has to be passed in rather than found. So patches,\n * commits and source reads go where this says, and remote file uploads still\n * address the real host.\n */\nconst valContentUrl = secret(\"VAL_CONTENT_URL\");\n/*\n * WHICH project's content this is, at the content service.\n *\n * Val's own name for the project (`org/name`), which is not the platform's\n * project id and cannot be derived from it. A repository that is deployed\n * anywhere else puts it in `val.config.ts`; one imported here need not have,\n * so it is configuration the platform can supply -- and it goes through\n * `secret` rather than `--env` for a second reason: a build-time literal\n * would have to be baked into the shared dependency layer, where\n * @valbuild/server reads `process.env.VAL_PROJECT`, and that layer is reused\n * by every project with the same dependencies.\n *\n * What the app configured wins over nothing at all, so a repository that does\n * name its project keeps working with no secret set.\n */\nconst valProject = secret(\"VAL_PROJECT\");\n/*\n * WHICH BUILD this is, as the platform running it says.\n *\n * Not baked like `BUILT_FROM`, because it cannot be: a build's hash is taken\n * of its output, this file included. The platform hands it over at runtime,\n * and Val sends it to the content service, which places this build's overlay\n * by it -- the one answer that holds for the minute after a publish in which\n * the edge still serves this build while the pointer already names the next.\n * Ignored by a @valbuild/tanstack that predates it.\n */\nconst servedBuild = secret(\"VAL_BUILD\");\n").concat(PROPOSAL_BLOCK).concat(CONTENT_BLOCK, "const valConfig = {\n ...config,\n ...(valProject !== undefined ? { project: valProject } : {}),\n};\n/*\n * CREDENTIALS ALONE. A commit is not part of what puts Val in http mode.\n *\n * It used to be: `GIT !== null` was in this condition, and a build with no\n * commit fell through to `undefined` -- which meant every site this platform\n * seeded was silently unable to edit, because a shared build cannot know a\n * commit. The binding that worked around it (`VAL_GIT_COMMIT` /\n * `VAL_GIT_BRANCH` out of the project's secrets) is gone with it: it named a\n * commit in the TEMPLATE's repository, which was true only for as long as\n * seeding and repository creation shared a template, and it was one more thing\n * in KV that could go stale.\n *\n * The commit is optional NOW, and it is still sent where there is one -- see\n * the note at the spread below. What is gone is the binding that supplied one\n * from KV, so there is one source per environment and no precedence rule\n * between a baked value and a bound one.\n */\nconst http =\n apiKey !== undefined && valSecret !== undefined\n ? {\n apiKey,\n valSecret,\n /*\n * BOTH SPELLINGS OF THE COMMIT, because the APP decides which one is\n * read and this file cannot know which app it is being written into.\n *\n * `ValHttpMode` has been renamed in both directions. Up to 0.132 it\n * took `gitCommit`/`gitBranch`; 0.133.0 replaced that pair with a\n * nested `git`; the version this package ships beside flattens it\n * back again. The generated file is compiled against whatever\n * `@valbuild/tanstack` the PROJECT installed -- the starter pins\n * 0.133.0 -- and a platform writing this file has no say in that. So\n * this is not one rename behind or ahead: it is on both sides of one at\n * once, and will be until every app it publishes has moved.\n *\n * Sending only the wrong one is SILENT, which is why this is belt and\n * braces rather than a version check. An unknown key on the options\n * object is ignored, so the commit is simply dropped and a build wired\n * FROM A COMMIT runs as though it had none -- which means a publish\n * produces no mirrored `.val.ts`, so a save commits and hands over\n * nothing, and the site keeps serving its old content with the patches\n * already consumed. Nothing reports it. valbuild/home's loop is the one\n * thing that sees it, and it was bisected there: 25/25 with the key the\n * installed version reads, 21/23 without, failing at exactly \"the save\n * left the file it rewrote pending\".\n *\n * Whichever version is installed reads its own key and ignores the\n * other two. Drop this to one spelling when every app this platform\n * publishes is past the rename -- not before, and not on the say-so of\n * a compiler in the Val repository, which is looking at a different\n * version of `@valbuild/tanstack` than the app is.\n */\n ...(BUILT_FROM !== null\n ? {\n git: BUILT_FROM,\n gitCommit: BUILT_FROM.commit,\n gitBranch: BUILT_FROM.branch,\n }\n : {}),\n ...(valContentUrl !== undefined ? { valContentUrl } : {}),\n projectSource: FILES,\n ...(BUILT_FOR_JOB !== null ? { publishJob: BUILT_FOR_JOB } : {}),\n ...(servedBuild !== undefined ? { publishBuild: servedBuild } : {}),\n").concat(PROPOSAL_OPTION).concat(CONTENT_OPTION, " }\n : undefined;\n\nconst { valApiHandler, draftMode } = initValServer(\n valModules,\n valConfig,\n {\n ...(http ? { http } : {}),\n },\n);\n\nconst content = initValContent(valConfig, valModules, {\n draftMode,\n /*\n * The SAME object the API got.\n *\n * These readers resolve content through a Val server of their own rather than\n * by calling the API over HTTP, so the mode question is put to them\n * separately -- configuring only `initValServer` left them inferring `fs`\n * mode, looking for a working tree that is not in here. `gitCommit` is the\n * field that would be silently wrong rather than loudly missing: two\n * different shas means the API edits one version of a file while the page\n * renders another.\n */\n ...(http ? { http } : {}),\n});\n\nconst {\n fetchValStega: fetchVal,\n fetchValKeyStega: fetchValKey,\n fetchValRouteStega: fetchValRoute,\n fetchValRouteUrl,\n} = content;\n\n/**\n * The draft a page renders with in preview: `<ValProvider draft>`, read in the\n * site layout's loader. The starter imports it from this file, so a file\n * without it fails the build with a missing export.\n *\n * Asked of the result rather than destructured, because this file is compiled\n * against whatever `@valbuild/tanstack` the PROJECT installed, and one from\n * before 0.140 has no such reader. There it is \"no draft\", which is the\n * render that version had anyway -- and it is still a function either way, so\n * a page that calls it compiles against both.\n */\nconst fetchValDraft = async () =>\n \"fetchValDraft\" in content && typeof content.fetchValDraft === \"function\"\n ? content.fetchValDraft()\n : null;\n\n/**\n * Content analytics for `<ValProvider analytics>`, read in the site layout's\n * loader beside `fetchValDraft`: whether it is on, and the content version.\n *\n * A setting of the project, which its owner turns on in the project's settings\n * and the platform hands over as the `VAL_ANALYTICS` secret -- at RUNTIME,\n * like every secret, so switching it is not a rebuild. The value reaches the\n * browser in the layout's loader data, which a prerendered page has baked in;\n * the platform keeps a prerendered page only for the secrets it was rendered\n * with, so after a switch pages render live until they are prerendered again.\n * Off unless that secret says `true`. A `@valbuild/tanstack` from before analytics ignores the\n * prop, so this is safe to call against any version.\n *\n * With it, the id of the content version this render serves\n * (`VAL_CONTENT_VERSION`, which the loader hands every isolate it starts for\n * the site, whether the version is the bundle's own or handed over), so every\n * count is stored with the version it was seen in.\n *\n * What the platform handed over ONLY, not `secret()`: that falls back to\n * `process.env`, which the builder bakes into this bundle, so a\n * `VAL_ANALYTICS` set at build time would be a second switch in the code --\n * and one that keeps counting after the owner has turned it off.\n */\nconst fetchValAnalytics = async (): Promise<{\n enabled: boolean;\n contentVersion?: string;\n}> => {\n const handed = globalThis.__PLATFORM_SECRETS ?? {};\n const contentVersion = handed[\"VAL_CONTENT_VERSION\"];\n return {\n enabled: handed[\"VAL_ANALYTICS\"] === \"true\",\n ...(contentVersion ? { contentVersion } : {}),\n };\n};\n\n/**\n * A build that is MEANT to edit and cannot, refusing instead of pretending to.\n *\n * `BUILT_FROM` being non-null says this build came from a commit, so it was\n * made to edit against a content service. If the credentials for that service are not\n * here, the configuration is broken -- and the failure that was reaching people\n * was not an error at all. Val picks its storage mode by inference, so an\n * isolate with no api key lands in a mode that ACCEPTS the write and keeps it\n * in the isolate. Cloudflare starts an isolate per concurrent request, so the\n * save answers 200 and the next request, served by a different isolate, has\n * never heard of it. The edit is simply gone, and nothing anywhere said so.\n *\n * That is the worst available outcome: a person is told their work is saved\n * when it is not. Refusing is strictly better, and naming the missing secret\n * turns an evening of reading logs into one line in a response body.\n *\n * WHY HERE rather than relying on `VAL_ENV=app`: that is a build-time\n * substitution into the shared dependency layer, so whether a build fails\n * loudly depends on which layer it happens to be pinned to. This file is\n * written on every build, by the platform, and cannot be missing from one.\n *\n * Only the editing API. Page renders do not come through here, and a site whose\n * content cannot be edited should still serve the content it has.\n */\nconst editingApiHandler =\n http === undefined\n ? async () => {\n const missing = [\n apiKey === undefined ? \"VAL_API_KEY\" : null,\n valSecret === undefined ? \"VAL_SECRET\" : null,\n /*\n * A build from no commit is listed the same way, because from the\n * outside the two are one state. It is not a secret somebody can set\n * -- a commit is a property OF THE BUILD, and the only cure is\n * publishing this project's own repository over whatever is serving\n * it. Named anyway, because \"it was built from no commit\" is the\n * sentence that ends the search.\n */\n BUILT_FROM === null ? \"a commit (this build was made from none)\" : null,\n ].filter(Boolean);\n return Response.json(\n {\n error:\n \"This site cannot be edited. Its content lives in a content service, and \" +\n missing.join(\", \") +\n \" \" +\n (missing.length > 1 ? \"are\" : \"is\") +\n \" missing, so there is nothing to edit against. Editing is refused rather \" +\n \"than kept in this isolate's memory, where it would be lost without being \" +\n \"reported.\" +\n (BUILT_FROM === null\n ? \" A build made from no commit is usually one SEEDED from a template: \" +\n \"publish this project's own repository to replace it.\"\n : \" This build was made from commit \" + BUILT_FROM.commit.slice(0, 8) + \".\"),\n missing,\n },\n { status: 503 },\n );\n }\n : valApiHandler;\n\nexport {\n editingApiHandler as valApiHandler,\n draftMode,\n fetchVal,\n fetchValKey,\n fetchValRoute,\n fetchValRouteUrl,\n fetchValDraft,\n fetchValAnalytics,\n};\n");
|
|
1392
|
+
return "".concat(WIRED_MARKER, "\nimport {\n initValContent,\n initValServer,\n} from \"@valbuild/tanstack/server\";\nimport { config } from \"../../val.config\";\nimport valModules from \"../../val.modules\";\n/*\n * This build's own source, which a publish patches. A project with no\n * repository has no other copy of its `.val.ts` text: content keeps its\n * content as data. Ignored by a @valbuild/tanstack that predates it.\n */\nimport { FILES } from \"platform:project-source\";\n\n/**\n * A secret, as the platform hands it over at RUNTIME.\n *\n * Preferred over `process.env`, which the builder inlines as a literal into\n * this bundle: that puts the value in storage inside the code, copies it into\n * every isolate that loads it, and makes rotating it a republish.\n *\n * Falls back to the build-time value, so an app published before secrets\n * existed keeps working.\n */\nfunction secret(name: string): string | undefined {\n return (globalThis.__PLATFORM_SECRETS ?? {})[name] ?? process.env[name];\n}\n\n/**\n * The commit this build was made from, and the branch it commits to.\n *\n * Baked in rather than handed over at runtime, unlike a secret, because it is\n * not configuration -- it is a property OF THIS BUILD. Every read of a\n * `.val.ts` in http mode fetches that path from the content service at this\n * sha, so a build served with somebody else's commit renders and edits a\n * version of its files it was not compiled from. A secret can be rotated under\n * a running build; this cannot, and publishing again is how it changes.\n *\n * WHAT THIS IS NOT. It is not every read: a committed render reads the source\n * bundled into this build and asks the content service nothing. It is the\n * PUBLISH path -- turning pending patches into new `.val.ts` text means\n * fetching the current text to patch, and that is the read that happens at\n * this sha. The docblock used to say \"every read\", which sent readers looking\n * for a content call on the serving path that is not there.\n *\n * `null` when the source came from no commit -- a record assembled in a tab,\n * a fixture, or ANY build this platform makes, which is the common case rather\n * than the exception. Such a build has no repository to mirror commits into,\n * and does not need one: the content service is the store of record for\n * content and mints its own commit shas. Val is in http mode on credentials\n * alone.\n */\nconst BUILT_FROM = ").concat(git ? JSON.stringify(git) : "null", ";\n\n/**\n * The publish job this build was made for, when a Studio built it in a tab.\n *\n * A tab's build has no commit to bake -- the job's is minted at the seal, after\n * the build -- so this is how it says where it sits in the content service's\n * chain. Without it the service places it at whatever build is live, which is\n * a different build for a request this one is still serving when the pointer\n * moves. Set by the Studio (`rebakeGit`), `null` for any other build.\n */\nconst BUILT_FOR_JOB = null;\n\n/**\n * What puts Val in http mode: its content service owns the content.\n *\n * The same three things any deployed Val app is configured with. Note what is\n * NOT here: no `sourceFiles`, so patches are relayed to the content service\n * instead of being kept by this platform, and the browser uploads an image\n * straight there on a presigned URL instead of streaming it through here.\n *\n * `undefined` when a credential or the commit is missing, and deliberately not\n * a throw at module scope: that would take the isolate down with it, page\n * renders included. Val is left to refuse the request and name what it wanted\n * -- `VAL_ENV=app` is set on this build precisely so that a missing credential\n * is an error instead of a fall-through to `fs` mode, looking for a working\n * tree that is not in here.\n */\nconst apiKey = secret(\"VAL_API_KEY\");\nconst valSecret = secret(\"VAL_SECRET\");\n/*\n * Which content service, for a project that is not pointed at the real one.\n *\n * A secret rather than a baked literal, because unlike the commit this IS\n * configuration: the same build should be servable against a stand-in and\n * against production. It is what makes the editing path testable at all --\n * Val's own `e2e/mock-content-host` implements this wire protocol with no git\n * repository behind it -- and without it a build could only ever talk to\n * content.val.build.\n *\n * It does NOT redirect everything, and the gap is in Val rather than here:\n * `getSettings`, which remote FILES use, reads `process.env.VAL_CONTENT_URL`\n * at module scope inside @valbuild/server. This platform bundles its\n * dependencies separately from the app, so nothing it sets reaches that read --\n * the same reason `apiKey` has to be passed in rather than found. So patches,\n * commits and source reads go where this says, and remote file uploads still\n * address the real host.\n */\nconst valContentUrl = secret(\"VAL_CONTENT_URL\");\n/*\n * WHICH project's content this is, at the content service.\n *\n * Val's own name for the project (`org/name`), which is not the platform's\n * project id and cannot be derived from it. A repository that is deployed\n * anywhere else puts it in `val.config.ts`; one imported here need not have,\n * so it is configuration the platform can supply -- and it goes through\n * `secret` rather than `--env` for a second reason: a build-time literal\n * would have to be baked into the shared dependency layer, where\n * @valbuild/server reads `process.env.VAL_PROJECT`, and that layer is reused\n * by every project with the same dependencies.\n *\n * What the app configured wins over nothing at all, so a repository that does\n * name its project keeps working with no secret set.\n */\nconst valProject = secret(\"VAL_PROJECT\");\n/*\n * WHICH BUILD this is, as the platform running it says.\n *\n * Not baked like `BUILT_FROM`, because it cannot be: a build's hash is taken\n * of its output, this file included. The platform hands it over at runtime,\n * and Val sends it to the content service, which places this build's overlay\n * by it -- the one answer that holds for the minute after a publish in which\n * the edge still serves this build while the pointer already names the next.\n * Ignored by a @valbuild/tanstack that predates it.\n */\nconst servedBuild = secret(\"VAL_BUILD\");\n").concat(PROPOSAL_BLOCK).concat(CONTENT_BLOCK).concat(DEPENDENCIES_BLOCK, "const valConfig = {\n ...config,\n ...(valProject !== undefined ? { project: valProject } : {}),\n};\n/*\n * CREDENTIALS ALONE. A commit is not part of what puts Val in http mode.\n *\n * It used to be: `GIT !== null` was in this condition, and a build with no\n * commit fell through to `undefined` -- which meant every site this platform\n * seeded was silently unable to edit, because a shared build cannot know a\n * commit. The binding that worked around it (`VAL_GIT_COMMIT` /\n * `VAL_GIT_BRANCH` out of the project's secrets) is gone with it: it named a\n * commit in the TEMPLATE's repository, which was true only for as long as\n * seeding and repository creation shared a template, and it was one more thing\n * in KV that could go stale.\n *\n * The commit is optional NOW, and it is still sent where there is one -- see\n * the note at the spread below. What is gone is the binding that supplied one\n * from KV, so there is one source per environment and no precedence rule\n * between a baked value and a bound one.\n */\nconst http =\n apiKey !== undefined && valSecret !== undefined\n ? {\n apiKey,\n valSecret,\n /*\n * BOTH SPELLINGS OF THE COMMIT, because the APP decides which one is\n * read and this file cannot know which app it is being written into.\n *\n * `ValHttpMode` has been renamed in both directions. Up to 0.132 it\n * took `gitCommit`/`gitBranch`; 0.133.0 replaced that pair with a\n * nested `git`; the version this package ships beside flattens it\n * back again. The generated file is compiled against whatever\n * `@valbuild/tanstack` the PROJECT installed -- the starter pins\n * 0.133.0 -- and a platform writing this file has no say in that. So\n * this is not one rename behind or ahead: it is on both sides of one at\n * once, and will be until every app it publishes has moved.\n *\n * Sending only the wrong one is SILENT, which is why this is belt and\n * braces rather than a version check. An unknown key on the options\n * object is ignored, so the commit is simply dropped and a build wired\n * FROM A COMMIT runs as though it had none -- which means a publish\n * produces no mirrored `.val.ts`, so a save commits and hands over\n * nothing, and the site keeps serving its old content with the patches\n * already consumed. Nothing reports it. valbuild/home's loop is the one\n * thing that sees it, and it was bisected there: 25/25 with the key the\n * installed version reads, 21/23 without, failing at exactly \"the save\n * left the file it rewrote pending\".\n *\n * Whichever version is installed reads its own key and ignores the\n * other two. Drop this to one spelling when every app this platform\n * publishes is past the rename -- not before, and not on the say-so of\n * a compiler in the Val repository, which is looking at a different\n * version of `@valbuild/tanstack` than the app is.\n */\n ...(BUILT_FROM !== null\n ? {\n git: BUILT_FROM,\n gitCommit: BUILT_FROM.commit,\n gitBranch: BUILT_FROM.branch,\n }\n : {}),\n ...(valContentUrl !== undefined ? { valContentUrl } : {}),\n projectSource: FILES,\n ...(BUILT_FOR_JOB !== null ? { publishJob: BUILT_FOR_JOB } : {}),\n ...(servedBuild !== undefined ? { publishBuild: servedBuild } : {}),\n").concat(PROPOSAL_OPTION).concat(CONTENT_OPTION).concat(DEPENDENCIES_OPTION, " }\n : undefined;\n\nconst { valApiHandler, draftMode } = initValServer(\n valModules,\n valConfig,\n {\n ...(http ? { http } : {}),\n },\n);\n\nconst content = initValContent(valConfig, valModules, {\n draftMode,\n /*\n * The SAME object the API got.\n *\n * These readers resolve content through a Val server of their own rather than\n * by calling the API over HTTP, so the mode question is put to them\n * separately -- configuring only `initValServer` left them inferring `fs`\n * mode, looking for a working tree that is not in here. `gitCommit` is the\n * field that would be silently wrong rather than loudly missing: two\n * different shas means the API edits one version of a file while the page\n * renders another.\n */\n ...(http ? { http } : {}),\n});\n\nconst {\n fetchValStega: fetchVal,\n fetchValKeyStega: fetchValKey,\n fetchValRouteStega: fetchValRoute,\n fetchValRouteUrl,\n} = content;\n\n/**\n * The draft a page renders with in preview: `<ValProvider draft>`, read in the\n * site layout's loader. The starter imports it from this file, so a file\n * without it fails the build with a missing export.\n *\n * Asked of the result rather than destructured, because this file is compiled\n * against whatever `@valbuild/tanstack` the PROJECT installed, and one from\n * before 0.140 has no such reader. There it is \"no draft\", which is the\n * render that version had anyway -- and it is still a function either way, so\n * a page that calls it compiles against both.\n */\nconst fetchValDraft = async () =>\n \"fetchValDraft\" in content && typeof content.fetchValDraft === \"function\"\n ? content.fetchValDraft()\n : null;\n\n/**\n * Content analytics for `<ValProvider analytics>`, read in the site layout's\n * loader beside `fetchValDraft`: whether it is on, and the content version.\n *\n * A setting of the project, which its owner turns on in the project's settings\n * and the platform hands over as the `VAL_ANALYTICS` secret -- at RUNTIME,\n * like every secret, so switching it is not a rebuild. The value reaches the\n * browser in the layout's loader data, which a prerendered page has baked in;\n * the platform keeps a prerendered page only for the secrets it was rendered\n * with, so after a switch pages render live until they are prerendered again.\n * Off unless that secret says `true`. A `@valbuild/tanstack` from before analytics ignores the\n * prop, so this is safe to call against any version.\n *\n * With it, the id of the content version this render serves\n * (`VAL_CONTENT_VERSION`, which the loader hands every isolate it starts for\n * the site, whether the version is the bundle's own or handed over), so every\n * count is stored with the version it was seen in.\n *\n * What the platform handed over ONLY, not `secret()`: that falls back to\n * `process.env`, which the builder bakes into this bundle, so a\n * `VAL_ANALYTICS` set at build time would be a second switch in the code --\n * and one that keeps counting after the owner has turned it off.\n */\nconst fetchValAnalytics = async (): Promise<{\n enabled: boolean;\n contentVersion?: string;\n}> => {\n const handed = globalThis.__PLATFORM_SECRETS ?? {};\n const contentVersion = handed[\"VAL_CONTENT_VERSION\"];\n return {\n enabled: handed[\"VAL_ANALYTICS\"] === \"true\",\n ...(contentVersion ? { contentVersion } : {}),\n };\n};\n\n/**\n * A build that is MEANT to edit and cannot, refusing instead of pretending to.\n *\n * `BUILT_FROM` being non-null says this build came from a commit, so it was\n * made to edit against a content service. If the credentials for that service are not\n * here, the configuration is broken -- and the failure that was reaching people\n * was not an error at all. Val picks its storage mode by inference, so an\n * isolate with no api key lands in a mode that ACCEPTS the write and keeps it\n * in the isolate. Cloudflare starts an isolate per concurrent request, so the\n * save answers 200 and the next request, served by a different isolate, has\n * never heard of it. The edit is simply gone, and nothing anywhere said so.\n *\n * That is the worst available outcome: a person is told their work is saved\n * when it is not. Refusing is strictly better, and naming the missing secret\n * turns an evening of reading logs into one line in a response body.\n *\n * WHY HERE rather than relying on `VAL_ENV=app`: that is a build-time\n * substitution into the shared dependency layer, so whether a build fails\n * loudly depends on which layer it happens to be pinned to. This file is\n * written on every build, by the platform, and cannot be missing from one.\n *\n * Only the editing API. Page renders do not come through here, and a site whose\n * content cannot be edited should still serve the content it has.\n */\nconst editingApiHandler =\n http === undefined\n ? async () => {\n const missing = [\n apiKey === undefined ? \"VAL_API_KEY\" : null,\n valSecret === undefined ? \"VAL_SECRET\" : null,\n /*\n * A build from no commit is listed the same way, because from the\n * outside the two are one state. It is not a secret somebody can set\n * -- a commit is a property OF THE BUILD, and the only cure is\n * publishing this project's own repository over whatever is serving\n * it. Named anyway, because \"it was built from no commit\" is the\n * sentence that ends the search.\n */\n BUILT_FROM === null ? \"a commit (this build was made from none)\" : null,\n ].filter(Boolean);\n return Response.json(\n {\n error:\n \"This site cannot be edited. Its content lives in a content service, and \" +\n missing.join(\", \") +\n \" \" +\n (missing.length > 1 ? \"are\" : \"is\") +\n \" missing, so there is nothing to edit against. Editing is refused rather \" +\n \"than kept in this isolate's memory, where it would be lost without being \" +\n \"reported.\" +\n (BUILT_FROM === null\n ? \" A build made from no commit is usually one SEEDED from a template: \" +\n \"publish this project's own repository to replace it.\"\n : \" This build was made from commit \" + BUILT_FROM.commit.slice(0, 8) + \".\"),\n missing,\n },\n { status: 503 },\n );\n }\n : valApiHandler;\n\nexport {\n editingApiHandler as valApiHandler,\n draftMode,\n fetchVal,\n fetchValKey,\n fetchValRoute,\n fetchValRouteUrl,\n fetchValDraft,\n fetchValAnalytics,\n};\n");
|
|
1383
1393
|
};
|
|
1384
1394
|
|
|
1385
1395
|
/**
|
|
@@ -1397,7 +1407,7 @@ var valServerSource = function valServerSource(_ref) {
|
|
|
1397
1407
|
* declaration, and a top-level `declare var` is a global without needing
|
|
1398
1408
|
* `declare global`, which a script may not contain.
|
|
1399
1409
|
*/
|
|
1400
|
-
var PROJECT_SOURCE_DECLARATIONS = "// Generated by the Val studio when this project was wired up to the platform.\n// The build resolves this specifier to the project's own source, shipped into\n// the isolate as a module.\n//\n// Deliberately not a module: an `export` anywhere in this file would turn the\n// declaration below into an augmentation, and the import would stop resolving.\ndeclare module 'platform:project-source' {\n /** Every source file of this project, keyed by its path from the root. */\n export const FILES: Record<string, string>\n}\n\n/**\n * The project this isolate is serving, set per request by the platform from\n * the id the loader resolved off the hostname.\n *\n * Absent when server-rendering outside the platform, and in the browser.\n */\n// eslint-disable-next-line no-var\ndeclare var __PLATFORM_PROJECT_ID: string | undefined\n/**\n * This project's secrets, handed over per request rather than built in.\n *\n * SERVER ONLY -- set by the platform's Worker entry, which never runs in a\n * browser. Absent outside the platform.\n */\n// eslint-disable-next-line no-var\ndeclare var __PLATFORM_SECRETS: Record<string, string> | undefined\n";
|
|
1410
|
+
var PROJECT_SOURCE_DECLARATIONS = "// Generated by the Val studio when this project was wired up to the platform.\n// The build resolves this specifier to the project's own source, shipped into\n// the isolate as a module.\n//\n// Deliberately not a module: an `export` anywhere in this file would turn the\n// declaration below into an augmentation, and the import would stop resolving.\ndeclare module 'platform:project-source' {\n /** Every source file of this project, keyed by its path from the root. */\n export const FILES: Record<string, string>\n}\n\n/**\n * The project this isolate is serving, set per request by the platform from\n * the id the loader resolved off the hostname.\n *\n * Absent when server-rendering outside the platform, and in the browser.\n */\n// eslint-disable-next-line no-var\ndeclare var __PLATFORM_PROJECT_ID: string | undefined\n/**\n * This project's secrets, handed over per request rather than built in.\n *\n * SERVER ONLY -- set by the platform's Worker entry, which never runs in a\n * browser. Absent outside the platform.\n */\n// eslint-disable-next-line no-var\ndeclare var __PLATFORM_SECRETS: Record<string, string> | undefined\n/**\n * What each Val module of this build depends on, by path, as the build\n * resolved its imports. Defined by the platform's build; absent from a\n * builder that predates it.\n */\n// eslint-disable-next-line no-var\ndeclare var __VAL_MODULE_DEPENDENCIES__: Record<string, string[]> | undefined\n";
|
|
1401
1411
|
|
|
1402
1412
|
/**
|
|
1403
1413
|
* The wired `val.server.ts`, on its own.
|
|
@@ -1517,6 +1527,38 @@ function rebakeContent(source) {
|
|
|
1517
1527
|
});
|
|
1518
1528
|
}
|
|
1519
1529
|
|
|
1530
|
+
/**
|
|
1531
|
+
* `source` handing Val each module's dependencies: {@link DEPENDENCIES_BLOCK}
|
|
1532
|
+
* and its option added after the content version's, to a file wired before
|
|
1533
|
+
* they existed. Idempotent, and only where both places are exactly as
|
|
1534
|
+
* generated -- a file somebody edited is left as it is, and Val counts only
|
|
1535
|
+
* staged module files at a proposal's address, as before.
|
|
1536
|
+
*/
|
|
1537
|
+
function rebakeDependencies(source) {
|
|
1538
|
+
var once = function once(needle) {
|
|
1539
|
+
var at = source.indexOf(needle);
|
|
1540
|
+
return at !== -1 && source.indexOf(needle, at + 1) === -1;
|
|
1541
|
+
};
|
|
1542
|
+
if (!once(CONTENT_BLOCK) || !once(CONTENT_OPTION)) return source;
|
|
1543
|
+
var hasBlock = source.includes(DEPENDENCIES_BLOCK);
|
|
1544
|
+
var hasOption = source.includes(DEPENDENCIES_OPTION);
|
|
1545
|
+
if (hasBlock && hasOption) return source;
|
|
1546
|
+
// Each piece once, whatever left the other there: an option without its
|
|
1547
|
+
// block names a constant that does not exist.
|
|
1548
|
+
var next = source;
|
|
1549
|
+
if (!hasBlock) {
|
|
1550
|
+
next = next.replace(CONTENT_BLOCK, function () {
|
|
1551
|
+
return CONTENT_BLOCK + DEPENDENCIES_BLOCK;
|
|
1552
|
+
});
|
|
1553
|
+
}
|
|
1554
|
+
if (!hasOption) {
|
|
1555
|
+
next = next.replace(CONTENT_OPTION, function () {
|
|
1556
|
+
return CONTENT_OPTION + DEPENDENCIES_OPTION;
|
|
1557
|
+
});
|
|
1558
|
+
}
|
|
1559
|
+
return next;
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1520
1562
|
/** `source` with its job set, or `source` itself when it cannot carry one. */
|
|
1521
1563
|
function rebakeJob(source, job) {
|
|
1522
1564
|
var line = "const BUILT_FOR_JOB = ".concat(job === null ? "null" : JSON.stringify(job), ";");
|
|
@@ -1600,7 +1642,7 @@ job) {
|
|
|
1600
1642
|
if (!BUILT_FROM_LINE.test(source)) return files;
|
|
1601
1643
|
var withGit = source.replace(BUILT_FROM_LINE, "const BUILT_FROM = ".concat(git === null ? "null" : JSON.stringify(git), ";"));
|
|
1602
1644
|
var withJob = job === undefined ? withGit : rebakeJob(withGit, job);
|
|
1603
|
-
return _objectSpread2(_objectSpread2({}, files), {}, _defineProperty({}, VAL_SERVER, rebakeContent(rebakeProposal(withJob))));
|
|
1645
|
+
return _objectSpread2(_objectSpread2({}, files), {}, _defineProperty({}, VAL_SERVER, rebakeDependencies(rebakeContent(rebakeProposal(withJob)))));
|
|
1604
1646
|
}
|
|
1605
1647
|
|
|
1606
1648
|
/** Is this a Val project at all? */
|
|
@@ -2094,30 +2136,67 @@ function bundleValModules(_x) {
|
|
|
2094
2136
|
}
|
|
2095
2137
|
|
|
2096
2138
|
/**
|
|
2097
|
-
*
|
|
2098
|
-
*
|
|
2099
|
-
*
|
|
2100
|
-
*
|
|
2101
|
-
*
|
|
2102
|
-
*
|
|
2103
|
-
*
|
|
2104
|
-
*
|
|
2105
|
-
*
|
|
2106
|
-
* of `docs/plans/one-content-model.md` in valbuild/val.
|
|
2107
|
-
*
|
|
2108
|
-
* Empty -- and the build goes on -- for a project with no `val.modules.ts`,
|
|
2109
|
-
* or one whose Val modules cannot be bundled for the browser (a `.val.ts`
|
|
2110
|
-
* importing something server-only): such a build has no entry, and a Studio
|
|
2111
|
-
* that cannot import one reloads the page instead, as it did before. Said
|
|
2112
|
-
* in the build's warnings.
|
|
2139
|
+
* For each module file (`*.val.ts` / `*.val.js`) the graph reaches, every
|
|
2140
|
+
* project file it depends on, transitively, sorted: what tells Val's server
|
|
2141
|
+
* at a proposal's address that a module whose own file is not staged is of
|
|
2142
|
+
* code the build was not made of, through a file it imports
|
|
2143
|
+
* (`moduleDependencies`, `stagedAfterBuild` in `@valbuild/server`). From the
|
|
2144
|
+
* imports as this bundle resolved them -- relative, tsconfig aliases,
|
|
2145
|
+
* whatever resolved -- so it cannot disagree with what the build evaluated.
|
|
2146
|
+
* An entry's `.val.json` is left out: it is content, and a record of 10,000
|
|
2147
|
+
* entries would make the map that long.
|
|
2113
2148
|
*/
|
|
2114
2149
|
function _bundleValModules() {
|
|
2115
2150
|
_bundleValModules = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(input) {
|
|
2116
2151
|
var _input$entry;
|
|
2117
|
-
var files, target, origin, entry, warnings, aliases, base, project, resolveProjectPath, _yield$loadRolldown, build, result, chunks, _t;
|
|
2152
|
+
var files, target, origin, entry, warnings, aliases, base, project, entryPath, resolveProjectPath, imports, _yield$loadRolldown, build, result, resolveOne, chunks, _t;
|
|
2118
2153
|
return _regenerator().w(function (_context) {
|
|
2119
2154
|
while (1) switch (_context.p = _context.n) {
|
|
2120
2155
|
case 0:
|
|
2156
|
+
resolveOne = function _resolveOne(source, importer) {
|
|
2157
|
+
if (source.startsWith(".")) {
|
|
2158
|
+
return resolveProjectPath(resolve(dirname(importer !== null && importer !== void 0 ? importer : entryPath), source));
|
|
2159
|
+
}
|
|
2160
|
+
if (source in files) return source;
|
|
2161
|
+
var baseChunk = target.base.modules[source];
|
|
2162
|
+
if (baseChunk) {
|
|
2163
|
+
return {
|
|
2164
|
+
id: "".concat(base).concat(baseChunk, ".js"),
|
|
2165
|
+
external: true
|
|
2166
|
+
};
|
|
2167
|
+
}
|
|
2168
|
+
var projectChunk = target.project.modules[source];
|
|
2169
|
+
if (projectChunk && project !== null) {
|
|
2170
|
+
if (target.project.workerOnly.includes(source)) {
|
|
2171
|
+
throw new Error("'".concat(source, "' is server-only in this project's vendor layer, so a .val.ts importing it cannot be read in the browser."));
|
|
2172
|
+
}
|
|
2173
|
+
return {
|
|
2174
|
+
id: "".concat(project).concat(projectChunk, ".js"),
|
|
2175
|
+
external: true
|
|
2176
|
+
};
|
|
2177
|
+
}
|
|
2178
|
+
if (aliases) {
|
|
2179
|
+
var _iterator4 = _createForOfIteratorHelper(aliases.candidates(source)),
|
|
2180
|
+
_step4;
|
|
2181
|
+
try {
|
|
2182
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
2183
|
+
var candidate = _step4.value;
|
|
2184
|
+
var _hit = resolveProjectPath(candidate);
|
|
2185
|
+
if (_hit) return _hit;
|
|
2186
|
+
}
|
|
2187
|
+
} catch (err) {
|
|
2188
|
+
_iterator4.e(err);
|
|
2189
|
+
} finally {
|
|
2190
|
+
_iterator4.f();
|
|
2191
|
+
}
|
|
2192
|
+
var fromBaseUrl = aliases.baseUrlCandidate(source);
|
|
2193
|
+
var hit = fromBaseUrl && resolveProjectPath(fromBaseUrl);
|
|
2194
|
+
if (hit) return hit;
|
|
2195
|
+
}
|
|
2196
|
+
// An error, not a warning: rolldown would otherwise leave the
|
|
2197
|
+
// specifier as it is, and it would fail when imported, unnamed.
|
|
2198
|
+
throw new Error("'".concat(source, "' is not an available dependency. Available: ").concat([].concat(_toConsumableArray(Object.keys(target.base.modules)), _toConsumableArray(Object.keys(target.project.modules))).join(", "), "."));
|
|
2199
|
+
};
|
|
2121
2200
|
files = input.files, target = input.target, origin = input.origin;
|
|
2122
2201
|
entry = (_input$entry = input.entry) !== null && _input$entry !== void 0 ? _input$entry : ["val.modules.ts", "val.modules.js"].find(function (path) {
|
|
2123
2202
|
return path in files;
|
|
@@ -2134,9 +2213,12 @@ function _bundleValModules() {
|
|
|
2134
2213
|
});
|
|
2135
2214
|
base = "".concat(origin, "/_vendor/");
|
|
2136
2215
|
project = target.project.rev === null ? null : "".concat(origin, "/_pvendor/").concat(target.project.rev, "/");
|
|
2216
|
+
entryPath = entry;
|
|
2137
2217
|
resolveProjectPath = function resolveProjectPath(path) {
|
|
2138
2218
|
return resolveInFiles(path, files);
|
|
2139
2219
|
};
|
|
2220
|
+
/** Which project file imports which, as resolved: one edge per import. */
|
|
2221
|
+
imports = new Map();
|
|
2140
2222
|
_context.n = 2;
|
|
2141
2223
|
return loadRolldown();
|
|
2142
2224
|
case 2:
|
|
@@ -2154,48 +2236,18 @@ function _bundleValModules() {
|
|
|
2154
2236
|
plugins: [{
|
|
2155
2237
|
name: "val:modules",
|
|
2156
2238
|
resolveId: function resolveId(source, importer) {
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
if (
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
external: true
|
|
2166
|
-
};
|
|
2167
|
-
}
|
|
2168
|
-
var projectChunk = target.project.modules[source];
|
|
2169
|
-
if (projectChunk && project !== null) {
|
|
2170
|
-
if (target.project.workerOnly.includes(source)) {
|
|
2171
|
-
throw new Error("'".concat(source, "' is server-only in this project's vendor layer, so a .val.ts importing it cannot be read in the browser."));
|
|
2239
|
+
var resolved = resolveOne(source, importer);
|
|
2240
|
+
// A project file importing a project file: an edge of the graph
|
|
2241
|
+
// the dependencies are read from.
|
|
2242
|
+
if (importer !== undefined && importer in files && typeof resolved === "string" && resolved in files) {
|
|
2243
|
+
var from = imports.get(importer);
|
|
2244
|
+
if (from === undefined) {
|
|
2245
|
+
from = new Set();
|
|
2246
|
+
imports.set(importer, from);
|
|
2172
2247
|
}
|
|
2173
|
-
|
|
2174
|
-
id: "".concat(project).concat(projectChunk, ".js"),
|
|
2175
|
-
external: true
|
|
2176
|
-
};
|
|
2248
|
+
from.add(resolved);
|
|
2177
2249
|
}
|
|
2178
|
-
|
|
2179
|
-
var _iterator = _createForOfIteratorHelper(aliases.candidates(source)),
|
|
2180
|
-
_step;
|
|
2181
|
-
try {
|
|
2182
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2183
|
-
var candidate = _step.value;
|
|
2184
|
-
var _hit = resolveProjectPath(candidate);
|
|
2185
|
-
if (_hit) return _hit;
|
|
2186
|
-
}
|
|
2187
|
-
} catch (err) {
|
|
2188
|
-
_iterator.e(err);
|
|
2189
|
-
} finally {
|
|
2190
|
-
_iterator.f();
|
|
2191
|
-
}
|
|
2192
|
-
var fromBaseUrl = aliases.baseUrlCandidate(source);
|
|
2193
|
-
var hit = fromBaseUrl && resolveProjectPath(fromBaseUrl);
|
|
2194
|
-
if (hit) return hit;
|
|
2195
|
-
}
|
|
2196
|
-
// An error, not a warning: rolldown would otherwise leave the
|
|
2197
|
-
// specifier as it is, and it would fail when imported, unnamed.
|
|
2198
|
-
throw new Error("'".concat(source, "' is not an available dependency. Available: ").concat([].concat(_toConsumableArray(Object.keys(target.base.modules)), _toConsumableArray(Object.keys(target.project.modules))).join(", "), "."));
|
|
2250
|
+
return resolved;
|
|
2199
2251
|
},
|
|
2200
2252
|
load: function load(id) {
|
|
2201
2253
|
return id in files ? files[id] : null;
|
|
@@ -2237,19 +2289,98 @@ function _bundleValModules() {
|
|
|
2237
2289
|
throw new Error("Bundling the Val modules made ".concat(chunks.length, " chunks rather than one."));
|
|
2238
2290
|
case 7:
|
|
2239
2291
|
return _context.a(2, {
|
|
2240
|
-
code: chunks[0].code
|
|
2292
|
+
code: chunks[0].code,
|
|
2293
|
+
dependencies: moduleDependenciesOf(imports)
|
|
2241
2294
|
});
|
|
2242
2295
|
}
|
|
2243
2296
|
}, _callee, null, [[3, 5]]);
|
|
2244
2297
|
}));
|
|
2245
2298
|
return _bundleValModules.apply(this, arguments);
|
|
2246
2299
|
}
|
|
2300
|
+
function moduleDependenciesOf(imports) {
|
|
2301
|
+
var dependencies = {};
|
|
2302
|
+
var isModule = function isModule(path) {
|
|
2303
|
+
return /\.val\.(ts|js)$/.test(path);
|
|
2304
|
+
};
|
|
2305
|
+
var isEntry = function isEntry(path) {
|
|
2306
|
+
return path.endsWith(".val.json");
|
|
2307
|
+
};
|
|
2308
|
+
var modules = new Set();
|
|
2309
|
+
var _iterator = _createForOfIteratorHelper(imports),
|
|
2310
|
+
_step;
|
|
2311
|
+
try {
|
|
2312
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2313
|
+
var _step$value = _slicedToArray(_step.value, 2),
|
|
2314
|
+
from = _step$value[0],
|
|
2315
|
+
to = _step$value[1];
|
|
2316
|
+
if (isModule(from)) modules.add(from);
|
|
2317
|
+
var _iterator3 = _createForOfIteratorHelper(to),
|
|
2318
|
+
_step3;
|
|
2319
|
+
try {
|
|
2320
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
2321
|
+
var path = _step3.value;
|
|
2322
|
+
if (isModule(path)) modules.add(path);
|
|
2323
|
+
}
|
|
2324
|
+
} catch (err) {
|
|
2325
|
+
_iterator3.e(err);
|
|
2326
|
+
} finally {
|
|
2327
|
+
_iterator3.f();
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
} catch (err) {
|
|
2331
|
+
_iterator.e(err);
|
|
2332
|
+
} finally {
|
|
2333
|
+
_iterator.f();
|
|
2334
|
+
}
|
|
2335
|
+
var _iterator2 = _createForOfIteratorHelper(_toConsumableArray(modules).sort()),
|
|
2336
|
+
_step2;
|
|
2337
|
+
try {
|
|
2338
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
2339
|
+
var _imports$get;
|
|
2340
|
+
var module = _step2.value;
|
|
2341
|
+
var seen = new Set();
|
|
2342
|
+
var queue = _toConsumableArray((_imports$get = imports.get(module)) !== null && _imports$get !== void 0 ? _imports$get : []);
|
|
2343
|
+
while (queue.length > 0) {
|
|
2344
|
+
var _imports$get2;
|
|
2345
|
+
var next = queue.pop();
|
|
2346
|
+
if (next === module || seen.has(next) || isEntry(next)) continue;
|
|
2347
|
+
seen.add(next);
|
|
2348
|
+
queue.push.apply(queue, _toConsumableArray((_imports$get2 = imports.get(next)) !== null && _imports$get2 !== void 0 ? _imports$get2 : []));
|
|
2349
|
+
}
|
|
2350
|
+
dependencies[module] = _toConsumableArray(seen).sort();
|
|
2351
|
+
}
|
|
2352
|
+
} catch (err) {
|
|
2353
|
+
_iterator2.e(err);
|
|
2354
|
+
} finally {
|
|
2355
|
+
_iterator2.f();
|
|
2356
|
+
}
|
|
2357
|
+
return dependencies;
|
|
2358
|
+
}
|
|
2359
|
+
|
|
2360
|
+
/**
|
|
2361
|
+
* A build's `val.modules` registry, as the build emits it beside its client
|
|
2362
|
+
* chunks: `{ "val-modules-<build>.js": code }`, served at `/_app/` with
|
|
2363
|
+
* them, its npm imports pointing at the site's vendor chunks on its own
|
|
2364
|
+
* origin (`/_vendor/`, `/_pvendor/<rev>/`) as the client bundle's do.
|
|
2365
|
+
*
|
|
2366
|
+
* What a Studio opened on an older build imports, once the server's
|
|
2367
|
+
* manifest names it (`registry`, from the build's name the platform hands
|
|
2368
|
+
* the server: `VAL_BUILD`), to take this build's schemas in WITHOUT
|
|
2369
|
+
* reloading the page: `HostStore.reloadCode` in `@valbuild/ui`, and phase 9
|
|
2370
|
+
* of `docs/plans/one-content-model.md` in valbuild/val.
|
|
2371
|
+
*
|
|
2372
|
+
* Empty -- and the build goes on -- for a project with no `val.modules.ts`,
|
|
2373
|
+
* or one whose Val modules cannot be bundled for the browser (a `.val.ts`
|
|
2374
|
+
* importing something server-only): such a build has no entry, and a Studio
|
|
2375
|
+
* that cannot import one reloads the page instead, as it did before. Said
|
|
2376
|
+
* in the build's warnings.
|
|
2377
|
+
*/
|
|
2247
2378
|
function valModulesEntry(_x2, _x3, _x4) {
|
|
2248
2379
|
return _valModulesEntry.apply(this, arguments);
|
|
2249
2380
|
}
|
|
2250
2381
|
function _valModulesEntry() {
|
|
2251
2382
|
_valModulesEntry = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(input, build, warnings) {
|
|
2252
|
-
var entry, _yield$bundleValModul, code, _t2;
|
|
2383
|
+
var entry, _yield$bundleValModul, code, dependencies, _t2;
|
|
2253
2384
|
return _regenerator().w(function (_context2) {
|
|
2254
2385
|
while (1) switch (_context2.p = _context2.n) {
|
|
2255
2386
|
case 0:
|
|
@@ -2260,7 +2391,10 @@ function _valModulesEntry() {
|
|
|
2260
2391
|
_context2.n = 1;
|
|
2261
2392
|
break;
|
|
2262
2393
|
}
|
|
2263
|
-
return _context2.a(2, {
|
|
2394
|
+
return _context2.a(2, {
|
|
2395
|
+
files: {},
|
|
2396
|
+
dependencies: null
|
|
2397
|
+
});
|
|
2264
2398
|
case 1:
|
|
2265
2399
|
_context2.p = 1;
|
|
2266
2400
|
_context2.n = 2;
|
|
@@ -2275,12 +2409,19 @@ function _valModulesEntry() {
|
|
|
2275
2409
|
case 2:
|
|
2276
2410
|
_yield$bundleValModul = _context2.v;
|
|
2277
2411
|
code = _yield$bundleValModul.code;
|
|
2278
|
-
|
|
2412
|
+
dependencies = _yield$bundleValModul.dependencies;
|
|
2413
|
+
return _context2.a(2, {
|
|
2414
|
+
files: _defineProperty({}, valModulesEntryFile(build), code),
|
|
2415
|
+
dependencies: dependencies
|
|
2416
|
+
});
|
|
2279
2417
|
case 3:
|
|
2280
2418
|
_context2.p = 3;
|
|
2281
2419
|
_t2 = _context2.v;
|
|
2282
2420
|
warnings.push("The Val modules were not emitted for the Studio, so an open Studio reloads the page to take this build's code: ".concat(_t2 instanceof Error ? _t2.message : String(_t2)));
|
|
2283
|
-
return _context2.a(2, {
|
|
2421
|
+
return _context2.a(2, {
|
|
2422
|
+
files: {},
|
|
2423
|
+
dependencies: null
|
|
2424
|
+
});
|
|
2284
2425
|
}
|
|
2285
2426
|
}, _callee2, null, [[1, 3]]);
|
|
2286
2427
|
}));
|
|
@@ -3689,6 +3830,11 @@ var CSS_URL_ID = "\0platform:css-url";
|
|
|
3689
3830
|
* would be both a leak and, for a real app, enormous.
|
|
3690
3831
|
*/
|
|
3691
3832
|
var PROJECT_SOURCE = "platform:project-source";
|
|
3833
|
+
/**
|
|
3834
|
+
* The global the server build defines as each Val module's project
|
|
3835
|
+
* dependencies (`valModulesEntry`), read by the generated `val.server.ts`.
|
|
3836
|
+
*/
|
|
3837
|
+
var MODULE_DEPENDENCIES_GLOBAL = "globalThis.__VAL_MODULE_DEPENDENCIES__";
|
|
3692
3838
|
var PROJECT_SOURCE_ID = "\0platform:project-source";
|
|
3693
3839
|
var PUBLIC_PREFIX = "PUBLIC_";
|
|
3694
3840
|
var VALID_KEY = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
@@ -4022,19 +4168,42 @@ function projectPlugin(files, projectSource, splitter, cssModules, aliases, asse
|
|
|
4022
4168
|
}
|
|
4023
4169
|
|
|
4024
4170
|
/**
|
|
4025
|
-
*
|
|
4171
|
+
* What `import.meta.env` is in a build: Vite's built-ins, inlined, and the
|
|
4172
|
+
* project's `PUBLIC_` variables, read at RUNTIME.
|
|
4173
|
+
*
|
|
4174
|
+
* Runtime because a hosted project's variables are set in Val Build, and a
|
|
4175
|
+
* build is made in an editor's browser tab: inlined, a value would sit in that
|
|
4176
|
+
* tab, and changing one would wait for somebody to build before it went live.
|
|
4177
|
+
* So `import.meta.env` is an identifier, and `inject` makes each module that
|
|
4178
|
+
* reads it import {@link RUNTIME_ENV_SPECIFIER} -- a real import, so it is
|
|
4179
|
+
* evaluated before any split chunk that reads it, top level included. That
|
|
4180
|
+
* module ({@link runtimeEnvSource}) reads the variables once:
|
|
4181
|
+
*
|
|
4182
|
+
* - in the browser, from the `<head>` script the platform's loader writes
|
|
4183
|
+
* (`globalThis.__PLATFORM_PUBLIC_ENV`), which runs before any module does;
|
|
4184
|
+
* - on the server, from `process.env`, which the isolate's env fills before the
|
|
4185
|
+
* app's modules run.
|
|
4026
4186
|
*
|
|
4027
|
-
*
|
|
4028
|
-
*
|
|
4029
|
-
*
|
|
4187
|
+
* Only `PUBLIC_` names, on both sides, as in Vite: a secret is
|
|
4188
|
+
* `process.env.NAME` on the server and nothing at all in the browser. The
|
|
4189
|
+
* platform refuses a secret by a `PUBLIC_` name, so nothing read here was ever
|
|
4190
|
+
* a secret.
|
|
4030
4191
|
*
|
|
4031
|
-
*
|
|
4032
|
-
*
|
|
4033
|
-
*
|
|
4192
|
+
* `env`, when a caller passes it -- the CLI's `--env` -- is the FALLBACK for
|
|
4193
|
+
* a `PUBLIC_` name: a value set at runtime wins, so changing a variable in Val
|
|
4194
|
+
* Build changes what a build that was also given it reads. A name that is not
|
|
4195
|
+
* `PUBLIC_` is still inlined where it is read by name, on the server only; in
|
|
4196
|
+
* the client bundle it is `undefined` rather than left alone.
|
|
4034
4197
|
*/
|
|
4035
|
-
function
|
|
4198
|
+
function envFor(env, target, warnings) {
|
|
4036
4199
|
var define = {};
|
|
4037
|
-
|
|
4200
|
+
/**
|
|
4201
|
+
* What the `import.meta.env` OBJECT falls back to of `env`: the PUBLIC_
|
|
4202
|
+
* names, on both sides, as Vite's holds. A server-only name is a literal
|
|
4203
|
+
* where it is read by name, and nowhere else -- in the object it would be in
|
|
4204
|
+
* the server bundle whether anything read it or not.
|
|
4205
|
+
*/
|
|
4206
|
+
var fallback = {};
|
|
4038
4207
|
for (var _i = 0, _Object$entries = Object.entries(env); _i < _Object$entries.length; _i++) {
|
|
4039
4208
|
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
4040
4209
|
key = _Object$entries$_i[0],
|
|
@@ -4043,11 +4212,17 @@ function defineFor(env, target, warnings) {
|
|
|
4043
4212
|
warnings.push("env var '".concat(key, "' is not a valid identifier and was ignored."));
|
|
4044
4213
|
continue;
|
|
4045
4214
|
}
|
|
4046
|
-
|
|
4047
|
-
|
|
4215
|
+
if (key.startsWith(PUBLIC_PREFIX)) {
|
|
4216
|
+
// Read through the object, where the runtime value wins over this one.
|
|
4217
|
+
// `import.meta.env.KEY` already is; `process.env.KEY` on the server
|
|
4218
|
+
// would otherwise read `process.env` alone and never see the fallback.
|
|
4219
|
+
fallback[key] = value;
|
|
4220
|
+
define["process.env.".concat(key)] = "".concat(RUNTIME_ENV, ".").concat(key);
|
|
4221
|
+
continue;
|
|
4222
|
+
}
|
|
4223
|
+
var literal = target === "server" ? JSON.stringify(value) : "undefined";
|
|
4048
4224
|
define["import.meta.env.".concat(key)] = literal;
|
|
4049
4225
|
define["process.env.".concat(key)] = literal;
|
|
4050
|
-
if (exposed) visible[key] = value;
|
|
4051
4226
|
}
|
|
4052
4227
|
|
|
4053
4228
|
// Vite's built-ins, and they win over a project env var of the same name as
|
|
@@ -4074,25 +4249,73 @@ function defineFor(env, target, warnings) {
|
|
|
4074
4249
|
// "development" -- so a published site's code was told it was in dev.
|
|
4075
4250
|
define["process.env.NODE_ENV"] = JSON.stringify("production");
|
|
4076
4251
|
|
|
4077
|
-
// Always defined
|
|
4078
|
-
//
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4252
|
+
// Always defined: it makes `import.meta.env` destructuring work and stops a
|
|
4253
|
+
// bare reference from throwing. Specific keys above take precedence.
|
|
4254
|
+
define["import.meta.env"] = RUNTIME_ENV;
|
|
4255
|
+
// In the browser `process` does not exist, so an untouched
|
|
4256
|
+
// `process.env.PUBLIC_X` threw there. Read as the same object instead.
|
|
4257
|
+
if (target === "client") define["process.env"] = RUNTIME_ENV;
|
|
4258
|
+
return {
|
|
4259
|
+
define: define,
|
|
4260
|
+
// In the browser the object is `process.env` too, so it carries what
|
|
4261
|
+
// `process.env.NODE_ENV` reads: `const { NODE_ENV } = process.env` would
|
|
4262
|
+
// otherwise read `undefined` and take the development branch.
|
|
4263
|
+
runtime: runtimeEnvSource(target, fallback, target === "client" ? _objectSpread2(_objectSpread2({}, builtins), {}, {
|
|
4264
|
+
NODE_ENV: "production"
|
|
4265
|
+
}) : builtins)
|
|
4266
|
+
};
|
|
4267
|
+
}
|
|
4268
|
+
|
|
4269
|
+
/**
|
|
4270
|
+
* The identifier `import.meta.env` becomes, and the module `inject` imports
|
|
4271
|
+
* for it. The specifier is resolved by {@link runtimeEnvPlugin} and nothing
|
|
4272
|
+
* else, and a project cannot name it: `platform:` is not a package.
|
|
4273
|
+
*/
|
|
4274
|
+
var RUNTIME_ENV = "__PLATFORM_RUNTIME_ENV__";
|
|
4275
|
+
var RUNTIME_ENV_SPECIFIER = "platform:runtime-env";
|
|
4276
|
+
var RUNTIME_ENV_ID = "\0platform:runtime-env";
|
|
4277
|
+
|
|
4278
|
+
/**
|
|
4279
|
+
* The module {@link RUNTIME_ENV} imports: `fallback` (the `PUBLIC_` names the
|
|
4280
|
+
* caller built in), then what is set at runtime, then the built-ins, each
|
|
4281
|
+
* winning over the one before. The built-ins last, as in Vite.
|
|
4282
|
+
*
|
|
4283
|
+
* Not frozen, as Vite's is not: a project that assigns to `import.meta.env`
|
|
4284
|
+
* in a test setup or a polyfill keeps working.
|
|
4285
|
+
*
|
|
4286
|
+
* `globalThis.process?.env` rather than `process.env`: a server bundle that
|
|
4287
|
+
* runs where there is no `process` reads no variables instead of throwing.
|
|
4288
|
+
*/
|
|
4289
|
+
function runtimeEnvSource(target, fallback, builtins) {
|
|
4290
|
+
var read = target === "client" ? "globalThis.__PLATFORM_PUBLIC_ENV" : "globalThis.process?.env";
|
|
4291
|
+
return "const source = ".concat(read, " ?? {};\n") + "const runtime = {};\n" + "for (const name of Object.keys(source)) {\n" + " if (name.startsWith(".concat(JSON.stringify(PUBLIC_PREFIX), ")) runtime[name] = source[name];\n") + "}\n" + "export default Object.assign(".concat(JSON.stringify(fallback, null, 2), ", runtime, ").concat(JSON.stringify(builtins, null, 2), ");\n");
|
|
4292
|
+
}
|
|
4293
|
+
function runtimeEnvPlugin(source) {
|
|
4294
|
+
return {
|
|
4295
|
+
name: "platform:runtime-env",
|
|
4296
|
+
resolveId: function resolveId(id) {
|
|
4297
|
+
return id === RUNTIME_ENV_SPECIFIER ? RUNTIME_ENV_ID : null;
|
|
4298
|
+
},
|
|
4299
|
+
load: function load(id) {
|
|
4300
|
+
return id === RUNTIME_ENV_ID ? source : null;
|
|
4301
|
+
}
|
|
4302
|
+
};
|
|
4082
4303
|
}
|
|
4083
4304
|
function buildOnce(_x, _x2, _x3, _x4, _x5) {
|
|
4084
4305
|
return _buildOnce.apply(this, arguments);
|
|
4085
4306
|
}
|
|
4086
4307
|
function _buildOnce() {
|
|
4087
4308
|
_buildOnce = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(input, vendorBase, projectVendorBase, target, warnings) {
|
|
4088
|
-
var _input$
|
|
4309
|
+
var _input$env, _input$projectSource, _input$assets;
|
|
4089
4310
|
var clientModules,
|
|
4090
4311
|
isRsc,
|
|
4091
4312
|
assetUrls,
|
|
4092
4313
|
cssModules,
|
|
4093
4314
|
aliases,
|
|
4315
|
+
moduleDependencies,
|
|
4094
4316
|
vendor,
|
|
4095
4317
|
projectVendor,
|
|
4318
|
+
env,
|
|
4096
4319
|
_yield$loadRolldown,
|
|
4097
4320
|
build,
|
|
4098
4321
|
result,
|
|
@@ -4111,6 +4334,7 @@ function _buildOnce() {
|
|
|
4111
4334
|
assetUrls = _args2.length > 7 && _args2[7] !== undefined ? _args2[7] : new Map();
|
|
4112
4335
|
cssModules = _args2.length > 8 && _args2[8] !== undefined ? _args2[8] : {};
|
|
4113
4336
|
aliases = _args2.length > 9 && _args2[9] !== undefined ? _args2[9] : null;
|
|
4337
|
+
moduleDependencies = _args2.length > 10 && _args2[10] !== undefined ? _args2[10] : null;
|
|
4114
4338
|
vendor = vendorRules(input.target);
|
|
4115
4339
|
/*
|
|
4116
4340
|
* The project's own layer, in the shape the plugin already reads.
|
|
@@ -4124,7 +4348,8 @@ function _buildOnce() {
|
|
|
4124
4348
|
modules: input.target.project.modules,
|
|
4125
4349
|
css: input.target.project.css,
|
|
4126
4350
|
workerOnly: input.target.project.workerOnly
|
|
4127
|
-
};
|
|
4351
|
+
};
|
|
4352
|
+
env = envFor((_input$env = input.env) !== null && _input$env !== void 0 ? _input$env : {}, target, warnings); // The RSC pass is a server build in every respect the transforms care about:
|
|
4128
4353
|
// it runs on the server, so server-only code stays and client-only code goes.
|
|
4129
4354
|
// Only the vendor layer differs.
|
|
4130
4355
|
_context2.n = 1;
|
|
@@ -4147,7 +4372,7 @@ function _buildOnce() {
|
|
|
4147
4372
|
moduleTypes: {
|
|
4148
4373
|
".css": "empty"
|
|
4149
4374
|
},
|
|
4150
|
-
plugins: [projectPlugin(input.files, (_input$projectSource = input.projectSource) !== null && _input$projectSource !== void 0 ? _input$projectSource : input.files, input.routeSplitter, cssModules, aliases, (_input$assets = input.assets) !== null && _input$assets !== void 0 ? _input$assets : {}, assetUrls, vendorBase, projectVendorBase, projectVendor, vendor, warnings, target, new Set(), clientModules, isRsc)],
|
|
4375
|
+
plugins: [runtimeEnvPlugin(env.runtime), projectPlugin(input.files, (_input$projectSource = input.projectSource) !== null && _input$projectSource !== void 0 ? _input$projectSource : input.files, input.routeSplitter, cssModules, aliases, (_input$assets = input.assets) !== null && _input$assets !== void 0 ? _input$assets : {}, assetUrls, vendorBase, projectVendorBase, projectVendor, vendor, warnings, target, new Set(), clientModules, isRsc)],
|
|
4151
4376
|
// oxc handles TS and JSX natively, so there is no separate transform pass
|
|
4152
4377
|
// and no type-checking on the publish path. Types are the editor's job.
|
|
4153
4378
|
transform: {
|
|
@@ -4155,7 +4380,8 @@ function _buildOnce() {
|
|
|
4155
4380
|
runtime: "automatic",
|
|
4156
4381
|
importSource: "react"
|
|
4157
4382
|
},
|
|
4158
|
-
define:
|
|
4383
|
+
define: _objectSpread2(_objectSpread2({}, env.define), target === "server" && moduleDependencies !== null ? _defineProperty({}, MODULE_DEPENDENCIES_GLOBAL, JSON.stringify(moduleDependencies)) : {}),
|
|
4384
|
+
inject: _defineProperty({}, RUNTIME_ENV, RUNTIME_ENV_SPECIFIER)
|
|
4159
4385
|
},
|
|
4160
4386
|
output: {
|
|
4161
4387
|
format: "esm",
|
|
@@ -4231,7 +4457,7 @@ function buildUserApp(_x6) {
|
|
|
4231
4457
|
function _buildUserApp() {
|
|
4232
4458
|
_buildUserApp = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(input) {
|
|
4233
4459
|
var _input$target$project;
|
|
4234
|
-
var warnings, started, rev, clientModules, assetUrls, assetFiles, _i3, _Object$entries3, _input$assets2, _Object$entries3$_i, path, base64, resolved, aliases, css, styles, tailwindMs, compiled, serverStarted, serverBuild, server, clientStarted, clientBuild, client,
|
|
4460
|
+
var warnings, started, rev, clientModules, assetUrls, assetFiles, _i3, _Object$entries3, _input$assets2, _Object$entries3$_i, path, base64, resolved, aliases, css, styles, tailwindMs, compiled, hash, registryEntry, serverStarted, serverBuild, server, clientStarted, clientBuild, client, rscBuild, publicFiles, _i4, _Object$entries4, _input$publicFiles, _Object$entries4$_i, _path, _base, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t0, _t1, _t10, _t11, _t12, _t13, _t14, _t15, _t16;
|
|
4235
4461
|
return _regenerator().w(function (_context3) {
|
|
4236
4462
|
while (1) switch (_context3.n) {
|
|
4237
4463
|
case 0:
|
|
@@ -4320,33 +4546,28 @@ function _buildUserApp() {
|
|
|
4320
4546
|
tailwindMs = compiled.ms;
|
|
4321
4547
|
warnings.push.apply(warnings, _toConsumableArray(compiled.warnings));
|
|
4322
4548
|
case 10:
|
|
4323
|
-
serverStarted = performance.now();
|
|
4324
4549
|
_context3.n = 11;
|
|
4325
|
-
return
|
|
4550
|
+
return buildInputId(input);
|
|
4326
4551
|
case 11:
|
|
4327
|
-
|
|
4328
|
-
server = performance.now() - serverStarted;
|
|
4329
|
-
clientStarted = performance.now();
|
|
4552
|
+
hash = _context3.v;
|
|
4330
4553
|
_context3.n = 12;
|
|
4331
|
-
return
|
|
4554
|
+
return valModulesEntry(input, hash, warnings);
|
|
4332
4555
|
case 12:
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
/*
|
|
4336
|
-
* The build's `val.modules` registry, as an ES module of its own beside
|
|
4337
|
-
* the client chunks and named after the build: what a Studio opened on an
|
|
4338
|
-
* older build imports to take this one's code in, rather than reloading
|
|
4339
|
-
* the page (`valModulesEntry`). The build's name is a hash of its inputs,
|
|
4340
|
-
* so it is known before anything is emitted.
|
|
4341
|
-
*/
|
|
4556
|
+
registryEntry = _context3.v;
|
|
4557
|
+
serverStarted = performance.now();
|
|
4342
4558
|
_context3.n = 13;
|
|
4343
|
-
return
|
|
4559
|
+
return buildOnce(input, "./vendor/", "./pvendor/", "server", warnings, clientModules, false, assetUrls, css.modules, aliases, registryEntry.dependencies);
|
|
4344
4560
|
case 13:
|
|
4345
|
-
|
|
4561
|
+
serverBuild = _context3.v;
|
|
4562
|
+
server = performance.now() - serverStarted;
|
|
4563
|
+
clientStarted = performance.now();
|
|
4346
4564
|
_context3.n = 14;
|
|
4347
|
-
return
|
|
4565
|
+
return buildOnce(input, "/_vendor/", "/_pvendor/".concat(rev, "/"), "client", warnings, clientModules, false, assetUrls, css.modules, aliases);
|
|
4348
4566
|
case 14:
|
|
4349
|
-
|
|
4567
|
+
clientBuild = _context3.v;
|
|
4568
|
+
client = performance.now() - clientStarted; // Paths are relative to `rsc/app.js`, one directory down, so both layers are
|
|
4569
|
+
// addressed with a leading `../`. Getting this wrong does not fail the build;
|
|
4570
|
+
// the cold isolate simply refuses to boot.
|
|
4350
4571
|
if (!input.rsc) {
|
|
4351
4572
|
_context3.n = 16;
|
|
4352
4573
|
break;
|
|
@@ -4358,7 +4579,7 @@ function _buildUserApp() {
|
|
|
4358
4579
|
// there is exactly one layer and the key is `pvendor/<name>.js`, so a
|
|
4359
4580
|
// revision here is a path segment that does not exist -- and the cold
|
|
4360
4581
|
// isolate is where you would find that out.
|
|
4361
|
-
input, "../vendor-rsc/", "../pvendor/", "server", warnings, clientModules, true, assetUrls, css.modules, aliases);
|
|
4582
|
+
input, "../vendor-rsc/", "../pvendor/", "server", warnings, clientModules, true, assetUrls, css.modules, aliases, registryEntry.dependencies);
|
|
4362
4583
|
case 15:
|
|
4363
4584
|
_t2 = _context3.v;
|
|
4364
4585
|
_context3.n = 17;
|
|
@@ -4378,7 +4599,7 @@ function _buildUserApp() {
|
|
|
4378
4599
|
_t3 = serverBuild.code;
|
|
4379
4600
|
_t4 = clientBuild.code;
|
|
4380
4601
|
_t5 = serverBuild.chunks;
|
|
4381
|
-
_t6 = _objectSpread2(_objectSpread2({}, clientBuild.chunks), registryEntry);
|
|
4602
|
+
_t6 = _objectSpread2(_objectSpread2({}, clientBuild.chunks), registryEntry.files);
|
|
4382
4603
|
_t7 = assetFiles;
|
|
4383
4604
|
_t8 = publicFiles;
|
|
4384
4605
|
_t9 = styles;
|
|
@@ -4851,4 +5072,4 @@ function treeShaOfText(files) {
|
|
|
4851
5072
|
})));
|
|
4852
5073
|
}
|
|
4853
5074
|
|
|
4854
|
-
export { ENTRY_CHUNK, PROJECT_SOURCE, PUBLIC_PREFIX, VAL_SERVER_PATH, aliasMap, bakedGit, bakedJob, blobSha, buildInputId, buildUserApp, bundleValModules, fetchBuildTarget, fetchBuildTargetRev, isValProject, isWired, loadRolldown, publishArtifacts, publishPayload, rebakeGit, resolveInFiles, scanCandidates, treeSha, treeShaOfText, useRolldown, usesTailwind, wireUp, wiredValServer, withoutBakedJob };
|
|
5075
|
+
export { ENTRY_CHUNK, MODULE_DEPENDENCIES_GLOBAL, PROJECT_SOURCE, PUBLIC_PREFIX, VAL_SERVER_PATH, aliasMap, bakedGit, bakedJob, blobSha, buildInputId, buildUserApp, bundleValModules, fetchBuildTarget, fetchBuildTargetRev, isValProject, isWired, loadRolldown, publishArtifacts, publishPayload, rebakeGit, resolveInFiles, scanCandidates, treeSha, treeShaOfText, useRolldown, usesTailwind, wireUp, wiredValServer, withoutBakedJob };
|