Repository navigation
feat(cli): compose static assets, functions, and routes into the Vercel build output - #696
Merged
Merged
Conversation
Co-Authored-By: Claude Fable 5.1 <[email protected]>
…lidator Pure resolver for build.vercel (functionName, static, functions, routes), route composition in Build Output order, and a validator that accepts a composed tree while keeping the runtime function config exact. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…e Vercel build output build.vercel describes the Build Output tree beyond the runtime function. The target checks every configured path before touching .vercel/, copies the static dir, bundles each extra function, orders routes as user routes -> filesystem -> runtime -> SPA fallback, and validates the composed tree before the existing atomic publish. The runtime function is b4.func when static assets are configured so it does not shadow static/index.html. Refs #679, #687 Co-Authored-By: Claude Fable 5.1 <[email protected]>
…SEO lastmod Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
blove
temporarily deployed
to
vercel-preview
September 17, 2026 05:36 — with
GitHub Actions
Inactive
…-output # Conflicts: # apps/web/app/seo/lastmod.generated.json # apps/web/content/docs/configuration.mdx # packages/cli/src/lib/build/targets/index.ts # packages/core/src/types.ts
Co-Authored-By: Claude Opus 5 <[email protected]>
blove
enabled auto-merge (squash)
September 17, 2026 16:24
blove
temporarily deployed
to
vercel-preview
September 17, 2026 16:27 — with
GitHub Actions
Inactive
…-output # Conflicts: # apps/web/app/seo/lastmod.generated.json # apps/web/content/docs/cli.mdx # apps/web/content/docs/configuration.mdx # packages/cli/src/lib/build/targets/index.ts # packages/cli/src/lib/build/targets/vercel.ts # packages/core/src/types.ts # scripts/check-docs.mjs
…-output # Conflicts: # apps/web/app/seo/lastmod.generated.json
Co-Authored-By: Claude Opus 5 <[email protected]>
blove
temporarily deployed
to
vercel-preview
September 17, 2026 17:07 — with
GitHub Actions
Inactive
…-output # Conflicts: # apps/web/app/seo/lastmod.generated.json
#694 added /readyz beside /healthz. The scoped runtime route a SPA fallback installs did not list it, so on a composed Vercel deployment /readyz matched the fallback and served the SPA document with a 200 rather than reaching the runtime — a readiness probe that looks healthy while reporting nothing. Add readyz, and cover the composed route with one case per rooted runtime surface so a future surface cannot be added without updating it. Co-Authored-By: Claude Opus 5 <[email protected]>
The integration test duplicated the route string, so adding /readyz to the implementation left a stale literal asserting the old value. Reference the constant instead. Co-Authored-By: Claude Opus 5 <[email protected]>
blove
temporarily deployed
to
vercel-preview
September 17, 2026 18:10 — with
GitHub Actions
Inactive
…-output # Conflicts: # apps/web/app/seo/lastmod.generated.json # apps/web/content/docs/cli.mdx # apps/web/content/docs/configuration.mdx # packages/cli/src/lib/build/targets/vercel-config.ts # packages/cli/src/lib/build/targets/vercel-output.ts # packages/cli/src/lib/build/targets/vercel.ts # packages/cli/test/vercel-target.test.ts # packages/core/src/types.ts # scripts/check-docs.mjs
blove
temporarily deployed
to
vercel-preview
September 17, 2026 20:09 — with
GitHub Actions
Inactive
…-output # Conflicts: # apps/web/app/seo/lastmod.generated.json
Co-Authored-By: Claude Opus 5 <[email protected]>
The runtime function's .vc-config.json carried only handler, launcherType and runtime, so Vercel's Node launcher buffered its responses. The runtime answers /agui/:routeId and /threads/:id/runs/stream with text/event-stream, which meant a deployed frontend received nothing until a run finished instead of tokens as they were produced. Extra functions configured through build.vercel.functions could already opt into streaming; the one function that always streams could not. supportsResponseStreaming is fixed rather than configurable: it follows from what the runtime serves, not from how the app is deployed. validateVercelOutput keeps asserting the runtime config exactly, deriving both the written bytes and the expectation from the same constant. Co-Authored-By: Claude Opus 5 <[email protected]>
…s link resolveVercelComposition threw bare CliErrors, so a malformed build.vercel.static.dir printed an uncoded line while an unknown build.vercel key printed the coded, linked form check-error-codes.test.ts asserts. Move the shared invalidBuildConfig helper into vercel-compose.ts, which vercel-config.ts already depends on, and route every throw through it. Also qualify the local-run snippet in the edge docs: the runtime function is index.func only until build.vercel.static renames it. Co-Authored-By: Claude Opus 5 <[email protected]>
…-output # Conflicts: # apps/web/app/seo/lastmod.generated.json # apps/web/content/docs/deployment/edge.mdx
Co-Authored-By: Claude Opus 5 <[email protected]>
blove
temporarily deployed
to
vercel-preview
September 17, 2026 20:56 — with
GitHub Actions
Inactive
…-output # Conflicts: # apps/web/app/seo/lastmod.generated.json
blove
temporarily deployed
to
vercel-preview
September 17, 2026 22:04 — with
GitHub Actions
Inactive
…-output # Conflicts: # apps/web/app/seo/lastmod.generated.json # apps/web/content/docs/cli.mdx # apps/web/content/docs/deployment.mdx
#700 added the guide against the pre-change behaviour: its compose section said the target emits no static dir, no extra functions and no routes, and cited #679/#687 as open proposals. Rewrite it around build.vercel, keep the assemble-it-yourself path as a scoped subsection since outDir still serves that case, and qualify the artifacts table as the bare-build shape. Co-Authored-By: Claude Opus 5 <[email protected]>
blove
temporarily deployed
to
vercel-preview
September 17, 2026 22:28 — with
GitHub Actions
Inactive
blove
added a commit
that referenced
this pull request
Sep 17, 2026
…716) The runtime function's supportsResponseStreaming: true is what stops Vercel's Node launcher buffering the whole body; the page now names that mechanism and its symptom, and notes that a function declared under build.vercel.functions must ask for the flag itself. The local-run snippet's functions/index.func/index.mjs is the bare build's path; a build configuring build.vercel.static emits b4.func, so the snippet now says so. Follow-up to #700, audited against #696's source and tests. Co-Authored-By: Claude Opus 5 <[email protected]>
This was referenced Sep 18, 2026
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #679. Also resolves the validator half of #680 and the function-name half of #687.
b4 buildwith theverceltarget used to emit only the runtime function and a catch-allconfig.json, so a real app had to post-process the published tree (hashbrown'stools/vercel/assemble.mjs). The target can now compose the whole Build Output API v3 tree fromb4.config.ts:build.vercelschema (@b4run/core):functionName,static { dir, spaFallback },functions { entry, runtime, maxDuration, supportsResponseStreaming },routes. Exported asVercelBuildConfig/VercelBuildRoute.@b4run/cli): every configured path is checked before.vercel/is touched; the static dir is copied intostatic/(symlinks dereferenced); each extra function is esbuild-bundled intofunctions/<name>.func/with its.vc-config.json; routes are ordered user routes →{ handle: "filesystem" }→ runtime → SPA fallback. Everything lands in the existing per-invocation staging dir and goes through the existing validate → atomic rename → backup/rollback publish.index.funcfor a bare runtime build (the gatedvercel-nativelane pins that listing). Oncestaticis configured the default becomesb4.func, since a function namedindexis served at/and shadowsstatic/index.html;functionNameoverrides either default, and"index"besidestaticfails the build with a pointed error./(healthz|agui|threads|memory)(/.*)?so every other path falls through to the SPA document. Without a fallback the runtime stays the catch-all.validateVercelOutput(outputDir, { functionName })(vercel target: allow an output directory override and relax validateVercelOutput #680): accepts a composedconfig.json(must route to the runtime function;{ handle: "filesystem" }at most once; route keys allow-listed), keeps the runtime function's.vc-config.jsonexact, and applies the same symlink/dependency containment checks to every extrafunctions/*.func. The one-argument call used by the native lane keeps working.BuildEmitContextgains optionalconfigso targets can read the loaded config.Not in this PR: per-option config for the runtime function (
maxDuration/supportsResponseStreaming, which hashbrown merges into it).build.vercel.outDir/--out-dirarrived separately in #695 and is integrated here (see below).Design note:
docs/superpowers/specs/2026-09-16-vercel-composed-output-design.md.Validation
pnpm lintpnpm buildpnpm --filter @b4run/core --filter @b4run/cli typecheckvitest test/vercel-target.test.ts test/vercel-compose.test.ts test/build-targets.test.ts— 165 passed (29 new pure-unit tests, 26 new validator/integration tests; the composed-tree integration test builds a fixture with a SPA, an extra function, and a user route throughrunBuildCommandand asserts the published tree,config.json, both.vc-config.jsonfiles, and the reported artifact list)node scripts/check-docs.mjs(config-path inventory extended withbuild.vercel.*)node scripts/check-changesets.mjspnpm test:release-integritypnpm --filter @b4run/web seo:lastmod:check(manifest regenerated)pnpm --filter @b4run/cli test— 165 files, 1918 passed, 4 skipped on the post-merge tree (raised per-test timeout; the machine was saturated by a concurrent vitest, no assertion failures).pnpm pack:check— not run locally (no packaging changes; CIpack-smokecovers it).vercel-nativelane — gated; the default build listing it pins is unchanged.Merged with main (2026-09-17)
Rebased onto main after #693 (
build.targetstyped asBuildTargetName), #698 (vercel target reaching plain Postgres), and #692. Conflicts resolved in four files:packages/core/src/types.ts— kept main'sreadonly BuildTargetName[]typing fortargets, addedvercel?: VercelBuildConfigbeside it.packages/cli/src/lib/build/targets/index.ts— kept main'sRecord<BuildTargetName, BuildTarget>registry, kept the addedconfig?: B4Configcontext field.apps/web/content/docs/configuration.mdx— merged main'sBuildTargetNameprose with thebuild.vercelschema block and paragraph.apps/web/app/seo/lastmod.generated.json— took main's copy, regenerated.Re-verified on the merged tree:
pnpm build,pnpm typecheck(53 tasks),pnpm lint,node scripts/check-docs.mjs,seo:lastmod:check,@b4run/coretests (539 passed),@b4run/clitests (165 files, 1918 passed, 4 skipped).Second merge with main — unified
build.vercel(2026-09-17)Main then took #697, which introduced
build.vercel.reconcileVercelJsonunder the same config key as this PR, with its ownresolveVercelBuildConfigthat rejects unknown keys, plus actx.buildConfigfield overlapping thectx.configadded here. Left side by side, each resolver would reject the other's options —build.vercel: { static: … }would have failed with "Unknown build.vercel option(s): static".Unified into the single resolver #697's own commit message asks for:
vercel-config.ts'sresolveVercelBuildConfig(build, appRoot)now owns the shape of all ofbuild.verceland returns{ reconcileVercelJson, composition }. It keeps feat(cli): opt the vercel target out of vercel.json reconciliation #697's misplaced-flag, non-object and non-boolean rejections, and delegates the tree keys toresolveVercelComposition(this PR's resolver, renamed from its colliding name).VERCEL_BUILD_OPTION_KEYSis the union of both key sets, so an unknown option names every known one.BuildEmitContextkeeps only feat(cli): opt the vercel target out of vercel.json reconciliation #697'sbuildConfig; the redundantconfigfield added here is gone.b4 checknow validates the composition keys too, which two separate resolvers would not have done.VercelBuildConfigin@b4run/coreabsorbsreconcileVercelJson, so one interface describes the key.Eight new tests cover the unified resolver (both axes together, each alone, an absent section, the unknown-key message, the misplaced and non-boolean flag, and a composition error surfacing through the same entry point). Four pass shapes the type forbids, via an explicit untyped cast, since a
b4.config.jsor JSON config arrives with no compiler.Re-verified after this merge:
pnpm build,pnpm typecheck(53 tasks),pnpm lint,node scripts/check-docs.mjs,node scripts/check-changesets.mjs,seo:lastmod:check,@b4run/core(539 passed),@b4run/cli(167 files, 1982 passed, 4 skipped) — including main's own tests for #697's rejection paths.A real bug caught by merging #694 (2026-09-17)
#694 added a
/readyzreadiness probe beside/healthz. The scoped runtime route this PR installs under a SPA fallback listed only/healthz,/agui,/threads,/memory— so on a composed Vercel deployment/readyzfell through to{ src: "/(.*)", dest: "/<spaFallback>" }and served the SPA document with a 200. A readiness probe that returns HTML and success is the worst shape of wrong: it reports healthy while reporting nothing.Fixed test-first. Beyond adding
readyz, the composed route is now covered by one case per rooted runtime surface (/healthz,/readyz,/threads,/threads/:id/runs/stream,/agui/:id,/memory/candidates, …) plus negative cases (/,/index.html,/assets/app.js,/about), so a surface added to the runtime later cannot be left out of this route silently. The integration test now asserts the route from the exported constant rather than a duplicated literal.Integrating #695 —
outDirand a second validator relaxation (2026-09-17)Main then took #695, which implemented the half of #680 this PR had deferred — and relaxed the same
validateVercelOutputin its own way.outDirjoins the unifiedbuild.vercel: the one resolver now validatesfunctionName,static,functions,routes,outDirandreconcileVercelJsontogether and returns the output directory, the flag and the composition./index; this PR's parameterizes on the runtime function name and also checks route shapes, the filesystem phase and every extra function. Kept the parameterized one, adopted feat(cli): vercel output directory override and relaxed output validator #695's clearer error wording (its tests assert that phrasing), and aligned this PR's own assertions to match.Re-verified:
pnpm build,pnpm typecheck(54 tasks),pnpm lint,node scripts/check-docs.mjs,seo:lastmod:check,@b4run/cli(167 files, 1996 passed, 4 skipped).One unrelated flake appeared in an intermediate run:
dev-command.test.ts > serializes a watched edit that arrives during initial child startuptimed out waiting for a child pid file. It passes in isolation, passed in the runs either side, and is in a file this PR does not touch — the known process-runner descendant-startup flake.Release Notes
@b4run/cli,@b4run/core, patch).Screenshots Or Artifacts
Composed output for the test fixture:
{ "routes": [ { "dest": "/api", "src": "/api/(.*)" }, { "handle": "filesystem" }, { "dest": "/b4", "src": "/(healthz|agui|threads|memory)(/.*)?" }, { "dest": "/index.html", "src": "/(.*)" } ], "version": 3 }Checklist
CONTRIBUTING.md.CODE_OF_CONDUCT.md.🤖 Generated with Claude Code