title: Using commonjs modules in Angular4 services?
body: <p>I first tested using the commonjs module that I installed like this:</p>
  
  <pre><code>npm install the-module;
  </code></pre>
  
  <p>I then created <code>main.js</code> which looked something like this:</p>
  
  <pre><code>var module = require('the-module');
  module.doStuff();
  </code></pre>
  
  <p>Then compiled <code>main.js</code> with webpack into <code>bundle.js</code>, loaded it in the browser, and it did stuff.</p>
  
  <p>Now I want to use <code>the-module</code> inside an angular 4 service.  How should I import it?  </p>
  
  <p>I also found <a href="http://blog.angular-university.io/how-to-create-an-angular-2-library-and-how-to-consume-it-jspm-vs-webpack/" rel="nofollow noreferrer">this article</a> on how to create an angular 2 component library.  Curious whether this set of steps is required for all commonjs modules that will be imported by Angular or whether there is a more direct approach?</p>
  
  <h1>Related Concepts</h1>
  
  <p>Ended up writing this article:</p>
  
  <p><a href="https://medium.com/@ole.ersoy/using-vanilla-npm-javascript-modules-with-typescript-5052ca503178" rel="nofollow noreferrer">using-vanilla-npm-javascript-modules-with-typescript</a></p>