Skip to content

Commit fc1b13d

Browse files
authored
docs: add information about JavaScript API (#1037)
1 parent b54081f commit fc1b13d

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

docs/README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ If you have multiple entry files, each entry will get a corresponding `.d.ts` fi
195195

196196
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.
197197

198-
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.
198+
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.
199199

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

@@ -581,6 +581,22 @@ Use `--publicDir` flag to copy files inside `./public` folder to the output dire
581581

582582
You can also specify a custom directory using `--publicDir another-directory`.
583583

584+
### JavaScript API
585+
586+
If you want to use `tsup` in your Node.js program, you can use the JavaScript API:
587+
588+
```js
589+
import { build } from 'tsup'
590+
591+
await build({
592+
entry: ['src/index.ts'],
593+
sourcemap: true,
594+
dts: true,
595+
})
596+
```
597+
598+
For all available options for the `build` function, please see [the API docs](https://paka.dev/npm/tsup).
599+
584600
## Troubleshooting
585601

586602
### error: No matching export in "xxx.ts" for import "xxx"

0 commit comments

Comments
 (0)