Skip to content

Commit e9e812f

Browse files
authored
fix: remove runtime helper check (#495)
1 parent 621a30d commit e9e812f

File tree

4 files changed

+4
-131
lines changed

4 files changed

+4
-131
lines changed

docs/options/target.md

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@ You can disable all syntax transformations by setting the target to `false`. Thi
3636
```
3737

3838
When `target` is set to `false`:
39+
3940
- No JavaScript syntax downleveling occurs (modern features like optional chaining `?.`, nullish coalescing `??`, etc. are preserved)
4041
- No CSS syntax transformations are applied (modern CSS features like nesting are preserved)
4142
- No runtime helper plugins are loaded
4243
- The output will use the exact syntax from your source code
4344

4445
This is particularly useful when:
46+
4547
- You're targeting modern environments that support the latest JavaScript/CSS features
4648
- You want to handle syntax transformations in a different build step
4749
- You're building a library that will be further processed by the consuming application
@@ -75,54 +77,6 @@ You can also pass an array of targets to ensure compatibility across multiple en
7577
tsdown --target chrome100 --target node20.18
7678
```
7779

78-
## Runtime Helpers
79-
80-
When downleveling certain modern JavaScript features, `tsdown` may require runtime helpers provided by the `@oxc-project/runtime` package. For example, transforming `await` expressions into older syntax requires the helper `@oxc-project/runtime/helpers/asyncToGenerator`.
81-
82-
If your target includes features that require these helpers, you may need to install the `@oxc-project/runtime` package in your project:
83-
84-
::: code-group
85-
86-
```sh [npm]
87-
npm install @oxc-project/runtime
88-
```
89-
90-
```sh [pnpm]
91-
pnpm add @oxc-project/runtime
92-
```
93-
94-
```sh [yarn]
95-
yarn add @oxc-project/runtime
96-
```
97-
98-
```sh [bun]
99-
bun add @oxc-project/runtime
100-
```
101-
102-
:::
103-
104-
If you want to **inline helper functions** instead of importing them from the runtime package, you can install `@oxc-project/runtime` as a development dependency:
105-
106-
::: code-group
107-
108-
```sh [npm]
109-
npm install -D @oxc-project/runtime
110-
```
111-
112-
```sh [pnpm]
113-
pnpm add -D @oxc-project/runtime
114-
```
115-
116-
```sh [yarn]
117-
yarn add -D @oxc-project/runtime
118-
```
119-
120-
```sh [bun]
121-
bun add -D @oxc-project/runtime
122-
```
123-
124-
:::
125-
12680
# CSS Targeting
12781

12882
`tsdown` can also downlevel CSS features to match your specified browser targets. For example, a CSS nesting `&` selector will be flattened if the target is `chrome108` or lower.

docs/zh-CN/options/target.md

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@
3636
```
3737

3838
`target` 设置为 `false` 时:
39+
3940
- 不会进行 JavaScript 语法降级(现代特性如可选链 `?.`、空值合并 `??` 等会被保留)
4041
- 不会应用 CSS 语法转换(现代 CSS 特性如嵌套会被保留)
4142
- 不会加载运行时辅助插件
4243
- 输出将使用源代码中的确切语法
4344

4445
这在以下情况下特别有用:
46+
4547
- 您的目标是支持最新 JavaScript/CSS 特性的现代环境
4648
- 您希望在不同的构建步骤中处理语法转换
4749
- 您正在构建一个将由使用应用程序进一步处理的库
@@ -75,54 +77,6 @@ tsdown --target es2020
7577
tsdown --target chrome100 --target node20.18
7678
```
7779

78-
## 运行时辅助工具
79-
80-
在降级某些现代 JavaScript 特性时,`tsdown` 可能需要由 `@oxc-project/runtime` 包提供的运行时辅助工具。例如,将 `await` 表达式转换为旧语法时,需要使用辅助工具 `@oxc-project/runtime/helpers/asyncToGenerator`
81-
82-
如果您的目标环境包含需要这些辅助工具的特性,您可能需要在项目中安装 `@oxc-project/runtime` 包:
83-
84-
::: code-group
85-
86-
```sh [npm]
87-
npm install @oxc-project/runtime
88-
```
89-
90-
```sh [pnpm]
91-
pnpm add @oxc-project/runtime
92-
```
93-
94-
```sh [yarn]
95-
yarn add @oxc-project/runtime
96-
```
97-
98-
```sh [bun]
99-
bun add @oxc-project/runtime
100-
```
101-
102-
:::
103-
104-
如果您希望**内联辅助函数**,而不是从运行时包中导入它们,可以将 `@oxc-project/runtime` 作为开发依赖进行安装:
105-
106-
::: code-group
107-
108-
```sh [npm]
109-
npm install -D @oxc-project/runtime
110-
```
111-
112-
```sh [pnpm]
113-
pnpm add -D @oxc-project/runtime
114-
```
115-
116-
```sh [yarn]
117-
yarn add -D @oxc-project/runtime
118-
```
119-
120-
```sh [bun]
121-
bun add -D @oxc-project/runtime
122-
```
123-
124-
:::
125-
12680
# CSS 目标
12781

12882
`tsdown` 也可以将 CSS 特性降级以匹配您指定的浏览器目标。例如,如果目标是 `chrome108` 或更低版本,CSS 嵌套的 `&` 选择器将被展开为平铺结构。

src/features/rolldown.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { resolveChunkAddon, resolveChunkFilename } from './output'
1515
import { ReportPlugin } from './report'
1616
import { ShebangPlugin } from './shebang'
1717
import { getShimsInject } from './shims'
18-
import { RuntimeHelperCheckPlugin } from './target'
1918
import type {
2019
BuildOptions,
2120
InputOptions,
@@ -128,7 +127,6 @@ export async function resolveInputOptions(
128127
}
129128
if (target) {
130129
plugins.push(
131-
RuntimeHelperCheckPlugin(logger, target),
132130
// Use Lightning CSS to handle CSS input. This is a temporary solution
133131
// until Rolldown supports CSS syntax lowering natively.
134132
await LightningCSSPlugin({ target }),

src/features/target.ts

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import { blue } from 'ansis'
21
import minVersion from 'semver/ranges/min-version.js'
32
import { resolveComma, toArray } from '../utils/general'
43
import { generateColor, prettyName, type Logger } from '../utils/logger'
54
import type { PackageJson } from 'pkg-types'
6-
import type { Plugin } from 'rolldown'
75

86
export function resolveTarget(
97
logger: Logger,
@@ -38,34 +36,3 @@ export function resolvePackageTarget(pkg?: PackageJson): string | undefined {
3836
if (nodeMinVersion.version === '0.0.0') return
3937
return `node${nodeMinVersion.version}`
4038
}
41-
42-
let warned = false
43-
export function RuntimeHelperCheckPlugin(
44-
logger: Logger,
45-
targets: string[],
46-
): Plugin {
47-
return {
48-
name: 'tsdown:runtime-helper-check',
49-
resolveId: {
50-
filter: { id: /^@oxc-project\/runtime/ },
51-
async handler(id, ...args) {
52-
const EXTERNAL = { id, external: true }
53-
if (warned) return EXTERNAL
54-
55-
const resolved = await this.resolve(id, ...args)
56-
if (!resolved) {
57-
if (!warned) {
58-
warned = true
59-
logger.warn(
60-
`The target environment (${targets.join(', ')}) requires runtime helpers from ${blue`@oxc-project/runtime`}. ` +
61-
`Please install it to ensure all necessary polyfills are included.\n` +
62-
`For more information, visit: https://tsdown.dev/options/target#runtime-helpers`,
63-
)
64-
}
65-
return EXTERNAL
66-
}
67-
return resolved
68-
},
69-
},
70-
}
71-
}

0 commit comments

Comments
 (0)