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

react throws error "Can't import the named export '__rest' from non EcmaScript module (only default export is available)" #148

Closed
ayanb1991 opened this issue Jun 13, 2023 · 2 comments

Comments

@ayanb1991
Copy link

ayanb1991 commented Jun 13, 2023

Describe the bug
React 16 is throwing error while using remark-slate-transformer@0.7.5. Compilation fails with below error.

Can't import the named export '__rest' from non EcmaScript module (only default export is available)

Steps to Reproduce

  • Create a new CRA project
  • Install remark-slate-transformer@0.7.5. It has a dependency with a ‘.mjs’ file extension
  • Import the package in your project.
  • Run npm start

Expected behavior
The project should run without any errors, and the package should be imported successfully.

Additional context
Node Version: 14
React Version: 16.13.1

Note:
Changing import {__rest} from 'tslib'; to import __rest from 'tslib'; in index.mjs fixes the issue.

@inokawa
Copy link
Owner

inokawa commented Jun 13, 2023

I think it would be a problem of CRA with mjs.
facebook/create-react-app#10356

@inokawa inokawa closed this as completed Jun 13, 2023
@ayanb1991
Copy link
Author

Thanks for pointing out. Adding below module rule to webpack.config.js (after ejecting react app), resolves the above problem.

{
     test: /\.mjs$/,
     include: /node_modules/,
     type: "javascript/auto"
}

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