Skip to content

test(package): consume the tarball the way npm does - #9

Merged
github-actions[bot] merged 1 commit into
mainfrom
worktree-ai-forms-pack-gate
Aug 16, 2026
Merged

test(package): consume the tarball the way npm does#9
github-actions[bot] merged 1 commit into
mainfrom
worktree-ai-forms-pack-gate

Conversation

@catomean

Copy link
Copy Markdown
Collaborator

Why

Every existing test imports ../dist/index.js by relative path. That walks straight past the two things a consumer actually depends on — the exports map and the files allowlist — so either can break while the suite stays green. On a package about to be published for the first time, the first witness to a broken exports map would be whoever runs npm install.

ai-forms/react had no test at all.

What

Packs the real tarball, unpacks it as node_modules/ai-forms, and imports it by bare specifier from a temp workspace outside the repo — so resolution goes through the published manifest, not the repo layout.

Five assertions: every declared entry point resolves; the runtime entry points expose their whole public API; the react entry point ships its exports; every entry point's types file is actually in the tarball; README and LICENSE ship.

React is an optional peer, so ./react is resolved and read rather than executed — that still proves the exports map and the file exist without dragging the temp workspace's dependencies into the assertion.

Verified red before green

Confirmed the gate fails, with a precise message, against three real breakages:

Breakage Result
./react removed from exports 2 targeted failures naming the subpath, 3 unrelated tests still pass
./server types → a nonexistent file "./server" advertises types at ./dist/nope.d.ts, which is not in the tarball
files: ["README.md"] (drops dist) 4 failures, each naming what went missing

Each probe records failure as a value rather than throwing. An earlier draft let a broken exports map crash the setup hook, which failed all five assertions at once and buried the cause; that is fixed and re-verified.

npm run verify: 19/19 pass. No script change needed — the existing test/*.test.js glob picks it up.

🤖 Generated with Claude Code

The suite imported `../dist/index.js` by relative path, which walks past
the two things a consumer actually depends on: the `exports` map and the
`files` allowlist. Both can break while every other test stays green, and
the first witness would be whoever runs `npm install` — a bad way to
learn it on a first publish.

This packs the real tarball, unpacks it as `node_modules/ai-forms`, and
imports it by bare specifier from a temp workspace outside the repo. It
also covers `ai-forms/react`, which had no test at all: React is an
optional peer, so the subpath is resolved and read rather than executed.

Verified red before green against three breakages — a dropped subpath, a
`types` path pointing at nothing, and a `files` list that forgets `dist`.
Each probe records failure as a value instead of throwing, so a broken
entry point names itself rather than failing all five assertions at once.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions
github-actions Bot merged commit c224dc3 into main Aug 16, 2026
1 check passed
@github-actions
github-actions Bot deleted the worktree-ai-forms-pack-gate branch August 16, 2026 07:32
@catomean catomean mentioned this pull request Aug 16, 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