这是indexloc提供的服务,不要输入任何密码
Skip to content

docs: add information about JavaScript API #1037

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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"
Expand Down