title: How to load XRegExp in Angular2
body: <p>I want to use XRegExp library in an Angular2 application written in TypeScript.</p>
  
  <p>I have installed XRegExp as a node.js module.</p>
  
  <p>How do I get <code>var unicodeWord = XRegExp("^\\pL+$");</code> to work in a component method?</p>
  
  <p>(How do I reference the JS library in TypeScript? How do I load the node.js module in angular?)</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>typings.json:</p>
  
  <pre><code>{
      "ambientDependencies": {
          "es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#6697d6f7dadbf5773cb40ecda35a76027e0783b2",
          "jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#d594ef506d1efe2fea15f8f39099d19b39436b71",
          "xregexp": "github:DefinitelyTyped/DefinitelyTyped/xregexp/xregexp.d.ts"
      }
  }
  </code></pre>
  
  <p><code>&lt;head&gt;</code> tag in my index.html:</p>
  
  <pre><code>&lt;head&gt;
      &lt;title&gt;Amadeus&lt;/title&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;    
  
      &lt;!-- 1. Load libraries --&gt;
      &lt;!-- IE required polyfills, in this exact order --&gt;
      &lt;script src="node_modules/es6-shim/es6-shim.min.js"&gt;&lt;/script&gt;
      &lt;script src="node_modules/systemjs/dist/system-polyfills.js"&gt;&lt;/script&gt;
  
      &lt;script src="node_modules/angular2/bundles/angular2-polyfills.js"&gt;&lt;/script&gt;
      &lt;script src="node_modules/systemjs/dist/system.src.js"&gt;&lt;/script&gt;
      &lt;script src="node_modules/rxjs/bundles/Rx.js"&gt;&lt;/script&gt;
      &lt;script src="node_modules/angular2/bundles/angular2.js"&gt;&lt;/script&gt;
  
      &lt;!-- 2. Configure SystemJS --&gt;
      &lt;script&gt;
          System.config({
              paths: {
                  xregexp: 'node_modules/xregexp/src/xregexp.js'
              },
              packages: {        
                  angular_components: {
                      format: 'register',
                      defaultExtension: 'js'
                  }
              }
          });
  
          System.import('angular_components/ignition')
              .then(null, console.error.bind(console));
      &lt;/script&gt;
  
  &lt;/head&gt;
  </code></pre>
  
  <p>ignition.ts:</p>
  
  <pre><code>import {bootstrap}    from 'angular2/platform/browser'
  import {AmadeusComponent} from './amadeus/amadeus.component'
  
  bootstrap(AmadeusComponent);
  </code></pre>
  
  <p>amadeus.component.ts:</p>
  
  <pre><code>import {Component} from 'angular2/core';
  import {XRegExp} from 'xregexp';
  
  @Component({
      selector: 'amadeus',
      templateUrl: 'angular_components/amadeus/amadeus.component.ahtml'
  })
  
  export class AmadeusComponent {
  
      constructor(){
          console.log(XRegExp); // undefined
      }
  
  }
  </code></pre>