Skip to content

feat: switch from tsup to tsdown #2224

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pnpm install

## Building

Run [**tsup**](https://tsup.egoist.dev) locally to build source files from `src/` into output files in `lib/`:
Run [**tsdown**](https://tsdown.dev) locally to build source files from `src/` into output files in `lib/`:

```shell
pnpm build
Expand Down
8 changes: 4 additions & 4 deletions docs/Blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ This table summarizes each block and which base levels they're included in:
| Renovate | `--add-renovate`, `--exclude-renovate` | | | 💯 |
| Security Docs | `--add-security-docs`, `--exclude-security-docs` | ✔️ | ✅ | 💯 |
| Templated With | `--add-templated-with`, `--exclude-templated-with` | ✔️ | ✅ | 💯 |
| TSup | `--add-tsup`, `--exclude-tsup` | ✔️ | ✅ | 💯 |
| TSDown | `--add-tsdown`, `--exclude-tsdown` | ✔️ | ✅ | 💯 |
| TypeScript | `--add-typescript`, `--exclude-typescript` | ✔️ | ✅ | 💯 |
| Vitest | `--add-vitest`, `--exclude-vitest` | | ✅ | 💯 |
| VS Code | `--add-vs-code`, `--exclude-vs-code` | | | 💯 |
| Web-ext | `--add-web-ext`, `--exclude-web-ext` | | | |

For example, this uses ncc instead of the default tsup builder:
For example, this uses ncc instead of the default tsdown builder:

```shell
npx create-typescript-app --add-ncc --exclude-tsup
npx create-typescript-app --add-ncc --exclude-tsdown
```

See also [CLI](./CLI.md) for customizing templated repositories when running `npx create-typescript-app`.
Expand All @@ -82,7 +82,7 @@ We strongly recommend using at least the [_"common"_ base level](#common-base-le

### Building

[**tsup**](https://tsup.egoist.dev): Builds output definitions and JavaScript files using [esbuild](https://esbuild.github.io).
[**tsdown**](https://tsdown.dev): Builds output definitions and JavaScript files.
Each `*.ts` source file within `src/` is built into `.d.ts` and `.js` output files in `lib/`.

Building once:
Expand Down
10 changes: 5 additions & 5 deletions docs/FAQs.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,18 @@ Here we'll outline the steps required to migrate a CTA app to a GitHub Action:
</details>

- GitHub Actions run without installing package dependencies.
Replace `tsup` with [`ncc`](https://github.com/vercel/ncc) to build source files and dependencies into a single JS file.
Delete `tsup.config.ts` then execute the following commands:
Replace `tsdown` with [`ncc`](https://github.com/vercel/ncc) to build source files and dependencies into a single JS file.
Delete `tsdown.config.ts` then execute the following commands:

```bash
pnpm remove tsup
pnpm remove tsdown
pnpm add @vercel/ncc -D
```

- Now we need to update the `build` script in our `package.json`:

```diff
-"build": "tsup",
-"build": "tsdown",
+"build": "ncc build src/index.ts -o dist --license licenses.txt",
```

Expand Down Expand Up @@ -106,7 +106,7 @@ First, I'd suggest reading [TypeScript Handbook > Modules - Introduction](https:

Then:

1. In `tsup.config.ts`, change the [tsup `format` option](https://tsup.egoist.dev/#bundle-formats) from `["esm"]` to `["cjs", "esm"]`
1. In `tsdown.config.ts`, change the [tsdown `format` option](https://tsdown.dev/options/output-format) from `["esm"]` to `["cjs", "esm"]`
2. Add a [`package.json` `"exports"` entry](https://nodejs.org/api/packages.html#subpath-exports) like:

<!-- eslint-disable jsonc/sort-keys -->
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"package.json"
],
"scripts": {
"build": "tsup",
"build": "tsdown",
"format": "prettier .",
"lint": "eslint . --max-warnings 0",
"lint:knip": "knip",
Expand Down Expand Up @@ -114,7 +114,7 @@
"prettier-plugin-sh": "0.15.0",
"release-it": "18.1.2",
"sentences-per-line": "0.3.0",
"tsup": "8.4.0",
"tsdown": "0.12.7",
"typescript": "5.8.2",
"typescript-eslint": "8.26.1",
"vitest": "3.0.9"
Expand Down
Loading
Loading