【发布时间】:2021-10-08 22:58:51
【问题描述】:
升级到 Webpack 5 后,我现在遇到了这个错误:
./node-modules/@fizz/my-library/components/MyComponent/MyComponent.js:97:19-39 - 错误:不应导入命名导出“foo”(导入为“bar”) 来自默认导出模块(仅默认导出很快可用)
问题出现在我无法修改的导入库中。有问题的导入是这样的:
import { foo as bar } from '../ParentComponent.css.json';
ParentComponent.css.json 看起来像这样:
{
"foo": {
"a": 1,
"b": 2,
"c": 3
},
...
}
我在 tsconfig.json 中有以下内容:
"compilerOptions": {
"module": "commonjs",
"moduleResolution": 'node",
"target": "es2015",
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"esModuleInterop": true,
...
}
关于如何解决此错误的任何想法?我试过删除 node_modules 和 package-lock.json 但没有成功。
【问题讨论】:
标签: javascript typescript webpack tsconfig