Skip to content

Commit a104223

Browse files
committed
feat!: drop Node.js < 22.18.0 support, make unrun optional, add tsx config loader
- Bump engines to `>=22.18.0` across all packages - Move `unrun` from dependencies to optional peerDependencies - Add `tsx` as a new config loader option via tsImport API - Add `tsx` as optional peerDependency - Update docs and references accordingly
1 parent 5de04ad commit a104223

20 files changed

Lines changed: 1126 additions & 688 deletions

File tree

__snapshots__/tsnapi/index.snapshot.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export interface ExportsOptions {
6060
}
6161
export interface InlineConfig extends UserConfig {
6262
config?: boolean | string;
63-
configLoader?: "auto" | "native" | "unrun";
63+
configLoader?: "auto" | "native" | "tsx" | "unrun";
6464
filter?: RegExp | Arrayable<string>;
6565
}
6666
export interface Logger {

docs/guide/getting-started.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,7 @@ bun add -D typescript
5959
:::
6060

6161
:::tip Compatibility Note
62-
`tsdown` requires Node.js version 20.19 or higher. Please ensure your development environment meets this requirement before installing. While `tsdown` is primarily tested with Node.js, support for Deno and Bun is experimental and may not work as expected.
63-
:::
64-
65-
:::warning Node.js Deprecation
66-
Node.js versions below 22.18.0 are deprecated and support will be removed in the next minor release. Please upgrade to Node.js 22.18.0 or later.
62+
`tsdown` requires Node.js version 22.18.0 or higher. Please ensure your development environment meets this requirement before installing. While `tsdown` is primarily tested with Node.js, support for Deno and Bun is experimental and may not work as expected.
6763
:::
6864

6965
### Starter Templates {#starter-templates}

docs/options/config-file.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,12 @@ This is useful if you want to rely solely on command-line options or default set
6767
`tsdown` supports multiple config loaders to accommodate various file formats. You can select a config loader using the `--config-loader` option. The available loaders are:
6868

6969
- `auto` (default): Utilizes native runtime loading for TypeScript if supported; otherwise, defaults to `unrun`.
70-
- `native`: Loads TypeScript configuration files using native runtime support. Requires a compatible environment, such as the latest Node.js, Deno, or Bun.
71-
- `unrun`: Loads configuration files using the [`unrun`](https://gugustinette.github.io/unrun/) library. It provides more powerful and flexible loading capabilities.
70+
- `native`: Loads TypeScript configuration files using native runtime support. Requires a compatible environment, such as Node.js 22.18.0+, Deno, or Bun.
71+
- `tsx`: Loads configuration files using the [`tsx`](https://tsx.is/) library via its [tsImport API](https://tsx.is/dev-api/ts-import). Note that `tsx` is an optional peer dependency — you need to install it manually if you want to use this loader.
72+
- `unrun`: Loads configuration files using the [`unrun`](https://gugustinette.github.io/unrun/) library. It provides more powerful and flexible loading capabilities. Note that `unrun` is an optional peer dependency — you need to install it manually if you want to use this loader.
7273

7374
> [!TIP]
74-
> Node.js does not natively support importing TypeScript files without specifying the file extension. If you are using Node.js and want to load a TypeScript config file without including the `.ts` extension, consider using the `unrun` loader for seamless compatibility.
75+
> Node.js does not natively support importing TypeScript files without specifying the file extension. If you are using Node.js and want to load a TypeScript config file without including the `.ts` extension, consider installing and using the `tsx` or `unrun` loader for seamless compatibility.
7576
7677
## Extending Vite or Vitest Config (Experimental)
7778

docs/zh-CN/guide/getting-started.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,7 @@ bun add -D typescript
5959
:::
6060

6161
:::tip 兼容性说明
62-
`tsdown` 需要 Node.js 20.19 或更高版本。请确保您的开发环境满足此要求后再进行安装。虽然 `tsdown` 主要在 Node.js 下测试,但对 Deno 和 Bun 的支持仍为实验性,可能无法正常工作。
63-
:::
64-
65-
:::warning Node.js 弃用警告
66-
低于 22.18.0 的 Node.js 版本已被弃用,将在下一个 minor 版本中移除支持。请升级到 Node.js 22.18.0 或更高版本。
62+
`tsdown` 需要 Node.js 22.18.0 或更高版本。请确保您的开发环境满足此要求后再进行安装。虽然 `tsdown` 主要在 Node.js 下测试,但对 Deno 和 Bun 的支持仍为实验性,可能无法正常工作。
6763
:::
6864

6965
### 起步模板 {#starter-templates}

docs/zh-CN/options/config-file.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,12 @@ tsdown --no-config
6767
`tsdown` 支持多种配置加载器,以适配不同的文件格式。您可以通过 `--config-loader` 选项选择配置加载器。可用的加载器包括:
6868

6969
- `auto`(默认):如果运行时支持,则使用原生方式加载 TypeScript,否则回退到 `unrun`
70-
- `native`:通过原生运行时支持加载 TypeScript 配置文件。需要兼容的环境,如最新版 Node.js、Deno 或 Bun。
71-
- `unrun`:使用 [`unrun`](https://gugustinette.github.io/unrun/) 库加载配置文件,提供更强大和灵活的加载能力。
70+
- `native`:通过原生运行时支持加载 TypeScript 配置文件。需要兼容的环境,如 Node.js 22.18.0+、Deno 或 Bun。
71+
- `tsx`:使用 [`tsx`](https://tsx.is/) 库通过其 [tsImport API](https://tsx.is/dev-api/ts-import) 加载配置文件。注意 `tsx` 是可选的 peer dependency,需要手动安装后才能使用。
72+
- `unrun`:使用 [`unrun`](https://gugustinette.github.io/unrun/) 库加载配置文件,提供更强大和灵活的加载能力。注意 `unrun` 是可选的 peer dependency,需要手动安装后才能使用。
7273

7374
> [!TIP]
74-
> Node.js 原生需要指定文件扩展名才能导入 TypeScript 文件。如果您在 Node.js 环境下希望加载不带 `.ts` 扩展名的 TypeScript 配置文件,建议使用 `unrun` 加载器以获得更好的兼容性。
75+
> Node.js 原生需要指定文件扩展名才能导入 TypeScript 文件。如果您在 Node.js 环境下希望加载不带 `.ts` 扩展名的 TypeScript 配置文件,建议安装并使用 `tsx` `unrun` 加载器以获得更好的兼容性。
7576
7677
## 扩展 Vite 或 Vitest 配置(实验性功能){#extending-vite-or-vitest-config-experimental}
7778

package.json

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
}
7373
},
7474
"engines": {
75-
"node": ">=20.19.0"
75+
"node": ">=22.18.0"
7676
},
7777
"scripts": {
7878
"lint": "eslint --cache --max-warnings 0 .",
@@ -94,8 +94,10 @@
9494
"@tsdown/exe": "workspace:*",
9595
"@vitejs/devtools": "*",
9696
"publint": "^0.3.0",
97+
"tsx": "*",
9798
"typescript": "^5.0.0 || ^6.0.0",
98-
"unplugin-unused": "^0.5.0"
99+
"unplugin-unused": "^0.5.0",
100+
"unrun": "*"
99101
},
100102
"peerDependenciesMeta": {
101103
"@arethetypeswrong/core": {
@@ -113,11 +115,17 @@
113115
"publint": {
114116
"optional": true
115117
},
118+
"tsx": {
119+
"optional": true
120+
},
116121
"typescript": {
117122
"optional": true
118123
},
119124
"unplugin-unused": {
120125
"optional": true
126+
},
127+
"unrun": {
128+
"optional": true
121129
}
122130
},
123131
"dependencies": {
@@ -135,8 +143,7 @@
135143
"tinyexec": "catalog:prod",
136144
"tinyglobby": "catalog:prod",
137145
"tree-kill": "catalog:prod",
138-
"unconfig-core": "catalog:prod",
139-
"unrun": "catalog:prod"
146+
"unconfig-core": "catalog:prod"
140147
},
141148
"inlinedDependencies": {
142149
"is-in-ci": "2.0.0",
@@ -174,12 +181,14 @@
174181
"rolldown-plugin-require-cjs": "catalog:dev",
175182
"sass": "catalog:dev",
176183
"tsnapi": "catalog:dev",
184+
"tsx": "catalog:dev",
177185
"typescript": "catalog:dev",
178186
"unocss": "catalog:docs",
179187
"unplugin-ast": "catalog:dev",
180188
"unplugin-raw": "catalog:dev",
181189
"unplugin-unused": "catalog:peer",
182190
"unplugin-vue": "catalog:dev",
191+
"unrun": "catalog:dev",
183192
"vite": "catalog:docs",
184193
"vitest": "catalog:dev",
185194
"vue": "catalog:docs"

packages/create-tsdown/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
}
5454
},
5555
"engines": {
56-
"node": ">=20.19.0"
56+
"node": ">=22.18.0"
5757
},
5858
"scripts": {
5959
"dev": "node ./src/run.ts",

packages/css/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
}
4343
},
4444
"engines": {
45-
"node": ">=20.19.0"
45+
"node": ">=22.18.0"
4646
},
4747
"scripts": {
4848
"build": "node -C dev ../../src/run.ts -c ../../tsdown.config.ts -F ."

packages/exe/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
}
4343
},
4444
"engines": {
45-
"node": ">=20.19.0"
45+
"node": ">=22.18.0"
4646
},
4747
"scripts": {
4848
"build": "node -C dev ../../src/run.ts -c ../../tsdown.config.ts -F ."

packages/migrate/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
}
5454
},
5555
"engines": {
56-
"node": ">=20.19.0"
56+
"node": ">=22.18.0"
5757
},
5858
"scripts": {
5959
"dev": "node ./src/run.ts",

0 commit comments

Comments
 (0)