本文介绍了babel-eslint不允许动态导入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用webpack 2,我想进行动态导入。 Linter在动态导入时出现以下错误(即 import(...)
):
I use webpack 2 and I want to make dynamic import. Linter gives the following error on dynamic import (that is import(...)
):
我有以下 .eslintrc
摘录):
I have following .eslintrc
(excerpt):
{
"parser": "babel-eslint",
"parserOptions": {
"allowImportExportEverywhere": true
}
}
已安装:
"eslint": "^3.16.1",
"babel-eslint": "^7.2.3",
"babel-plugin-dynamic-import-webpack": "^1.0.1",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
babelrc配置:
babelrc configuration:
{
"presets": [
"es2015",
"react"
],
"plugins": ["syntax-dynamic-import", "dynamic-import-webpack"]
}
更新:发生错误的示例(反应应用程序)。 (这里的错误只是 [js]声明或声明预期
):
Update: Example where error occurs (react app). (Here the error is just [js] Declaration or statement expected
):
const App = () => {
import('./routes/Main/Main').then((Main) => {});
return(<div />);
};
推荐答案
我发现了这种情况的原因。我在这里发布了答案
I found the reason why this happens. I posted the answer here
这篇关于babel-eslint不允许动态导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!