Skip to content

Commit 36eaa0d

Browse files
committed
fixing tests and simplifying system-config
1 parent ccab53a commit 36eaa0d

File tree

5 files changed

+104
-179
lines changed

5 files changed

+104
-179
lines changed

src/demo-app/system-config.ts

Lines changed: 17 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,26 @@
1-
/***********************************************************************************************
2-
* User Configuration.
3-
**********************************************************************************************/
4-
5-
const angularDeps = [
6-
// Angular specific barrels.
7-
'@angular/core',
8-
'@angular/common',
9-
'@angular/compiler',
10-
'@angular/http',
11-
'@angular/forms',
12-
'@angular/router',
13-
'@angular/platform-browser',
14-
'@angular/platform-browser-dynamic',
15-
];
16-
17-
const barrels: string[] = [
18-
// Thirdparty barrels.
19-
'rxjs',
20-
21-
// App specific barrels.
22-
'demo-app',
23-
'button-toggle',
24-
'gestures',
25-
'live-announcer',
26-
'portal',
27-
'overlay',
28-
];
29-
30-
31-
const angularPackages: any = angularDeps.reduce((config: any, pkg: string) => {
32-
config[pkg] = { main: `bundles/${pkg.replace('@angular/', '')}.umd.js` };
33-
return config;
34-
}, {});
35-
barrels.forEach((barrelName: string) => {
36-
angularPackages[barrelName] = { main: 'index' };
37-
});
38-
39-
const angularMaps: any = angularDeps.reduce((config: any, pkg: string) => {
40-
config[pkg] = `vendor/${pkg}`;
41-
return config;
42-
}, {});
43-
441
/** Type declaration for ambient System. */
452
declare var System: any;
463

