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

Importing from an export = namespace not supported #93

Closed
OmgImAlexis opened this issue May 18, 2020 · 7 comments
Closed

Importing from an export = namespace not supported #93

OmgImAlexis opened this issue May 18, 2020 · 7 comments
Labels
wontfix This will not be worked on

Comments

@OmgImAlexis
Copy link

Seems rollup-plugin-dts doesn't support import from namespace yet?:

Ref: egoist/tsup#14 (comment)

@Swatinem
Copy link
Owner

Copy-pasting from egoist/tsup#14 (comment):

Sometimes the things from @types have really strange idioms in them, and its a nightmare to work with.

This example in particular. I think, this is whats going on:

  • I treat TS namespace as an opaque "item". Due to declaration merging, you can have namespaces which have the same name as functions, which is basically the same as having an interface with members and a call signature.
  • And in commonjs, you used to be able to module.exports = fn_with_props
  • And then just require that, since the result is just any kind of value.
  • But with ES modules, this is just not possible cleanly, unless you use some kind of "import default interop".
  • And that is something that I don‘t know how to really translate to the .d.ts world. And TBH, I don‘t want to, since its something that is fundamentally different when using ES modules.

@Swatinem Swatinem added the wontfix This will not be worked on label May 22, 2020
@Swatinem Swatinem changed the title 'ModuleName' is not exported by Importing from an export = namespace not supported May 22, 2020
@trusktr
Copy link

trusktr commented Oct 19, 2020

I agree, let's support the ES Module future and not dwell on CommonJS pitfalls.

@IanVS
Copy link

IanVS commented Jul 27, 2022

Hi, is this still an issue? I'm hitting problems when using tsup because of various sub-dependencies using export = in their .d.ts files, and I'm unsure what's needed to solve it.

@Swatinem
Copy link
Owner

This is still not supported, and I doubt I will add support for this myself. PRs welcome of course.

The question here would rather be: Why are you trying to bundle your sub-dependencies in the first place?

@IanVS
Copy link

IanVS commented Jul 28, 2022

I don't think I am. But I'm not sure. I'm trying to add a feature into Storybook, which has recently started using tsup. Importing types from fastify is breaking the build, apparently because of this issue. What configuration would I need to look for to see whether or not sub-dependencies are being bundled? I've not worked with tsup before, and I don't have a great grasp of how it's all working right now.

@Swatinem
Copy link
Owner

I've not worked with tsup before, and I don't have a great grasp of how it's all working

Neither have I 🤷🏻‍♂️

My plugin ignores external dependencies by default.

@Nick-Hopps
Copy link

Is it possible to make the output d.ts file using export = format to support both ESM and CJS?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

5 participants