mkdist icon indicating copy to clipboard operation
mkdist copied to clipboard

fix!: declaration extensions should correspond to their js extension

Open cjpearson opened this issue 11 months ago • 3 comments

This is a partial fix for #138. (Wasn't sure if I should split it out into a new bug) It addresses the issue where changing the extension of the output does not affect extension of the declaration so there is a mismatch. It does not implement automatically choosing the extension based on the source file.

The other important thing is that .ts, .cts, .mts on the declaration files imply the existence of the file with the same basename: that is, index.d.ts says ‘the declaration file is for index.js’, a.d.cts is ‘for a.cjs’, and b.d.mts is ‘for b.mjs’.

https://www.typescriptlang.org/docs/handbook/modules/reference.html#file-extension-substitution

The change itself is relatively straightforward, but it does have a large impact, especially because mjs is the default extension for esm output. Perhaps a major bump would be necessary or hiding the behavior behind a flag?

cjpearson avatar Dec 13 '24 20:12 cjpearson

Codecov Report

Attention: Patch coverage is 75.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 83.84%. Comparing base (9000888) to head (a68becc). Report is 101 commits behind head on main.

Files with missing lines Patch % Lines
src/loaders/js.ts 75.00% 3 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #268      +/-   ##
==========================================
+ Coverage   82.86%   83.84%   +0.97%     
==========================================
  Files          12       12              
  Lines         852      953     +101     
  Branches      133      197      +64     
==========================================
+ Hits          706      799      +93     
- Misses        144      153       +9     
+ Partials        2        1       -1     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Dec 13 '24 21:12 codecov[bot]

@danielroe light ping

productdevbook avatar Mar 25 '25 04:03 productdevbook

@pi0 perhaps we could include this behaviour under a flag, if you want to avoid a major bump?

danielroe avatar Apr 04 '25 17:04 danielroe