<h3 dir="auto"><strong>Do you want to request a <em>feature</em> or report a <em>bug</em>?</strong></h3>
<p dir="auto">Bug</p>


<h3 dir="auto"><strong>What is the current behavior?</strong></h3>
<blockquote>
<p dir="auto">(I wanna cry: )The optimization of Scope Hoisting could break core-js <code class="notranslate">Array.from</code>.</p>
</blockquote>
<p dir="auto"><strong>After updated to webpack v3. My code will throw the error:</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Uncaught TypeError: Cannot assign to read only property 'length' of function 'function from() { [native code] }'"><pre lang="log" class="notranslate"><code class="notranslate">Uncaught TypeError: Cannot assign to read only property 'length' of function 'function from() { [native code] }'
</code></pre></div>
<h3 dir="auto"><strong>If the current behavior is a bug, please provide the steps to reproduce.</strong></h3>
<p dir="auto">The error due to wrong context:</p>
<ul dir="auto">
<li>webpack use <code class="notranslate">__webpack_require__.n</code> &amp; <code class="notranslate">__webpack_require__.d</code> to mangle exports name;</li>
<li>Array.from transformed to <code class="notranslate">__WEBPACK_IMPORTED_MODULE_4_babel_runtime_core_js_array_from___default.a</code>;</li>
<li>While calling <code class="notranslate">arrayfrom.a(arraylike)</code>, the context will be <code class="notranslate">function getDefault</code>;</li>
<li><a href="https://github.com/zloirock/core-js/blob/8cf8d1e0cba3601fc533f8b27a3966d0d6100daf/modules/es6.array.from.js#L15">es6.array.from.js#L15</a>, <code class="notranslate">C</code> will be <code class="notranslate">getDefault</code>;</li>
<li><a href="https://github.com/zloirock/core-js/blob/8cf8d1e0cba3601fc533f8b27a3966d0d6100daf/modules/es6.array.from.js#L25">#L25</a> <code class="notranslate">new C()</code> will return <code class="notranslate">function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {...}</code>;</li>
<li><code class="notranslate">createProperty</code> will make the returned function property <code class="notranslate">length</code> read only;</li>
<li>finally when it call <code class="notranslate">result.length = index</code>, the error <code class="notranslate">Uncaught TypeError</code> will be threw.</li>
</ul>



<h3 dir="auto"><strong>What is the expected behavior?</strong></h3>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/9346008/27423701-0af63cb8-5765-11e7-8db4-6473deb40a38.png"><img src="https://user-images.githubusercontent.com/9346008/27423701-0af63cb8-5765-11e7-8db4-6473deb40a38.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.</strong></p>
<p dir="auto">webpack v3</p>
<h1 dir="auto">Bug report</h1>




<p dir="auto"><strong>What is the current behavior?</strong><br>
webpack.config.js</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
    target: 'electron-main',
    node: {
      __dirname: false
    },
    entry: {
      main: './src/main.ts'
    },
}"><pre class="notranslate"><span class="pl-kos">{</span>
    <span class="pl-c1">target</span>: <span class="pl-s">'electron-main'</span><span class="pl-kos">,</span>
    <span class="pl-c1">node</span>: <span class="pl-kos">{</span>
      <span class="pl-c1">__dirname</span>: <span class="pl-c1">false</span>
    <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-c1">entry</span>: <span class="pl-kos">{</span>
      <span class="pl-c1">main</span>: <span class="pl-s">'./src/main.ts'</span>
    <span class="pl-kos">}</span><span class="pl-kos">,</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">main.ts</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="console.log(__dirname)"><pre class="notranslate"><span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s1">__dirname</span><span class="pl-kos">)</span></pre></div>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$ node main.js"><pre class="notranslate">$ node main.js</pre></div>
<p dir="auto">ouput '/'</p>
<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">it should output the absolute path</p>


<p dir="auto"><strong>Other relevant information:</strong><br>
webpack version:  4.44.1<br>
Node.js version: 12.18.3<br>
Operating System: macOS 10.15.6<br>
Additional tools:</p>