Repository navigation
Conversation
| "dist/dir-export.mjs", | ||
| "dist/foo.mjs", | ||
| "dist/foo.d.ts", | ||
| "dist/foo.d.mts", |
There was a problem hiding this comment.
In this case there is an existing foo.d.ts in the source, but the generated foo.d.mts will be used instead. Would it be good to copy foo.d.ts and rename it? The developer could rename it to foo.d.mts in the src dir, but that would not work if they are generating both cjs and esm.
| "dist/ts/test2.mjs", | ||
| "dist/ts/test1.d.mts", | ||
| "dist/ts/test2.d.cts", | ||
| "dist/ts/test2.d.mts", |
There was a problem hiding this comment.
In this case we have a test2.cts in the src. I think there are two ways to handle it:
- When a
.ctsor.mtsfile is found in the source, generate.cjs/.d.ctsor.mjs/.d.mtspairs regardless of theextoption. This is the issue described by Declarations not genered to.mtsand.ctsfiles #138. Another variation would be to only overrideextif it were not explicitly set. - Always use the
extoption and treat.mts,.cts, and.tsfiles insrc/identically.
It's just important that the declaration and js file match, so you don't end up with foo.cjs and foo.d.mts
Codecov Report❌ Patch coverage is
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 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@danielroe light ping |
|
@pi0 perhaps we could include this behaviour under a flag, if you want to avoid a major bump? |
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.
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?