Skip to content

Commit 5bd4985

Browse files
committed
chore: reformat system-config to be more intuitive. (angular#605)
1 parent a9f14a7 commit 5bd4985

File tree

1 file changed

+27
-17
lines changed

1 file changed

+27
-17
lines changed
Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1-
/** Only use System here. */
2-
declare var System: any;
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+
};
311

4-
const barrels: string[] = [
12+
////////////////////////////////////////////////////////////////////////////////////////////////
13+
/***********************************************************************************************
14+
* Everything underneath this line is managed by the CLI.
15+
**********************************************************************************************/
16+
const barrels = [
517
// Angular specific barrels.
618
'@angular/core',
719
'@angular/common',
@@ -11,6 +23,7 @@ const barrels: string[] = [
1123
'@angular/platform-browser',
1224
'@angular/platform-browser-dynamic',
1325

26+
// Thirdparty barrels.
1427
'rxjs',
1528

1629
// App specific barrels.
@@ -19,26 +32,23 @@ const barrels: string[] = [
1932
/** @cli-barrel */
2033
];
2134

35+
const _cliSystemConfig = {};
36+
barrels.forEach((barrelName: string) => {
37+
_cliSystemConfig[barrelName] = { main: 'index' };
38+
});
39+
40+
/** Type declaration for ambient System. */
41+
declare var System: any;
2242

23-
// Angular CLI SystemJS configuration.
43+
// Apply the CLI SystemJS configuration.
2444
System.config({
2545
map: {
2646
'@angular': 'vendor/@angular',
2747
'rxjs': 'vendor/rxjs',
2848
'main': 'main.js'
2949
},
30-
packages: barrels.reduce((barrelConfig: any, barrelName: string) => {
31-
barrelConfig[barrelName] = {
32-
main: 'index'
33-
};
34-
return barrelConfig;
35-
}, {})
50+
packages: _cliSystemConfig
3651
});
3752

38-
39-
// Add your custom SystemJS configuration here.
40-
System.config({
41-
packages: {
42-
// Add your custom SystemJS packages here.
43-
}
44-
});
53+
// Apply the user's configuration.
54+
System.config({ map, packages });

0 commit comments

Comments
 (0)