Skip to content

Commit 838f344

Browse files
Gugustinettesxzz
andauthored
fix: make unrun optionnal (#570)
Co-authored-by: Kevin Deng <sxzz@sxzz.moe>
1 parent 33a0db6 commit 838f344

File tree

6 files changed

+20
-16
lines changed

6 files changed

+20
-16
lines changed

docs/options/config-file.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ This is useful if you want to rely solely on command-line options or default set
6969
- `auto` (default): Utilizes native runtime loading for TypeScript if supported; otherwise, defaults to `unconfig`.
7070
- `native`: Loads TypeScript configuration files using native runtime support. Requires a compatible environment, such as the latest Node.js, Deno, or Bun.
7171
- `unconfig`: Loads configuration files with the `unconfig` library, ensuring broad compatibility across different runtimes.
72-
- `unrun` _(experimental)_: Loads configuration files using the [`unrun`](https://gugustinette.github.io/unrun/) library, which provides similar compatibility as `unconfig` but with more performances.
72+
- `unrun` _(experimental)_: Loads configuration files using the [`unrun`](https://gugustinette.github.io/unrun/) library, which provides similar compatibility as `unconfig` but with more performances. Install the `unrun` package to use this loader.
7373

7474
> [!TIP]
7575
> 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 `unconfig` or `unrun` loader for seamless compatibility.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ tsdown --no-config
6969
- `auto`(默认):如果运行时支持,则使用原生方式加载 TypeScript,否则回退到 `unconfig`
7070
- `native`:通过原生运行时支持加载 TypeScript 配置文件。需要兼容的环境,如最新版 Node.js、Deno 或 Bun。
7171
- `unconfig`:使用 `unconfig` 库加载配置文件,确保在不同运行时下具有广泛兼容性。
72-
- `unrun` _(experimental)_: Loads configuration files using the [`unrun`](https://gugustinette.github.io/unrun/) library, which provides similar compatibility as `unconfig` but with more performances.
72+
- `unrun` _(实验性)_: 使用 [`unrun`](https://gugustinette.github.io/unrun/) 库加载配置文件,兼容性与 `unconfig` 类似,但性能更高。要使用此加载器,请先安装 `unrun` 包。
7373

7474
> [!TIP]
7575
> Node.js 原生不支持在不指定文件扩展名的情况下导入 TypeScript 文件。如果您在 Node.js 环境下希望加载不带 `.ts` 扩展名的 TypeScript 配置文件,建议使用 `unconfig``unrun` 加载器以获得更好的兼容性。

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@
6565
"publint": "^0.3.0",
6666
"typescript": "^5.0.0",
6767
"unplugin-lightningcss": "^0.4.0",
68-
"unplugin-unused": "^0.5.0"
68+
"unplugin-unused": "^0.5.0",
69+
"unrun": "^0.2.1"
6970
},
7071
"peerDependenciesMeta": {
7172
"@arethetypeswrong/core": {
@@ -82,6 +83,9 @@
8283
},
8384
"unplugin-unused": {
8485
"optional": true
86+
},
87+
"unrun": {
88+
"optional": true
8589
}
8690
},
8791
"dependencies": {
@@ -98,8 +102,7 @@
98102
"tinyexec": "catalog:prod",
99103
"tinyglobby": "catalog:prod",
100104
"tree-kill": "catalog:prod",
101-
"unconfig": "catalog:prod",
102-
"unrun": "catalog:prod"
105+
"unconfig": "catalog:prod"
103106
},
104107
"devDependencies": {
105108
"@arethetypeswrong/core": "catalog:dev",
@@ -122,6 +125,7 @@
122125
"unocss": "catalog:docs",
123126
"unplugin-lightningcss": "catalog:dev",
124127
"unplugin-unused": "catalog:dev",
128+
"unrun": "catalog:dev",
125129
"vite": "catalog:docs",
126130
"vitest": "catalog:dev"
127131
},

pnpm-lock.yaml

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ catalogs:
2525
typescript: ~5.9.3
2626
unplugin-lightningcss: ^0.4.3
2727
unplugin-unused: ^0.5.4
28+
unrun: ^0.2.1
2829
vitest: ^4.0.3
2930

3031
docs:
@@ -61,7 +62,6 @@ catalogs:
6162
tinyglobby: ^0.2.15
6263
tree-kill: ^1.2.2
6364
unconfig: ^7.3.3
64-
unrun: ^0.2.0
6565

6666
ignoredBuiltDependencies:
6767
- rolldown

src/options/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import process from 'node:process'
33
import { pathToFileURL } from 'node:url'
44
import { underline } from 'ansis'
55
import { loadConfig } from 'unconfig'
6-
import { unrun } from 'unrun'
76
import { fsStat } from '../utils/fs'
87
import { toArray } from '../utils/general'
98
import { globalLogger } from '../utils/logger'
@@ -154,6 +153,7 @@ async function nativeImport(id: string) {
154153
}
155154

156155
async function unrunImport(id: string) {
156+
const { unrun } = await import('unrun')
157157
const { module } = await unrun({
158158
path: pathToFileURL(id).href,
159159
}).catch((error) => {

0 commit comments

Comments
 (0)