2016-12-22 5 views
2

webpack release v2.1.0-beta.28で(私は2.2.0-rc.1を使用しています)モジュールビルドに失敗しました:SyntaxError: 'import'と 'export'はトップレベルにのみ表示されます

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.

は、だから私は、変換:

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

しかし取得:

require.ensure(['./hero/homepage'],() => { 
    require('./hero/homepage') 
}, 'hero-homepage') 

中に、Module build failed: SyntaxError: 'import' and 'export' may only appear at the top level

webpackの設定に追加する必要があるものがあります。

答えて

3

を1として:

https://twitter.com/addyosmani/status/811958786273333248https://twitter.com/usefulthink/status/811958593100587009

答えは、あなたの代わりにバベル-eslintでビットを支配eslint修正しない理由を、確実に必要とするインポートを変換するのbabel-plugin-dynamic-import-webpack

+0

が必要になりますです。 https://stackoverflow.com/questions/39158552/ignore-eslint-error-import-and-export-may-only-appear-at-the-top-level –

関連する問題