-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Closed
Labels
Milestone
Description
What is the current behavior?
Running a module with if(...) { import().then(...) } through ModuleConcatenationPlugin results in an Acorn exception with Webpack 3.5.2. The module has been run through Babel w/ babel-preset-env and modules=false.
ERROR in chunk global [initial]
[name].[hash].js
'import' and 'export' may only appear at the top level (112:2)
|
| if (false) {
| import('react-addons-perf').then(function (Perf) {
| window.Perf = Perf;
| });
SyntaxError: 'import' and 'export' may only appear at the top level (112:2)
|
| if (false) {
| import('react-addons-perf').then(function (Perf) {
| window.Perf = Perf;
| });
at Parser.pp$4.raise (~/node_modules/webpack/node_modules/acorn/dist/acorn.js:2610:13)
at Parser.pp$1.parseStatement (~/node_modules/webpack/node_modules/acorn/dist/acorn.js:780:16)
at Parser.pp$1.parseBlock (~/node_modules/webpack/node_modules/acorn/dist/acorn.js:1076:23)
at Parser.pp$1.parseStatement (~/node_modules/webpack/node_modules/acorn/dist/acorn.js:774:34)
at Parser.pp$1.parseIfStatement (~/node_modules/webpack/node_modules/acorn/dist/acorn.js:901:26)
at Parser.pp$1.parseStatement (~/node_modules/webpack/node_modules/acorn/dist/acorn.js:763:31)
at Parser.pp$1.parseTopLevel (~/node_modules/webpack/node_modules/acorn/dist/acorn.js:690:23)
at Parser.parse (~/node_modules/webpack/node_modules/acorn/dist/acorn.js:543:15)
at Object.parse (~/node_modules/webpack/node_modules/acorn/dist/acorn.js:3669:37)
at modulesWithInfo.forEach.info (~/node_modules/webpack/lib/optimize/ConcatenatedModule.js:418:18)
at Array.forEach (<anonymous>)
at ConcatenatedModule.source (~/node_modules/webpack/lib/optimize/ConcatenatedModule.js:411:19)
at ModuleTemplate.render (~/node_modules/webpack/lib/ModuleTemplate.js:14:31)
at ~/node_modules/webpack/lib/Template.js:116:28
at Function.from (native)
at Chunk.mapModules (~/node_modules/webpack/lib/Chunk.js:163:16)
at ChunkTemplate.renderChunkModules (~/node_modules/webpack/lib/Template.js:113:26)
at ChunkTemplate.render (~/node_modules/webpack/lib/ChunkTemplate.js:16:30)
at Compilation.createChunkAssets (~/node_modules/webpack/lib/Compilation.js:1290:35)
at sealPart2 (~/node_modules/webpack/lib/Compilation.js:646:10)
at next (~/node_modules/tapable/lib/Tapable.js:202:11)
at Compilation.compilation.plugin (~/node_modules/webpack/lib/ProgressPlugin.js:111:6)
at Compilation.applyPluginsAsyncSeries (~/node_modules/tapable/lib/Tapable.js:206:13)
at Compilation.seal (~/node_modules/webpack/lib/Compilation.js:596:8)
at applyPluginsParallel.err (~/node_modules/webpack/lib/Compiler.js:514:17)
at ~/node_modules/tapable/lib/Tapable.js:289:11
at _addModuleChain (~/node_modules/webpack/lib/Compilation.js:498:11)
at processModuleDependencies.err (~/node_modules/webpack/lib/Compilation.js:468:14)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
If the current behavior is a bug, please provide the steps to reproduce.
I'm unfortunately unable to reproduce this using a minimal repo – a minimal repo I tried to make works fine
What is the expected behavior?
No crashing :)
Naturally the workaround is to disable ModuleConcatenationPlugin.
Reactions are currently unavailable