Repository navigation
fix(core): type build.targets as the known target union - #693
Merged
Merged
Conversation
`build.targets` in `config()` was `readonly string[]`, so a typo such as
`targets: ["vercell"]` type-checked and only failed at `b4 build` time.
Add `BUILD_TARGET_NAMES` to `@b4run/core` as the single source of truth,
derive `BuildTargetName` from it, and type `B4Config.build.targets` as
`readonly BuildTargetName[]`. The CLI's target registry is now a
`Record<BuildTargetName, BuildTarget>`, so adding a target on one side
without the other is a compile error. No `(string & {})` escape hatch: the
registry is a closed object literal with no plugin registration, so a hatch
would only reopen the typo gap.
Runtime validation in `b4 build` and `b4 check` is kept with the same
message, because JS and JSON configs arrive untyped, and it now narrows
through `isBuildTargetName`.
Closes #686
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:30 — with
GitHub Actions
Inactive
14 of 16 tasks
blove
added a commit
that referenced
this pull request
Sep 17, 2026
Resolves four conflicts against #693 (typed build.targets) and #698 (vercel Postgres driver): - core types.ts and the configuration reference keep main's BuildTargetName union alongside the new build.vercel block. - The targets registry keeps main's Record<BuildTargetName, BuildTarget> alongside the config field on BuildEmitContext. - The SEO lastmod manifest is regenerated rather than hand-merged. Also renames the function path in #698's new "Run the Vercel bundle locally" snippet, which still imported index.func. Co-Authored-By: Claude Opus 5 <[email protected]>
blove
added a commit
that referenced
this pull request
Sep 17, 2026
#698 landed while this branch was open and closed #690: the vercel target's generated stores now select a driver per request, so the built bundle reaches a plain local Postgres over pooled `pg` with no WebSocket proxy at all. The guide documented the proxy as a hard requirement, so that section was rewritten: - the local recipe is now DATABASE_URL plus a bare `node --input-type=module` import, no Docker network and no wsproxy containers; - `B4_PG_WS_PROXY` is described with the forms it actually accepts (host:port, ws://, wss://), as a way to rehearse the Neon path rather than as a precondition, alongside `B4_PG_DRIVER` and the proxy-with-pg configuration error; - the driver detail links to the edge page's new "Database drivers" section instead of restating it; - the fit check no longer claims WebSocket Postgres is required, and the Neon section notes non-Neon hosts get a pooled `pg` connection. Conflicts resolved toward main: configuration.mdx takes main's `BuildTargetName` union wording from #693, which already names both edge targets, and lastmod.generated.json is regenerated. Co-Authored-By: Claude Opus 5 <[email protected]>
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.
Closes #686.
Problem
build.targetsinconfig()was typedreadonly string[], sotargets: ["vercell"]type-checked and only failed atb4 buildtime.Change
@b4run/core: newbuild-targets.tsexportsBUILD_TARGET_NAMES(["node", "langsmith", "hono", "vercel"] as const), the derivedBuildTargetNameunion, and anisBuildTargetNameguard.B4Config.build.targetsis nowreadonly BuildTargetName[].@b4run/cli: the target registry is typedReadonly<Record<BuildTargetName, BuildTarget>>with literal keys,BuildTarget.nameisBuildTargetName, andknownTargetNames()returns the core tuple. Adding a target to the registry without adding its name in core, or the reverse, is now a compile error, so the config type and the registry cannot drift.b4 buildandb4 checkkeep their runtime validation and the exactUnknown build target "…". Known targets: …message, since ab4.config.jsor JSON config arrives untyped.build.tsnarrows through the guard instead of anascast.configuration.mdxdescribes the union; the three new exports are listed on the core API page; the SEO lastmod manifest is regenerated for those two pages.@b4run/coreand@b4run/cli.No plugin escape hatch
The issue floated an optional
(string & {})hatch. The registry is a closed object literal with no plugin registration path, so a hatch would only reopen the typo gap the issue is about. If plugin targets land later, the hatch is a one-line change at the type.Tests
packages/core/test/build-targets.test.ts:expectTypeOfpins the union exactly,// @ts-expect-errorproves["vercell"]and a plainstring[]are rejected byconfig(), plus runtime guard cases. Verified bytsc -p tsconfig.test.jsonin core's typecheck (an unneeded@ts-expect-errorwould itself fail).packages/cli/test/build-target-registry.test.ts: registry keys equalBUILD_TARGET_NAMESat runtime, every target reports the name it is keyed by, and the registry/default/known-names types are pinned to the union.Verification
pnpm typecheck53/53,pnpm lint28/28,node scripts/check-docs.mjspass.@b4run/coretests 539/539.@b4run/clifull suite alone: 4 files timed out under load (no assertion failures); those 4 files re-run in isolation 422/422, including the existingbuild-targets.test.tsunknown-target cases.apps/webgenerate-lastmodtest passes after regeneration.🤖 Generated with Claude Code