New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: include .d.ts extension in multiple outputs #161
Conversation
Can confirm this happens with multiple entry files. A workaround currently is to use the dts({
insertTypesEntry: true,
beforeWriteFile(filePath) {
return { filePath: filePath.endsWith('.d.ts') ? filePath : `${filePath}.d.ts` }
},
}), |
@@ -438,7 +438,7 @@ export function dtsPlugin(options: PluginOptions = {}): import('vite').Plugin { | |||
const typesPath = types ? resolve(root, types) : resolve(outputDir, indexName) | |||
|
|||
for (const name of entryNames) { | |||
let filePath = multiple ? resolve(outputDir, name.replace(tsRE, '.d.ts')) : typesPath | |||
let filePath = multiple ? resolve(outputDir, `${name}.d.ts`) : typesPath |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should judge whether the extension is included here, because it will fail when extension exists (xxx.ts
-> xxx.ts.d.ts
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And we should apply the same change to line 491.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense 👍
Also, I'm no longer using your library and don't have time to contribute anymore. Feel free to pick up this PR where I left off.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All right, thanks for your contributions, I will fix it directly.
Fix for this comment #136 (comment)
Perhaps it also fixes this issue #144
Problem
With multiple entries,
name
equals the name of the input, which doesn't include any file extension. Therefore, thetsRe
regex doesn't work.Fix
Add
.d.ts
extension manually to these entries