Conversation
|
Sorry for late review dear @userquin. Do you think you can add some unit tests for |
To test the cjs types we can:
I'm going to create a new repo to test the same fixtures using tsup (will fail for mixed declarations) and pkgroll (using import + require package exports here to allow re-use them in pkgroll). |
|
When all remaining exports (from the default export) only contains types ( When re-exporting types from another import, there is no an easy way to know if the export is a type, and so when re-exporting exports, the export contining the default will not be changed. Check |
|
Nice work @userquin. I'm wondering if you would be interested in maintaining it as an external/shared library now. (that converts |
|
Good idea, maybe we can add it here to the unjs ecosystem... I need to find some free time, too busy at work. |
|
I've created this repository https://github.com/userquin/unbuild-cjs-exports (instructions on readme file: pnpm monorepo): the repo using a modified plugin version to include required transformations to fix I need to include some test here, no idea how to do that without using monorepo (any hint?). I guess we need a default export from some installed dependency: exporting default from another package as default and exporting some named export from another package as default. Ofc we also need to mix them with some types. |
|
I've on my local the changes, ping me if you want the modified plugin here. |
|
I'm getting weird dts files when re-exporting as default from another packages, for example We can also re-export default as default, for example I guess we need to check rollup-dts-plugin... |
|
@danielroe @pi0 added cjs.md in the rollup/plugins folder to cover previous cases. |
|
|
| ); | ||
| } else { | ||
| magicString.prepend( | ||
| `import _default from '${defaultExport.specifier}';\n`, |
There was a problem hiding this comment.
should we parse imports to avoid collisions or just use some suffix or another layout? if someone using import { x as _default } from ...
for example: _default$unbuild or __default__
|
@userquin Could we please extract this to external package? Maintaining it from unbuild might be tricky in long term with all tests. |
ok, I will try to create the repository tomorrow or maybe late this afternoon (CEST) |
|
@pi0 any suggestion for the name? |
|
@pi0 @danielroe something like this https://github.com/userquin/fix-dts-default-cjs-exports ? I want to allow use it from api or via cli (this todo https://github.com/userquin/fix-dts-default-cjs-exports/blob/main/src/index.ts#L14 ) Check test fixtures, using unbuild to build them with some hack to remove current cjs dts plugin... |
|
Closing in favor of #513 |




We should add
exportstoESMExportinterface inmlly, missing in dts, that's why I added the regex to extract the exports (upps, it is onNamedExporttype):resolves #474