From f1bf7f9ffcb8762497b2c10c9229a2f52c454e90 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Tue, 10 Mar 2026 18:49:48 +0100 Subject: [PATCH 1/3] feat: rename onlyAllowBundle to onlyBundle --- docs/guide/how-it-works.md | 2 +- docs/options/dependencies.md | 21 ++++---- docs/zh-CN/guide/how-it-works.md | 2 +- docs/zh-CN/options/dependencies.md | 21 ++++---- dts.snapshot.json | 4 +- skills/tsdown/SKILL.md | 2 +- .../tsdown/references/option-dependencies.md | 11 ++-- src/config/types.ts | 2 +- src/features/deps.ts | 53 ++++++++++++------- ...elisted-dependencies-to-be-bundled.snap.md | 0 .../should-warn-for-unused-patterns.snap.md | 0 tests/e2e.test.ts | 8 +-- tsdown.config.ts | 4 +- 13 files changed, 74 insertions(+), 56 deletions(-) rename tests/__snapshots__/{onlyAllowBundle => onlyBundle}/should-allow-whitelisted-dependencies-to-be-bundled.snap.md (100%) rename tests/__snapshots__/{onlyAllowBundle => onlyBundle}/should-warn-for-unused-patterns.snap.md (100%) diff --git a/docs/guide/how-it-works.md b/docs/guide/how-it-works.md index 5b4813db3..e03c78334 100644 --- a/docs/guide/how-it-works.md +++ b/docs/guide/how-it-works.md @@ -35,7 +35,7 @@ When you publish a library, your consumers install its `dependencies` and `peerD | Option | What it does | | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [`deps.onlyAllowBundle`](../options/dependencies.md#deps-onlyallowbundle) | Whitelist of dependencies allowed to be bundled. Any unlisted dependency that ends up in the bundle causes an error. Useful for catching accidental inlining in large projects. | +| [`deps.onlyBundle`](../options/dependencies.md#deps-onlybundle) | Whitelist of dependencies allowed to be bundled. Any unlisted dependency that ends up in the bundle causes an error. Useful for catching accidental inlining in large projects. | | [`deps.neverBundle`](../options/dependencies.md#deps-neverbundle) | Explicitly mark additional packages as external (never bundled). | | [`deps.alwaysBundle`](../options/dependencies.md#deps-alwaysbundle) | Force specific packages to be bundled, even if they're in `dependencies`. | | [`deps.skipNodeModulesBundle`](../options/dependencies.md#deps-skipnodemodulebundle) | Skip resolving and bundling everything from `node_modules`. | diff --git a/docs/options/dependencies.md b/docs/options/dependencies.md index f3cecdcf4..78b1a5d37 100644 --- a/docs/options/dependencies.md +++ b/docs/options/dependencies.md @@ -29,7 +29,7 @@ export default defineConfig({ deps: { neverBundle: ['lodash', /^@my-scope\//], alwaysBundle: ['some-package'], - onlyAllowBundle: ['cac', 'bumpp'], + onlyBundle: ['cac', 'bumpp'], skipNodeModulesBundle: true, }, }) @@ -55,16 +55,16 @@ This will prevent `tsdown` from parsing and bundling any dependencies from `node `skipNodeModulesBundle` cannot be used together with `alwaysBundle`. These options are mutually exclusive. ::: -### `deps.onlyAllowBundle` +### `deps.onlyBundle` -The `onlyAllowBundle` option acts as a whitelist for dependencies that are allowed to be bundled from `node_modules`. If any dependency not in the list is found in the bundle, tsdown will throw an error. This is useful for preventing unexpected dependencies from being silently inlined into your output, especially in large projects. +The `onlyBundle` option acts as a whitelist for dependencies that are allowed to be bundled from `node_modules`. If any dependency not in the list is found in the bundle, tsdown will throw an error. This is useful for preventing unexpected dependencies from being silently inlined into your output, especially in large projects. ```ts [tsdown.config.ts] import { defineConfig } from 'tsdown' export default defineConfig({ deps: { - onlyAllowBundle: ['cac', 'bumpp'], + onlyBundle: ['cac', 'bumpp'], }, }) ``` @@ -73,12 +73,12 @@ In this example, only `cac` and `bumpp` are allowed to be bundled. If any other #### Behavior -- **`onlyAllowBundle` is an array** (e.g., `['cac', /^my-/]`): Only dependencies matching the list are allowed to be bundled. An error is thrown for any others. Unused patterns in the list will also be reported. -- **`onlyAllowBundle` is `false`**: All warnings and checks about bundled dependencies are suppressed. -- **`onlyAllowBundle` is not set** (default): A warning is shown if any `node_modules` dependencies are bundled, suggesting you add the `onlyAllowBundle` option or set it to `false` to suppress warnings. +- **`onlyBundle` is an array** (e.g., `['cac', /^my-/]`): Only dependencies matching the list are allowed to be bundled. An error is thrown for any others. Unused patterns in the list will also be reported. +- **`onlyBundle` is `false`**: All warnings and checks about bundled dependencies are suppressed. +- **`onlyBundle` is not set** (default): A warning is shown if any `node_modules` dependencies are bundled, suggesting you add the `onlyBundle` option or set it to `false` to suppress warnings. ::: tip -Make sure to include all required sub-dependencies in the `onlyAllowBundle` list as well, not just the top-level packages you directly import. +Make sure to include all required sub-dependencies in the `onlyBundle` list as well, not just the top-level packages you directly import. ::: ### `deps.neverBundle` @@ -141,7 +141,8 @@ The following top-level options are deprecated. Please migrate to the `deps` nam | ----------------------- | ---------------------------- | | `external` | `deps.neverBundle` | | `noExternal` | `deps.alwaysBundle` | -| `inlineOnly` | `deps.onlyAllowBundle` | +| `inlineOnly` | `deps.onlyBundle` | +| `onlyAllowBundle` | `deps.onlyBundle` | | `skipNodeModulesBundle` | `deps.skipNodeModulesBundle` | ## Summary @@ -150,7 +151,7 @@ The following top-level options are deprecated. Please migrate to the `deps` nam - `dependencies` and `peerDependencies` are treated as external and not bundled. - `devDependencies` and phantom dependencies are only bundled if they are actually used in your code. - **Customization**: - - Use `deps.onlyAllowBundle` to whitelist dependencies allowed to be bundled, and throw an error for any others. + - Use `deps.onlyBundle` to whitelist dependencies allowed to be bundled, and throw an error for any others. - Use `deps.neverBundle` to mark specific dependencies as external. - Use `deps.alwaysBundle` to force specific dependencies to be bundled. - Use `deps.skipNodeModulesBundle` to skip resolving and bundling all dependencies from `node_modules`. diff --git a/docs/zh-CN/guide/how-it-works.md b/docs/zh-CN/guide/how-it-works.md index 2c3669150..8edcf5680 100644 --- a/docs/zh-CN/guide/how-it-works.md +++ b/docs/zh-CN/guide/how-it-works.md @@ -35,7 +35,7 @@ tsdown 读取你的 `package.json` 和 `tsconfig.json` 来推断合理的默认 | 选项 | 说明 | | ------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------- | -| [`deps.onlyAllowBundle`](../options/dependencies.md#deps-onlyallowbundle) | 允许打包的依赖白名单。任何不在列表中的依赖如果出现在 bundle 中将触发错误。适用于防止大型项目中的意外内联。 | +| [`deps.onlyBundle`](../options/dependencies.md#deps-onlybundle) | 允许打包的依赖白名单。任何不在列表中的依赖如果出现在 bundle 中将触发错误。适用于防止大型项目中的意外内联。 | | [`deps.neverBundle`](../options/dependencies.md#deps-neverbundle) | 显式将额外的包标记为外部依赖(不打包)。 | | [`deps.alwaysBundle`](../options/dependencies.md#deps-alwaysbundle) | 强制打包特定的包,即使它们在 `dependencies` 中。 | | [`deps.skipNodeModulesBundle`](../options/dependencies.md#deps-skipnodemodulebundle) | 跳过解析和打包所有来自 `node_modules` 的内容。 | diff --git a/docs/zh-CN/options/dependencies.md b/docs/zh-CN/options/dependencies.md index ad7cd3639..ed16284d4 100644 --- a/docs/zh-CN/options/dependencies.md +++ b/docs/zh-CN/options/dependencies.md @@ -29,7 +29,7 @@ export default defineConfig({ deps: { neverBundle: ['lodash', /^@my-scope\//], alwaysBundle: ['some-package'], - onlyAllowBundle: ['cac', 'bumpp'], + onlyBundle: ['cac', 'bumpp'], skipNodeModulesBundle: true, }, }) @@ -55,16 +55,16 @@ export default defineConfig({ `skipNodeModulesBundle` 不能与 `alwaysBundle` 一起使用,这两个选项互斥。 ::: -### `deps.onlyAllowBundle` +### `deps.onlyBundle` -`onlyAllowBundle` 选项作为允许从 `node_modules` 中打包的依赖白名单。如果有任何不在列表中的依赖被打包,tsdown 将抛出错误。这对于防止意外的依赖被静默内联到输出文件中非常有用,尤其是在大型项目中可能存在许多依赖的情况下。 +`onlyBundle` 选项作为允许从 `node_modules` 中打包的依赖白名单。如果有任何不在列表中的依赖被打包,tsdown 将抛出错误。这对于防止意外的依赖被静默内联到输出文件中非常有用,尤其是在大型项目中可能存在许多依赖的情况下。 ```ts [tsdown.config.ts] import { defineConfig } from 'tsdown' export default defineConfig({ deps: { - onlyAllowBundle: ['cac', 'bumpp'], + onlyBundle: ['cac', 'bumpp'], }, }) ``` @@ -73,12 +73,12 @@ export default defineConfig({ #### 行为 -- **`onlyAllowBundle` 为数组**(例如 `['cac', /^my-/]`):只有匹配列表的依赖才允许被打包,其他依赖会触发错误。列表中未使用的模式也会被报告。 -- **`onlyAllowBundle` 为 `false`**:抑制所有关于打包依赖的警告和检查。 -- **`onlyAllowBundle` 未设置**(默认):如果有 `node_modules` 依赖被打包,会显示一条警告,建议您添加 `onlyAllowBundle` 选项或将其设置为 `false` 来抑制警告。 +- **`onlyBundle` 为数组**(例如 `['cac', /^my-/]`):只有匹配列表的依赖才允许被打包,其他依赖会触发错误。列表中未使用的模式也会被报告。 +- **`onlyBundle` 为 `false`**:抑制所有关于打包依赖的警告和检查。 +- **`onlyBundle` 未设置**(默认):如果有 `node_modules` 依赖被打包,会显示一条警告,建议您添加 `onlyBundle` 选项或将其设置为 `false` 来抑制警告。 ::: tip -请确保在 `onlyAllowBundle` 中包含所有子依赖,不仅是直接导入的顶层包。 +请确保在 `onlyBundle` 中包含所有子依赖,不仅是直接导入的顶层包。 ::: ### `deps.neverBundle` @@ -141,7 +141,8 @@ export default defineConfig({ | ----------------------- | ---------------------------- | | `external` | `deps.neverBundle` | | `noExternal` | `deps.alwaysBundle` | -| `inlineOnly` | `deps.onlyAllowBundle` | +| `inlineOnly` | `deps.onlyBundle` | +| `onlyAllowBundle` | `deps.onlyBundle` | | `skipNodeModulesBundle` | `deps.skipNodeModulesBundle` | ## 总结 @@ -150,7 +151,7 @@ export default defineConfig({ - `dependencies` 和 `peerDependencies` 被视为外部依赖,不会被打包。 - `devDependencies` 和幻影依赖只有在代码中实际使用时才会被打包。 - **自定义**: - - 使用 `deps.onlyAllowBundle` 设置允许被打包的依赖白名单,不在列表中的依赖会触发错误。 + - 使用 `deps.onlyBundle` 设置允许被打包的依赖白名单,不在列表中的依赖会触发错误。 - 使用 `deps.neverBundle` 将特定依赖标记为外部依赖。 - 使用 `deps.alwaysBundle` 强制将特定依赖打包。 - 使用 `deps.skipNodeModulesBundle` 跳过解析和打包所有来自 `node_modules` 的依赖。 diff --git a/dts.snapshot.json b/dts.snapshot.json index 137760819..a3ade1d28 100644 --- a/dts.snapshot.json +++ b/dts.snapshot.json @@ -125,7 +125,7 @@ "CopyOptions": "type CopyOptions = Arrayable", "CopyOptionsFn": "type CopyOptionsFn = (_: ResolvedConfig) => Awaitable", "DepPlugin": "declare function DepPlugin(_: ResolvedConfig, _: TsdownBundle): Plugin", - "DepsConfig": "interface DepsConfig {\n neverBundle?: ExternalOption\n alwaysBundle?: Arrayable | NoExternalFn\n onlyAllowBundle?: Arrayable | false\n skipNodeModulesBundle?: boolean\n}", + "DepsConfig": "interface DepsConfig {\n neverBundle?: ExternalOption\n alwaysBundle?: Arrayable | NoExternalFn\n onlyBundle?: Arrayable | false\n onlyAllowBundle?: Arrayable | false\n skipNodeModulesBundle?: boolean\n}", "DevtoolsOptions": "interface DevtoolsOptions extends NonNullable {\n ui?: boolean | Partial\n clean?: boolean\n}", "ExeOptions": "interface ExeOptions extends ExeExtensionOptions {\n seaConfig?: Omit\n fileName?: string | ((_: RolldownChunk) => string)\n outDir?: string\n}", "ExportsOptions": "interface ExportsOptions {\n devExports?: boolean | string\n packageJson?: boolean\n all?: boolean\n exclude?: (RegExp | string)[]\n legacy?: boolean\n customExports?: Record | ((_: Record, _: { pkg: PackageJson; chunks: ChunksByFormat; isPublish: boolean }) => Awaitable>)\n inlinedDependencies?: boolean\n}", @@ -154,7 +154,7 @@ "ReportOptions": "interface ReportOptions {\n gzip?: boolean\n brotli?: boolean\n maxCompressSize?: number\n}", "ReportPlugin": "declare function ReportPlugin(_: ResolvedConfig, _: boolean, _: boolean): Plugin", "ResolvedConfig": "type ResolvedConfig = Overwrite, 'globalName' | 'inputOptions' | 'outputOptions' | 'minify' | 'define' | 'alias' | 'onSuccess' | 'outExtensions' | 'hooks' | 'copy' | 'loader' | 'name' | 'banner' | 'footer' | 'checks' | 'css'>, { entry: Record; rawEntry?: TsdownInputOption; nameLabel: string | undefined; format: NormalizedFormat; target?: string[]; clean: string[]; pkg?: PackageJsonWithPath; nodeProtocol: 'strip' | boolean; logger: Logger; ignoreWatch: Array; deps: ResolvedDepsConfig; root: string; dts: false | DtsOptions; report: false | ReportOptions; tsconfig: false | string; exports: false | ExportsOptions; devtools: false | DevtoolsOptions; publint: false | PublintOptions; attw: false | AttwOptions; unused: false | UnusedOptions; exe: false | ExeOptions }>", - "ResolvedDepsConfig": "interface ResolvedDepsConfig {\n neverBundle?: ExternalOption\n alwaysBundle?: NoExternalFn\n onlyAllowBundle?: Array | false\n skipNodeModulesBundle: boolean\n}", + "ResolvedDepsConfig": "interface ResolvedDepsConfig {\n neverBundle?: ExternalOption\n alwaysBundle?: NoExternalFn\n onlyBundle?: Array | false\n skipNodeModulesBundle: boolean\n}", "RolldownChunk": "type RolldownChunk = (OutputChunk | OutputAsset) & { outDir: string }", "RolldownContext": "interface RolldownContext {\n buildOptions: BuildOptions\n}", "SeaConfig": "interface SeaConfig {\n main?: string\n executable?: string\n output?: string\n mainFormat?: 'commonjs' | 'module'\n disableExperimentalSEAWarning?: boolean\n useSnapshot?: boolean\n useCodeCache?: boolean\n execArgv?: string[]\n execArgvExtension?: 'none' | 'env' | 'cli'\n assets?: Record\n}", diff --git a/skills/tsdown/SKILL.md b/skills/tsdown/SKILL.md index 39c78130f..356130a8e 100644 --- a/skills/tsdown/SKILL.md +++ b/skills/tsdown/SKILL.md @@ -85,7 +85,7 @@ export default defineConfig({ |---------|-------|-----------| | Never bundle | `deps: { neverBundle: ['react', /^@myorg\//] }` | [option-dependencies](references/option-dependencies.md) | | Always bundle | `deps: { alwaysBundle: ['dep-to-bundle'] }` | [option-dependencies](references/option-dependencies.md) | -| Only allow bundle | `deps: { onlyAllowBundle: ['cac', 'bumpp'] }` - Whitelist | [option-dependencies](references/option-dependencies.md) | +| Only bundle | `deps: { onlyBundle: ['cac', 'bumpp'] }` - Whitelist | [option-dependencies](references/option-dependencies.md) | | Skip node_modules | `deps: { skipNodeModulesBundle: true }` | [option-dependencies](references/option-dependencies.md) | | Auto external | Automatic peer/dependency externalization | [option-dependencies](references/option-dependencies.md) | diff --git a/skills/tsdown/references/option-dependencies.md b/skills/tsdown/references/option-dependencies.md index a6f1481a7..52162c4f9 100644 --- a/skills/tsdown/references/option-dependencies.md +++ b/skills/tsdown/references/option-dependencies.md @@ -31,7 +31,7 @@ export default defineConfig({ deps: { neverBundle: ['react', /^@myorg\//], alwaysBundle: ['some-package'], - onlyAllowBundle: ['cac', 'bumpp'], + onlyBundle: ['cac', 'bumpp'], skipNodeModulesBundle: true, }, }) @@ -71,7 +71,7 @@ export default defineConfig({ }) ``` -### `deps.onlyAllowBundle` +### `deps.onlyBundle` Whitelist of dependencies allowed to be bundled from node_modules. Throws an error if any unlisted dependency is bundled: @@ -79,7 +79,7 @@ Whitelist of dependencies allowed to be bundled from node_modules. Throws an err export default defineConfig({ entry: ['src/index.ts'], deps: { - onlyAllowBundle: [ + onlyBundle: [ 'cac', // Allow bundling cac 'bumpp', // Allow bundling bumpp /^my-utils/, // Regex patterns supported @@ -235,7 +235,8 @@ tsdown --deps.skip-node-modules-bundle |---|---| | `external` | `deps.neverBundle` | | `noExternal` | `deps.alwaysBundle` | -| `inlineOnly` | `deps.onlyAllowBundle` | +| `inlineOnly` | `deps.onlyBundle` | +| `onlyAllowBundle` | `deps.onlyBundle` | | `skipNodeModulesBundle` | `deps.skipNodeModulesBundle` | ## Examples by Use Case @@ -359,7 +360,7 @@ export default defineConfig({ **Override (under `deps`):** - `neverBundle` → Force external - `alwaysBundle` → Force bundled -- `onlyAllowBundle` → Whitelist bundled deps +- `onlyBundle` → Whitelist bundled deps - `skipNodeModulesBundle` → Skip all node_modules **Declaration files:** diff --git a/src/config/types.ts b/src/config/types.ts index 9be385b08..e67e35514 100644 --- a/src/config/types.ts +++ b/src/config/types.ts @@ -166,7 +166,7 @@ export interface UserConfig { */ noExternal?: Arrayable | NoExternalFn /** - * @deprecated Use `deps.onlyAllowBundle` instead. + * @deprecated Use `deps.onlyBundle` instead. */ inlineOnly?: Arrayable | false /** diff --git a/src/features/deps.ts b/src/features/deps.ts index 2775b3f23..87fd67a96 100644 --- a/src/features/deps.ts +++ b/src/features/deps.ts @@ -51,6 +51,10 @@ export interface DepsConfig { * * Note: Be sure to include all required sub-dependencies as well. */ + onlyBundle?: Arrayable | false + /** + * @deprecated Use `deps.onlyBundle` instead. + */ onlyAllowBundle?: Arrayable | false /** * Skip bundling all `node_modules` dependencies. @@ -65,7 +69,7 @@ export interface DepsConfig { export interface ResolvedDepsConfig { neverBundle?: ExternalOption alwaysBundle?: NoExternalFn - onlyAllowBundle?: Array | false + onlyBundle?: Array | false skipNodeModulesBundle: boolean } @@ -76,7 +80,7 @@ export function resolveDepsConfig( let { neverBundle, alwaysBundle, - onlyAllowBundle, + onlyBundle, skipNodeModulesBundle = false, } = config.deps || {} @@ -98,16 +102,27 @@ export function resolveDepsConfig( logger?.warn('`noExternal` is deprecated. Use `deps.alwaysBundle` instead.') alwaysBundle = config.noExternal } + if (config.deps?.onlyAllowBundle != null) { + if (onlyBundle != null) { + throw new TypeError( + '`deps.onlyAllowBundle` is deprecated. Cannot be used with `deps.onlyBundle`.', + ) + } + logger?.warn( + '`deps.onlyAllowBundle` is deprecated. Use `deps.onlyBundle` instead.', + ) + onlyBundle = config.deps.onlyAllowBundle + } if (config.inlineOnly != null) { - if (onlyAllowBundle != null) { + if (onlyBundle != null) { throw new TypeError( - '`inlineOnly` is deprecated. Cannot be used with `deps.onlyAllowBundle`.', + '`inlineOnly` is deprecated. Cannot be used with `deps.onlyBundle`.', ) } logger?.warn( - '`inlineOnly` is deprecated. Use `deps.onlyAllowBundle` instead.', + '`inlineOnly` is deprecated. Use `deps.onlyBundle` instead.', ) - onlyAllowBundle = config.inlineOnly + onlyBundle = config.inlineOnly } if (config.skipNodeModulesBundle != null) { if (config.deps?.skipNodeModulesBundle != null) { @@ -137,14 +152,14 @@ export function resolveDepsConfig( '`deps.skipNodeModulesBundle` and `deps.alwaysBundle` are mutually exclusive options and cannot be used together.', ) } - if (onlyAllowBundle != null && onlyAllowBundle !== false) { - onlyAllowBundle = toArray(onlyAllowBundle) + if (onlyBundle != null && onlyBundle !== false) { + onlyBundle = toArray(onlyBundle) } return { neverBundle, alwaysBundle, - onlyAllowBundle, + onlyBundle, skipNodeModulesBundle, } } @@ -182,7 +197,7 @@ async function parseBundledDep( export function DepPlugin( { pkg, - deps: { alwaysBundle, onlyAllowBundle, skipNodeModulesBundle }, + deps: { alwaysBundle, onlyBundle, skipNodeModulesBundle }, logger, nameLabel, }: ResolvedConfig, @@ -253,13 +268,13 @@ export function DepPlugin( debug('found deps in bundle: %o', deps) - if (onlyAllowBundle) { + if (onlyBundle) { const errors = Array.from(deps) - .filter((dep) => !matchPattern(dep, onlyAllowBundle)) + .filter((dep) => !matchPattern(dep, onlyBundle)) .map( (dep) => - `${yellow(dep)} is located in ${blue`node_modules`} but is not included in ${blue`deps.onlyAllowBundle`} option.\n` + - `To fix this, either add it to ${blue`deps.onlyAllowBundle`}, declare it as a production or peer dependency in your package.json, or externalize it manually.\n` + + `${yellow(dep)} is located in ${blue`node_modules`} but is not included in ${blue`deps.onlyBundle`} option.\n` + + `To fix this, either add it to ${blue`deps.onlyBundle`}, declare it as a production or peer dependency in your package.json, or externalize it manually.\n` + `Imported by\n${[...(importers.get(dep) || [])] .map((s) => `- ${underline(s)}`) .join('\n')}`, @@ -268,25 +283,25 @@ export function DepPlugin( this.error(errors.join('\n\n')) } - const unusedPatterns = onlyAllowBundle.filter( + const unusedPatterns = onlyBundle.filter( (pattern) => !Array.from(deps).some((dep) => matchPattern(dep, [pattern])), ) if (unusedPatterns.length) { logger.info( nameLabel, - `The following entries in ${blue`deps.onlyAllowBundle`} are not used in the bundle:\n${unusedPatterns + `The following entries in ${blue`deps.onlyBundle`} are not used in the bundle:\n${unusedPatterns .map((pattern) => `- ${yellow(pattern)}`) .join( '\n', )}\nConsider removing them to keep your configuration clean.`, ) } - } else if (onlyAllowBundle == null && deps.size) { + } else if (onlyBundle == null && deps.size) { logger.info( nameLabel, - `Hint: consider adding ${blue`deps.onlyAllowBundle`} option to avoid unintended bundling of dependencies, or set ${blue`deps.onlyAllowBundle: false`} to disable this hint.\n` + - `See more at ${underline`https://tsdown.dev/options/dependencies#deps-onlyallowbundle`}\n` + + `Hint: consider adding ${blue`deps.onlyBundle`} option to avoid unintended bundling of dependencies, or set ${blue`deps.onlyBundle: false`} to disable this hint.\n` + + `See more at ${underline`https://tsdown.dev/options/dependencies#deps-onlybundle`}\n` + `Detected dependencies in bundle:\n${Array.from(deps) .map((dep) => `- ${blue(dep)}`) .join('\n')}`, diff --git a/tests/__snapshots__/onlyAllowBundle/should-allow-whitelisted-dependencies-to-be-bundled.snap.md b/tests/__snapshots__/onlyBundle/should-allow-whitelisted-dependencies-to-be-bundled.snap.md similarity index 100% rename from tests/__snapshots__/onlyAllowBundle/should-allow-whitelisted-dependencies-to-be-bundled.snap.md rename to tests/__snapshots__/onlyBundle/should-allow-whitelisted-dependencies-to-be-bundled.snap.md diff --git a/tests/__snapshots__/onlyAllowBundle/should-warn-for-unused-patterns.snap.md b/tests/__snapshots__/onlyBundle/should-warn-for-unused-patterns.snap.md similarity index 100% rename from tests/__snapshots__/onlyAllowBundle/should-warn-for-unused-patterns.snap.md rename to tests/__snapshots__/onlyBundle/should-warn-for-unused-patterns.snap.md diff --git a/tests/e2e.test.ts b/tests/e2e.test.ts index 68887ae91..618a6502b 100644 --- a/tests/e2e.test.ts +++ b/tests/e2e.test.ts @@ -177,7 +177,7 @@ describe('deps', () => { }) }) - describe('onlyAllowBundle', () => { + describe('onlyBundle', () => { test('should allow whitelisted dependencies to be bundled', async (context) => { const files = { 'index.ts': `export * from 'cac'; export * from 'bumpp'`, @@ -188,7 +188,7 @@ describe('deps', () => { options: { deps: { alwaysBundle: ['cac'], - onlyAllowBundle: ['cac', 'bumpp'], + onlyBundle: ['cac', 'bumpp'], }, plugins: [pluginMockDepCode], inputOptions: { @@ -209,7 +209,7 @@ describe('deps', () => { context, files, options: { - deps: { onlyAllowBundle: [] }, + deps: { onlyBundle: [] }, plugins: [pluginMockDepCode], }, }), @@ -228,7 +228,7 @@ describe('deps', () => { options: { deps: { alwaysBundle: ['cac'], - onlyAllowBundle: ['cac', 'unused-dep'], + onlyBundle: ['cac', 'unused-dep'], }, plugins: [pluginMockDepCode], customLogger: { diff --git a/tsdown.config.ts b/tsdown.config.ts index 90c76fc61..7ccd339ef 100644 --- a/tsdown.config.ts +++ b/tsdown.config.ts @@ -10,7 +10,7 @@ export default defineConfig([ entry: ['./src/{index,run,plugins,config,internal}.ts'], name: 'tsdown', deps: { - onlyAllowBundle: [ + onlyBundle: [ '@publint/pack', 'is-in-ci', 'package-manager-detector', @@ -59,7 +59,7 @@ export default defineConfig([ workspace: { include: ['packages/*'], }, - deps: { onlyAllowBundle: [] }, + deps: { onlyBundle: [] }, failOnWarn: 'ci-only', publint: 'ci-only', attw: { From a793b2d379a50c1db11fe7b1215f1b0ad5b092ad Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Tue, 10 Mar 2026 17:54:31 +0000 Subject: [PATCH 2/3] [autofix.ci] apply automated fixes --- docs/guide/how-it-works.md | 2 +- docs/zh-CN/guide/how-it-works.md | 2 +- src/features/deps.ts | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/guide/how-it-works.md b/docs/guide/how-it-works.md index e03c78334..2f8e2aa0a 100644 --- a/docs/guide/how-it-works.md +++ b/docs/guide/how-it-works.md @@ -35,7 +35,7 @@ When you publish a library, your consumers install its `dependencies` and `peerD | Option | What it does | | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [`deps.onlyBundle`](../options/dependencies.md#deps-onlybundle) | Whitelist of dependencies allowed to be bundled. Any unlisted dependency that ends up in the bundle causes an error. Useful for catching accidental inlining in large projects. | +| [`deps.onlyBundle`](../options/dependencies.md#deps-onlybundle) | Whitelist of dependencies allowed to be bundled. Any unlisted dependency that ends up in the bundle causes an error. Useful for catching accidental inlining in large projects. | | [`deps.neverBundle`](../options/dependencies.md#deps-neverbundle) | Explicitly mark additional packages as external (never bundled). | | [`deps.alwaysBundle`](../options/dependencies.md#deps-alwaysbundle) | Force specific packages to be bundled, even if they're in `dependencies`. | | [`deps.skipNodeModulesBundle`](../options/dependencies.md#deps-skipnodemodulebundle) | Skip resolving and bundling everything from `node_modules`. | diff --git a/docs/zh-CN/guide/how-it-works.md b/docs/zh-CN/guide/how-it-works.md index 8edcf5680..8e93323c7 100644 --- a/docs/zh-CN/guide/how-it-works.md +++ b/docs/zh-CN/guide/how-it-works.md @@ -35,7 +35,7 @@ tsdown 读取你的 `package.json` 和 `tsconfig.json` 来推断合理的默认 | 选项 | 说明 | | ------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------- | -| [`deps.onlyBundle`](../options/dependencies.md#deps-onlybundle) | 允许打包的依赖白名单。任何不在列表中的依赖如果出现在 bundle 中将触发错误。适用于防止大型项目中的意外内联。 | +| [`deps.onlyBundle`](../options/dependencies.md#deps-onlybundle) | 允许打包的依赖白名单。任何不在列表中的依赖如果出现在 bundle 中将触发错误。适用于防止大型项目中的意外内联。 | | [`deps.neverBundle`](../options/dependencies.md#deps-neverbundle) | 显式将额外的包标记为外部依赖(不打包)。 | | [`deps.alwaysBundle`](../options/dependencies.md#deps-alwaysbundle) | 强制打包特定的包,即使它们在 `dependencies` 中。 | | [`deps.skipNodeModulesBundle`](../options/dependencies.md#deps-skipnodemodulebundle) | 跳过解析和打包所有来自 `node_modules` 的内容。 | diff --git a/src/features/deps.ts b/src/features/deps.ts index 87fd67a96..0e2ffeacb 100644 --- a/src/features/deps.ts +++ b/src/features/deps.ts @@ -119,9 +119,7 @@ export function resolveDepsConfig( '`inlineOnly` is deprecated. Cannot be used with `deps.onlyBundle`.', ) } - logger?.warn( - '`inlineOnly` is deprecated. Use `deps.onlyBundle` instead.', - ) + logger?.warn('`inlineOnly` is deprecated. Use `deps.onlyBundle` instead.') onlyBundle = config.inlineOnly } if (config.skipNodeModulesBundle != null) { From 38e355b2f24328220417b73c59f70d001cf7bd4e Mon Sep 17 00:00:00 2001 From: Kevin Deng Date: Wed, 11 Mar 2026 21:38:57 +0800 Subject: [PATCH 3/3] docs: improve --- docs/options/dependencies.md | 2 +- docs/zh-CN/options/dependencies.md | 2 +- skills/tsdown/references/option-dependencies.md | 2 +- src/features/deps.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/options/dependencies.md b/docs/options/dependencies.md index 78b1a5d37..1ec897968 100644 --- a/docs/options/dependencies.md +++ b/docs/options/dependencies.md @@ -142,7 +142,7 @@ The following top-level options are deprecated. Please migrate to the `deps` nam | `external` | `deps.neverBundle` | | `noExternal` | `deps.alwaysBundle` | | `inlineOnly` | `deps.onlyBundle` | -| `onlyAllowBundle` | `deps.onlyBundle` | +| `deps.onlyAllowBundle` | `deps.onlyBundle` | | `skipNodeModulesBundle` | `deps.skipNodeModulesBundle` | ## Summary diff --git a/docs/zh-CN/options/dependencies.md b/docs/zh-CN/options/dependencies.md index ed16284d4..96147b2b6 100644 --- a/docs/zh-CN/options/dependencies.md +++ b/docs/zh-CN/options/dependencies.md @@ -142,7 +142,7 @@ export default defineConfig({ | `external` | `deps.neverBundle` | | `noExternal` | `deps.alwaysBundle` | | `inlineOnly` | `deps.onlyBundle` | -| `onlyAllowBundle` | `deps.onlyBundle` | +| `deps.onlyAllowBundle` | `deps.onlyBundle` | | `skipNodeModulesBundle` | `deps.skipNodeModulesBundle` | ## 总结 diff --git a/skills/tsdown/references/option-dependencies.md b/skills/tsdown/references/option-dependencies.md index 52162c4f9..0a8cfb4ed 100644 --- a/skills/tsdown/references/option-dependencies.md +++ b/skills/tsdown/references/option-dependencies.md @@ -236,7 +236,7 @@ tsdown --deps.skip-node-modules-bundle | `external` | `deps.neverBundle` | | `noExternal` | `deps.alwaysBundle` | | `inlineOnly` | `deps.onlyBundle` | -| `onlyAllowBundle` | `deps.onlyBundle` | +| `deps.onlyAllowBundle` | `deps.onlyBundle` | | `skipNodeModulesBundle` | `deps.skipNodeModulesBundle` | ## Examples by Use Case diff --git a/src/features/deps.ts b/src/features/deps.ts index 0e2ffeacb..49fe51fe8 100644 --- a/src/features/deps.ts +++ b/src/features/deps.ts @@ -53,7 +53,7 @@ export interface DepsConfig { */ onlyBundle?: Arrayable | false /** - * @deprecated Use `deps.onlyBundle` instead. + * @deprecated Use {@link onlyBundle} instead. */ onlyAllowBundle?: Arrayable | false /**