Cannot get types to be generated in the location I want.
Checklist
- [ ] I can reproduce this issue when running this plugin on its own.
The issue arises when being used with the typescript plugin.
- [ ] I am running this plugin on
.d.tsfiles generated by TypeScript.
I am sorry but I am not sure what answer this question is looking for.
- [ ] This issue is not related to rolling up
@types.
No?
Code Snipped
The issue is complex enough for me to create a repo where it can be reproduced in.
https://github.com/CodeMedic42/rollup-dts-issue
There is a README
I will however try to elaborate.
I have a React component and hook library. I want to generate js files from typescript files. Each component and hook are separate chunks. I am managing multiple entry points via the exports option in the package.json. It is also through this I am exporting the types for each component. I want the types generated to be colocated with the generated js files. However when I run the build rollup-plugin-dts creates a whole new folder aside from the one created by the typescript plugin.
Would someone be able to help me understand what is going on here?
@CodeMedic42 you can resolve this issue by changing your input from an array to an object with explicit chunk names
const input = Object.fromEntries(
Object.values(packageJson.exports).map((chunk) => {
const source = chunk.import
.replace("/dist/", "/src/")
.replace(".mjs", ".ts");
const entry = source.replace(/\.\/src\/|\.ts/g, "");
return [entry, source];
}),
);
@igordanchenko Thank you so much this fix it very well!