title: Webpack won't compile if i use the dynamic import function
body: <p>I have a function that looks like this:</p>
  
  <pre><code>async importer ( path ) {
      const maxAttempts = 4;
      let p = Promise.reject();
  
      const rejectDelay = reason =&gt; {
          return new Promise((resolve, reject) =&gt; {
              setTimeout(reject.bind(null, reason), 1000);
              });
          };
  
      const attempt = () =&gt; {
          return new Promise((resolve, reject) =&gt; {
              import('../../src/pages/desktop/index.jsx').then(data =&gt; {
                  resolve(data);
              }).catch(error =&gt; {
                  reject(error);
              });
          });
      };
  
      for(let i = 0; i &lt; maxAttempts; i++) {
        p = p.catch(attempt).catch(rejectDelay);
      }
  
      p = p.then(data =&gt; {
          console.log(data);
      }).catch(error =&gt; {
          console.error(error);
      });
  }
  </code></pre>
  
  <p>If I include the import part my webpack won't compile and eventually will crash. Node then gives me this error:</p>
  
  <pre><code>&lt;--- Last few GCs ---&gt;
  
  [1864:00000260CFC24890]   242486 ms: Mark-sweep 1317.0 (1441.8) -&gt; 1301.3 (1441.3) MB, 667.9 / 0.1 ms  (average mu = 0.316, current mu = 0.275) allocation failure scavenge might not succeed
  [1864:00000260CFC24890]   243400 ms: Mark-sweep 1318.2 (1442.8) -&gt; 1304.5 (1442.8) MB, 662.4 / 0.0 ms  (average mu = 0.296, current mu = 0.275) allocation failure scavenge might not succeed
  
  
  &lt;--- JS stacktrace ---&gt;
  
  ==== JS stack trace =========================================
  
      0: ExitFrame [pc: 000003DB79A50361]
      1: StubFrame [pc: 000003DB79A0DEF8]
  Security context: 0x0369d989d949 &lt;JSObject&gt;
      2: /* anonymous */ [0000035D7180D9D1] [C:\Users\Rick\PhpstormProjects\witteveen_new_dev\node_modules\acorn\dist\acorn.js:~4658] [pc=000003DB7C8C0810](this=0x008c53a992d1 &lt;Parser map = 000003D9D2615211&gt;,2)
      3: /* anonymous */ [0000035D7180D7D1] [C:\Users\Rick\PhpstormProjects\witteveen_new_dev\node_modules\acor...
  
  FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
   1: 00007FF7DCA221C5
   2: 00007FF7DC9FA056
   3: 00007FF7DC9FAA40
   4: 00007FF7DCE4499E
   5: 00007FF7DCE448D7
   6: 00007FF7DD11D804
   7: 00007FF7DD113444
   8: 00007FF7DD111B18
   9: 00007FF7DD11B487
  10: 00007FF7DD11B506
  11: 00007FF7DCCDC311
  12: 00007FF7DD436DEA
  13: 000003DB79A50361
  events.js:167
        throw er; // Unhandled 'error' event
        ^
  
  Error: EOF: end of file, write
      at Socket._write (internal/net.js:58:25)
      at doWrite (_stream_writable.js:410:12)
      at writeOrBuffer (_stream_writable.js:394:5)
      at Socket.Writable.write (_stream_writable.js:294:11)
      at compilerCallback (C:\Users\Rick\PhpstormProjects\witteveen_new_dev\node_modules\webpack-cli\bin\cli.js:512:30)
      at finalCallback (C:\Users\Rick\PhpstormProjects\witteveen_new_dev\node_modules\webpack\lib\Compiler.js:204:39)
      at hooks.done.callAsync.err (C:\Users\Rick\PhpstormProjects\witteveen_new_dev\node_modules\webpack\lib\Compiler.js:253:14)
      at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\Users\Rick\PhpstormProjects\witteveen_new_dev\node_modules\tapable\lib\HookCodeFactory.js:32:10), &lt;anonymous&gt;:6:1)
      at AsyncSeriesHook.lazyCompileHook (C:\Users\Rick\PhpstormProjects\witteveen_new_dev\node_modules\tapable\lib\Hook.js:154:20)
      at emitRecords.err (C:\Users\Rick\PhpstormProjects\witteveen_new_dev\node_modules\webpack\lib\Compiler.js:251:22)
      at Compiler.emitRecords (C:\Users\Rick\PhpstormProjects\witteveen_new_dev\node_modules\webpack\lib\Compiler.js:366:39)
      at emitAssets.err (C:\Users\Rick\PhpstormProjects\witteveen_new_dev\node_modules\webpack\lib\Compiler.js:245:10)
      at hooks.afterEmit.callAsync.err (C:\Users\Rick\PhpstormProjects\witteveen_new_dev\node_modules\webpack\lib\Compiler.js:352:14)
      at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\Users\Rick\PhpstormProjects\witteveen_new_dev\node_modules\tapable\lib\HookCodeFactory.js:32:10), &lt;anonymous&gt;:6:1)
      at AsyncSeriesHook.lazyCompileHook (C:\Users\Rick\PhpstormProjects\witteveen_new_dev\node_modules\tapable\lib\Hook.js:154:20)
      at asyncLib.forEach.err (C:\Users\Rick\PhpstormProjects\witteveen_new_dev\node_modules\webpack\lib\Compiler.js:349:27)
      at done (C:\Users\Rick\PhpstormProjects\witteveen_new_dev\node_modules\neo-async\async.js:2854:11)
      at C:\Users\Rick\PhpstormProjects\witteveen_new_dev\node_modules\neo-async\async.js:2805:7
      at C:\Users\Rick\PhpstormProjects\witteveen_new_dev\node_modules\graceful-fs\graceful-fs.js:43:10
      at FSReqCallback.oncomplete (fs.js:148:20)
  Emitted 'error' event at:
      at onwriteError (_stream_writable.js:425:12)
      at onwrite (_stream_writable.js:456:5)
      at Socket._write (internal/net.js:62:14)
      at doWrite (_stream_writable.js:410:12)
      [... lines matching original stack trace ...]
      at FSReqCallback.oncomplete (fs.js:148:20)
  </code></pre>
  
  <p>The weird thing is, is that if I use the import function in another file it works perfectly but in this file it just won't work and the webpack compiler just gives up.</p>