提问人:Jacopo Trapani 提问时间:11/17/2023 更新时间:11/17/2023 访问量:9
在 CRA 中使用 babel 解析 mjs 文件时出现问题
Problem parsing a mjs file with babel in a CRA
问:
我有一个使用 CRA 制作的项目,其中我使用此package.json导入了一个外部库
"type": "module",
"main": "build/index.umd.js",
"module": "./build/index.mjs",
"types": "./build/index.d.ts",
当我尝试导入它并在我的项目中使用它时,解析 index.mjs 文件失败。
模块分析失败:意外的令牌 (9388:70) 文件已使用以下加载程序进行处理:
- ./node_modules/babel-loader/lib/index.js 您可能需要一个额外的加载程序来处理这些加载程序的结果。
我尝试了很多方法:我使用带有 customize-cra 的 react-app-rewired 来显式配置要用 babel-loader 解决的 .mjs 文件,但没有任何效果。看起来那个 babel-loader 无法处理该脚本。
有人有什么建议吗?
答: 暂无答案
评论