build: drop ambient host types from the published build - #7
Merged
Conversation
The fold is pure ECMAScript and imports no Node built-ins, but the build inherited types: ["node"] from the root config, so a stray built-in import in src would compile and only break for consumers bundling to a browser. The build config already scopes to src, so emptying the types list there constrains the published surface without touching the test program, which needs the Node globals that vitest and vite pull in. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Adds
"types": []totsconfig.build.json.Why
src/imports no Node built-ins — the fold is pure ECMAScript. But the build config inheritstypes: ["node"]from the roottsconfig.json, so a strayimport { randomUUID } from "node:crypto"insrc/would compile cleanly, pass lint, and break only for consumers who bundle the package for a browser.tsconfig.build.jsonalready scopes toinclude: ["src"], so emptying the types list lands exactly on the published surface. The test program is untouched and keeps the Node globals thatvitestandvitepull in through their own type declarations.Verification
npm run checkpasses end to end.import { randomUUID } from "node:crypto"added tosrc/objects.ts,npm run buildfails:npm run typecheckstill passes on that same code, since the root config supplies node types tosrc. That is why the guard belongs in the build config. Both steps run undernpm run check, so CI catches it either way..d.tsreferences nothing node-related, before or after.Scope
Independent of #6 — that one pins the
@types/nodeversion, this one bounds where those types apply. Branched offmain, so the two can merge in either order.🤖 Generated with Claude Code
Summary by cubic
Remove ambient Node types from the published build to keep the library browser-safe. Set "types": [] in tsconfig.build.json so any Node built-in import in src fails at build time, while tests keep Node types from the root config.
Written for commit 49a0cad. Summary will update on new commits.