在webpack版本v2.1.0-beta.28中他們添加了(我使用的是2.2.0-rc.1):模塊構建失敗:SyntaxError:'import'和'export'只能出現在頂層
add
import()
as Code Splitting construct. It should be used instead ofSystem.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配置,以允許導入使用他們建議?
,而不是將進口要求,確保爲什麼不修改eslint排除有點與巴貝爾,eslint。 https://stackoverflow.com/questions/39158552/ignore-eslint-error-import-and-export-may-only-appear-at-the-top-level –