Skip to content

build: migrate to tsgo, strip internal declarations, extract FieldMetaApplier - #43

Closed
parkrevil wants to merge 4 commits into
mainfrom
build/tsgo-and-strip-internal
Closed

build: migrate to tsgo, strip internal declarations, extract FieldMetaApplier#43
parkrevil wants to merge 4 commits into
mainfrom
build/tsgo-and-strip-internal

Conversation

@parkrevil

Copy link
Copy Markdown
Contributor

Summary

Build-infra + internal-hygiene changes. No public API change (no semver-major).

  • tsgo migration — replace the bun build --production + tsc --emitDeclarationOnly + extension-fixup pipeline with a single tsgo -p tsconfig.build.json, matching sibling @zipbul/* packages. typecheck ~10× faster. types: ["bun"] added; noEmitOnError on the build; stale build scripts + --production comments removed.
  • stripInternal@internal helpers (toBakerIssueSet, checkCallOptions, CircularPlaceholder, EmitContext.pathExpr) are now stripped from published .d.ts. Public rule constants surface as EmittableRule (were leaking InternalRule); toBakerIssueSet no longer re-exported from the common barrel.
  • FieldMetaApplier — the @Field meta-application helpers (which threaded the same meta/propertyKey/options trio) become a class, mirroring the seal-stage builders.
  • dist cleanrm -rf dist before emit so stale output can't be published.

Verification

  • tsgo typecheck (main + both bench tsconfigs) clean
  • 2469 tests pass, coverage gate (0.9/file) green
  • lint 0/0, knip clean, dist runtime smoke passes
  • consumer typecheck (skipLibCheck:true) against the built package is clean; stripped internals are provably not importable

🤖 Generated with Claude Code

parkrevil and others added 4 commits July 11, 2026 23:39
Replace the per-file `bun build --production` + `tsc --emitDeclarationOnly`
+ extension-fixup pipeline with a single `tsgo -p tsconfig.build.json`, matching
the sibling @zipbul/* packages (e.g. ashward). typecheck and typecheck:bench move
to tsgo as well.

- add @typescript/native-preview (exact pin, same as ashward)
- tsconfig: add `types: ["bun"]` (tsgo does not auto-include bun ambient types)
- tsconfig.build: `noEmitOnError` so a broken emit fails loud
- delete scripts/build.sh and scripts/add-js-extensions.ts
- drop stale `--production` enum-inlining comments and the knip `tsc` binary ignore

Typecheck drops from ~1.75s to ~0.17s. Emitted .d.ts is byte-identical to tsc
except cosmetic quote style. JS now ships extensionless relative imports (as the
sibling packages do); baker is Bun-only (relies on Symbol.metadata), so Node-native
ESM resolvability is not a supported consumption path, and bundlers resolve fine.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Enable `stripInternal` so @internal-tagged symbols (toBakerIssueSet,
checkCallOptions, CircularPlaceholder, EmitContext.pathExpr) are removed from the
emitted .d.ts while remaining exported from source for direct unit testing — the
intended use of @internal.

Two source fixes were required so stripping leaves no dangling references:
- makeRule/makePlannedRule now return EmittableRule (not the internal InternalRule),
  so public rule constants (isString, min, …) surface as EmittableRule. @field
  already casts to InternalRule at the metadata boundary, so builders keep .plan.
- toBakerIssueSet is no longer re-exported from the common barrel; the two runtime
  consumers import it directly from common/errors.
- InternalRule keeps its @internal-free doc (it is shared metadata↔builder plumbing,
  never reachable through the exports map, so it needs no stripping).

Verified: published .d.ts no longer contains the stripped helpers; a consumer
typecheck (skipLibCheck:true) against the built package is clean and cannot import
the stripped symbols; 2469 tests green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The six meta-application helpers (applyValidation/applyExpose/applyTransform +
decorateRuleDef/withGroups/wrapTransform) plus the inline flags/type/exclude/
message-context blocks all threaded the same (meta, propertyKey, options) trio — the
exact param-threading pattern the seal-stage builders were refactored away from. Move
them into a FieldMetaApplier class that holds the trio as fields, so the @field
decorator now only validates the decorator context and parses args, then delegates
application. Pure move; behavior and public API unchanged; field.ts stays 100% covered.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
`tsgo -p tsconfig.build.json` does not remove obsolete output, so a renamed or
deleted source could leave a stale file that the `dist/**` files glob would publish.
Prepend `rm -rf dist` (the old build.sh did this) so the build is self-cleaning.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@parkrevil

Copy link
Copy Markdown
Contributor Author

Closing — continuing work directly, not as a separate PR.

@parkrevil parkrevil closed this Jul 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant