Skip to content

Commit 2bee685

Browse files
committed
chore: reformat system-config to be more intuitive.
1 parent 8c78b58 commit 2bee685

File tree

1 file changed

+47
-12
lines changed

1 file changed

+47
-12
lines changed
Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,59 @@
1-
const barrels: string[] = [
1+
/***********************************************************************************************
2+
* User Configuration.
3+
**********************************************************************************************/
4+
/** Map relative paths to URLs. */
5+
const map: any = {
6+
};
7+
8+
/** User packages configuration. */
9+
const packages: any = {
10+
};
11+
12+
////////////////////////////////////////////////////////////////////////////////////////////////
13+
/***********************************************************************************************
14+
* Everything underneath this line is managed by the CLI.
15+
**********************************************************************************************/
16+
const barrels = [
17+
// Angular specific barrels.
18+
'@angular/core',
19+
'@angular/common',
20+
'@angular/compiler',
21+
'@angular/http',
22+
'@angular/router',
23+
'@angular/platform-browser',
24+
'@angular/platform-browser-dynamic',
25+
26+
// Thirdparty barrels.
27+
'rxjs',
28+
29+
// App specific barrels.
230
'app',
331
'app/shared',
432
/** @cli-barrel */
533
];
634

7-
function createPackageConfig(barrelList: string[]): any {
8-
return barrelList.reduce((barrelConfig: any, barrelName: string) => {
9-
barrelConfig[barrelName] = {
35+
const _cliSystemConfig = {};
36+
barrels.forEach((barrelName: string) => {
37+
_cliSystemConfig[barrelName] = { main: 'index' };
1038
format: 'register',
1139
defaultExtension: 'js',
1240
main: 'index'
1341
};
1442
return barrelConfig;
15-
}, {});
16-
}
43+
});
1744

45+
/** Type declaration for ambient System. */
46+
declare var System: any;
1847

19-
// Add your custom SystemJS configuration here.
20-
export const config: any = {
21-
packages: Object.assign({
22-
// Add your custom SystemJS packages here.
23-
}, createPackageConfig(barrels))
24-
};
48+
// Apply the CLI SystemJS configuration.
49+
System.config({
50+
map: {
51+
'@angular': 'vendor/@angular',
52+
'rxjs': 'vendor/rxjs',
53+
'main': 'main.js'
54+
},
55+
packages: _cliSystemConfig
56+
});
57+
58+
// Apply the user's configuration.
59+
System.config({ map, packages });

0 commit comments

Comments
 (0)