title: NodeJS crypto module not working in browser after bundling with webpack
body: <p>I keep getting the following error when I view my code in the browser:</p>
  <blockquote>
  <p>Uncaught TypeError: crypto.createHash is not a function</p>
  </blockquote>
  <p>I've tried loading the module during runtime using webpack:</p>
  <pre class="lang-json prettyprint-override"><code>module.exports = {
    target: &quot;web&quot;,
    mode: &quot;production&quot;,
    entry: &quot;./dist/index.js&quot;,
    output: { filename: &quot;../dist/bundle.js&quot; },
    externals: { crypto: require(&quot;crypto&quot;) }, &lt;=== here
  };
  </code></pre>
  <p>and importing as: <code>import * as crypto from &quot;crypto&quot;</code>, but this leads to the same error outlined above.</p>
  <p>I realize that the browser has its own native <code>crypto</code> API and thus also tried aliasing the name to a different name like <code>import * as crypt from &quot;crypto&quot;</code>, however this leads to the same error.</p>
  <p>Repository with full code is available: <a href="https://www.github.com/lbragile/LibraCoin" rel="nofollow noreferrer">https://www.github.com/lbragile/LibraCoin</a></p>