gpt4 book ai didi

webpack - 模块构建失败 : SyntaxError: 'import' and 'export' may only appear at the top level

转载 作者:行者123 更新时间:2023-12-05 00:53:26 38 4
gpt4 key购买 nike

他们在 webpack 版本 v2.1.0-beta.28 中添加了(我使用的是 2.2.0-rc.1):

add import() as Code Splitting construct. It should be used instead of System.import when possible. System.import will be deprecated in webpack 2 release (removed in webpack 3) as it's behavior is incorrect according to the spec.



所以我转换了:
require.ensure(['./hero/homepage'], () => {
require('./hero/homepage')
}, 'hero-homepage')

进入:
import('./hero/homepage')
.then(module => module.default)
.catch(err => console.error(`Chunk loading failed, ${err}`))

但是得到: Module build failed: SyntaxError: 'import' and 'export' may only appear at the top level
有什么我必须添加到 webpack 配置中以允许在他们建议的地方使用导入吗?

最佳答案

关于webpack - 模块构建失败 : SyntaxError: 'import' and 'export' may only appear at the top level,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41281483/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com