<p dir="auto">I am in the process of migrating from RequireJS to Webpack, but following AMD module that worked in RequireJS produces "SyntaxError: missing ; before statement" with webpack:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="define([], function() {
    var modules = [];
    if (modules.length) {
        require(modules, function() {});
    }
});"><pre class="notranslate"><code class="notranslate">define([], function() {
    var modules = [];
    if (modules.length) {
        require(modules, function() {});
    }
});
</code></pre></div>
<p dir="auto">This is basically an excerpt that causes error. Webpack transforms it to following:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function() {
        var modules = [];

        if (modules.length) {
            __webpack_require__(1)!/* require */(/* empty */function() { var __WEBPACK_AMD_REQUIRE_ARRAY__ = modules; (function () {}.apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));}());
        }
    }.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined &amp;&amp; (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));"><pre class="notranslate"><code class="notranslate">    var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function() {
        var modules = [];

        if (modules.length) {
            __webpack_require__(1)!/* require */(/* empty */function() { var __WEBPACK_AMD_REQUIRE_ARRAY__ = modules; (function () {}.apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));}());
        }
    }.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined &amp;&amp; (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
</code></pre></div>
<p dir="auto">Browser reports "SyntaxError: missing ; before statement" in the string <em><strong>webpack_require</strong>(1)!</em> after function call.</p>
<p dir="auto">Is it a bug or I can transform this call to some other form?</p>
<p dir="auto">I use webpack 1.7.3</p>
<h1 dir="auto">Bug report</h1>




<p dir="auto"><strong>What is the current behavior?</strong><br>
When using an import() in the base level of a file (i.e. not inside any functions/classes), webpack fetches 4 files on the browser. It's possible that this is caused by two separate issues (one about the extra <code class="notranslate">vendor~</code> file and the other about the duplicate requests). The code I use is:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import(
    /* webpackChunkName: &quot;brace_modes&quot; */
    /* webpackMode: &quot;lazy&quot; */
    /* webpackPrefetch: true */
    './brace_modes'
);"><pre class="notranslate"><code class="notranslate">import(
    /* webpackChunkName: "brace_modes" */
    /* webpackMode: "lazy" */
    /* webpackPrefetch: true */
    './brace_modes'
);
</code></pre></div>
<p dir="auto">and this is what the browser does:<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/4096676/52254179-da76b780-28d1-11e9-830a-e9deb309daca.png"><img src="https://user-images.githubusercontent.com/4096676/52254179-da76b780-28d1-11e9-830a-e9deb309daca.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">For my full webpack.config.js, go <a href="https://gist.github.com/shravan2x/f2c37c3d365cfa8ec16a938cdd14045f">here</a>.</p>
<p dir="auto">Note that this seems to be a regression in Webpack 4.</p>
<p dir="auto"><strong>If the current behavior is a bug, please provide the steps to reproduce.</strong><br>
Create a dynamic import in the base level of a file. Run it.</p>






<p dir="auto"><strong>What is the expected behavior?</strong><br>
Only a single file is imported dynamically - <code class="notranslate">brace_modes.&lt;hash&gt;.js</code>.</p>


<p dir="auto"><strong>Other relevant information:</strong><br>
webpack version:  4.28.4 (I didn't use 4.29 due to the issues with import)<br>
Node.js version: 10<br>
Operating System: Windows 10<br>
Additional tools: -</p>