docs(plunker): revise systemjs.config for plunker to load fewer files

This commit is contained in:
Ward Bell 2016-05-11 18:24:43 -07:00
parent 2e486cc046
commit 19b50c82f6
2 changed files with 34 additions and 39 deletions

View File

@ -2,7 +2,6 @@
* PLUNKER VERSION (based on systemjs.config.js in angular.io) * PLUNKER VERSION (based on systemjs.config.js in angular.io)
* System configuration for Angular 2 samples * System configuration for Angular 2 samples
* Adjust as necessary for your application needs. * Adjust as necessary for your application needs.
* Override at the last minute with global.filterSystemConfig (as plunkers do)
*/ */
(function(global) { (function(global) {
@ -10,9 +9,13 @@
//map tells the System loader where to look for things //map tells the System loader where to look for things
var map = { var map = {
'app': 'app', // 'dist', 'app': 'app',
'@angular': 'https://npmcdn.com/@angular', // sufficient if we didn't pin the version
'angular2-in-memory-web-api': 'https://npmcdn.com/angular2-in-memory-web-api', // get latest
'rxjs': 'https://npmcdn.com/rxjs@5.0.0-beta.6', 'rxjs': 'https://npmcdn.com/rxjs@5.0.0-beta.6',
'angular2-in-memory-web-api': 'https://npmcdn.com/angular2-in-memory-web-api' // get latest 'ts': 'https://npmcdn.com/plugin-typescript@4.0.10/lib/plugin.js',
'typescript': 'https://npmcdn.com/typescript@1.8.10/lib/typescript.js',
}; };
//packages tells the System loader how to load when no filename and/or no extension //packages tells the System loader how to load when no filename and/or no extension
@ -22,40 +25,45 @@
'angular2-in-memory-web-api': { defaultExtension: 'js' }, 'angular2-in-memory-web-api': { defaultExtension: 'js' },
}; };
var packageNames = [ var ngPackageNames = [
'@angular/common', 'common',
'@angular/compiler', 'compiler',
'@angular/core', 'core',
'@angular/http', 'http',
'@angular/platform-browser', 'platform-browser',
'@angular/platform-browser-dynamic', 'platform-browser-dynamic',
'@angular/router', 'router',
'@angular/router-deprecated', 'router-deprecated',
'@angular/upgrade', 'upgrade',
]; ];
// add map entries for angular packages in the form '@angular/common': 'https://npmcdn.com/@angular/common@0.0.0-3?main=browser' // Add map entries for each angular package
packageNames.forEach(function(pkgName) { // only because we're pinning the version with `ngVer`.
map[pkgName] = 'https://npmcdn.com/' + pkgName + ngVer; ngPackageNames.forEach(function(pkgName) {
map['@angular/'+pkgName] = 'https://npmcdn.com/@angular/' + pkgName + ngVer;
}); });
// add package entries for angular packages in the form '@angular/common': { main: 'index.js', defaultExtension: 'js' } // Add package entries for angular packages
packageNames.forEach(function(pkgName) { ngPackageNames.forEach(function(pkgName) {
packages[pkgName] = { main: 'index.js', defaultExtension: 'js' };
// Bundled (~40 requests):
packages['@angular/'+pkgName] = { main: pkgName + '.umd.js', defaultExtension: 'js' };
// Individual files (~300 requests):
//packages['@angular/'+pkgName] = { main: 'index.js', defaultExtension: 'js' };
}); });
var config = { var config = {
// DEMO ONLY! REAL CODE SHOULD NOT TRANSPILE IN THE BROWSER
transpiler: 'typescript', transpiler: 'typescript',
typescriptOptions: { typescriptOptions: {
emitDecoratorMetadata: true emitDecoratorMetadata: true
}, },
map: map, map: map,
packages: packages packages: packages
} }
// filterSystemConfig - index.html's chance to modify config before we register it.
if (global.filterSystemConfig) { global.filterSystemConfig(config); }
System.config(config); System.config(config);
})(this); })(this);

View File

@ -18,17 +18,7 @@ var _rxRules = {
link: { link: {
from: '/<link rel="stylesheet" href=".*%tag%".*>/', from: '/<link rel="stylesheet" href=".*%tag%".*>/',
to: '<link rel="stylesheet" href="%tag%">' to: '<link rel="stylesheet" href="%tag%">'
}, }
config: {
from: /\s*System.config\(\{[\s\S]*\}\);/m,
to: "\n" +
" System.config({\n" +
" transpiler: 'typescript', \n" +
" typescriptOptions: { emitDecoratorMetadata: true }, \n" +
" packages: {'app': {defaultExtension: 'ts'}} \n" +
" });"
},
}; };
var _rxData = [ var _rxData = [
@ -38,7 +28,7 @@ var _rxData = [
{ {
pattern: 'script', pattern: 'script',
from: 'node_modules/es6-shim/es6-shim.min.js', from: 'node_modules/es6-shim/es6-shim.min.js',
to: 'https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.35.0/es6-shim.min.js' to: 'https://npmcdn.com/es6-shim@0.35.0/es6-shim.min.js'
}, },
{ {
pattern: 'script', pattern: 'script',
@ -58,7 +48,7 @@ var _rxData = [
{ {
pattern: 'script', pattern: 'script',
from: 'node_modules/systemjs/dist/system.src.js', from: 'node_modules/systemjs/dist/system.src.js',
to: ['https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.27/system.js', 'https://npmcdn.com/typescript@1.8.10/lib/typescript.js'] to: 'https://npmcdn.com/systemjs@0.19.27/dist/system.src.js'
}, },
{ {
pattern: 'script', pattern: 'script',
@ -72,9 +62,6 @@ var _rxData = [
}, },
{ {
pattern: 'angular_pkg', pattern: 'angular_pkg',
},
{
pattern: 'config',
} }
]; ];