mkdist icon indicating copy to clipboard operation
mkdist copied to clipboard

When using `addRelativeDeclarationExtensions`, the extension should be based on the extension of the output file

Open cjpearson opened this issue 11 months ago • 0 comments

Environment

[email protected] node 20.9.0

Reproduction

  • Set the output extension to mjs or cjs, enable outputting declarations and enable addRelativeDeclarationExtensions
  • Have a file which imports from another file
  • Build and review the definitions

Describe the bug

When compiling a .ts file to .mjs or .cjs, the declaration for the file should be .d.mts or .d.cts accordingly. Additionally, when the declarations include imports with extensions (required for node16), the extension also needs to match. It should be .js in .d.ts files, .cjs in .d.cts files and .mjs in .d.mts files.

Right now the feature just looks at the input file. Typescript would compile a .mts file to .mjs, but since mlly also allows explicitly defining the output extension, it should use that option as the source of truth here as well.

Additional context

https://github.com/unjs/mkdist/pull/134

Logs

No response

cjpearson avatar Dec 13 '24 18:12 cjpearson