Skip to content

Commit 61fc06c

Browse files
authored
feat: add experimental dts rollup using @microsoft/api-extractor (#983)
1 parent 690af7b commit 61fc06c

File tree

14 files changed

+1395
-74
lines changed

14 files changed

+1395
-74
lines changed

docs/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,16 @@ If you have multiple entry files, each entry will get a corresponding `.d.ts` fi
193193

194194
Note that `--dts` does not resolve external (aka in `node_modules`) types used in the `.d.ts` file, if that's somehow a requirement, try the experimental `--dts-resolve` flag instead.
195195

196+
Since tsup version 7.4.0, you can also use `--experimental-dts` flag to generate declaration files. This flag use [@microsoft/api-extractor](https://www.npmjs.com/package/@microsoft/api-extractor) to generate declaration files, which is more reliable than the previous `--dts` flag. It's still experimental and we are looking for feedbacks.
197+
198+
To use `--experimental-dts`, you would need to install `@microsoft/api-extractor`, as it's a peer dependency of tsup:
199+
200+
```bash
201+
npm i @microsoft/api-extractor -D
202+
# Or Yarn
203+
yarn add @microsoft/api-extractor --dev
204+
```
205+
196206
#### Emit declaration file only
197207

198208
The `--dts-only` flag is the equivalent of the `emitDeclarationOnly` option in `tsc`. Using this flag will only emit the declaration file, without the JavaScript files.
@@ -500,6 +510,8 @@ esbuild has [experimental CSS support](https://esbuild.github.io/content-types/#
500510
To use PostCSS, you need to install PostCSS:
501511

502512
```bash
513+
npm i postcss -D
514+
# Or Yarn
503515
yarn add postcss --dev
504516
```
505517

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"tree-kill": "^1.2.2"
4545
},
4646
"devDependencies": {
47+
"@microsoft/api-extractor": "^7.38.3",
4748
"@rollup/plugin-json": "6.0.1",
4849
"@swc/core": "1.2.218",
4950
"@types/debug": "4.1.7",
@@ -74,6 +75,7 @@
7475
},
7576
"peerDependencies": {
7677
"@swc/core": "^1",
78+
"@microsoft/api-extractor": "^7.36.0",
7779
"postcss": "^8.4.12",
7880
"typescript": ">=4.5.0"
7981
},
@@ -86,6 +88,9 @@
8688
},
8789
"@swc/core": {
8890
"optional": true
91+
},
92+
"@microsoft/api-extractor": {
93+
"optional": true
8994
}
9095
},
9196
"engines": {

0 commit comments

Comments
 (0)