How to add new packages that I just downloaded from npm to my Angular 2 components using SystemJS and using this system.config.js file. The following code was created for me by the starter pack. I tried putting links to modules in the "Map and Packages" section of this file, but it does not seem to work. All I want to know is how I can take a library like underscore js located in my node_modules and enter it in this file so that I can easily import the file into my typescript Angular components.
var isPublic = typeof window != "undefined";
(function(global) {
var map = {
'app': 'client',
'@angular': (isPublic)? '@angular' : 'node_modules/@angular',
'@angular/router': (isPublic)? '@angular/router' : 'node_modules/@angular/router',
'angular2-in-memory-web-api': (isPublic)? 'angular2-in-memory-web-api' : 'node_modules/angular2-in-memory-web-api',
'rxjs': (isPublic)? 'rxjs' : 'node_modules/rxjs',
'ng-semantic': (isPublic)? 'ng-semantic' : 'node_modules/ng-semantic'
};
var packages = {
'app': { main: 'main.js', defaultExtension: 'js' },
'rxjs': { defaultExtension: 'js' },
'ng2-ace': { defaultExtension: 'js' },
'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' },
'ng-semantic': { main: 'ng-semantic', defaultExtension: 'js' }
};
var ngPackageNames = [
'common',
'compiler',
'core',
'http',
'forms',
'platform-browser',
'platform-browser-dynamic',
'router-deprecated',
'upgrade',
'ng2-ace'
];
function packIndex(pkgName) {
packages['@angular/'+pkgName] = { main: 'index.js', defaultExtension: 'js' };
}
function packUmd(pkgName) {
packages['@angular/'+pkgName] = { main: '/bundles/' + pkgName + '.umd.js', defaultExtension: 'js' };
}
packages['@angular/router'] = { main: 'index.js', defaultExtension: 'js' };
var setPackageConfig = System.packageWithIndex ? packIndex : packUmd;
ngPackageNames.forEach(setPackageConfig);
var config = {
map: map,
packages: packages
};
System.config(config);
})(this);
source
share