474
// Apply the CLI SystemJS configuration.
485
System.config({
49-
map: Object.assign({
6+
map: {
507
'rxjs': 'vendor/rxjs',
518
'main': 'main.js',
52-
}, angularMaps),
53-
packages: Object.assign({
9+
10+
// Angular specific mappings.
11+
'@angular/core': 'vendor/@angular/core/bundles/core.umd.js',
12+
'@angular/common': 'vendor/@angular/common/bundles/common.umd.js',
13+
'@angular/compiler': 'vendor/@angular/compiler/bundles/compiler.umd.js',
14+
'@angular/http': 'vendor/@angular/http/bundles/http.umd.js',
15+
'@angular/forms': 'vendor/@angular/forms/bundles/forms.umd.js',
16+
'@angular/router': 'vendor/@angular/router/bundles/router.umd.js',
17+
'@angular/platform-browser': 'vendor/@angular/platform-browser/bundles/platform-browser.umd.js',
18+
'@angular/platform-browser-dynamic':
19+
'vendor/@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
20+
},
21+
packages: {
22+
// Thirdparty barrels.
23+
'rxjs': { main: 'index' },
5424
'@angular/material': {
5525
format: 'cjs',
5626
main: 'material.umd.js'
@@ -60,5 +30,5 @@ System.config({
6030
'.': {
6131
defaultExtension: 'js'
6232
}
63-
}, angularPackages)
33+
}
6434
});

src/e2e-app/system-config.ts

Lines changed: 18 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,34 @@
1-
/***********************************************************************************************
2-
* User Configuration.
3-
**********************************************************************************************/
4-
5-
const angularDeps = [
6-
// Angular specific barrels.
7-
'@angular/core',
8-
'@angular/common',
9-
'@angular/compiler',
10-
'@angular/http',
11-
'@angular/forms',
12-
'@angular/router',
13-
'@angular/platform-browser',
14-
'@angular/platform-browser-dynamic',
15-
];
16-
17-
const barrels: string[] = [
18-
// Thirdparty barrels.
19-
'rxjs',
20-
21-
// App specific barrels.
22-
'demo-app',
23-
'button-toggle',
24-
'gestures',
25-
'live-announcer',
26-
'portal',
27-
'overlay',
28-
];
29-
30-
31-
const angularPackages: any = angularDeps.reduce((config: any, pkg: string) => {
32-
config[pkg] = { main: `bundles/${pkg.replace('@angular/', '')}.umd.js` };
33-
return config;
34-
}, {});
35-
barrels.forEach((barrelName: string) => {
36-
angularPackages[barrelName] = { main: 'index' };
37-
});
38-
39-
const angularMaps: any = angularDeps.reduce((config: any, pkg: string) => {
40-
config[pkg] = `vendor/${pkg}`;
41-
return config;
42-
}, {});
43-
441
/** Type declaration for ambient System. */
452
declare var System: any;
463

474
// Apply the CLI SystemJS configuration.
485
System.config({
49-
map: Object.assign({
6+
map: {
507
'rxjs': 'vendor/rxjs',
518
'main': 'main.js',
52-
}, angularMaps),
53-
packages: Object.assign({
9+
10+
// Angular specific mappings.
11+
'@angular/core': 'vendor/@angular/core/bundles/core.umd.js',
12+
'@angular/common': 'vendor/@angular/common/bundles/common.umd.js',
13+
'@angular/compiler': 'vendor/@angular/compiler/bundles/compiler.umd.js',
14+
'@angular/http': 'vendor/@angular/http/bundles/http.umd.js',
15+
'@angular/forms': 'vendor/@angular/forms/bundles/forms.umd.js',
16+
'@angular/router': 'vendor/@angular/router/bundles/router.umd.js',
17+
'@angular/platform-browser': 'vendor/@angular/platform-browser/bundles/platform-browser.umd.js',
18+
'@angular/platform-browser-dynamic':
19+
'vendor/@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
20+
},
21+
packages: {
22+
// Thirdparty barrels.
23+
'rxjs': { main: 'index' },
5424
'@angular/material': {
5525
format: 'cjs',
5626
main: 'material.umd.js'
57-
},
27+
},
5828
// Set the default extension for the root package, because otherwise the demo-app can't
5929
// be built within the production mode. Due to missing file extensions.
6030
'.': {
6131
defaultExtension: 'js'
6232
}
63-
}, angularPackages)
33+
}
6434
});

src/lib/index.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
export * from './core';
22
export * from './module';
33

4-
export * from './button/button';
5-
export * from './button-toggle/button-toggle';
6-
export * from './card/card';
7-
export * from './checkbox/checkbox';
8-
export * from './dialog/dialog';
9-
export * from './grid-list/grid-list';
10-
export * from './icon/icon';
11-
export * from './input/input';
12-
export * from './list/list';
13-
export * from './menu/menu';
14-
export * from './progress-bar/progress-bar';
15-
export * from './progress-circle/progress-circle';
16-
export * from './radio/radio';
17-
export * from './select/select';
18-
export * from './sidenav/sidenav';
19-
export * from './slider/slider';
20-
export * from './slide-toggle/slide-toggle';
21-
export * from './tabs/tabs';
22-
export * from './toolbar/toolbar';
23-
export * from './tooltip/tooltip';
4+
export * from './button/index';
5+
export * from './button-toggle/index';
6+
export * from './card/index';
7+
export * from './checkbox/index';
8+
export * from './dialog/index';
9+
export * from './grid-list/index';
10+
export * from './icon/index';
11+
export * from './input/index';
12+
export * from './list/index';
13+
export * from './menu/index';
14+
export * from './progress-bar/index';
15+
export * from './progress-circle/index';
16+
export * from './radio/index';
17+
export * from './select/index';
18+
export * from './sidenav/index';
19+
export * from './slider/index';
20+
export * from './slide-toggle/index';
21+
export * from './tabs/index';
22+
export * from './toolbar/index';
23+
export * from './tooltip/index';

src/lib/system-config-spec.ts

Lines changed: 27 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,36 @@
1-
/***********************************************************************************************
2-
* User Configuration.
3-
**********************************************************************************************/
4-
5-
const angularDeps = [
6-
// Angular specific barrels.
7-
'@angular/core',
8-
'@angular/common',
9-
'@angular/compiler',
10-
'@angular/http',
11-
'@angular/forms',
12-
'@angular/router',
13-
'@angular/platform-browser',
14-
'@angular/platform-browser-dynamic',
15-
];
16-
17-
const barrels: string[] = [
18-
// Thirdparty barrels.
19-
'rxjs',
20-
21-
// App specific barrels.
22-
'demo-app',
23-
'button-toggle',
24-
'gestures',
25-
'live-announcer',
26-
'portal',
27-
'overlay',
28-
];
29-
30-
31-
const angularPackages: any = angularDeps.reduce((config: any, pkg: string) => {
32-
const name = pkg.replace('@angular/', '');
33-
const main = `bundles/${name}.umd.js`;
34-
const testMain = `../bundles/${name}-testing.umd.js`;
35-
36-
config[pkg] = { main };
37-
config[`${pkg}/testing`] = { main: testMain };
38-
return config;
39-
}, {});
40-
barrels.forEach((barrelName: string) => {
41-
angularPackages[barrelName] = { main: 'index' };
42-
});
43-
44-
const angularMaps: any = angularDeps.reduce((config: any, pkg: string) => {
45-
config[pkg] = `vendor/${pkg}`;
46-
return config;
47-
}, {});
48-
491
/** Type declaration for ambient System. */
502
declare var System: any;
513

524
// Apply the CLI SystemJS configuration.
535
System.config({
54-
map: Object.assign({
6+
map: {
557
'rxjs': 'vendor/rxjs',
568
'main': 'main.js',
57-
}, angularMaps),
58-
packages: Object.assign({
9+
10+
// Angular specific mappings.
11+
'@angular/core': 'vendor/@angular/core/bundles/core.umd.js',
12+
'@angular/core/testing': 'vendor/@angular/core/bundles/core-testing.umd.js',
13+
'@angular/common': 'vendor/@angular/common/bundles/common.umd.js',
14+
'@angular/common/testing': 'vendor/@angular/common/bundles/common-testing.umd.js',
15+
'@angular/compiler': 'vendor/@angular/compiler/bundles/compiler.umd.js',
16+
'@angular/compiler/testing': 'vendor/@angular/compiler/bundles/compiler-testing.umd.js',
17+
'@angular/http': 'vendor/@angular/http/bundles/http.umd.js',
18+
'@angular/http/testing': 'vendor/@angular/http/bundles/http-testing.umd.js',
19+
'@angular/forms': 'vendor/@angular/forms/bundles/forms.umd.js',
20+
'@angular/forms/testing': 'vendor/@angular/forms/bundles/forms-testing.umd.js',
21+
'@angular/router': 'vendor/@angular/router/bundles/router.umd.js',
22+
'@angular/router/testing': 'vendor/@angular/router/bundles/router-testing.umd.js',
23+
'@angular/platform-browser': 'vendor/@angular/platform-browser/bundles/platform-browser.umd.js',
24+
'@angular/platform-browser/testing':
25+
'vendor/@angular/platform-browser/bundles/platform-browser-testing.umd.js',
26+
'@angular/platform-browser-dynamic':
27+
'vendor/@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
28+
'@angular/platform-browser-dynamic/testing':
29+
'vendor/@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js',
30+
},
31+
packages: {
32+
// Thirdparty barrels.
33+
'rxjs': { main: 'index' },
5934
'@angular/material': {
6035
format: 'cjs',
6136
main: 'material.umd.js'
@@ -65,5 +40,5 @@ System.config({
6540
'.': {
6641
defaultExtension: 'js'
6742
}
68-
}, angularPackages)
43+
}
6944
});

tools/gulp/tasks/components.ts

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as path from 'path';
44

55
import {SOURCE_ROOT, DIST_COMPONENTS_ROOT, PROJECT_ROOT} from '../constants';
66
import {sassBuildTask, tsBuildTask, execNodeTask, copyTask, sequenceTask} from '../task_helpers';
7+
import {writeFileSync} from 'fs';
78

89
// No typings for these.
910
const inlineResources = require('../../../scripts/release/inline-resources');
@@ -53,24 +54,33 @@ task(':build:components:rollup', [':build:components:inline'], () => {
5354
'rxjs/add/operator/share': 'Rx.Observable.prototype',
5455
'rxjs/add/operator/finally': 'Rx.Observable.prototype',
5556
'rxjs/add/operator/catch': 'Rx.Observable.prototype',
56-
'rxjs/Observable': 'Rx',
57-
58-
// Angular Material
59-
'@angular/material': 'md'
57+
'rxjs/Observable': 'Rx'
6058
};
6159

6260
// Build the all package.
6361
return rollup({
6462
entry: path.join(DIST_COMPONENTS_ROOT, 'index.js'),
6563
context: 'this',
66-
external: Object.keys(globals).filter(x => x != '@angular/material')
67-
}).then((bundle: { write: any }) => bundle.write({
68-
moduleName: 'ng.material',
69-
format: 'umd',
70-
globals,
71-
sourceMap: true,
72-
dest: path.join(DIST_COMPONENTS_ROOT, 'material.umd.js')
73-
}));
64+
external: Object.keys(globals)
65+
}).then((bundle: { generate: any }) => {
66+
const result = bundle.generate({
67+
moduleName: 'ng.material',
68+
format: 'umd',
69+
globals,
70+
sourceMap: true,
71+
dest: path.join(DIST_COMPONENTS_ROOT, 'material.umd.js')
72+
});
73+
74+
// Add source map URL to the code.
75+
result.code += '\n\n//# sourceMappingURL=./material.umd.js.map\n';
76+
// Format mapping to show properly in the browser. Rollup by default will put the path
77+
// as relative to the file, and since that path is in src/lib and the file is in
78+
// dist/@angular/material, we need to kill a few `../`.
79+
result.map.sources = result.map.sources.map((s: string) => s.replace(/^(\.\.\/)+/, ''));
80+
81+
writeFileSync(path.join(DIST_COMPONENTS_ROOT, 'material.umd.js'), result.code, 'utf8');
82+
writeFileSync(path.join(DIST_COMPONENTS_ROOT, 'material.umd.js.map'), result.map, 'utf8');
83+
});
7484
});
7585

7686
task(':build:components:inline', [

0 commit comments

Comments
 (0)