Jacopo Trapani
Jacopo Trapani

Reputation: 31

Problem parsing a mjs file with babel in a CRA

I have a project made with CRA where I've imported an external library with this package.json

"type": "module",
"main": "build/index.umd.js",
"module": "./build/index.mjs",
"types": "./build/index.d.ts",

When i try to import it and use it in my project, there is a failure in parsing the index.mjs file.

Module parse failed: Unexpected token (9388:70) File was processed with these loaders:

I tried many approaches: I used the react-app-rewired with customize-cra in order to explictly configure .mjs file to be solved with babel-loader, but nothing worked. It just looks like that babel-loader couldn't manage to handle that script.

Does anyone have any suggestions?

Upvotes: 3

Views: 256

Answers (0)

Related Questions