Skip to content

fix(ts-document): build lib on install so gend works from a clean checkout - #235

Open
tallneil wants to merge 1 commit into
childrentime:mainfrom
tallneil:neil/fix-ts-document-build
Open

tallneil wants to merge 1 commit into
childrentime:mainfrom
tallneil:neil/fix-ts-document-build

Conversation

@tallneil

@tallneil tallneil commented Sep 22, 2026 •

Copy link
Copy Markdown

Description

Fixes #233. pnpm --filter @reactuses/core gend fails from a clean install with MODULE_NOT_FOUND for @reactuses/ts-document.

packages/core depends on it as workspace:*, so it always resolves to packages/ts-document, which declares "main": "lib/index.js". lib/ is build output — gitignored (.gitignore:28), nothing under it tracked — and the only script that produces it is tsc, referenced solely by prepublishOnly. That runs on npm publish, not on install, and neither the package nor the root manifest defined prepare or postinstall. So lib/ never existed for any contributor who had not run the build by hand.

The fix is one line: "prepare": "npm run tsc", the lifecycle hook intended for exactly this case. pnpm runs it for workspace projects during pnpm install.

This matters because CLAUDE.md makes regeneration mandatory ("If you change an interface.ts, re-run gend and commit the result"), while the remark plugin drops the %%API%% marker silently when the generated file is missing — so a contributor either hits MODULE_NOT_FOUND or ships a docs page with no signature table and nothing fails.

Options considered

  • prepare in packages/ts-document/package.json — chosen. Standard lifecycle hook, scoped to the package that owns the build, and tsc is already rm -rf lib/ && tsc, so it is idempotent.
  • Root postinstall calling pnpm --filter @reactuses/ts-document run tsc — works, but moves one package's build concern into the root manifest.

Verification

Reproduced and verified locally on 48561e0:

rm -rf packages/ts-document/lib packages/ts-document/node_modules
pnpm install     # -> "packages/ts-document prepare$ npm run tsc" -> Done
pnpm --filter @reactuses/core gend   # succeeds, no diff in generated docs
  • pnpm lint passes.
  • pnpm test (core): 74 suites, 431 tests passing.
  • pnpm-lock.yaml unchanged — adding a script does not affect resolution.

One pre-existing failure, unrelated to this change and reproducible on main at 48561e0: pnpm --filter @reactuses/ts-document test fails with TypeError: Cannot read properties of undefined (reading 'testEnvironmentOptions'), because jest 27.5.1 in that package resolves jest-environment-node 29.7.0 from the root. Untouched here since it is out of scope, but it does mean prepublishOnly would fail today.

Type of Change

  • Bug fix
  • New hook
  • Enhancement to existing hook
  • Documentation update
  • Other (please describe)

Checklist

  • I have read the Contributing Guide
  • I have read and understood every line of this diff myself, including any AI-written parts (AI usage policy)
  • My code follows the project's coding style
  • I have added tests for my changes
  • All existing tests pass
  • I have updated the documentation

Notes on the unticked boxes: no tests added — this is a one-line lifecycle script, verified by the clean-install reproduction above rather than by a unit test. No docs update needed. "All existing tests pass" refers to lint and the core suite; see the pre-existing ts-document jest failure noted above.

AI disclosure: investigation, the clean-install verification, and this description were done with Claude Code.

🤖 Generated with Claude Code

…ckout

`packages/core` depends on `@reactuses/ts-document` as `workspace:*`, and that package declares `"main": "lib/index.js"`. `lib/` is build output: it is gitignored and produced only by `tsc`, which was referenced solely by `prepublishOnly`. Nothing ran it on install, so `pnpm --filter @reactuses/core gend` failed with MODULE_NOT_FOUND for any contributor who had not built it by hand.

Adding `prepare` makes pnpm build the package during `pnpm install`, which is the lifecycle hook intended for exactly this case.

Fixes childrentime#233

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

pnpm gend fails from a clean install — @reactuses/ts-document is never built

1 participant