title: How to import a custom UMD module in a Webpack 4 project
body: <p>I am developping a library that needs to work in both node and a react app. I use a webpack 4 project that generates a UMD module, but I have a problem when I try to import it in a simple webpack project. </p>
  
  <p>When I use <code>import lib from 'myLib';</code> lib is undefined</p>
  
  <p>This is what my lib look like</p>
  
  <pre><code>export const printMsg = function() {
    return "This is a message from the lib";
  };
  </code></pre>
  
  <p>With this webpack configuration </p>
  
  <pre><code>const path = require("path");
  
  module.exports = {
    entry: "./src/index.js",
    output: {
      path: path.resolve(__dirname, "dist"),
      filename: "mylib.js",
      library: "mylib",
      libraryTarget: "umd",
      umdNamedDefine: true,
      globalObject: `(typeof self !== 'undefined' ? self : this)`
    }
  };
  </code></pre>
  
  <p>for now I'm using a boilerplate project (<a href="https://github.com/wbkd/webpack-starter" rel="nofollow noreferrer">https://github.com/wbkd/webpack-starter</a>) to test.</p>
  
  <p>I used <code>npm install --save mylib</code> to add it, and my dist code is inside my <code>node_modules</code> folder.
  My index.js file look like this : </p>
  
  <pre><code>import "../styles/index.scss";
  import lib from "watson-tile-lib";
  console.log(lib);
  </code></pre>
  
  <p>When I run the page I got <code>undefined</code> in my browser console.</p>
  
  <p>Any idea ?</p>