title: Possibility about conditional export ES6 module based on process.env.NODE_ENV?
body: <p>I wrote a utility library and I want to <code>tree-shaking</code> them when my user <code>publishes</code> their app.</p>
  
  <p>In Webpack v4, you need to make your module <code>ES6</code> to support <code>tree-shaking</code>, but I also want to split my <code>development build</code> and my <code>production build</code> into different files.</p>
  
  <p>What I want is exactly like react's NPM module:</p>
  
  <pre><code>// index.js
  'use strict';
  
  if (process.env.NODE_ENV === 'production') {
    module.exports = require('./cjs/react.production.min.js');
  } else {
    module.exports = require('./cjs/react.development.js');
  }
  </code></pre>
  
  <p>This leads me questions.</p>
  
  <p>If I make my utility modules all <code>commonjs</code>, I will never get <code>tree-shaking</code>, my app gets so huge.</p>
  
  <p>If I make my utility modules all <code>ES6 static export</code>, I will have to include <code>development message</code> in <code>production code</code>.</p>
  
  <p>And publishing two modules (eg: <code>my-utility</code> and <code>my-utility-es</code>) will not helping, because in development, my code looks like this:</p>
  
  <pre><code>import { someFunc } from 'my-utility';
  </code></pre>
  
  <p>but in production code, I will have to change it to this:</p>
  
  <pre><code>import { someFunc } from 'my-utility-es';
  </code></pre>
  
  <p>How can I solve this problem?</p>
  
  <h1>Update</h1>
  
  <p>To be more clear, my <code>development build</code> and <code>production build</code> contains different source code <strong>(eg: production build has stripped all error message)</strong>.</p>
  
  <p>So specify webpack mode isn't satisfying for me.</p>