Skip to content

Commit a6742ae

Browse files
authored
chore: replace rollup-plugin-dts with tsc for declaration emission (#385)
Remove rollup-plugin-dts and emit type declarations directly with tsc via a new tsconfig.build.json. The build now produces lib/types/*.d.ts alongside the existing lib/cjs and lib/esm bundles; the `types` / `exports.types` entries in package.json point at lib/types/index.d.ts. The rollup-plugin-dts was just combining all the types into a single .d.ts file for this project. It wasn't rolling up the .d.ts from its dependencies. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Primarily build/publish metadata changes, but it affects the emitted/packaged TypeScript declaration layout and could break consumers if the new `lib/types` output differs or is incomplete. > > **Overview** > Build output now generates `.d.ts` files via `tsc -p tsconfig.build.json` into `lib/types/` (declarations-only), rather than using Rollup to bundle a single `lib/index.d.ts`. > > `package.json` and `exports.types` are updated to point consumers at `./lib/types/index.d.ts`, and `rollup-plugin-dts` is removed from the Rollup config and dev dependencies. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 9227a7d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 2e9dab5 commit a6742ae

3 files changed

Lines changed: 17 additions & 13 deletions

File tree

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
"bindings"
1414
],
1515
"exports": {
16-
"types": "./lib/index.d.ts",
16+
"types": "./lib/types/index.d.ts",
1717
"require": "./lib/cjs/index.js",
1818
"import": "./lib/esm/index.js"
1919
},
2020
"main": "./lib/cjs/index.js",
21-
"types": "./lib/index.d.ts",
21+
"types": "./lib/types/index.d.ts",
2222
"files": [
2323
"lib",
2424
"src",
@@ -29,7 +29,7 @@
2929
"test": "jest",
3030
"test:junit": "jest --ci --reporters=default",
3131
"clean": "rimraf lib/*",
32-
"rb": "rollup -c --configPlugin typescript",
32+
"rb": "rollup -c --configPlugin typescript && tsc -p tsconfig.build.json",
3333
"rbw": "npm run rb --watch",
3434
"build": "npm run clean && npm run rb",
3535
"lint": "eslint ./src",
@@ -75,7 +75,6 @@
7575
"react-test-renderer": "^18.0.0",
7676
"rimraf": "^6.0.1",
7777
"rollup": "^4.19.0",
78-
"rollup-plugin-dts": "^6.1.0",
7978
"rollup-plugin-esbuild": "^6.1.1",
8079
"ts-jest": "^29.2.2",
8180
"tslib": "^2.8.1",

rollup.config.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import dts from 'rollup-plugin-dts';
21
import esbuild from 'rollup-plugin-esbuild';
32
import json from '@rollup/plugin-json';
43
import resolve from '@rollup/plugin-node-resolve';
@@ -33,12 +32,4 @@ export default [
3332
plugins,
3433
external,
3534
},
36-
{
37-
input: 'src/index.ts',
38-
plugins: [dts(), json()],
39-
output: {
40-
file: 'lib/index.d.ts',
41-
format: 'es',
42-
},
43-
},
4435
];

tsconfig.build.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"rootDir": "src",
5+
"declaration": true,
6+
"declarationDir": "lib/types",
7+
"emitDeclarationOnly": true,
8+
"sourceMap": false,
9+
"sourceRoot": null,
10+
"noEmit": false
11+
},
12+
"include": ["src"],
13+
"exclude": ["node_modules", "lib", "dist", "example", "**/*.test.ts", "**/*.test.tsx"]
14+
}

0 commit comments

Comments
 (0)