Skip to content

Bug: type issue in [email protected]+ with esm #1348

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

Closed
Mister-Hope opened this issue Nov 19, 2022 · 3 comments
Closed

Bug: type issue in [email protected]+ with esm #1348

Mister-Hope opened this issue Nov 19, 2022 · 3 comments

Comments

@Mister-Hope
Copy link

Mister-Hope commented Nov 19, 2022

A lot of plugins are exporting esm version

In a recent change in ts4.8, this leaves to type failue. as [email protected]+ will assume users are importing a commonjs module.

Here is a example:

TS will report issues with:

import commonjs from "@rollup/plugin-commonjs";

commonjs()

Saying the expression is not callable.

That's because a cjs module will have it's module.exports on default key, so:

import commonjs from "@rollup/plugin-commonjs";

commonjs.default()

is fine to typescript, but it's not acually working (because we do have esm modules using export default)

This happens under

  • esm package (with type: module in pacakge.json) and of course target: ESxxx in ts.config.json
  • together with moduleResolution: NodeNext is in ts.config.json
@Mister-Hope
Copy link
Author

image

@Mister-Hope
Copy link
Author

Mister-Hope commented Nov 19, 2022

I belived this issue is releated to microsoft/TypeScript#50690

Adding type: module in package.json can solve the problem at my use case, but I am not pretty sure if it will break other use cases.

@shellscape
Copy link
Collaborator

Thanks for opening an issue. Citing the issue template:

🚨 Issues WITHOUT a valid reproduction WILL BE CLOSED!

Please provide one by:

  1. Using the REPL.it plugin reproduction template at https://repl.it/@rollup/rollup-plugin-repro
  2. Provide a minimal repository link (Read https://git.io/fNzHA for instructions).
    Please use NPM for installing dependencies!
    These may take more time to triage than the other options.
  3. Using the Rollup REPL at https://rollupjs.org/repl/

⚠️ ZIP Files are unsafe and maintainers will NOT download them.

We cannot make this any clearer. Please add a reproduction and we'll be happy to triage further.

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

No branches or pull requests

2 participants