Skip to content

Commit

Permalink
feat: add experimental dts rollup using @microsoft/api-extractor (#983)
Browse files Browse the repository at this point in the history
  • Loading branch information
ocavue authored Nov 17, 2023
1 parent 690af7b commit 61fc06c
Show file tree
Hide file tree
Showing 14 changed files with 1,395 additions and 74 deletions.
12 changes: 12 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,16 @@ If you have multiple entry files, each entry will get a corresponding `.d.ts` fi

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.

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.

To use `--experimental-dts`, you would need to install `@microsoft/api-extractor`, as it's a peer dependency of tsup:

```bash
npm i @microsoft/api-extractor -D
# Or Yarn
yarn add @microsoft/api-extractor --dev
```

#### Emit declaration file only

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.
Expand Down Expand Up @@ -500,6 +510,8 @@ esbuild has [experimental CSS support](https://esbuild.github.io/content-types/#
To use PostCSS, you need to install PostCSS:

```bash
npm i postcss -D
# Or Yarn
yarn add postcss --dev
```

Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"tree-kill": "^1.2.2"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.38.3",
"@rollup/plugin-json": "6.0.1",
"@swc/core": "1.2.218",
"@types/debug": "4.1.7",
Expand Down Expand Up @@ -74,6 +75,7 @@
},
"peerDependencies": {
"@swc/core": "^1",
"@microsoft/api-extractor": "^7.36.0",
"postcss": "^8.4.12",
"typescript": ">=4.5.0"
},
Expand All @@ -86,6 +88,9 @@
},
"@swc/core": {
"optional": true
},
"@microsoft/api-extractor": {
"optional": true
}
},
"engines": {
Expand Down
Loading

0 comments on commit 61fc06c

Please sign in to comment.