<h1 dir="auto">Bug report</h1>




<p dir="auto"><strong>What is the current behavior?</strong></p>
<p dir="auto">Destructuring DefinePlugin variables causes runtime error <code class="notranslate">Uncaught ReferenceError: process is not defined</code></p>
<p dir="auto"><strong>If the current behavior is a bug, please provide the steps to reproduce.</strong></p>
<ol dir="auto">
<li>have DefinePlugin plugin defined in the webpack config like this:</li>
</ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  plugins: [
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
    })
  ]"><pre class="notranslate"><code class="notranslate">  plugins: [
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
    })
  ]
</code></pre></div>
<ol start="2" dir="auto">
<li>try to access <code class="notranslate">NODE_ENV</code> via destructuring: <code class="notranslate">const { NODE_ENV } = process.env;</code></li>
<li>you get runtime failure <code class="notranslate">Uncaught ReferenceError: process is not defined</code></li>
</ol>
<p dir="auto">However!</p>
<p dir="auto">if you access NODE_ENV like <code class="notranslate">const NODE_ENV = process.env.NODE_ENV;</code> instead of <code class="notranslate">const { NODE_ENV } = process.env;</code> you don't get runtime error and everything works like expected.</p>






<p dir="auto"><strong>What is the expected behavior?</strong></p>
<p dir="auto">Both ways of accessing the variable should be equal and should not cause runtime error.</p>
<p dir="auto">It is pretty confusing and hard to debug problem and also problematic due to widely used <code class="notranslate">prefer-destructuring</code> eslint rule.</p>


<p dir="auto"><strong>Other relevant information:</strong><br>
webpack version:  5.64.4<br>
Node.js version: v16.13.0<br>
Operating System: MacOS Big Sur<br>
Additional tools:</p>
<h1 dir="auto">Bug report</h1>




<p dir="auto"><strong>What is the current behavior?</strong></p>
<p dir="auto">Hi, I am working with webpack 4 and yarn berry workspaces.</p>
<p dir="auto">whenever I try to import a "package (workspace)" the browser console gives me a warning:</p>
<p dir="auto">"export 'IAppError' was not found in './src/reduce_request_error'</p>
<p dir="auto">The app however works, and no other places throw this warning. It happens to all of the packages that we import and export in our index files <code class="notranslate">index.ts</code></p>
<p dir="auto">Thanks,<br>
Best regards.<br>
TC</p>
<p dir="auto"><strong>If the current behavior is a bug, please provide the steps to reproduce.</strong></p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/16632552/87426951-53f2f900-c5e0-11ea-81eb-ac6ffdeaf921.png"><img width="770" alt="Zrzut ekranu 2020-07-14 o 14 38 23" src="https://user-images.githubusercontent.com/16632552/87426951-53f2f900-c5e0-11ea-81eb-ac6ffdeaf921.png" style="max-width: 100%;"></a></p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/16632552/87426956-55bcbc80-c5e0-11ea-8605-dbe164fa6971.png"><img width="684" alt="Zrzut ekranu 2020-07-14 o 14 38 43" src="https://user-images.githubusercontent.com/16632552/87426956-55bcbc80-c5e0-11ea-8605-dbe164fa6971.png" style="max-width: 100%;"></a></p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/16632552/87426959-56555300-c5e0-11ea-98f7-fc8a33aab800.png"><img width="609" alt="Zrzut ekranu 2020-07-14 o 14 39 09" src="https://user-images.githubusercontent.com/16632552/87426959-56555300-c5e0-11ea-98f7-fc8a33aab800.png" style="max-width: 100%;"></a></p>






<p dir="auto"><strong>What is the expected behavior?</strong></p>
<p dir="auto">No warnings... because app works.</p>


<p dir="auto">Do you think its an issue on your side?<br>
Thanks in advance,<br>
best regards,<br>
TC</p>
<p dir="auto"><strong>Other relevant information:</strong><br>
webpack version:  "^4.43.0",<br>
Node.js version: 12.10<br>
Operating System:  macos<br>
Additional tools: yarn berry</p>