See index.d.ts for the output.
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.
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 '.'.
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.
- Install dependencies:
pnpm i - Build:
pnpm build - Inspect the output at
dist/index.d.tsand observe thedeclare moduletargets.
Source overview:
src/foo.tsdefinesclass Foosrc/bar.tsaugmentsFooviadeclare module './foo.js'src/sub/baz.tsaugmentsFooviadeclare module '@/foo.js'src/index.tsre-exports and serves as package entry; the bundler merges declarations into a singledist/index.d.ts
- rolldown: 1.0.0-beta.48
- rolldown-plugin-dts: ^0.17.5
- typescript: ^5.9.3
- tsconfig:
moduleResolution: 'bundler', path alias@/* -> src/*