title: Using a global with Ng-Packagr in an Angular library
body: <p>Given that we're trying to reference Lodash in an Angular project to be built using ng-packagr, we're getting the following error:</p>
  
  <blockquote>
    <p>error TS2686: '_' refers to a UMD global, but the current file is a
    module. Consider adding an import instead.</p>
  </blockquote>
  
  <p>This suggests to me that it's not correctly picking up the typescript definitions file we have set up.</p>
  
  <p>The error only occurs when using ng-packagr to build. When using ng-serve to test the demo app it works fine.</p>
  
  <p><strong>typings.d.ts</strong></p>
  
  <pre><code>/* SystemJS module definition */
  declare var module: NodeModule;
  interface NodeModule {
    id: string;
  }
  
  // lodash global typing - begin
  declare namespace _ {
  }
  // lodash global typing - end
  </code></pre>
  
  <p>I've seen various issues on ng-packagr's github page talking about using externals or embedded, but the documentation is pretty sparse and experimentation in this area hasn't yielded any leads for me to follow.</p>
  
  <p>I've seen this snippet pop up a few times, which appears to accurately reference the correct path.</p>
  
  <p><strong>ng-package.json</strong></p>
  
  <pre><code>...
      "externals": {
        "lodash": "./node_modules/lodash/index.js"
      },
  ...
  </code></pre>
  
  <p>Anyone got any ideas how I might debug and investigate this?</p>