Describe the bug
See https://github.com/dragon-fish/rolldown-plugin-dts-playground
When bundling the typings for this project with rolldown-plugin-dts into a single file, all types are merged into dist/index.d.ts. However, the emitted declare module augmentations still reference their original source module paths (e.g. './foo.js', '@/foo.js') instead of the entry module. Because the augmentations now live in the entry declaration file, their targets should be rewritten to the entry module ('.'), otherwise downstream interface merging does not apply to the types exported from the package root.
// src/bar.ts
declare module './foo.js' {
interface Foo {
bar: string
}
}
// src/sub/baz.ts
declare module '@/foo.js' {
interface Foo {
baz: number
}
}
This makes the augmentations unreachable for consumers who import from the package root (the entry), so properties like bar and baz are missing on Foo at usage sites.
Expected Behavior
Since everything is flattened into dist/index.d.ts (the entry), the augmentation targets should be the entry module:
declare module '.' {
interface Foo {
bar: string
}
}
declare module '.' {
interface Foo {
baz: number
}
}
Either two separate blocks as above, or a single merged block, but the module specifier should be '.'.
Actual Behavior
Augmentations are emitted with their original source paths ('./foo.js', '@/foo.js') inside the flattened dist/index.d.ts, which no longer matches what consumers import from.
Reproduction
https://github.com/dragon-fish/rolldown-plugin-dts-playground
System Info
System:
OS: Windows 11 10.0.26200
CPU: (16) x64 12th Gen Intel(R) Core(TM) i5-12600KF
Memory: 5.60 GB / 31.84 GB
Binaries:
Node: 22.18.0 - D:\nodejs\node.EXE
Yarn: 1.22.22 - C:\Users\xiaoy\AppData\Roaming\npm\yarn.CMD
npm: 10.9.3 - D:\nodejs\npm.CMD
pnpm: 10.20.0 - C:\Users\xiaoy\AppData\Roaming\npm\pnpm.CMD
bun: 1.3.1 - C:\Users\xiaoy\.bun\bin\bun.EXE
Browsers:
Chrome: 142.0.7444.60
Edge: Chromium (140.0.3485.54)
Firefox: 143.0.4 - C:\Program Files\Mozilla Firefox\firefox.exe
Used Package Manager
pnpm
Validations
Contributions
Describe the bug
When bundling the typings for this project with
rolldown-plugin-dtsinto a single file, all types are merged intodist/index.d.ts. However, the emitteddeclare moduleaugmentations still reference their original source module paths (e.g.'./foo.js','@/foo.js') instead of the entry module. Because the augmentations now live in the entry declaration file, their targets should be rewritten to the entry module ('.'), otherwise downstream interface merging does not apply to the types exported from the package root.This makes the augmentations unreachable for consumers who import from the package root (the entry), so properties like
barandbazare missing onFooat usage sites.Expected Behavior
Since everything is flattened into
dist/index.d.ts(the entry), the augmentation targets should be the entry module:Either two separate blocks as above, or a single merged block, but the module specifier should be
'.'.Actual Behavior
Augmentations are emitted with their original source paths (
'./foo.js','@/foo.js') inside the flatteneddist/index.d.ts, which no longer matches what consumers import from.Reproduction
https://github.com/dragon-fish/rolldown-plugin-dts-playground
System Info
System: OS: Windows 11 10.0.26200 CPU: (16) x64 12th Gen Intel(R) Core(TM) i5-12600KF Memory: 5.60 GB / 31.84 GB Binaries: Node: 22.18.0 - D:\nodejs\node.EXE Yarn: 1.22.22 - C:\Users\xiaoy\AppData\Roaming\npm\yarn.CMD npm: 10.9.3 - D:\nodejs\npm.CMD pnpm: 10.20.0 - C:\Users\xiaoy\AppData\Roaming\npm\pnpm.CMD bun: 1.3.1 - C:\Users\xiaoy\.bun\bin\bun.EXE Browsers: Chrome: 142.0.7444.60 Edge: Chromium (140.0.3485.54) Firefox: 143.0.4 - C:\Program Files\Mozilla Firefox\firefox.exeUsed Package Manager
pnpm
Validations
Contributions