Skip to content

Instantly share code, notes, and snippets.

@alexzuza
Last active October 10, 2016 18:09
Show Gist options
  • Save alexzuza/08d50ff9f9023a275a3df88c39926798 to your computer and use it in GitHub Desktop.
Save alexzuza/08d50ff9f9023a275a3df88c39926798 to your computer and use it in GitHub Desktop.
/**
 * System configuration for Angular 2 samples
 * Adjust as necessary for your application needs.
 */
(function (global) {
  function mapIndex() {
    return {
      'app': 'app',
      '@angular': 'npm:@angular',
      'rxjs': 'npm:rxjs',
      'typescript': 'npm:typescript/lib/typescript.js' //add typescript map
    };
  }

  var ngPackages = [ 'core',
      'common',
      'compiler',
      'forms',
      'http',
      'platform-browser',
      'platform-browser-dynamic',
      'router'
    ];

  function mapUmd() {
    var map = {
      'app': 'app',
      'rxjs': 'npm:rxjs',
    };

    ngPackages.forEach(function (name) {
      map['@angular/' + name] = 'npm:@angular/' + name + '/bundles/' + name + '.umd.js';
    });

    return map;
  }

  System.packageWithIndex = 1;

  var packages = {
    app: {
      main: './main.js',
      defaultExtension: 'js'
    },
    rxjs: {
      defaultExtension: 'js'
    }
  };

  if (System.packageWithIndex) {
    ngPackages.forEach(function (name) {
      packages['@angular/' + name] = { main: 'index.js' };
    });
  }

  var config = {
    // paths serve as alias
    paths: {
      'npm:': 'node_modules/'
    },
    map: System.packageWithIndex ? mapIndex() : mapUmd(),
    // packages tells the System loader how to load when no filename and/or no extension
    packages: packages
  };

  if (System.packageWithIndex) {
    config['transpiler'] = 'typescript';
  }

  System.config(config);
})(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment