package: CommonJS projects get their own declarations (dist/types-cjs; node16 / nodenext refused an ESM-only .d.ts from a CJS file, TS1541); the package-types test covers ES module and CommonJS projects under bundler / node16 / nodenext / node10 and loads the package with import() and require() under Node; pitfall 69

This commit is contained in:
CRTkafa 2026-10-15 06:01:33 +08:00
parent d717ceb4cd
commit 04647c079e
6 changed files with 42 additions and 14 deletions

View file

@ -794,3 +794,15 @@ that fails without the fix (see CONTRIBUTING.md).
SIGTERM / SIGHUP and the parent's death (SIGKILL included) end the Chrome; `console fill` closes it on errors too;
headless runs on macOS prefer Chromium / Chrome for Testing (its own bundle id) over Google Chrome.app
(`persistentExecutable`); `tests/chrome-guard.test.ts`.
## 69. `bun add -d storebound` broke a Next app's build
- **Symptom:** `next build` (or vue-tsc, ts-loader, `tsc --noEmit`) fails on the scaffolded `storebound.config.ts`:
`Cannot find module 'storebound' or its corresponding type declarations`.
- **Cause:** storebound <= 0.8.5 exported only its TypeScript source (`cli/lib/config.ts`) and shipped no `.d.ts`.
Bun imports .ts, so everything storebound tested passed; TypeScript never takes a package's .ts source as its types.
- **Do:** update to 0.8.6+ (declarations for ES module and CommonJS projects). Remove any tsconfig `exclude` of
storebound.config.ts that was added as a workaround.
- **Guard:** `buildEntry` / `pruneDeclarations` (tools/build-node.ts, run by prepack) and `tests/package-types.test.ts`:
the template config type-checks against the packed entry in ES module and CommonJS projects under bundler,
node16, nodenext and node10 with no @types/node and skipLibCheck off; `import()` and `require()` of the package
load under Node.