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

#233 · closed · 2 comments

View on GitHub ↗

tallneil

## What happens After a fresh `pnpm install`, the command `CLAUDE.md` instructs contributors to run fails: ``` $ pnpm --filter @reactuses/core gend Error: Cannot find module '.../packages/core/node_modules/@reactuses/ts-document/lib/index.js'. Please verify that the package.json has a valid "main" entry code: 'MODULE_NOT_FOUND', requestPath: '@reactuses/ts-document' ``` ## Why - `packages/core` depends on `@reactuses/ts-document` as `workspace:*`, so it always resolves to `packages/ts-document` and never to a published tarball. - `packages/ts-document/package.json` declares `"main": "lib/index.js"`. - `lib/` is build output: `**/lib` is gitignored (`.gitignore:28`) and no file under `packages/ts-document/lib/` is tracked. - The only script that produces it is `tsc`, referenced solely by `prepublishOnly` — which runs on `npm publish`, not on install. - Neither `packages/ts-document/package.json` nor the root `package.json` defines `prepare` or `postinstall`, so `pnpm install` never builds it. So `lib/` does not exist for any contributor who has not run the build by hand. ## Why CI does not catch it `.github/workflows/ci.yml` runs lint, tests, and `cd packages/core && pnpm run build`. It never runs `gend`, so the generator is never exercised in CI. ## Impact `CLAUDE.md` makes regeneration mandatory: > **If you change an `interface.ts`, re-run `gend` and commit the result.** and notes that the remark plugin drops the `%%API%%` marker silently when the generated file is missing or stale, with no build error. The two outcomes are therefore: - a contributor who follows the instruction hits `MODULE_NOT_FOUND` - a contributor who skips it ships a docs page with no signature table, and nothing fails This appears to have happened at least once already: `useBatchedMount` (#229) was merged to the hook branch with no `packages/website-astro/api/useBatchedMount-README*.md` files at all. ## Workaround ```bash pnpm --filter @reactuses/ts-document run tsc ``` ## Possible fix A `prepare` script in `packages/ts-document/package.json` would have pnpm build it on install: ```json "prepare": "npm run tsc" ``` ## Environment - `@reactuses/ts-document` 0.8.0 - pnpm workspace, `packages/*` - reproduced on `main` at 48561e0

Comments

childrentime

Confirmed — I hit this myself while reproducing #234. Verified the fix too: removed `packages/ts-document/lib`, added `"prepare": "pnpm run tsc"`, and `pnpm install` rebuilt it. Worth pairing it with a CI step that runs `gend` and fails on a diff, so a stale regeneration can't pass silently either. Would you like to open a PR?

tallneil

PR is open: https://github.com/childrentime/reactuse/pull/235 It takes the `prepare` route described above. Verified from a clean state: wiping `packages/ts-document/lib` and its `node_modules`, then `pnpm install`, builds the package on install, and `pnpm --filter @reactuses/core gend` then runs clean with no diff in the generated docs.