Skip to content

Commit 3c37020

Browse files
committedMar 10, 2025··
fix: respect external for dts
1 parent 9ea9ea3 commit 3c37020

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed
 

‎src/features/dts.ts

+5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import DtsPlugin from 'rollup-plugin-dts'
66
import { fsExists, fsRemove } from '../utils/fs'
77
import { typeAsserts } from '../utils/general'
88
import type { NormalizedFormat, ResolvedOptions } from '../options'
9+
import { ExternalPlugin } from './external'
910
import type { OutputExtension } from './output'
11+
import type { PackageJson } from 'pkg-types'
1012
import type { Options as IsolatedDeclOptions } from 'unplugin-isolated-decl'
1113

1214
const TEMP_DTS_DIR = '.tsdown-types'
@@ -21,6 +23,7 @@ export async function bundleDts(
2123
options: ResolvedOptions,
2224
jsExtension: OutputExtension,
2325
format: NormalizedFormat,
26+
pkg?: PackageJson,
2427
): Promise<void> {
2528
typeAsserts<IsolatedDeclOptions>(options.dts)
2629

@@ -40,12 +43,14 @@ export async function bundleDts(
4043
})
4144
const build = await rollup({
4245
input: dtsEntry,
46+
external: options.external,
4347
onLog(level, log, defaultHandler) {
4448
if (log.code !== 'EMPTY_BUNDLE' && log.code !== 'UNRESOLVED_IMPORT') {
4549
defaultHandler(level, log)
4650
}
4751
},
4852
plugins: [
53+
ExternalPlugin(options, pkg) as any,
4954
{
5055
name: 'resolve-dts',
5156
async resolveId(id, importer) {

‎src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export async function buildSingle(
163163
})
164164

165165
if (config.dts && config.bundleDts) {
166-
await bundleDts(config, extension, format)
166+
await bundleDts(config, extension, format, pkg)
167167
}
168168
}),
169169
)

0 commit comments

Comments
 (0)
Please sign in to comment.