Skip to content

Commit

Permalink
docs: add information about JavaScript API (#1037)
Browse files Browse the repository at this point in the history
  • Loading branch information
ocavue committed Nov 17, 2023
1 parent b54081f commit fc1b13d
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,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 @@ -581,6 +581,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

0 comments on commit fc1b13d

Please sign in to comment.