Skip to content

dragon-fish/rolldown-plugin-dts-playground

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

For minimal reproduction

See index.d.ts for the output.

Reported Issue

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.

Minimal Reproduction

  1. Install dependencies: pnpm i
  2. Build: pnpm build
  3. Inspect the output at dist/index.d.ts and observe the declare module targets.

Source overview:

  • src/foo.ts defines class Foo
  • src/bar.ts augments Foo via declare module './foo.js'
  • src/sub/baz.ts augments Foo via declare module '@/foo.js'
  • src/index.ts re-exports and serves as package entry; the bundler merges declarations into a single dist/index.d.ts

Environment

  • rolldown: 1.0.0-beta.48
  • rolldown-plugin-dts: ^0.17.5
  • typescript: ^5.9.3
  • tsconfig: moduleResolution: 'bundler', path alias @/* -> src/*

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors