fix(build): restore dist/typings/ in published package - #1574
Merged
Conversation
@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
force-pushed
the
fix/restore-dist-typings-v2.18.2
branch
from
March 26, 2026 11:09
6c5b06c to
89834c9
Compare
amitsingh05667
approved these changes
Mar 26, 2026
Merged
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 ```
3 tasks
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
v2.18.1 shipped without
dist/typings/, breaking TypeScript type resolution for all consumers (fixes #1573).Root cause:
@babel/preset-typescriptadded to the globalbabel.config.jsin v2.18.1 causedrollup-plugin-typescript2to defer TypeScript handling to Babel. Babel strips types successfully — no build error — but never emits.d.tsfiles.Changes
babel.config.js— remove@babel/preset-typescriptfrom global configrollup.config.mjs— move full Babel config inline withbabelrc: falseso rpt2 is unaffectedtsconfig.types.json— new dedicated config for declaration-only compilation (emitDeclarationOnly,skipLibCheck, explicitsrc/**include)package.json— addbuild:typesscript; run it inprepackso types are always generated fresh before publish;buildstays focused on JS bundles onlyscripts/prepack.js— replace shallow file-only copy with recursive directory move so nested.d.tsfiles are never silently droppedTest plan
npm run build— JS bundles build, no typings generatednpm run build:types—dist/typings/index.d.tspresent, 38 files totalnpm pack --dry-run | grep -c typingsreturns 38npm test— all 818 tests pass