<p dir="auto">Current webpack modules have several details that are not exactly spec-compliant, particularly when circular references are involved. It is "good enough" for most current cases, but in order to be as close to the spec as we can get without <code class="notranslate">Proxy</code>, I was thinking of how to change the way webpack emits ES modules.</p>
<p dir="auto">This tries to emit modules as close to the ES2017 and the current draft of EPS 002 as possible.</p>
<ul dir="auto">
<li>To simplify things, I'll write the emits as if NamedModulesPlugin is being used.<br>
The generated export names are also not minified here, but should (usually) be minified by webpack.</li>
<li>The actual values of the generated identifiers don't matter; e.g.<br>
<code class="notranslate">__imported_NAME__</code> could still be the same <code class="notranslate">__WEBPACK_IMPORTED_MODULE_N_NAME__</code>; I'm only using it as a shorthand.</li>
<li>The helpers attached to <code class="notranslate">__webpack_require__</code> would also, of course, be minimized similarly to current helpers.</li>
<li>It is not yet decided for sure whether commonjs modules will expose object keys, or only as a default export. It is, however, decided, that the namespace created for commonjs modules will still be a module namespace exotic object, so commonjs exports are never directly returned.</li>
</ul>
<h1 dir="auto"><code class="notranslate">__webpack_require__</code> helpers</h1>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="__webpack_require__.module = function module(moduleId) {
  // Check if module is in cache
  if(installedModules[moduleId] &amp;&amp; installedModules[moduleId].ns /*namespace*/)
    return installedModules[moduleId].ns;

  var exports = __webpack_require__(moduleId);

  // this should actually be in the base __webpack_require__,
  // should any commonjs require of an ES module happen.
  if (installedModules[moduleId].m) {
    installedModules[moduleId].exports = installedModules[moduleId].ns;
  }

  if (!installedModules[moduleId].m/*odule*/) {
    if (exports.__esModule) {
      installedModules[moduleId].ns = exports;
    } else {
      // https://github.com/nodejs/node-eps/blob/master/002-es6-modules.md#541-default-imports
      // is it safe to capture 'exports' instead of 'installedModules[moduleId]' even when hot reloading?
      var defs = { &quot;default&quot;: function() { return installedModules[moduleId].exports; } };
      for (var name in exports) {
        if (name === &quot;default&quot;) continue;
        if (!Object.prototype.hasOwnProperty.call(exports, name)) continue;
        defs[name] = function() { return installedModules[moduleId].exports[name]; };
      }
      __webpack_require__.export(installedModules[moduleId], defs);
      installedModules[moduleId].m = 0; // falsy; minifies better than false
    }
  }

  return installedModules[moduleId].ns;
}"><pre class="notranslate"><span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">module</span> <span class="pl-c1">=</span> <span class="pl-k">function</span> <span class="pl-smi">module</span><span class="pl-kos">(</span><span class="pl-s1">moduleId</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-c">// Check if module is in cache</span>
  <span class="pl-k">if</span><span class="pl-kos">(</span><span class="pl-s1">installedModules</span><span class="pl-kos">[</span><span class="pl-s1">moduleId</span><span class="pl-kos">]</span> <span class="pl-c1">&amp;&amp;</span> <span class="pl-s1">installedModules</span><span class="pl-kos">[</span><span class="pl-s1">moduleId</span><span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-c1">ns</span> <span class="pl-c">/*namespace*/</span><span class="pl-kos">)</span>
    <span class="pl-k">return</span> <span class="pl-s1">installedModules</span><span class="pl-kos">[</span><span class="pl-s1">moduleId</span><span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-c1">ns</span><span class="pl-kos">;</span>

  <span class="pl-k">var</span> <span class="pl-s1">exports</span> <span class="pl-c1">=</span> <span class="pl-en">__webpack_require__</span><span class="pl-kos">(</span><span class="pl-s1">moduleId</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

  <span class="pl-c">// this should actually be in the base __webpack_require__,</span>
  <span class="pl-c">// should any commonjs require of an ES module happen.</span>
  <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">installedModules</span><span class="pl-kos">[</span><span class="pl-s1">moduleId</span><span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-c1">m</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-s1">installedModules</span><span class="pl-kos">[</span><span class="pl-s1">moduleId</span><span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-c1">exports</span> <span class="pl-c1">=</span> <span class="pl-s1">installedModules</span><span class="pl-kos">[</span><span class="pl-s1">moduleId</span><span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-c1">ns</span><span class="pl-kos">;</span>
  <span class="pl-kos">}</span>

  <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-c1">!</span><span class="pl-s1">installedModules</span><span class="pl-kos">[</span><span class="pl-s1">moduleId</span><span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-c1">m</span><span class="pl-c">/*odule*/</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">exports</span><span class="pl-kos">.</span><span class="pl-c1">__esModule</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
      <span class="pl-s1">installedModules</span><span class="pl-kos">[</span><span class="pl-s1">moduleId</span><span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-c1">ns</span> <span class="pl-c1">=</span> <span class="pl-s1">exports</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span> <span class="pl-k">else</span> <span class="pl-kos">{</span>
      <span class="pl-c">// https://github.com/nodejs/node-eps/blob/master/002-es6-modules.md#541-default-imports</span>
      <span class="pl-c">// is it safe to capture 'exports' instead of 'installedModules[moduleId]' even when hot reloading?</span>
      <span class="pl-k">var</span> <span class="pl-s1">defs</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span> <span class="pl-s">"default"</span>: <span class="pl-k">function</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-s1">installedModules</span><span class="pl-kos">[</span><span class="pl-s1">moduleId</span><span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-c1">exports</span><span class="pl-kos">;</span> <span class="pl-kos">}</span> <span class="pl-kos">}</span><span class="pl-kos">;</span>
      <span class="pl-k">for</span> <span class="pl-kos">(</span><span class="pl-k">var</span> <span class="pl-s1">name</span> <span class="pl-k">in</span> <span class="pl-s1">exports</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">name</span> <span class="pl-c1">===</span> <span class="pl-s">"default"</span><span class="pl-kos">)</span> <span class="pl-k">continue</span><span class="pl-kos">;</span>
        <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-c1">!</span><span class="pl-v">Object</span><span class="pl-kos">.</span><span class="pl-c1">prototype</span><span class="pl-kos">.</span><span class="pl-c1">hasOwnProperty</span><span class="pl-kos">.</span><span class="pl-en">call</span><span class="pl-kos">(</span><span class="pl-s1">exports</span><span class="pl-kos">,</span> <span class="pl-s1">name</span><span class="pl-kos">)</span><span class="pl-kos">)</span> <span class="pl-k">continue</span><span class="pl-kos">;</span>
        <span class="pl-s1">defs</span><span class="pl-kos">[</span><span class="pl-s1">name</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-k">function</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-s1">installedModules</span><span class="pl-kos">[</span><span class="pl-s1">moduleId</span><span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-c1">exports</span><span class="pl-kos">[</span><span class="pl-s1">name</span><span class="pl-kos">]</span><span class="pl-kos">;</span> <span class="pl-kos">}</span><span class="pl-kos">;</span>
      <span class="pl-kos">}</span>
      <span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">export</span><span class="pl-kos">(</span><span class="pl-s1">installedModules</span><span class="pl-kos">[</span><span class="pl-s1">moduleId</span><span class="pl-kos">]</span><span class="pl-kos">,</span> <span class="pl-s1">defs</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
      <span class="pl-s1">installedModules</span><span class="pl-kos">[</span><span class="pl-s1">moduleId</span><span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-c1">m</span> <span class="pl-c1">=</span> <span class="pl-c1">0</span><span class="pl-kos">;</span> <span class="pl-c">// falsy; minifies better than false</span>
    <span class="pl-kos">}</span>
  <span class="pl-kos">}</span>

  <span class="pl-k">return</span> <span class="pl-s1">installedModules</span><span class="pl-kos">[</span><span class="pl-s1">moduleId</span><span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-c1">ns</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto"><code class="notranslate">compat</code> is only <code class="notranslate">true</code> when the module is also consumed by a commonjs module. <code class="notranslate">nofreeze</code> is used<br>
to support chaining with the other helpers; but the last helper called should always be allowed to<br>
freeze the namespace.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="__webpack_require__.export = function export(module, specifiers, nofreeze, compat) {
  module.m/*odule*/ = 1; // truthy; 1 minifies better than true

  var ns = module.ns /*namespace*/ = module.ns || (Object.create ? Object.create(null) : {});
  if (typeof Symbol === &quot;function&quot; &amp;&amp; Symbol.toStringTag) {
    Object.defineProperty(ns, Symbol.toStringTag, { value: &quot;Module&quot; })
  }
  if (compat) {
    Object.defineProperty(ns, &quot;__esModule&quot;, { value: true });
  }
  for (var name of specifiers) {
    if (!Object.prototype.hasOwnProperty.call(specifiers, name)) continue;
    Object.defineProperty(ns, name, { enumerable: true, get: specifiers[name] });
  }
  if (!nofreeze) Object.freeze(ns);
}"><pre class="notranslate"><span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">export</span> <span class="pl-c1">=</span> <span class="pl-k">function</span> <span class="pl-en">export</span><span class="pl-kos">(</span><span class="pl-s1">module</span><span class="pl-kos">,</span> <span class="pl-s1">specifiers</span><span class="pl-kos">,</span> <span class="pl-s1">nofreeze</span><span class="pl-kos">,</span> <span class="pl-s1">compat</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-s1">module</span><span class="pl-kos">.</span><span class="pl-c1">m</span><span class="pl-c">/*odule*/</span> <span class="pl-c1">=</span> <span class="pl-c1">1</span><span class="pl-kos">;</span> <span class="pl-c">// truthy; 1 minifies better than true</span>

  <span class="pl-k">var</span> <span class="pl-s1">ns</span> <span class="pl-c1">=</span> <span class="pl-s1">module</span><span class="pl-kos">.</span><span class="pl-c1">ns</span> <span class="pl-c">/*namespace*/</span> <span class="pl-c1">=</span> <span class="pl-s1">module</span><span class="pl-kos">.</span><span class="pl-c1">ns</span> <span class="pl-c1">||</span> <span class="pl-kos">(</span><span class="pl-v">Object</span><span class="pl-kos">.</span><span class="pl-c1">create</span> ? <span class="pl-v">Object</span><span class="pl-kos">.</span><span class="pl-en">create</span><span class="pl-kos">(</span><span class="pl-c1">null</span><span class="pl-kos">)</span> : <span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-k">typeof</span> <span class="pl-v">Symbol</span> <span class="pl-c1">===</span> <span class="pl-s">"function"</span> <span class="pl-c1">&amp;&amp;</span> <span class="pl-v">Symbol</span><span class="pl-kos">.</span><span class="pl-c1">toStringTag</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-v">Object</span><span class="pl-kos">.</span><span class="pl-en">defineProperty</span><span class="pl-kos">(</span><span class="pl-s1">ns</span><span class="pl-kos">,</span> <span class="pl-v">Symbol</span><span class="pl-kos">.</span><span class="pl-c1">toStringTag</span><span class="pl-kos">,</span> <span class="pl-kos">{</span> <span class="pl-c1">value</span>: <span class="pl-s">"Module"</span> <span class="pl-kos">}</span><span class="pl-kos">)</span>
  <span class="pl-kos">}</span>
  <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">compat</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-v">Object</span><span class="pl-kos">.</span><span class="pl-en">defineProperty</span><span class="pl-kos">(</span><span class="pl-s1">ns</span><span class="pl-kos">,</span> <span class="pl-s">"__esModule"</span><span class="pl-kos">,</span> <span class="pl-kos">{</span> <span class="pl-c1">value</span>: <span class="pl-c1">true</span> <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-kos">}</span>
  <span class="pl-k">for</span> <span class="pl-kos">(</span><span class="pl-k">var</span> <span class="pl-s1">name</span> <span class="pl-k">of</span> <span class="pl-s1">specifiers</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-c1">!</span><span class="pl-v">Object</span><span class="pl-kos">.</span><span class="pl-c1">prototype</span><span class="pl-kos">.</span><span class="pl-c1">hasOwnProperty</span><span class="pl-kos">.</span><span class="pl-en">call</span><span class="pl-kos">(</span><span class="pl-s1">specifiers</span><span class="pl-kos">,</span> <span class="pl-s1">name</span><span class="pl-kos">)</span><span class="pl-kos">)</span> <span class="pl-k">continue</span><span class="pl-kos">;</span>
    <span class="pl-v">Object</span><span class="pl-kos">.</span><span class="pl-en">defineProperty</span><span class="pl-kos">(</span><span class="pl-s1">ns</span><span class="pl-kos">,</span> <span class="pl-s1">name</span><span class="pl-kos">,</span> <span class="pl-kos">{</span> <span class="pl-c1">enumerable</span>: <span class="pl-c1">true</span><span class="pl-kos">,</span> <span class="pl-c1">get</span>: <span class="pl-s1">specifiers</span><span class="pl-kos">[</span><span class="pl-s1">name</span><span class="pl-kos">]</span> <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-kos">}</span>
  <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-c1">!</span><span class="pl-s1">nofreeze</span><span class="pl-kos">)</span> <span class="pl-v">Object</span><span class="pl-kos">.</span><span class="pl-en">freeze</span><span class="pl-kos">(</span><span class="pl-s1">ns</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">This helper is used when accessing a property that cannot be statically verified<br>
to exist in the namespace.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="__webpack_require__.namespaceGet = function namespaceGet(ns, name) {
  if (!Object.prototype.hasOwnProperty.call(ns, name)) throw new SyntaxError(&quot;Unknown export &quot; + name);
  return ns[name];
}"><pre class="notranslate"><span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">namespaceGet</span> <span class="pl-c1">=</span> <span class="pl-k">function</span> <span class="pl-en">namespaceGet</span><span class="pl-kos">(</span><span class="pl-s1">ns</span><span class="pl-kos">,</span> <span class="pl-s1">name</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-c1">!</span><span class="pl-v">Object</span><span class="pl-kos">.</span><span class="pl-c1">prototype</span><span class="pl-kos">.</span><span class="pl-c1">hasOwnProperty</span><span class="pl-kos">.</span><span class="pl-en">call</span><span class="pl-kos">(</span><span class="pl-s1">ns</span><span class="pl-kos">,</span> <span class="pl-s1">name</span><span class="pl-kos">)</span><span class="pl-kos">)</span> <span class="pl-k">throw</span> <span class="pl-k">new</span> <span class="pl-v">SyntaxError</span><span class="pl-kos">(</span><span class="pl-s">"Unknown export "</span> <span class="pl-c1">+</span> <span class="pl-s1">name</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-k">return</span> <span class="pl-s1">ns</span><span class="pl-kos">[</span><span class="pl-s1">name</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">This helper is only used if <a href="https://gist.github.com/Kovensky/2caf0eaefc9c00b46ab5afaed59ebd0b">implicit dependencies are allowed by the spec</a>.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="__webpack_require__.reexport = function reexport(module, reexports, nofreeze, compat) {
  if (!module.m) __webpack_require__.export(module, {}, true, compat);

  var specifiers = {};
  for (var name in reexports) {
    if (typeof reexports[name] !== &quot;object&quot;) {
      specifiers[name] = makeNsReexport(reexports[name]);
    } else {
      var moduleId = reexports[name][0];
      var reexport = reexports[name][1];
      specifiers[name] = makeReexport(moduleId, reexport);
    }
  }
  __webpack_require__.export(module, specifiers, nofreeze)

  function makeNsReexport(moduleId) {
    return function () { return __webpack_require__.module(moduleId); }
  }
  function makeReexport(moduleId, reexport) {
    return function() { return __webpack_require__.module(moduleId)[reexport]; }
  }
}"><pre class="notranslate"><span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">reexport</span> <span class="pl-c1">=</span> <span class="pl-k">function</span> <span class="pl-en">reexport</span><span class="pl-kos">(</span><span class="pl-s1">module</span><span class="pl-kos">,</span> <span class="pl-s1">reexports</span><span class="pl-kos">,</span> <span class="pl-s1">nofreeze</span><span class="pl-kos">,</span> <span class="pl-s1">compat</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-c1">!</span><span class="pl-s1">module</span><span class="pl-kos">.</span><span class="pl-c1">m</span><span class="pl-kos">)</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">export</span><span class="pl-kos">(</span><span class="pl-s1">module</span><span class="pl-kos">,</span> <span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-c1">true</span><span class="pl-kos">,</span> <span class="pl-s1">compat</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

  <span class="pl-k">var</span> <span class="pl-s1">specifiers</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">;</span>
  <span class="pl-k">for</span> <span class="pl-kos">(</span><span class="pl-k">var</span> <span class="pl-s1">name</span> <span class="pl-k">in</span> <span class="pl-s1">reexports</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-k">typeof</span> <span class="pl-s1">reexports</span><span class="pl-kos">[</span><span class="pl-s1">name</span><span class="pl-kos">]</span> <span class="pl-c1">!==</span> <span class="pl-s">"object"</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
      <span class="pl-s1">specifiers</span><span class="pl-kos">[</span><span class="pl-s1">name</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-en">makeNsReexport</span><span class="pl-kos">(</span><span class="pl-s1">reexports</span><span class="pl-kos">[</span><span class="pl-s1">name</span><span class="pl-kos">]</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span> <span class="pl-k">else</span> <span class="pl-kos">{</span>
      <span class="pl-k">var</span> <span class="pl-s1">moduleId</span> <span class="pl-c1">=</span> <span class="pl-s1">reexports</span><span class="pl-kos">[</span><span class="pl-s1">name</span><span class="pl-kos">]</span><span class="pl-kos">[</span><span class="pl-c1">0</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
      <span class="pl-k">var</span> <span class="pl-s1">reexport</span> <span class="pl-c1">=</span> <span class="pl-s1">reexports</span><span class="pl-kos">[</span><span class="pl-s1">name</span><span class="pl-kos">]</span><span class="pl-kos">[</span><span class="pl-c1">1</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
      <span class="pl-s1">specifiers</span><span class="pl-kos">[</span><span class="pl-s1">name</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-en">makeReexport</span><span class="pl-kos">(</span><span class="pl-s1">moduleId</span><span class="pl-kos">,</span> <span class="pl-s1">reexport</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span>
  <span class="pl-kos">}</span>
  <span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">export</span><span class="pl-kos">(</span><span class="pl-s1">module</span><span class="pl-kos">,</span> <span class="pl-s1">specifiers</span><span class="pl-kos">,</span> <span class="pl-s1">nofreeze</span><span class="pl-kos">)</span>

  <span class="pl-k">function</span> <span class="pl-en">makeNsReexport</span><span class="pl-kos">(</span><span class="pl-s1">moduleId</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">return</span> <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">module</span><span class="pl-kos">(</span><span class="pl-s1">moduleId</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-kos">}</span>
  <span class="pl-kos">}</span>
  <span class="pl-k">function</span> <span class="pl-en">makeReexport</span><span class="pl-kos">(</span><span class="pl-s1">moduleId</span><span class="pl-kos">,</span> <span class="pl-s1">reexport</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">return</span> <span class="pl-k">function</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">module</span><span class="pl-kos">(</span><span class="pl-s1">moduleId</span><span class="pl-kos">)</span><span class="pl-kos">[</span><span class="pl-s1">reexport</span><span class="pl-kos">]</span><span class="pl-kos">;</span> <span class="pl-kos">}</span>
  <span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">reexportAll always should always be the last helper called, so it always freezes the exports.<br>
This should only be called for reexporting commonjs dependencies, or other modules whose set of exports is not known (if they, say, reexport a commonjs dependency).</p>
<p dir="auto">This helper (and the special case for out-of-order importing) is only needed because EPS 002 says the module.export keys should be hoisted. Should that requirement be removed and the only apparent export is <code class="notranslate">default</code>, all <code class="notranslate">reexportAll</code> can just compile into corresponding <code class="notranslate">import</code>s -- <code class="notranslate">default</code> keys are never reexported via star reexporting.</p>
<p dir="auto">It must necessarily require the modules in order to be able to see their exports and add the<br>
accessors before the freeze. The exports are added after requiring each module to avoid further<br>
trouble with circular references.</p>
<p dir="auto">The duplicate reexports actually should be allowable when their values are <code class="notranslate">SameValue</code>,<br>
but it is unclear how that should apply to mutable bindings, since they can always mutate to not<br>
be <code class="notranslate">SameValue</code> anymore.</p>
<p dir="auto">The reexport getters call <code class="notranslate">__webpack_require__.module</code> to try and deal better with hot reloading.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="__webpack_require__.reexportAll = function reexportAll(module, cjsDeps, ownExports, compat) {
  if (!module.m) __webpack_require__.export(module, {}, true, compat);

  for (var i = 0; i &lt; cjsDeps.length; i++) {
    var dep = cjsDeps[i];
    var specifiers = {};
    var ns = __webpack_require__.module(dep);
    for (var name of ns) {
      if (name === &quot;default&quot;) continue;
      if (!Object.prototype.hasOwnProperty.call(ns, name)) continue;
      if (ownExports.indexOf(name) &gt;= 0) continue;
      if (Object.prototype.hasOwnProperty.call(module.ns, name)) throw new SyntaxError(&quot;Duplicate reexport &quot; + name);
      specifiers[name] = makeReexportAll(dep, name);
    }
    __webpack_require__.export(module, specifiers, true);
  }

  Object.freeze(module.ns);

  function makeReexportAll(moduleId, reexport) {
    return function() { return __webpack_require__.namespaceGet(__webpack_require__.module(moduleId), reexport); }
  }
}"><pre class="notranslate"><span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">reexportAll</span> <span class="pl-c1">=</span> <span class="pl-k">function</span> <span class="pl-en">reexportAll</span><span class="pl-kos">(</span><span class="pl-s1">module</span><span class="pl-kos">,</span> <span class="pl-s1">cjsDeps</span><span class="pl-kos">,</span> <span class="pl-s1">ownExports</span><span class="pl-kos">,</span> <span class="pl-s1">compat</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-c1">!</span><span class="pl-s1">module</span><span class="pl-kos">.</span><span class="pl-c1">m</span><span class="pl-kos">)</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">export</span><span class="pl-kos">(</span><span class="pl-s1">module</span><span class="pl-kos">,</span> <span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-c1">true</span><span class="pl-kos">,</span> <span class="pl-s1">compat</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

  <span class="pl-k">for</span> <span class="pl-kos">(</span><span class="pl-k">var</span> <span class="pl-s1">i</span> <span class="pl-c1">=</span> <span class="pl-c1">0</span><span class="pl-kos">;</span> <span class="pl-s1">i</span> <span class="pl-c1">&lt;</span> <span class="pl-s1">cjsDeps</span><span class="pl-kos">.</span><span class="pl-c1">length</span><span class="pl-kos">;</span> <span class="pl-s1">i</span><span class="pl-c1">++</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">var</span> <span class="pl-s1">dep</span> <span class="pl-c1">=</span> <span class="pl-s1">cjsDeps</span><span class="pl-kos">[</span><span class="pl-s1">i</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
    <span class="pl-k">var</span> <span class="pl-s1">specifiers</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">;</span>
    <span class="pl-k">var</span> <span class="pl-s1">ns</span> <span class="pl-c1">=</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">module</span><span class="pl-kos">(</span><span class="pl-s1">dep</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">for</span> <span class="pl-kos">(</span><span class="pl-k">var</span> <span class="pl-s1">name</span> <span class="pl-k">of</span> <span class="pl-s1">ns</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
      <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">name</span> <span class="pl-c1">===</span> <span class="pl-s">"default"</span><span class="pl-kos">)</span> <span class="pl-k">continue</span><span class="pl-kos">;</span>
      <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-c1">!</span><span class="pl-v">Object</span><span class="pl-kos">.</span><span class="pl-c1">prototype</span><span class="pl-kos">.</span><span class="pl-c1">hasOwnProperty</span><span class="pl-kos">.</span><span class="pl-en">call</span><span class="pl-kos">(</span><span class="pl-s1">ns</span><span class="pl-kos">,</span> <span class="pl-s1">name</span><span class="pl-kos">)</span><span class="pl-kos">)</span> <span class="pl-k">continue</span><span class="pl-kos">;</span>
      <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">ownExports</span><span class="pl-kos">.</span><span class="pl-en">indexOf</span><span class="pl-kos">(</span><span class="pl-s1">name</span><span class="pl-kos">)</span> <span class="pl-c1">&gt;=</span> <span class="pl-c1">0</span><span class="pl-kos">)</span> <span class="pl-k">continue</span><span class="pl-kos">;</span>
      <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-v">Object</span><span class="pl-kos">.</span><span class="pl-c1">prototype</span><span class="pl-kos">.</span><span class="pl-c1">hasOwnProperty</span><span class="pl-kos">.</span><span class="pl-en">call</span><span class="pl-kos">(</span><span class="pl-s1">module</span><span class="pl-kos">.</span><span class="pl-c1">ns</span><span class="pl-kos">,</span> <span class="pl-s1">name</span><span class="pl-kos">)</span><span class="pl-kos">)</span> <span class="pl-k">throw</span> <span class="pl-k">new</span> <span class="pl-v">SyntaxError</span><span class="pl-kos">(</span><span class="pl-s">"Duplicate reexport "</span> <span class="pl-c1">+</span> <span class="pl-s1">name</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
      <span class="pl-s1">specifiers</span><span class="pl-kos">[</span><span class="pl-s1">name</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-en">makeReexportAll</span><span class="pl-kos">(</span><span class="pl-s1">dep</span><span class="pl-kos">,</span> <span class="pl-s1">name</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span>
    <span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">export</span><span class="pl-kos">(</span><span class="pl-s1">module</span><span class="pl-kos">,</span> <span class="pl-s1">specifiers</span><span class="pl-kos">,</span> <span class="pl-c1">true</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-kos">}</span>

  <span class="pl-v">Object</span><span class="pl-kos">.</span><span class="pl-en">freeze</span><span class="pl-kos">(</span><span class="pl-s1">module</span><span class="pl-kos">.</span><span class="pl-c1">ns</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

  <span class="pl-k">function</span> <span class="pl-en">makeReexportAll</span><span class="pl-kos">(</span><span class="pl-s1">moduleId</span><span class="pl-kos">,</span> <span class="pl-s1">reexport</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">return</span> <span class="pl-k">function</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">namespaceGet</span><span class="pl-kos">(</span><span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">module</span><span class="pl-kos">(</span><span class="pl-s1">moduleId</span><span class="pl-kos">)</span><span class="pl-kos">,</span> <span class="pl-s1">reexport</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-kos">}</span>
  <span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">This helper should be called by the DelegatedModule plugin when the exposed module<br>
is an ES module. CJS modules should be exposed with the currently existing template.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="__webpack_require__.expose = function expose(module, moduleId) {
  __webpack_require__.module(moduleId);
  var exposed = installedModules[moduleId];
  module.m = exposed.m;
  module.ns = exposed.ns;
  module.exports = exposed.exports;
}"><pre class="notranslate"><span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">expose</span> <span class="pl-c1">=</span> <span class="pl-k">function</span> <span class="pl-en">expose</span><span class="pl-kos">(</span><span class="pl-s1">module</span><span class="pl-kos">,</span> <span class="pl-s1">moduleId</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">module</span><span class="pl-kos">(</span><span class="pl-s1">moduleId</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-k">var</span> <span class="pl-s1">exposed</span> <span class="pl-c1">=</span> <span class="pl-s1">installedModules</span><span class="pl-kos">[</span><span class="pl-s1">moduleId</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
  <span class="pl-s1">module</span><span class="pl-kos">.</span><span class="pl-c1">m</span> <span class="pl-c1">=</span> <span class="pl-s1">exposed</span><span class="pl-kos">.</span><span class="pl-c1">m</span><span class="pl-kos">;</span>
  <span class="pl-s1">module</span><span class="pl-kos">.</span><span class="pl-c1">ns</span> <span class="pl-c1">=</span> <span class="pl-s1">exposed</span><span class="pl-kos">.</span><span class="pl-c1">ns</span><span class="pl-kos">;</span>
  <span class="pl-s1">module</span><span class="pl-kos">.</span><span class="pl-c1">exports</span> <span class="pl-c1">=</span> <span class="pl-s1">exposed</span><span class="pl-kos">.</span><span class="pl-c1">exports</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<h1 dir="auto">Imports</h1>
<p dir="auto">All imports and export default should use <code class="notranslate">let</code> for correct TDZ, but the emit would not be Uglify-compatible, so they are written with <code class="notranslate">var</code>.</p>
<p dir="auto">All of the sample code has an implied <code class="notranslate">"use strict"</code> unless noted.</p>
<h2 dir="auto">default</h2>
<p dir="auto">A default import of, say, <code class="notranslate">import identifier from</code> will be treated exactly as <code class="notranslate">import { default as identifier } from</code>, that is, it's seen as a named import.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import defaultExport from './esmodule'
defaultExport"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">defaultExport</span> <span class="pl-k">from</span> <span class="pl-s">'./esmodule'</span>
<span class="pl-s1">defaultExport</span></pre></div>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var __imported_esmodule__ = __webpack_require__.module(&quot;./esmodule.js&quot;);
__imported_esmodule__[&quot;default&quot;];"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-s1">__imported_esmodule__</span> <span class="pl-c1">=</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">module</span><span class="pl-kos">(</span><span class="pl-s">"./esmodule.js"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-s1">__imported_esmodule__</span><span class="pl-kos">[</span><span class="pl-s">"default"</span><span class="pl-kos">]</span><span class="pl-kos">;</span></pre></div>
<h2 dir="auto">named</h2>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import { named as renamed } from './esmodule'
renamed"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">named</span> <span class="pl-k">as</span> <span class="pl-s1">renamed</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'./esmodule'</span>
<span class="pl-s1">renamed</span></pre></div>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var __imported_esmodule__ = __webpack_require__.module(&quot;./esmodule.js&quot;);
__imported_esmodule__.named;"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-s1">__imported_esmodule__</span> <span class="pl-c1">=</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">module</span><span class="pl-kos">(</span><span class="pl-s">"./esmodule.js"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-s1">__imported_esmodule__</span><span class="pl-kos">.</span><span class="pl-c1">named</span><span class="pl-kos">;</span></pre></div>
<h2 dir="auto">namespace with static member access</h2>
<p dir="auto">This includes bracketed access with statically-analyzable keys.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import * as namespace from './esmodule'
namespace.named"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-c1">*</span> <span class="pl-k">as</span> <span class="pl-s1">namespace</span> <span class="pl-k">from</span> <span class="pl-s">'./esmodule'</span>
<span class="pl-s1">namespace</span><span class="pl-kos">.</span><span class="pl-c1">named</span></pre></div>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var __imported_esmodule__ = __webpack_require__.module(&quot;./esmodule.js&quot;);
__imported_esmodule__.named;"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-s1">__imported_esmodule__</span> <span class="pl-c1">=</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">module</span><span class="pl-kos">(</span><span class="pl-s">"./esmodule.js"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-s1">__imported_esmodule__</span><span class="pl-kos">.</span><span class="pl-c1">named</span><span class="pl-kos">;</span></pre></div>
<h2 dir="auto">namespace with dynamic member access</h2>
<p dir="auto">This cannot have perfect coverage without using <code class="notranslate">Proxy</code>, but should be close<br>
enough for most cases.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import * as namespace from './esmodule'
namespace[(() =&gt; 'named')()]"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-c1">*</span> <span class="pl-k">as</span> <span class="pl-s1">namespace</span> <span class="pl-k">from</span> <span class="pl-s">'./esmodule'</span>
<span class="pl-s1">namespace</span><span class="pl-kos">[</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-s">'named'</span><span class="pl-kos">)</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">]</span></pre></div>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var __imported_esmodule__ = __webpack_require__.module(&quot;./esmodule.js&quot;);
__webpack_require__.namespaceGet(__imported_esmodule__, (() =&gt; 'named')());"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-s1">__imported_esmodule__</span> <span class="pl-c1">=</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">module</span><span class="pl-kos">(</span><span class="pl-s">"./esmodule.js"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">namespaceGet</span><span class="pl-kos">(</span><span class="pl-s1">__imported_esmodule__</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-s">'named'</span><span class="pl-kos">)</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<h1 dir="auto">commonjs require</h1>
<p dir="auto">Should have no changes.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const namespace = require('./esmodule')"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-s1">namespace</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">'./esmodule'</span><span class="pl-kos">)</span></pre></div>
<p dir="auto">Output should not have an implied <code class="notranslate">"use strict"</code>.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const namespace = __webpack_require__(&quot;./esmodule.js&quot;);"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-s1">namespace</span> <span class="pl-c1">=</span> <span class="pl-en">__webpack_require__</span><span class="pl-kos">(</span><span class="pl-s">"./esmodule.js"</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<h1 dir="auto">Exports</h1>
<p dir="auto">In ES modules, the wrapper function should be changed to:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="function (__webpack_module__, _ignored_unique_identifier, /* rest */)"><pre class="notranslate"><span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-s1">__webpack_module__</span><span class="pl-kos">,</span> <span class="pl-s1">_ignored_unique_identifier</span><span class="pl-kos">,</span> <span class="pl-c">/* rest */</span><span class="pl-kos">)</span></pre></div>
<p dir="auto">None of the helpers, or any of the generated code, should depend on the second argument to the wrapper<br>
function. However, it still needs to be provided for compatibility with CJS modules.</p>
<p dir="auto">The <code class="notranslate">__webpack_default__</code> identifier mentioned in the output should be a guaranteed-unique<br>
identifier (i.e. not visible from user code). Ideally, this would be the same with <code class="notranslate">__webpack_module__</code>,<br>
but it must still be available to support webpack's meta-properties like <code class="notranslate">module.hot</code>.</p>
<p dir="auto">Speaking of the meta-properties, they should be automatically translated from <code class="notranslate">module</code> to apply to<br>
<code class="notranslate">__webpack_module__</code> instead.</p>
<h2 dir="auto"><code class="notranslate">export default</code></h2>
<h3 dir="auto">of anonymous function</h3>
<p dir="auto">Note the <code class="notranslate">{default: function() {}}.default</code> wrapper. This is needed to ensure the anonymous function or class receives the correct <code class="notranslate">Function#name</code>. This also should be hoisted to happen immediately after the <code class="notranslate">"use strict";</code>, before any helpers or imports are called (barring special cases like ProvidePlugin).</p>
<p dir="auto">This also applies to <code class="notranslate">async function</code>.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="export default function () {}"><pre class="notranslate"><span class="pl-k">export</span> <span class="pl-k">default</span> <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span><span class="pl-kos">}</span></pre></div>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var __webpack_default__ = { &quot;default&quot;: function () {} }[&quot;default&quot;];
__webpack_require__.export(__webpack_module__, {
  &quot;default&quot;: function() { return __webpack_default__; }
});"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-s1">__webpack_default__</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span> <span class="pl-s">"default"</span>: <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span><span class="pl-kos">}</span> <span class="pl-kos">}</span><span class="pl-kos">[</span><span class="pl-s">"default"</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
<span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">export</span><span class="pl-kos">(</span><span class="pl-s1">__webpack_module__</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
  <span class="pl-s">"default"</span>: <span class="pl-k">function</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-s1">__webpack_default__</span><span class="pl-kos">;</span> <span class="pl-kos">}</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<h3 dir="auto">of anonymous class</h3>
<p dir="auto">The same wrapper is employed, but it is not hoisted like in the anonymous function case. All engines that support <code class="notranslate">class</code> also support <code class="notranslate">let</code>, so it should be safe to use <code class="notranslate">let</code> in this case to ensure proper TDZ.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="export default class {}"><pre class="notranslate"><span class="pl-k">export</span> <span class="pl-k">default</span> <span class="pl-k">class</span> <span class="pl-kos">{</span><span class="pl-kos">}</span></pre></div>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="__webpack_require__.export(__webpack_module__, {
  &quot;default&quot;: function() { return __webpack_default__; }
});
let __webpack_default__ = { &quot;default&quot;: class {} }[&quot;default&quot;];"><pre class="notranslate"><span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">export</span><span class="pl-kos">(</span><span class="pl-s1">__webpack_module__</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
  <span class="pl-s">"default"</span>: <span class="pl-k">function</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-s1">__webpack_default__</span><span class="pl-kos">;</span> <span class="pl-kos">}</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">let</span> <span class="pl-s1">__webpack_default__</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span> <span class="pl-s">"default"</span>: <span class="pl-k">class</span> <span class="pl-kos">{</span><span class="pl-kos">}</span> <span class="pl-kos">}</span><span class="pl-kos">[</span><span class="pl-s">"default"</span><span class="pl-kos">]</span><span class="pl-kos">;</span></pre></div>
<h3 dir="auto">of named function or class</h3>
<p dir="auto">No <code class="notranslate">__webpack_default__</code> or explicit hoisting involved.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="export default class Name {}"><pre class="notranslate"><span class="pl-k">export</span> <span class="pl-k">default</span> <span class="pl-k">class</span> <span class="pl-v">Name</span> <span class="pl-kos">{</span><span class="pl-kos">}</span></pre></div>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="__webpack_require__.export(__webpack_module__, {
  &quot;default&quot;: function() { return Name; }
});
class Name {}"><pre class="notranslate"><span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">export</span><span class="pl-kos">(</span><span class="pl-s1">__webpack_module__</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
  <span class="pl-s">"default"</span>: <span class="pl-k">function</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-v">Name</span><span class="pl-kos">;</span> <span class="pl-kos">}</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">class</span> <span class="pl-v">Name</span> <span class="pl-kos">{</span><span class="pl-kos">}</span></pre></div>
<h3 dir="auto">of expression (i.e. anything else)</h3>
<p dir="auto">No hoisting allowed.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="export default 1 + 1"><pre class="notranslate"><span class="pl-k">export</span> <span class="pl-k">default</span> <span class="pl-c1">1</span> <span class="pl-c1">+</span> <span class="pl-c1">1</span></pre></div>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="__webpack_require__.export(__webpack_module__, {
  &quot;default&quot;: function() { return __webpack_default__; }
});
var __webpack_default__ = (1 + 1);"><pre class="notranslate"><span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">export</span><span class="pl-kos">(</span><span class="pl-s1">__webpack_module__</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
  <span class="pl-s">"default"</span>: <span class="pl-k">function</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-s1">__webpack_default__</span><span class="pl-kos">;</span> <span class="pl-kos">}</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">var</span> <span class="pl-s1">__webpack_default__</span> <span class="pl-c1">=</span> <span class="pl-kos">(</span><span class="pl-c1">1</span> <span class="pl-c1">+</span> <span class="pl-c1">1</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<h2 dir="auto">Named export</h2>
<h3 dir="auto">With specifier</h3>
<p dir="auto">A specifier without <code class="notranslate">as</code> is treated as if it was exported <code class="notranslate">as</code> itself. For example, <code class="notranslate">export { foo }</code> is treated the same as <code class="notranslate">export { foo as foo }</code>.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="let foo = 1
export { foo as bar }"><pre class="notranslate"><span class="pl-k">let</span> <span class="pl-s1">foo</span> <span class="pl-c1">=</span> <span class="pl-c1">1</span>
<span class="pl-k">export</span> <span class="pl-kos">{</span> <span class="pl-s1">foo</span> <span class="pl-k">as</span> <span class="pl-s1">bar</span> <span class="pl-kos">}</span></pre></div>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="__webpack_require__.export(__webpack_module__, {
  &quot;bar&quot;: function () { return foo; }
});
let foo = 1"><pre class="notranslate"><span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">export</span><span class="pl-kos">(</span><span class="pl-s1">__webpack_module__</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
  <span class="pl-s">"bar"</span>: <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-s1">foo</span><span class="pl-kos">;</span> <span class="pl-kos">}</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">let</span> <span class="pl-s1">foo</span> <span class="pl-c1">=</span> <span class="pl-c1">1</span></pre></div>
<h3 dir="auto">With declarations</h3>
<p dir="auto">The emit is the same regardless of the declaration type; however, <code class="notranslate">var</code>, <code class="notranslate">let</code> and <code class="notranslate">const</code> can specify more than one name.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="export function foo () {}
export class Bar {}
export let hoge, fuga"><pre class="notranslate"><span class="pl-k">export</span> <span class="pl-k">function</span> <span class="pl-en">foo</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span><span class="pl-kos">}</span>
<span class="pl-k">export</span> <span class="pl-k">class</span> <span class="pl-v">Bar</span> <span class="pl-kos">{</span><span class="pl-kos">}</span>
<span class="pl-k">export</span> <span class="pl-k">let</span> <span class="pl-s1">hoge</span><span class="pl-kos">,</span> <span class="pl-s1">fuga</span></pre></div>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="__webpack_require__.export(__webpack_module__, {
  &quot;foo&quot;: function () { return foo; },
  &quot;Bar&quot;: function () { return Bar; },
  &quot;hoge&quot;: function () { return hoge; },
  &quot;fuga&quot;: function () { return fuga; }
});
function foo () {}
class Bar {}
let hoge, fuga"><pre class="notranslate"><span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">export</span><span class="pl-kos">(</span><span class="pl-s1">__webpack_module__</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
  <span class="pl-s">"foo"</span>: <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-s1">foo</span><span class="pl-kos">;</span> <span class="pl-kos">}</span><span class="pl-kos">,</span>
  <span class="pl-s">"Bar"</span>: <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-v">Bar</span><span class="pl-kos">;</span> <span class="pl-kos">}</span><span class="pl-kos">,</span>
  <span class="pl-s">"hoge"</span>: <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-s1">hoge</span><span class="pl-kos">;</span> <span class="pl-kos">}</span><span class="pl-kos">,</span>
  <span class="pl-s">"fuga"</span>: <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-s1">fuga</span><span class="pl-kos">;</span> <span class="pl-kos">}</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">function</span> <span class="pl-en">foo</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span><span class="pl-kos">}</span>
<span class="pl-k">class</span> <span class="pl-v">Bar</span> <span class="pl-kos">{</span><span class="pl-kos">}</span>
<span class="pl-k">let</span> <span class="pl-s1">hoge</span><span class="pl-kos">,</span> <span class="pl-s1">fuga</span></pre></div>
<h1 dir="auto">Reexports</h1>
<p dir="auto">This depends on the answer to <a href="https://gist.github.com/Kovensky/2caf0eaefc9c00b46ab5afaed59ebd0b">https://gist.github.com/Kovensky/2caf0eaefc9c00b46ab5afaed59ebd0b</a></p>
<p dir="auto">If it's allowed to be an implicit dependency, a much simpler reexport emit can be produced.</p>
<p dir="auto">If it has to be a TDZ error, then reexports are emitted identically to <code class="notranslate">import { name } from</code> followed by <code class="notranslate">export { name }</code>.</p>
<h2 dir="auto">of namespace</h2>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import * as namespace from './esmodule'
export { namespace }"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-c1">*</span> <span class="pl-k">as</span> <span class="pl-s1">namespace</span> <span class="pl-k">from</span> <span class="pl-s">'./esmodule'</span>
<span class="pl-k">export</span> <span class="pl-kos">{</span> <span class="pl-s1">namespace</span> <span class="pl-kos">}</span></pre></div>
<p dir="auto">Implicit dependency:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="__webpack_require__.reexport(__webpack_module__, {
  &quot;namespace&quot;: &quot;./esmodule.js&quot;
});
var __imported_esmodule__ = __webpack_require__.module(&quot;./esmodule.js&quot;);"><pre class="notranslate"><span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">reexport</span><span class="pl-kos">(</span><span class="pl-s1">__webpack_module__</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
  <span class="pl-s">"namespace"</span>: <span class="pl-s">"./esmodule.js"</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">var</span> <span class="pl-s1">__imported_esmodule__</span> <span class="pl-c1">=</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">module</span><span class="pl-kos">(</span><span class="pl-s">"./esmodule.js"</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">TDZ (doesn't quite work because of the <code class="notranslate">var</code> instead of <code class="notranslate">const</code>, but...):</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="__webpack_require__.export(__webpack_module__, {
  &quot;namespace&quot;: function () { return __imported_esmodule__; }
});
var __imported_esmodule__ = __webpack_require__.module(&quot;./esmodule.js&quot;);"><pre class="notranslate"><span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">export</span><span class="pl-kos">(</span><span class="pl-s1">__webpack_module__</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
  <span class="pl-s">"namespace"</span>: <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-s1">__imported_esmodule__</span><span class="pl-kos">;</span> <span class="pl-kos">}</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">var</span> <span class="pl-s1">__imported_esmodule__</span> <span class="pl-c1">=</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">module</span><span class="pl-kos">(</span><span class="pl-s">"./esmodule.js"</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">If the exported namespace comes from a cjs module, or a harmony module that reexports<br>
a cjs module, all accesses to members of this export should use the <code class="notranslate">namespaceGet</code> helper.</p>
<h2 dir="auto">of named</h2>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="export { default, foo as bar } from './esmodule'"><pre class="notranslate"><span class="pl-k">export</span> <span class="pl-kos">{</span> <span class="pl-s1">default</span><span class="pl-kos">,</span> <span class="pl-s1">foo</span> <span class="pl-k">as</span> <span class="pl-s1">bar</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'./esmodule'</span></pre></div>
<p dir="auto">Implicit dependency:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="__webpack_require__.reexport(__webpack_module__, {
  &quot;default&quot;: [&quot;./esmodule.js&quot;, &quot;default&quot;],
  &quot;bar&quot;: [&quot;./esmodule.js&quot;, &quot;foo&quot;]
});
var __imported_esmodule__ = __webpack_require__.module(&quot;./esmodule.js&quot;);"><pre class="notranslate"><span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">reexport</span><span class="pl-kos">(</span><span class="pl-s1">__webpack_module__</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
  <span class="pl-s">"default"</span>: <span class="pl-kos">[</span><span class="pl-s">"./esmodule.js"</span><span class="pl-kos">,</span> <span class="pl-s">"default"</span><span class="pl-kos">]</span><span class="pl-kos">,</span>
  <span class="pl-s">"bar"</span>: <span class="pl-kos">[</span><span class="pl-s">"./esmodule.js"</span><span class="pl-kos">,</span> <span class="pl-s">"foo"</span><span class="pl-kos">]</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">var</span> <span class="pl-s1">__imported_esmodule__</span> <span class="pl-c1">=</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">module</span><span class="pl-kos">(</span><span class="pl-s">"./esmodule.js"</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">TDZ:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="__webpack_require__.export(__webpack_module__, {
  &quot;default&quot;: function () { return __imported_esmodule__[&quot;default&quot;]; }
  &quot;bar&quot;: function () { return __imported_esmodule__[&quot;foo&quot;]; }
});
var __imported_esmodule__ = __webpack_require__.module(&quot;./esmodule.js&quot;);"><pre class="notranslate"><span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">export</span><span class="pl-kos">(</span><span class="pl-s1">__webpack_module__</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
  <span class="pl-s">"default"</span>: <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-s1">__imported_esmodule__</span><span class="pl-kos">[</span><span class="pl-s">"default"</span><span class="pl-kos">]</span><span class="pl-kos">;</span> <span class="pl-kos">}</span>
  <span class="pl-s">"bar"</span>: <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-s1">__imported_esmodule__</span><span class="pl-kos">[</span><span class="pl-s">"foo"</span><span class="pl-kos">]</span><span class="pl-kos">;</span> <span class="pl-kos">}</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">var</span> <span class="pl-s1">__imported_esmodule__</span> <span class="pl-c1">=</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">module</span><span class="pl-kos">(</span><span class="pl-s">"./esmodule.js"</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Webpack will not be able to statically check if the reexported symbols actually<br>
exist in a commonjs module, so when reexporting names from them, the generated<br>
getter should <code class="notranslate">return</code> something similar to<br>
<code class="notranslate">__webpack_require__.namespaceGet(__imported_cjs__, "foo")</code>.</p>
<h1 dir="auto">Star Reexports</h1>
<p dir="auto">Assuming "./esmodule.js" has <code class="notranslate">default</code>, <code class="notranslate">foo</code> and <code class="notranslate">bar</code> as exports.</p>
<h2 dir="auto">of ES module</h2>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="export * from './esmodule'
export function foo () {}"><pre class="notranslate"><span class="pl-k">export</span> <span class="pl-c1">*</span> <span class="pl-k">from</span> <span class="pl-s">'./esmodule'</span>
<span class="pl-k">export</span> <span class="pl-k">function</span> <span class="pl-en">foo</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span><span class="pl-kos">}</span></pre></div>
<p dir="auto">Implicit dependency:</p>
<p dir="auto">As, in this example, exports are combined with reexports, an additional argument to <code class="notranslate">__webpack_require__.export</code> is required.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="__webpack_require__.export(__webpack_module__, {
  &quot;foo&quot;: function () { return foo; }
}, true);
__webpack_require__.reexport(__webpack_module__, {
  &quot;bar&quot;: [ &quot;./esmodule.js&quot;, &quot;bar&quot; ]
});
var __imported_esmodule__ = __webpack_require__(&quot;./esmodule.js&quot;);
function foo () {}"><pre class="notranslate"><span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">export</span><span class="pl-kos">(</span><span class="pl-s1">__webpack_module__</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
  <span class="pl-s">"foo"</span>: <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-s1">foo</span><span class="pl-kos">;</span> <span class="pl-kos">}</span>
<span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-c1">true</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">reexport</span><span class="pl-kos">(</span><span class="pl-s1">__webpack_module__</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
  <span class="pl-s">"bar"</span>: <span class="pl-kos">[</span> <span class="pl-s">"./esmodule.js"</span><span class="pl-kos">,</span> <span class="pl-s">"bar"</span> <span class="pl-kos">]</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">var</span> <span class="pl-s1">__imported_esmodule__</span> <span class="pl-c1">=</span> <span class="pl-en">__webpack_require__</span><span class="pl-kos">(</span><span class="pl-s">"./esmodule.js"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">function</span> <span class="pl-en">foo</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span><span class="pl-kos">}</span></pre></div>
<p dir="auto">TDZ:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="__webpack_require__.export(__webpack_module__, {
  &quot;foo&quot;: function () { return foo; },
  &quot;bar&quot;: function () { return __imported_esmodule__[&quot;bar&quot;]; }
});
var __imported_esmodule__ = __webpack_require__(&quot;./esmodule.js&quot;);
function foo () {}"><pre class="notranslate"><span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">export</span><span class="pl-kos">(</span><span class="pl-s1">__webpack_module__</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
  <span class="pl-s">"foo"</span>: <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-s1">foo</span><span class="pl-kos">;</span> <span class="pl-kos">}</span><span class="pl-kos">,</span>
  <span class="pl-s">"bar"</span>: <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-s1">__imported_esmodule__</span><span class="pl-kos">[</span><span class="pl-s">"bar"</span><span class="pl-kos">]</span><span class="pl-kos">;</span> <span class="pl-kos">}</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">var</span> <span class="pl-s1">__imported_esmodule__</span> <span class="pl-c1">=</span> <span class="pl-en">__webpack_require__</span><span class="pl-kos">(</span><span class="pl-s">"./esmodule.js"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">function</span> <span class="pl-en">foo</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span><span class="pl-kos">}</span></pre></div>
<h2 dir="auto">of CJS module</h2>
<p dir="auto">This emit is the same regardless of Implicit dependency or TDZ.</p>
<p dir="auto"><code class="notranslate">reexportAll</code> receives the list of all named exports local to this module.<br>
This includes explicit reexports, but does <em>not</em> include names coming from<br>
other star reexports.</p>
<p dir="auto">As <code class="notranslate">reexportAll</code> will freeze the exports, it will have to internally<br>
<code class="notranslate">__webpack_require__</code> the dependent modules in order to be able to expose<br>
their exports.</p>
<p dir="auto">This also poisons all imports of this module such that they have to use<br>
the <code class="notranslate">__webpack_require__.namespaceGet</code> helper to be able to read any<br>
export that is not statically known to exist.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="export * from './cjs'
export function foo () {}"><pre class="notranslate"><span class="pl-k">export</span> <span class="pl-c1">*</span> <span class="pl-k">from</span> <span class="pl-s">'./cjs'</span>
<span class="pl-k">export</span> <span class="pl-k">function</span> <span class="pl-en">foo</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span><span class="pl-kos">}</span></pre></div>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="__webpack_require__.export(__webpack_module__, {
  &quot;foo&quot;: function () { return foo; }
}, true);
__webpack_require__.reexportAll(__webpack_module__, [
  &quot;./cjs.js&quot;
], [ &quot;foo&quot; ])
function foo () {}"><pre class="notranslate"><span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">export</span><span class="pl-kos">(</span><span class="pl-s1">__webpack_module__</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
  <span class="pl-s">"foo"</span>: <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-s1">foo</span><span class="pl-kos">;</span> <span class="pl-kos">}</span>
<span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-c1">true</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">reexportAll</span><span class="pl-kos">(</span><span class="pl-s1">__webpack_module__</span><span class="pl-kos">,</span> <span class="pl-kos">[</span>
  <span class="pl-s">"./cjs.js"</span>
<span class="pl-kos">]</span><span class="pl-kos">,</span> <span class="pl-kos">[</span> <span class="pl-s">"foo"</span> <span class="pl-kos">]</span><span class="pl-kos">)</span>
<span class="pl-k">function</span> <span class="pl-en">foo</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span><span class="pl-kos">}</span></pre></div>
<h1 dir="auto">All export kinds combined</h1>
<p dir="auto">With the same esmodule as the previous section.</p>
<p dir="auto">Also has an import and a default anonymous export to demonstrate ordering.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import * as some from 'some-module'
export { some }
export default function () {}
require('other-module')
export let foo
export { default as baz } from './esmodule'
export * from './esmodule';
export * from './cjs';"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-c1">*</span> <span class="pl-k">as</span> <span class="pl-s1">some</span> <span class="pl-k">from</span> <span class="pl-s">'some-module'</span>
<span class="pl-k">export</span> <span class="pl-kos">{</span> <span class="pl-s1">some</span> <span class="pl-kos">}</span>
<span class="pl-k">export</span> <span class="pl-k">default</span> <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span><span class="pl-kos">}</span>
<span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">'other-module'</span><span class="pl-kos">)</span>
<span class="pl-k">export</span> <span class="pl-k">let</span> <span class="pl-s1">foo</span>
<span class="pl-k">export</span> <span class="pl-kos">{</span> <span class="pl-s1">default</span> <span class="pl-k">as</span> <span class="pl-s1">baz</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'./esmodule'</span>
<span class="pl-k">export</span> <span class="pl-c1">*</span> <span class="pl-k">from</span> <span class="pl-s">'./esmodule'</span><span class="pl-kos">;</span>
<span class="pl-k">export</span> <span class="pl-c1">*</span> <span class="pl-k">from</span> <span class="pl-s">'./cjs'</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Implicit dependency:</p>
<p dir="auto">When combining ES star reexport with CJS star reexport, a <code class="notranslate">true</code> third argument is required on <code class="notranslate">reexport</code> as well.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="//exports
var __webpack_default__ = { &quot;default&quot;: function () {} }[&quot;default&quot;];
__webpack_require__.export(__webpack_module__, {
  &quot;default&quot;: function () { return __webpack_default__; },
  &quot;foo&quot;: function () { return foo; }
}, true);
__webpack_require__.reexport(__webpack_module__, {
  &quot;some&quot;: &quot;some-module&quot;,
  &quot;baz&quot;: [ &quot;./esmodule.js&quot;, &quot;default&quot; ]
}, true);
__webpack_require__.reexportAll(__webpack_module__, [
  &quot;./cjs.js&quot;
], [ &quot;some&quot;, &quot;foo&quot;, &quot;baz&quot; ]);
// imports
var __imported_some_module__ = __webpack_require__.module(&quot;some-module&quot;);
var __imported_esmodule__ = __webpack_require__.module(&quot;./esmodule.js&quot;);
// code
__webpack_require__(&quot;other-module&quot;);
let foo;"><pre class="notranslate"><span class="pl-c">//exports</span>
<span class="pl-k">var</span> <span class="pl-s1">__webpack_default__</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span> <span class="pl-s">"default"</span>: <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span><span class="pl-kos">}</span> <span class="pl-kos">}</span><span class="pl-kos">[</span><span class="pl-s">"default"</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
<span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">export</span><span class="pl-kos">(</span><span class="pl-s1">__webpack_module__</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
  <span class="pl-s">"default"</span>: <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-s1">__webpack_default__</span><span class="pl-kos">;</span> <span class="pl-kos">}</span><span class="pl-kos">,</span>
  <span class="pl-s">"foo"</span>: <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-s1">foo</span><span class="pl-kos">;</span> <span class="pl-kos">}</span>
<span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-c1">true</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">reexport</span><span class="pl-kos">(</span><span class="pl-s1">__webpack_module__</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
  <span class="pl-s">"some"</span>: <span class="pl-s">"some-module"</span><span class="pl-kos">,</span>
  <span class="pl-s">"baz"</span>: <span class="pl-kos">[</span> <span class="pl-s">"./esmodule.js"</span><span class="pl-kos">,</span> <span class="pl-s">"default"</span> <span class="pl-kos">]</span>
<span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-c1">true</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">reexportAll</span><span class="pl-kos">(</span><span class="pl-s1">__webpack_module__</span><span class="pl-kos">,</span> <span class="pl-kos">[</span>
  <span class="pl-s">"./cjs.js"</span>
<span class="pl-kos">]</span><span class="pl-kos">,</span> <span class="pl-kos">[</span> <span class="pl-s">"some"</span><span class="pl-kos">,</span> <span class="pl-s">"foo"</span><span class="pl-kos">,</span> <span class="pl-s">"baz"</span> <span class="pl-kos">]</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-c">// imports</span>
<span class="pl-k">var</span> <span class="pl-s1">__imported_some_module__</span> <span class="pl-c1">=</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">module</span><span class="pl-kos">(</span><span class="pl-s">"some-module"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">var</span> <span class="pl-s1">__imported_esmodule__</span> <span class="pl-c1">=</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">module</span><span class="pl-kos">(</span><span class="pl-s">"./esmodule.js"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-c">// code</span>
<span class="pl-en">__webpack_require__</span><span class="pl-kos">(</span><span class="pl-s">"other-module"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">let</span> <span class="pl-s1">foo</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">TDZ:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// exports
var __webpack_default__ = { &quot;default&quot;: function () {} }[&quot;default&quot;];
__webpack_require__.export(__webpack_module__, {
  &quot;some&quot;: function () { return __imported_some_module__; },
  &quot;default&quot;: function () { return __webpack_default__; },
  &quot;foo&quot;: function () { return foo; },
  &quot;baz&quot;: function () { return __imported_esmodule__[&quot;default&quot;]; }
}, true);
__webpack_require__.reexportAll(__webpack_module__, [
  &quot;./cjs.js&quot;
], [ &quot;some&quot;, &quot;foo&quot;, &quot;baz&quot; ]);
// imports
var __imported_some_module__ = __webpack_require__.module(&quot;some-module&quot;);
var __imported_esmodule__ = __webpack_require__.module(&quot;./esmodule.js&quot;);
// code
__webpack_require__(&quot;other-module&quot;);
let foo;"><pre class="notranslate"><span class="pl-c">// exports</span>
<span class="pl-k">var</span> <span class="pl-s1">__webpack_default__</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span> <span class="pl-s">"default"</span>: <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span><span class="pl-kos">}</span> <span class="pl-kos">}</span><span class="pl-kos">[</span><span class="pl-s">"default"</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
<span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">export</span><span class="pl-kos">(</span><span class="pl-s1">__webpack_module__</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
  <span class="pl-s">"some"</span>: <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-s1">__imported_some_module__</span><span class="pl-kos">;</span> <span class="pl-kos">}</span><span class="pl-kos">,</span>
  <span class="pl-s">"default"</span>: <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-s1">__webpack_default__</span><span class="pl-kos">;</span> <span class="pl-kos">}</span><span class="pl-kos">,</span>
  <span class="pl-s">"foo"</span>: <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-s1">foo</span><span class="pl-kos">;</span> <span class="pl-kos">}</span><span class="pl-kos">,</span>
  <span class="pl-s">"baz"</span>: <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-s1">__imported_esmodule__</span><span class="pl-kos">[</span><span class="pl-s">"default"</span><span class="pl-kos">]</span><span class="pl-kos">;</span> <span class="pl-kos">}</span>
<span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-c1">true</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">reexportAll</span><span class="pl-kos">(</span><span class="pl-s1">__webpack_module__</span><span class="pl-kos">,</span> <span class="pl-kos">[</span>
  <span class="pl-s">"./cjs.js"</span>
<span class="pl-kos">]</span><span class="pl-kos">,</span> <span class="pl-kos">[</span> <span class="pl-s">"some"</span><span class="pl-kos">,</span> <span class="pl-s">"foo"</span><span class="pl-kos">,</span> <span class="pl-s">"baz"</span> <span class="pl-kos">]</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-c">// imports</span>
<span class="pl-k">var</span> <span class="pl-s1">__imported_some_module__</span> <span class="pl-c1">=</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">module</span><span class="pl-kos">(</span><span class="pl-s">"some-module"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">var</span> <span class="pl-s1">__imported_esmodule__</span> <span class="pl-c1">=</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">module</span><span class="pl-kos">(</span><span class="pl-s">"./esmodule.js"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-c">// code</span>
<span class="pl-en">__webpack_require__</span><span class="pl-kos">(</span><span class="pl-s">"other-module"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">let</span> <span class="pl-s1">foo</span><span class="pl-kos">;</span></pre></div>
<h1 dir="auto">Bug report</h1>
<p dir="auto">I have an issue with <a href="https://www.npmjs.com/package/planout" rel="nofollow">planout</a> that bundled fine with Webpack 4 but no longer works with Webpack 5.</p>
<p dir="auto"><strong>What is the current behavior?</strong><br>
Module is not loaded:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Uncaught TypeError: Getter must be a function: A
    at Function.defineProperty (&lt;anonymous&gt;)
    at Function.__webpack_require__.d (bundle.js:963)
    at eval (index.js:2)
    at Module../build/index.js (planout.js:102)
    at __nested_webpack_require_539__ (planout.js:25)
    at eval (planout.js:89)
    at eval (planout.js:92)
    at webpackUniversalModuleDefinition (planout.js:3)
    at eval (planout.js:5)
    at Object../node_modules/planout/dist/planout.js (bundle.js:291)"><pre class="notranslate"><code class="notranslate">Uncaught TypeError: Getter must be a function: A
    at Function.defineProperty (&lt;anonymous&gt;)
    at Function.__webpack_require__.d (bundle.js:963)
    at eval (index.js:2)
    at Module../build/index.js (planout.js:102)
    at __nested_webpack_require_539__ (planout.js:25)
    at eval (planout.js:89)
    at eval (planout.js:92)
    at webpackUniversalModuleDefinition (planout.js:3)
    at eval (planout.js:5)
    at Object../node_modules/planout/dist/planout.js (bundle.js:291)
</code></pre></div>
<p dir="auto"><strong>If the current behavior is a bug, please provide the steps to reproduce.</strong><br>
Repo Here:</p>
<p dir="auto"><a href="https://github.com/gita-v/webpack_issue">https://github.com/gita-v/webpack_issue</a></p>
<p dir="auto"><strong>What is the expected behavior?</strong></p>
<p dir="auto">For module to load :)</p>
<p dir="auto"><strong>Other relevant information:</strong><br>
webpack version:  5.3.2<br>
Node.js version: 14.14.0</p>