Skip to content

fix(build): restore dist/typings/ in published package - #1574

Merged
yogeshchoudhary147 merged 1 commit into
mainfrom
fix/restore-dist-typings-v2.18.2
Mar 26, 2026
Merged

fix(build): restore dist/typings/ in published package#1574
yogeshchoudhary147 merged 1 commit into
mainfrom
fix/restore-dist-typings-v2.18.2

Conversation

@yogeshchoudhary147

Copy link
Copy Markdown
Contributor

Summary

v2.18.1 shipped without dist/typings/, breaking TypeScript type resolution for all consumers (fixes #1573).

Root cause: @babel/preset-typescript added to the global babel.config.js in v2.18.1 caused rollup-plugin-typescript2 to defer TypeScript handling to Babel. Babel strips types successfully — no build error — but never emits .d.ts files.

Changes

  • babel.config.js — remove @babel/preset-typescript from global config
  • rollup.config.mjs — move full Babel config inline with babelrc: false so rpt2 is unaffected
  • tsconfig.types.json — new dedicated config for declaration-only compilation (emitDeclarationOnly, skipLibCheck, explicit src/** include)
  • package.json — add build:types script; run it in prepack so types are always generated fresh before publish; build stays focused on JS bundles only
  • scripts/prepack.js — replace shallow file-only copy with recursive directory move so nested .d.ts files are never silently dropped

Test plan

  • npm run build — JS bundles build, no typings generated
  • npm run build:typesdist/typings/index.d.ts present, 38 files total
  • npm pack --dry-run | grep -c typings returns 38
  • npm test — all 818 tests pass

@yogeshchoudhary147
yogeshchoudhary147 requested a review from a team as a code owner March 26, 2026 11:07
@babel/preset-typescript in the global babel config caused
rollup-plugin-typescript2 to skip declaration generation, shipping
v2.18.1 without dist/typings/.

- Move @babel/preset-typescript inline in rollup config (babelrc: false)
- Add build:types script using tsc --project tsconfig.types.json
- Run build:types in prepack so types are always fresh before publish
- Fix prepack.js to move nested typings dirs, not only top-level files

Fixes #1573
@yogeshchoudhary147
yogeshchoudhary147 force-pushed the fix/restore-dist-typings-v2.18.2 branch from 6c5b06c to 89834c9 Compare March 26, 2026 11:09
@yogeshchoudhary147
yogeshchoudhary147 merged commit 6a3a043 into main Mar 26, 2026
19 of 21 checks passed
@yogeshchoudhary147
yogeshchoudhary147 deleted the fix/restore-dist-typings-v2.18.2 branch March 26, 2026 11:19
yogeshchoudhary147 added a commit that referenced this pull request Mar 26, 2026
**Fixed**
- fix(build): restore dist/typings/ in published package
[\#1574](#1574)
([yogeshchoudhary147](https://github.com/yogeshchoudhary147))
yogeshchoudhary147 added a commit that referenced this pull request Mar 27, 2026
## Summary

Preventive measures to avoid a repeat of #1573.

### CI: new `verify-types` job

Adds a dedicated CI job that runs `npm run build:types` in parallel with
unit tests on every PR. If type declaration generation fails, the build
fails before merge.

### Remove `scripts/prepack.js`

This file originally existed to flatten rpt2's output — rpt2 dumped
declarations into `dist/typings/src/` instead of `dist/typings/`, so the
script moved them up before publish.

Since #1574 moved declaration generation to `tsc --project
tsconfig.types.json`, this script became dead code. `tsc` outputs
directly to `dist/typings/` with no `src/` subdirectory. More
importantly, if `tsc` fails it exits non-zero — stopping the `prepack`
chain and blocking publish. A separate guard file adds nothing on top of
that.

`prepack` simplified from:
```
npm run build && npm run build:types && node ./scripts/prepack
```
to:
```
npm run build && npm run build:types
```
yogeshchoudhary147 added a commit that referenced this pull request Jun 24, 2026
## Summary

`rollup-plugin-typescript2` already emits all `.d.ts` files into
`dist/typings/` as part of the standard Rollup build. The separate
`build:types` step added in #1574 produces identical output, making it
redundant.

Also improves the `verify-types` CI job to use `npm pack --dry-run`
which directly catches the failure mode from #1573 (typings missing from
published package) rather than just checking local file existence.

## Changes

- Remove `build:types` script from `package.json`
- Simplify `prepack` to `npm run build` only
- Delete `tsconfig.types.json` (no longer referenced)
- Update `verify-types` CI job to verify typings are included in the
published package via `npm pack --dry-run`

## Test plan

- [x] `npm run build` generates 44 `.d.ts` files in `dist/typings/`
- [x] `npm pack --dry-run` shows 44 typings files included in package
- [x] All 998 unit tests pass
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.

v2.18.1 missing dist/typings/ — TypeScript type declarations not included in npm package

2 participants