From cdafd3f8add309bcd1d3d05873f24e185cc86be7 Mon Sep 17 00:00:00 2001 From: ocavue Date: Fri, 17 Nov 2023 23:19:40 +0800 Subject: [PATCH 1/2] docs: add information about JavaScript API --- docs/README.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 69324005..a1ed214e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -193,7 +193,7 @@ 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. +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: @@ -579,6 +579,22 @@ Use `--publicDir` flag to copy files inside `./public` folder to the output dire You can also specify a custom directory using `--publicDir another-directory`. +### JavaScript API + +If you want to use tsup in your Node.js program, you can use the JavaScript API: + +```js +import { build } from 'tsup' + +await build({ + entry: ['src/index.ts'], + sourcemap: true, + dts: true, +}) +``` + +For all available options for the `build` function, please see [the API docs](https://paka.dev/npm/tsup). + ## Troubleshooting ### error: No matching export in "xxx.ts" for import "xxx" From a1ead4297e63b20d6a03b801269cff8f7186f753 Mon Sep 17 00:00:00 2001 From: ocavue Date: Fri, 17 Nov 2023 23:20:46 +0800 Subject: [PATCH 2/2] Small update --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index a1ed214e..12f08319 100644 --- a/docs/README.md +++ b/docs/README.md @@ -581,7 +581,7 @@ You can also specify a custom directory using `--publicDir another-directory`. ### JavaScript API -If you want to use tsup in your Node.js program, you can use the JavaScript API: +If you want to use `tsup` in your Node.js program, you can use the JavaScript API: ```js import { build } from 'tsup'