Problem parsing a mjs file with babel in a CRA

116 Views Asked by At

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:

  • ./node_modules/babel-loader/lib/index.js You may need an additional loader to handle the result of 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?

0

There are 0 best solutions below