title: Loading bundled AMD modules with SystemJS
body: <p>I have a couple of AMD modules compiled using TypeScript's <code>--outFile</code> option into a single file:</p>
  
  <pre><code>define("partA", ["require", "exports"], function (require, exports) {
      "use strict";
      function partAFunc() {
          console.log('partAFunc');
          return 'partAFunc';
      }
      exports.partAFunc = partAFunc;
  });
  define("partB", ["require", "exports"], function (require, exports) {
      "use strict";
      exports.partB = 42;
  });
  define("partC", ["require", "exports"], function (require, exports) {
      ...
  });
  </code></pre>
  
  <p>Now I want to load only the <code>partA</code> module and call its <code>partAfunc()</code> so I can do the following in Node.js:</p>
  
  <pre><code>SystemJS.config({
    map: {
      'main': 'my-bundle.js',
    },
  });
  
  SystemJS.import('main').then((m) =&gt; {
    SystemJS.import('partA').then((m) =&gt; {
      m.partAFunc();
    });
  });
  </code></pre>
  
  <p>The first import <code>SystemJS.import('main')</code> just registers all the modules and then <code>SystemJS.import('partA')</code> works because module <code>partA</code> is already registered (or at least I guess that's what it does).</p>
  
  <p>However, why I can't just use <code>SystemJS.import('partA')</code> and set the bundle as a dependency:</p>
  
  <pre><code>SystemJS.config({
    meta: {
      'partA': {
        deps: [ 'my-bundle.js' ],
      }
    }
  });
  
  SystemJS.import('partA').then((m) =&gt; {
    m.partAFunc();
  });
  </code></pre>
  
  <p>The <code>meta</code> is completely ignored. The doc at <a href="https://github.com/systemjs/systemjs/blob/master/docs/config-api.md#meta" rel="nofollow noreferrer">https://github.com/systemjs/systemjs/blob/master/docs/config-api.md#meta</a> says:</p>
  
  <blockquote>
    <p>Dependencies to load before this module. Goes through regular paths and map normalization. Only supported for the cjs, amd and global formats.</p>
  </blockquote>
  
  <p>It looks like SystemJS first checks whether the file <code>partA</code> exists (which obviously doesn't) and throws an error (I tested it with an existing file and the <code>meta</code> config worked):</p>
  
  <pre><code>(node:60981) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: ENOENT: no such file or directory, open '/Users/.../partA'
    Instantiating /Users/.../partA
    Loading partA
  </code></pre>
  
  <p>I'd expect that also the following should work when the first variant works with two nested <code>SystemJS.import</code> calls.</p>
  
  <pre><code>SystemJS.config({
    map: {
      'partA': 'my-bundle.js',
    },
  });
  
  SystemJS.import('partA').then((m) =&gt; {
    // m.partAFunc();
    console.log(m)
  });
  </code></pre>
  
  <p>This prints an empty object. It looks like when there're more than one module in a single file it just registers them and doesn't load any of them?</p>
  
  <p>I read all the documents in <a href="https://github.com/systemjs/systemjs/tree/master/docs" rel="nofollow noreferrer">https://github.com/systemjs/systemjs/tree/master/docs</a> but I think I'm still lost.</p>