title: Is it possible to override map aliases in SystemJS config?
body: <p><strong>Scenario</strong></p>
  
  <p>I'm working with a library of code that has a specific namespace. But part of the codebase is local and several other parts are npm modules, that all fall under that same namespace.</p>
  
  <p><strong>Problem</strong></p>
  
  <p>I'm trying to work out if it's possible to 'override' a map alias within the SystemJS config? The problem i have is that i'd like to declare a base alias for the local version of the library and then more specific map aliases for the npm modules.</p>
  
  <p><strong>Attempt 1</strong></p>
  
  <p>Initially i thought it may be possible to do this:</p>
  
  <pre><code>{
      bundles: {
          'bx/google/drive': ['bx/google/drive/files', 'bx/google/drive/permissions', 'bx/google/drive/query']
      },
      map: {
          'bx/': '/src/bx',
          'bx/google/core': 'node_modules/bx.google.core/bundles/bx.google.core.js',
          'bx/google/drive': 'node_modules/bx.google.drive/bundles/bx.google.drive.js',
          'bx/google/analytics': 'node_modules/bx.google.analytics/bundles/bx.google.analytics.js',
          'typescript': 'node_modules/typescript/lib/typescript.js',
          'systemjs': 'node_modules/systemjs/dist/system.src.js'
      },
      packages: {
          bx: {
              defaultExtension: 'js'
          }
      }
  }
  </code></pre>
  
  <p>But this only uses the initial <code>bx/</code> alias to resolve any imports found starting with that path, so fails to load any of the <code>bx</code> npm module code.</p>
  
  <p><strong>Attempt 2</strong></p>
  
  <p>I thought i may be able to define all of the <code>bx</code> 'sub' modules using a package map:</p>
  
  <pre><code>System.config({
      bundles: {
          'bx/google/drive': ['bx/google/drive/files', 'bx/google/drive/permissions', 'bx/google/drive/query']
      },
      map: {
          'bx': '/src/bx',
          'typescript': 'node_modules/typescript/lib/typescript.js',
          'systemjs': 'node_modules/systemjs/dist/system.src.js'
      },
      packages: {
          bx: {
              defaultExtension: 'js',
              map: {
                  './google/core': 'node_modules/bx.google.core/bundles/bx.google.core.js',
                  './google/drive': 'node_modules/bx.google.drive/bundles/bx.google.drive.js',
                  './google/drive/files': 'node_modules/bx.google.drive/bundles/bx.google.drive.js',
                  './google/drive/permissions': 'node_modules/cx.google.drive/bundles/bx.google.drive.js',
                  './google/drive/query': 'node_modules/bx.google.drive/bundles/bx.google.drive.js',
                  './google/analytics': 'node_modules/bx.google.analytics/bundles/bx.google.analytics.js'
              }
          }
      }
  });
  </code></pre>
  
  <p>This fails, but not in the same way, as no errors are thrown until the imported classes are used, as any <code>bx</code> Class imported from the npm module is <code>undefined</code>. (I also had to explicitly define all the bundle import paths).</p>
  
  <p><strong>Solution so far</strong></p>
  
  <p>The only way i've found so far is to remove the <code>bx/</code> definition from the map and explicitly list every single map alias and package for code within <code>/src/bx/</code>. i.e</p>
  
  <pre><code>{
      bundles: {
          'bx/google/drive': ['bx/google/drive/files', 'bx/google/drive/permissions', 'bx/google/drive/query']
      },
      map: {
          'bx/forms': '/src/bx/forms',
          'bx/preload': '/src/bx/preload',
          'bx/cache': '/src/bx/cache',
          /* etc */
          'bx/google/core': 'node_modules/bx.google.core/bundles/bx.google.core.js',
          'bx/google/drive': 'node_modules/bx.google.drive/bundles/bx.google.drive.js',
          'bx/google/analytics': 'node_modules/bx.google.analytics/bundles/bx.google.analytics.js',
          'typescript': 'node_modules/typescript/lib/typescript.js',
          'systemjs': 'node_modules/systemjs/dist/system.src.js'
      },
      packages: {
          'bx/forms': {
              defaultExtension: 'js'
          },
          'bx/preload': {
              defaultExtension: 'js'
          },
          'bx/cache': {
              defaultExtension: 'js'
          }
      }
  }
  </code></pre>
  
  <p>Which is not really ideal.</p>
  
  <p><strong>Question</strong></p>
  
  <p>So what i'd like to know, is whether it's possible to define a 'base' map alias for the local <code>bx/</code> code (<code>bx: 'src/bx'</code>) and then override that with more specific map aliases for the <code>bx</code> npm modules?</p>
  
  <hr>
  
  <p>** Update **</p>
  
  <p>Adding the base <code>bx/</code> to <code>paths</code> removes the need to list all <code>bx</code> paths individually as unique values in <code>maps</code>, but they still need to be listed individually in <code>packages</code>.</p>
  
  <pre><code>{
      bundles: {
          'bx/google/drive': ['bx/google/drive/files', 'bx/google/drive/permissions', 'bx/google/drive/query']
      },
      paths: {
          'bx/': '/src/bx'
      },
      map: {
          'bx/google/core': 'node_modules/bx.google.core/bundles/bx.google.core.js',
          'bx/google/drive': 'node_modules/bx.google.drive/bundles/bx.google.drive.js',
          'bx/google/analytics': 'node_modules/bx.google.analytics/bundles/bx.google.analytics.js',
          'typescript': 'node_modules/typescript/lib/typescript.js',
          'systemjs': 'node_modules/systemjs/dist/system.src.js'
      },
      packages: {
          'bx/forms': {
              defaultExtension: 'js'
          },
          'bx/preload': {
              defaultExtension: 'js'
          },
          'bx/cache': {
              defaultExtension: 'js'
          }
      }
  }
  </code></pre>