<p dir="auto">Libraries often use <code class="notranslate">process.env.NODE_ENV</code> so they can compile conditionally, but they also often try to guard against <code class="notranslate">process</code>' absence with some <code class="notranslate">typeof</code> check which BY DEFAULT is causing every consumer of the library to include i.e. <code class="notranslate">process</code> polyfill.</p>
<p dir="auto">I think most webpack-generated code is targeting the browser and auto-polyfilling such things is at least unexpected. Its causing extra-bytes in users' bundles, but whats more troubling it causes it for UMD standalone builds too which causes serious duplication of the code which is not intended to run! And all of that often by accident.</p>
<p dir="auto">Also while writing isomorphic libraries people often use such lines:<br>
<code class="notranslate">const asap = typeof setImmediate !== 'undefined' ? setImmediate : setTimeout</code><br>
which when bundled by webpack will also include <code class="notranslate">setImmediate</code>'s polyfill automatically - again by accident. And even if libraries authors are aware of this (but mostly not), certainly users are not and they do not put configurations like below while targeting browsers only and not thinking about this too much:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="node: {
  global: false,
  process: false,
  __filename: false,
  __dirname: false,
  Buffer: false,
  setImmediate: false,
}"><pre class="notranslate">node: <span class="pl-kos">{</span>
  <span class="pl-c1">global</span>: <span class="pl-c1">false</span><span class="pl-kos">,</span>
  <span class="pl-c1">process</span>: <span class="pl-c1">false</span><span class="pl-kos">,</span>
  <span class="pl-c1">__filename</span>: <span class="pl-c1">false</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-c1">Buffer</span>: <span class="pl-c1">false</span><span class="pl-kos">,</span>
  <span class="pl-c1">setImmediate</span>: <span class="pl-c1">false</span><span class="pl-kos">,</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">Basically all from <a href="http://www.ecma-international.org/ecma-262/6.0/#sec-resolveexport" rel="nofollow">http://www.ecma-international.org/ecma-262/6.0/#sec-resolveexport</a></p>
<ol dir="auto">
<li>
<p dir="auto">Star exports should not include 'default'</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="// entry.js
import def from './a';
console.log(def);

// a.js
export * from './b';

// b.js
export default 'b-default';"><pre class="notranslate"><code class="notranslate">// entry.js
import def from './a';
console.log(def);

// a.js
export * from './b';

// b.js
export default 'b-default';
</code></pre></div>
<p dir="auto">should log <code class="notranslate">undefined</code> because <code class="notranslate">export * from</code> only applies to named exports, not <code class="notranslate">default</code>. This is the main one on this list that seems like a problem, because it silently does the wrong thing, and users may accidentally rely on it.</p>
</li>
<li>
<p dir="auto">Local exports take precedence over star exports.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="// entry.js
import {foo} from './a';
console.log(foo);

// a.js
export var foo = 'a-foo';
export * from './b';

// b.js
export var foo = 'b-foo';"><pre class="notranslate"><code class="notranslate">// entry.js
import {foo} from './a';
console.log(foo);

// a.js
export var foo = 'a-foo';
export * from './b';

// b.js
export var foo = 'b-foo';
</code></pre></div>
<p dir="auto">should log <code class="notranslate">a-foo</code> since named exports take precedence over star exports. Currently it throws because the <code class="notranslate">export * from</code> tries to redefine the non-configurable property.</p>
</li>
<li>
<p dir="auto">Local exports take precedence over indirect exports</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="// entry.js
import {foo} from './a';
console.log(foo);

// a.js
export var foo = 'a-foo';
export {foo} from './b';

// b.js
export var foo = 'b-foo';"><pre class="notranslate"><code class="notranslate">// entry.js
import {foo} from './a';
console.log(foo);

// a.js
export var foo = 'a-foo';
export {foo} from './b';

// b.js
export var foo = 'b-foo';
</code></pre></div>
<p dir="auto">should log <code class="notranslate">a-foo</code> since named exports take precedence over indirect exports. Currently it throws because the <code class="notranslate">export * from</code> tries to redefine the non-configurable property.</p>
</li>
<li>
<p dir="auto">Indirect exports take precedence over star exports.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="// entry.js
import {foo} from './a';
console.log(foo);

// a.js
export {foo} from './c';
export * from './b';

// b.js
export var foo = 'b-foo';

// c.js
export var foo = 'c-foo';"><pre class="notranslate"><code class="notranslate">// entry.js
import {foo} from './a';
console.log(foo);

// a.js
export {foo} from './c';
export * from './b';

// b.js
export var foo = 'b-foo';

// c.js
export var foo = 'c-foo';
</code></pre></div>
<p dir="auto">should log <code class="notranslate">c-foo</code> because indirect exports take precedence.</p>
</li>
</ol>