Skip to content

Commit 507661c

Browse files
committed
feat!: remove deprecated tsup compatibility options
Remove `inlineOnly`, `removeNodeProtocol`, `bundle`, `outExtension`, `injectStyle`, `publicDir` and the `--public-dir` CLI flag. tsdown-migrate now pins migrated projects to tsdown@^0.22.13, the last version accepting these options, so tsup users can resolve deprecation warnings before upgrading.
1 parent f2a3d8e commit 507661c

27 files changed

Lines changed: 99 additions & 481 deletions

__snapshots__/tsnapi/config.snapshot.d.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,6 @@ export interface UserConfig {
6767
workspace?: Workspace | Arrayable<string> | true;
6868
external?: ExternalOption;
6969
noExternal?: Arrayable<string | RegExp> | NoExternalFn;
70-
inlineOnly?: Arrayable<string | RegExp> | false;
71-
removeNodeProtocol?: boolean;
72-
bundle?: boolean;
73-
outExtension?: OutExtensionFactory;
74-
injectStyle?: boolean;
75-
publicDir?: CopyOptions | CopyOptionsFn;
7670
}
7771
// #endregion
7872

__snapshots__/tsnapi/index.snapshot.d.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,6 @@ export interface UserConfig {
194194
workspace?: Workspace | Arrayable<string> | true;
195195
external?: ExternalOption;
196196
noExternal?: Arrayable<string | RegExp> | NoExternalFn;
197-
inlineOnly?: Arrayable<string | RegExp> | false;
198-
removeNodeProtocol?: boolean;
199-
bundle?: boolean;
200-
outExtension?: OutExtensionFactory;
201-
injectStyle?: boolean;
202-
publicDir?: CopyOptions | CopyOptionsFn;
203197
}
204198
export interface Workspace {
205199
include?: "auto" | (string & {}) | string[];
@@ -222,7 +216,7 @@ export type NoExternalFn = (_: string, _: string | undefined) => boolean | null
222216
export type NormalizedFormat = InternalModuleFormat;
223217
export type OutExtensionFactory = (_: OutExtensionContext) => OutExtensionObject | undefined;
224218
export type PackageType = "module" | "commonjs" | undefined;
225-
export type ResolvedConfig = Overwrite<MarkPartial<Omit<UserConfig, "workspace" | "fromVite" | "publicDir" | "bundle" | "injectStyle" | "removeNodeProtocol" | "outExtension" | "external" | "noExternal" | "inlineOnly" | "logLevel" | "failOnWarn" | "suppressWarnings" | "customLogger" | "envFile" | "envPrefix">, "globalName" | "inputOptions" | "outputOptions" | "minify" | "define" | "alias" | "onSuccess" | "outExtensions" | "hooks" | "copy" | "loader" | "name" | "banner" | "footer" | "checks" | "css">, {
219+
export type ResolvedConfig = Overwrite<MarkPartial<Omit<UserConfig, "workspace" | "fromVite" | "external" | "noExternal" | "logLevel" | "failOnWarn" | "suppressWarnings" | "customLogger" | "envFile" | "envPrefix">, "globalName" | "inputOptions" | "outputOptions" | "minify" | "define" | "alias" | "onSuccess" | "outExtensions" | "hooks" | "copy" | "loader" | "name" | "banner" | "footer" | "checks" | "css">, {
226220
entry: Record<string, string>;
227221
rawEntry?: TsdownInputOption;
228222
nameLabel: string | undefined;

docs/guide/migrate-from-tsup.md

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ npx tsdown-migrate packages/foo packages/bar
2828
> [!TIP]
2929
> The migration tool will automatically install dependencies after migration. Make sure to run the command from within your project directory.
3030
31+
> [!IMPORTANT]
32+
> The migration tool installs **tsdown v0.22.13**, the last version that still accepts deprecated tsup-compatible options (with warnings). Newer versions of tsdown have removed these options entirely. Run your build on v0.22.13, resolve **all** deprecation warnings, and then upgrade `tsdown` to the latest version.
33+
3134
### Migration Options
3235

3336
The `migrate` command supports the following options to customize the migration process:
@@ -54,26 +57,28 @@ While `tsdown` aims to be highly compatible with `tsup`, there are some differen
5457

5558
Some options have been renamed for clarity:
5659

57-
| tsup | tsdown | Notes |
58-
| ----------------------- | ----------------------------- | ---------------------------------- |
59-
| `cjsInterop` | `cjsDefault` | CJS default export handling |
60-
| `esbuildPlugins` | `plugins` | Now uses Rolldown/Unplugin plugins |
61-
| `outExtension` | `outExtensions` | Custom output extensions |
62-
| `skipNodeModulesBundle` | `deps: { neverBundle: true }` | Externalize all dependencies |
60+
| tsup | tsdown | Notes |
61+
| -------------------------- | ----------------------------- | ---------------------------------- |
62+
| `entryPoints` | `entry` | Also deprecated in tsup itself |
63+
| `cjsInterop` | `cjsDefault` | CJS default export handling |
64+
| `esbuildPlugins` | `plugins` | Now uses Rolldown/Unplugin plugins |
65+
| `outExtension` | `outExtensions` | Custom output extensions |
66+
| `skipNodeModulesBundle` | `deps: { neverBundle: true }` | Externalize all dependencies |
67+
| `publicDir` | `copy` | Copy static files to output |
68+
| `bundle: false` | `unbundle: true` | Inverted to positive form |
69+
| `removeNodeProtocol: true` | `nodeProtocol: 'strip'` | More flexible with multiple modes |
70+
| `injectStyle: true` | `css: { inject: true }` | Moved into CSS namespace |
71+
72+
None of the old names work in the latest tsdown. Those that previously emitted deprecation warnings (`outExtension`, `skipNodeModulesBundle`, `publicDir`, `bundle`, `removeNodeProtocol`, `injectStyle`) were accepted up to tsdown v0.22.13 — if your config still uses any of them, migrate on v0.22.13 first.
6373

6474
### Deprecated but Compatible Options
6575

6676
The following tsup options still work in tsdown for backward compatibility, but they emit deprecation warnings and **will be removed in a future version**. Migrate them to the preferred alternatives immediately.
6777

68-
| tsup (deprecated) | tsdown (preferred) | Notes |
69-
| -------------------------- | ------------------------------- | --------------------------------- |
70-
| `entryPoints` | `entry` | Also deprecated in tsup itself |
71-
| `publicDir` | `copy` | Copy static files to output |
72-
| `bundle: false` | `unbundle: true` | Inverted to positive form |
73-
| `removeNodeProtocol: true` | `nodeProtocol: 'strip'` | More flexible with multiple modes |
74-
| `injectStyle: true` | `css: { inject: true }` | Moved into CSS namespace |
75-
| `external: [...]` | `deps: { neverBundle: [...] }` | Moved to deps namespace |
76-
| `noExternal: [...]` | `deps: { alwaysBundle: [...] }` | Moved to deps namespace |
78+
| tsup (deprecated) | tsdown (preferred) | Notes |
79+
| ------------------- | ------------------------------- | ----------------------- |
80+
| `external: [...]` | `deps: { neverBundle: [...] }` | Moved to deps namespace |
81+
| `noExternal: [...]` | `deps: { alwaysBundle: [...] }` | Moved to deps namespace |
7782

7883
tsdown also adds `deps.onlyBundle` for whitelisting allowed bundled packages.
7984

docs/options/dependencies.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ The following top-level options are deprecated. Please migrate to the `deps` nam
200200
| ----------------- | ------------------- |
201201
| `external` | `deps.neverBundle` |
202202
| `noExternal` | `deps.alwaysBundle` |
203-
| `inlineOnly` | `deps.onlyBundle` |
204203

205204
## Summary
206205

docs/reference/cli.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,6 @@ tsdown --copy public
245245

246246
All contents of the `public` directory will be copied to your output directory (e.g., `dist`).
247247

248-
## `--public-dir <dir>`
249-
250-
::: warning Deprecated
251-
Please use `--copy` instead.
252-
:::
253-
254-
An alias for `--copy`.
255-
256248
## `--exe`
257249

258250
**[experimental]** Bundle as a standalone executable using [Node.js Single Executable Applications](https://nodejs.org/api/single-executable-applications.html).

docs/zh-CN/guide/migrate-from-tsup.md

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ npx tsdown-migrate packages/foo packages/bar
2828
> [!TIP]
2929
> 迁移工具会在迁移后自动安装依赖。请确保在项目目录下运行该命令。
3030
31+
> [!IMPORTANT]
32+
> 迁移工具会安装 **tsdown v0.22.13**——这是最后一个仍接受已弃用的 tsup 兼容选项(并发出警告)的版本。更新的 tsdown 版本已完全移除这些选项。请先在 v0.22.13 上运行构建,解决**所有**弃用警告,然后再将 `tsdown` 升级到最新版本。
33+
3134
### 迁移选项
3235

3336
`migrate` 命令支持以下选项,用于自定义迁移过程:
@@ -54,26 +57,28 @@ npx tsdown-migrate packages/foo packages/bar
5457

5558
部分选项已重命名以提高清晰度:
5659

57-
| tsup | tsdown | 说明 |
58-
| ----------------------- | ----------------------------- | ----------------------------- |
59-
| `cjsInterop` | `cjsDefault` | CJS 默认导出处理 |
60-
| `esbuildPlugins` | `plugins` | 现使用 Rolldown/Unplugin 插件 |
61-
| `outExtension` | `outExtensions` | 自定义输出扩展名 |
62-
| `skipNodeModulesBundle` | `deps: { neverBundle: true }` | 外部化所有依赖 |
60+
| tsup | tsdown | 说明 |
61+
| -------------------------- | ----------------------------- | ----------------------------- |
62+
| `entryPoints` | `entry` | 在 tsup 中也已弃用 |
63+
| `cjsInterop` | `cjsDefault` | CJS 默认导出处理 |
64+
| `esbuildPlugins` | `plugins` | 现使用 Rolldown/Unplugin 插件 |
65+
| `outExtension` | `outExtensions` | 自定义输出扩展名 |
66+
| `skipNodeModulesBundle` | `deps: { neverBundle: true }` | 外部化所有依赖 |
67+
| `publicDir` | `copy` | 复制静态文件到输出目录 |
68+
| `bundle: false` | `unbundle: true` | 转换为正向表达 |
69+
| `removeNodeProtocol: true` | `nodeProtocol: 'strip'` | 更灵活,支持多种模式 |
70+
| `injectStyle: true` | `css: { inject: true }` | 移入 CSS 命名空间 |
71+
72+
以上旧名称在最新版 tsdown 中均不可用。其中曾发出弃用警告的选项(`outExtension``skipNodeModulesBundle``publicDir``bundle``removeNodeProtocol``injectStyle`)在 tsdown v0.22.13 及之前的版本中仍可使用——如果您的配置仍在使用它们,请先在 v0.22.13 上完成迁移。
6373

6474
### 已弃用但兼容的选项
6575

6676
以下 tsup 选项在 tsdown 中仍然可用(向后兼容),但会发出弃用警告,**未来版本将会移除**。请立即迁移到推荐的替代方案。
6777

68-
| tsup(已弃用) | tsdown(推荐) | 说明 |
69-
| -------------------------- | ------------------------------- | ---------------------- |
70-
| `entryPoints` | `entry` | 在 tsup 中也已弃用 |
71-
| `publicDir` | `copy` | 复制静态文件到输出目录 |
72-
| `bundle: false` | `unbundle: true` | 转换为正向表达 |
73-
| `removeNodeProtocol: true` | `nodeProtocol: 'strip'` | 更灵活,支持多种模式 |
74-
| `injectStyle: true` | `css: { inject: true }` | 移入 CSS 命名空间 |
75-
| `external: [...]` | `deps: { neverBundle: [...] }` | 移入 deps 命名空间 |
76-
| `noExternal: [...]` | `deps: { alwaysBundle: [...] }` | 移入 deps 命名空间 |
78+
| tsup(已弃用) | tsdown(推荐) | 说明 |
79+
| ------------------- | ------------------------------- | ------------------ |
80+
| `external: [...]` | `deps: { neverBundle: [...] }` | 移入 deps 命名空间 |
81+
| `noExternal: [...]` | `deps: { alwaysBundle: [...] }` | 移入 deps 命名空间 |
7782

7883
tsdown 还新增了 `deps.onlyBundle`,用于白名单指定允许打包的依赖。
7984

docs/zh-CN/options/dependencies.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ export default defineConfig({
200200
| ------------ | ------------------- |
201201
| `external` | `deps.neverBundle` |
202202
| `noExternal` | `deps.alwaysBundle` |
203-
| `inlineOnly` | `deps.onlyBundle` |
204203

205204
## 总结
206205

docs/zh-CN/reference/cli.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,6 @@ tsdown --copy public
245245

246246
`public` 目录中的所有内容将被复制到您的输出目录(如 `dist`)。
247247

248-
## `--public-dir <dir>`
249-
250-
::: warning 已废弃
251-
请使用 `--copy` 代替。
252-
:::
253-
254-
`--copy` 的别名。
255-
256248
## `--exe`
257249

258250
**[实验性]** 使用 [Node.js 单个可执行程序](https://nodejs.org/api/single-executable-applications.html)将输出打包为独立可执行文件。

packages/migrate/src/helpers/package-json.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@ import { readFile, writeFile } from 'node:fs/promises'
33
import consola from 'consola'
44
import { createPatch } from 'diff'
55
import { detectIndentation } from '../../../../src/utils/json.ts'
6-
import pkg from '../../package.json' with { type: 'json' }
76
import { outputDiff, renameKey } from '../utils.ts'
87

8+
// Migrated projects are pinned to the last v0.22.x release, which still
9+
// accepts deprecated tsup-compatible options (with warnings). Users should
10+
// resolve all deprecation warnings on this version before upgrading tsdown.
11+
const TSDOWN_VERSION = '^0.22.13'
12+
913
const DEP_FIELDS = {
10-
dependencies: `^${pkg.version}`,
11-
devDependencies: `^${pkg.version}`,
12-
optionalDependencies: `^${pkg.version}`,
14+
dependencies: TSDOWN_VERSION,
15+
devDependencies: TSDOWN_VERSION,
16+
optionalDependencies: TSDOWN_VERSION,
1317
peerDependencies: '*',
1418
peerDependenciesMeta: null,
1519
} as const

packages/migrate/src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,9 @@ export async function migrate({ dirs, dryRun }: MigrateOptions): Promise<void> {
8585
await run(parseNi, [], { cwd: baseCwd })
8686
consola.success('Dependencies installed.')
8787
}
88+
89+
consola.box(
90+
`Your project now uses tsdown v0.22, the last version that accepts deprecated tsup-compatible options.\n` +
91+
`Run your build, resolve all deprecation warnings, then upgrade tsdown to the latest version.`,
92+
)
8893
}

0 commit comments

Comments
 (0)