<h1 dir="auto">Bug report</h1>
<p dir="auto"><strong>What is the current behavior?</strong></p>
<p dir="auto">Using the following config works in Webpack 4 but not Webpack 5:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="module.exports = {
  output: {
    library: &quot;A&quot;,
  },
  optimization: {
    runtimeChunk: &quot;single&quot;
  },
};"><pre class="notranslate"><span class="pl-smi">module</span><span class="pl-kos">.</span><span class="pl-c1">exports</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
  <span class="pl-c1">output</span>: <span class="pl-kos">{</span>
    <span class="pl-c1">library</span>: <span class="pl-s">"A"</span><span class="pl-kos">,</span>
  <span class="pl-kos">}</span><span class="pl-kos">,</span>
  <span class="pl-c1">optimization</span>: <span class="pl-kos">{</span>
    <span class="pl-c1">runtimeChunk</span>: <span class="pl-s">"single"</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">I would expect the module to be assigned to a variable <code class="notranslate">A</code>, but in Webpack 5 <code class="notranslate">A</code> is undefined.</p>
<p dir="auto"><strong>Webpack 4 output:</strong></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var A =
(window[&quot;webpackJsonpA&quot;] = window[&quot;webpackJsonpA&quot;] || []).push([[&quot;main&quot;],{
  ...
},[[&quot;./src/index.js&quot;,&quot;runtime&quot;]]]);"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-v">A</span> <span class="pl-c1">=</span>
<span class="pl-kos">(</span><span class="pl-smi">window</span><span class="pl-kos">[</span><span class="pl-s">"webpackJsonpA"</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-smi">window</span><span class="pl-kos">[</span><span class="pl-s">"webpackJsonpA"</span><span class="pl-kos">]</span> <span class="pl-c1">||</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">push</span><span class="pl-kos">(</span><span class="pl-kos">[</span><span class="pl-kos">[</span><span class="pl-s">"main"</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-kos">[</span><span class="pl-s">"./src/index.js"</span><span class="pl-kos">,</span><span class="pl-s">"runtime"</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"><strong>Webpack 5 output:</strong></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var A;
(self[&quot;webpackChunkA&quot;] = self[&quot;webpackChunkA&quot;] || []).push([[&quot;main&quot;],{
  ...
},
0,[[&quot;./src/index.js&quot;,&quot;runtime&quot;]]]);"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-v">A</span><span class="pl-kos">;</span>
<span class="pl-kos">(</span><span class="pl-s1">self</span><span class="pl-kos">[</span><span class="pl-s">"webpackChunkA"</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-s1">self</span><span class="pl-kos">[</span><span class="pl-s">"webpackChunkA"</span><span class="pl-kos">]</span> <span class="pl-c1">||</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">push</span><span class="pl-kos">(</span><span class="pl-kos">[</span><span class="pl-kos">[</span><span class="pl-s">"main"</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">0</span><span class="pl-kos">,</span><span class="pl-kos">[</span><span class="pl-kos">[</span><span class="pl-s">"./src/index.js"</span><span class="pl-kos">,</span><span class="pl-s">"runtime"</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"><strong>If the current behavior is a bug, please provide the steps to reproduce.</strong></p>
<p dir="auto">Smallest reproducible bug demo: <a href="https://github.com/keeganstreet/webpack-5-library">https://github.com/keeganstreet/webpack-5-library</a></p>
<p dir="auto"><strong>What is the expected behavior?</strong></p>
<p dir="auto">The module should be assigned to <code class="notranslate">A</code>.</p>
<p dir="auto"><strong>Other relevant information:</strong><br>
webpack version:  5.24.2<br>
Node.js version: v14.4.0<br>
Operating System: Mac OS<br>
Additional tools: N/A</p>
<h1 dir="auto">Bug report</h1>




<p dir="auto"><strong>What is the current behavior?</strong></p>
<p dir="auto">I build using the following output configuration:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="output: {
	filename: './js/react/[name]-src.js',
	library: ['RF', '[name]'],
	libraryTarget: 'var',
	path: outputPath,
},"><pre class="notranslate"><code class="notranslate">output: {
	filename: './js/react/[name]-src.js',
	library: ['RF', '[name]'],
	libraryTarget: 'var',
	path: outputPath,
},
</code></pre></div>
<p dir="auto">This results in a variable <code class="notranslate">RF</code> which is <code class="notranslate">undefined</code>.</p>
<p dir="auto">The declaration of a property of RF now occurs using the following code (generated):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="var RF;
(self[&quot;webpackChunkRF_name_&quot;] = self[&quot;webpackChunkRF_name_&quot;] || []).push([[&quot;audit-trail&quot;], {"><pre class="notranslate"><code class="notranslate">var RF;
(self["webpackChunkRF_name_"] = self["webpackChunkRF_name_"] || []).push([["audit-trail"], {
</code></pre></div>
<p dir="auto"><strong>If the current behavior is a bug, please provide the steps to reproduce.</strong></p>






<p dir="auto"><strong>What is the expected behavior?</strong></p>
<p dir="auto">In versions of webpack before v5.22 (up until 5.21.2), this resulted in an object 'RF' being declared, where (as in the example above) the following would be available <code class="notranslate">RF['audit-trail']</code>.</p>
<p dir="auto">The same file resulted in this before 5.22</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="var RF;(RF = typeof RF === &quot;undefined&quot; ? {} : RF)[&quot;audit-trail&quot;] =
	(self[&quot;webpackChunkRF_name_&quot;] = self[&quot;webpackChunkRF_name_&quot;] || []).push([[&quot;audit-trail&quot;], {"><pre class="notranslate"><code class="notranslate">var RF;(RF = typeof RF === "undefined" ? {} : RF)["audit-trail"] =
	(self["webpackChunkRF_name_"] = self["webpackChunkRF_name_"] || []).push([["audit-trail"], {
</code></pre></div>


<p dir="auto"><strong>Other relevant information:</strong><br>
webpack version:  5.22 (also tried 5.23)<br>
Node.js version: 15.7.0<br>
Operating System: Windows 10<br>
Additional tools:</p>