Skip to content
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

Invalid exports when using isolatedModules: true #276

Closed
3 tasks done
mithodin opened this issue Jul 26, 2023 · 2 comments · Fixed by #278
Closed
3 tasks done

Invalid exports when using isolatedModules: true #276

mithodin opened this issue Jul 26, 2023 · 2 comments · Fixed by #278

Comments

@mithodin
Copy link
Contributor

Checklist

  • I can reproduce this issue when running this plugin on its own.
    Other plugins, such as node-resolve are known to cause issues.
  • I am running this plugin on .d.ts files generated by TypeScript.
    The plugin can consume .ts and even .js files (with allowJs: true), but this is known to cause issues.
  • This issue is not related to rolling up @types.
    The plugin ignores these by default, unless respectExternal is set. @types can contain hand-crafted code which is known to cause issues.

Issue Description

When creating files using the tsconfig setting isolatedModules: true, type exports must explicitly use export type { ... } or export { type ... } (TS1205 is the relevant error code). tsc does this correctly, e.g. the following code snippet:

type Test = {
    challenge: string;
}
export { type Test };

is reproduced as-is in the corresponding .d.ts file.
However, rollup-plugin-dts elides the type part of the export, leading to the mentioned error.
A minimal reproduction can be found here: https://github.com/mithodin/dts-bundle-isolation-repro
Compile using npm install && npm run build and check the file /dist/bundle.d.ts. For comparison with tsc, run npx tsc and check /out/gameLibrary.d.ts.

It should be mentioned that this causes issues for anyone using a library bundled using rollup-plugin-dts, who wants to enable isolatedModules.

@mithodin
Copy link
Contributor Author

The problem persists with version 5.3.1., I have updated my example repo: https://github.com/mithodin/dts-bundle-isolation-repro

@Swatinem
Copy link
Owner

I was trying to bulk-close all of the old issues in the repo, as I have moved the project into maintenance mode: #277 Too bad github does not allow bulk-close-with-comment.

That being said, I will most likely not work on resolving this issue, but would very much appreciate a PR.

Solving this would likely involve changing the "post processing" code to split type-only exports from normal exports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants