Skip to content

Commit

Permalink
fixing tests and simplifying system-config
Browse files Browse the repository at this point in the history
  • Loading branch information
hansl committed Sep 21, 2016
1 parent a505dc1 commit c71e9b1
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 179 deletions.
64 changes: 17 additions & 47 deletions src/demo-app/system-config.ts
Original file line number Diff line number Diff line change
@@ -1,56 +1,26 @@
/***********************************************************************************************
* User Configuration.
**********************************************************************************************/

const angularDeps = [
// Angular specific barrels.
'@angular/core',
'@angular/common',
'@angular/compiler',
'@angular/http',
'@angular/forms',
'@angular/router',
'@angular/platform-browser',
'@angular/platform-browser-dynamic',
];

const barrels: string[] = [
// Thirdparty barrels.
'rxjs',

// App specific barrels.
'demo-app',
'button-toggle',
'gestures',
'live-announcer',
'portal',
'overlay',
];


const angularPackages: any = angularDeps.reduce((config: any, pkg: string) => {
config[pkg] = { main: `bundles/${pkg.replace('@angular/', '')}.umd.js` };
return config;
}, {});
barrels.forEach((barrelName: string) => {
angularPackages[barrelName] = { main: 'index' };
});

const angularMaps: any = angularDeps.reduce((config: any, pkg: string) => {
config[pkg] = `vendor/${pkg}`;
return config;
}, {});

/** Type declaration for ambient System. */
declare var System: any;

// Apply the CLI SystemJS configuration.
System.config({
map: Object.assign({
map: {
'rxjs': 'vendor/rxjs',
'main': 'main.js',
}, angularMaps),
packages: Object.assign({

// Angular specific mappings.
'@angular/core': 'vendor/@angular/core/bundles/core.umd.js',
'@angular/common': 'vendor/@angular/common/bundles/common.umd.js',
'@angular/compiler': 'vendor/@angular/compiler/bundles/compiler.umd.js',
'@angular/http': 'vendor/@angular/http/bundles/http.umd.js',
'@angular/forms': 'vendor/@angular/forms/bundles/forms.umd.js',
'@angular/router': 'vendor/@angular/router/bundles/router.umd.js',
'@angular/platform-browser': 'vendor/@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic':
'vendor/@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
},
packages: {
// Thirdparty barrels.
'rxjs': { main: 'index' },
'@angular/material': {
format: 'cjs',
main: 'material.umd.js'
Expand All @@ -60,5 +30,5 @@ System.config({
'.': {
defaultExtension: 'js'
}
}, angularPackages)
}
});
66 changes: 18 additions & 48 deletions src/e2e-app/system-config.ts
Original file line number Diff line number Diff line change
@@ -1,64 +1,34 @@
/***********************************************************************************************
* User Configuration.
**********************************************************************************************/

const angularDeps = [
// Angular specific barrels.
'@angular/core',
'@angular/common',
'@angular/compiler',
'@angular/http',
'@angular/forms',
'@angular/router',
'@angular/platform-browser',
'@angular/platform-browser-dynamic',
];

const barrels: string[] = [
// Thirdparty barrels.
'rxjs',

// App specific barrels.
'demo-app',
'button-toggle',
'gestures',
'live-announcer',
'portal',
'overlay',
];


const angularPackages: any = angularDeps.reduce((config: any, pkg: string) => {
config[pkg] = { main: `bundles/${pkg.replace('@angular/', '')}.umd.js` };
return config;
}, {});
barrels.forEach((barrelName: string) => {
angularPackages[barrelName] = { main: 'index' };
});

const angularMaps: any = angularDeps.reduce((config: any, pkg: string) => {
config[pkg] = `vendor/${pkg}`;
return config;
}, {});

/** Type declaration for ambient System. */
declare var System: any;

// Apply the CLI SystemJS configuration.
System.config({
map: Object.assign({
map: {
'rxjs': 'vendor/rxjs',
'main': 'main.js',
}, angularMaps),
packages: Object.assign({

// Angular specific mappings.
'@angular/core': 'vendor/@angular/core/bundles/core.umd.js',
'@angular/common': 'vendor/@angular/common/bundles/common.umd.js',
'@angular/compiler': 'vendor/@angular/compiler/bundles/compiler.umd.js',
'@angular/http': 'vendor/@angular/http/bundles/http.umd.js',
'@angular/forms': 'vendor/@angular/forms/bundles/forms.umd.js',
'@angular/router': 'vendor/@angular/router/bundles/router.umd.js',
'@angular/platform-browser': 'vendor/@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic':
'vendor/@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
},
packages: {
// Thirdparty barrels.
'rxjs': { main: 'index' },
'@angular/material': {
format: 'cjs',
main: 'material.umd.js'
},
},
// Set the default extension for the root package, because otherwise the demo-app can't
// be built within the production mode. Due to missing file extensions.
'.': {
defaultExtension: 'js'
}
}, angularPackages)
}
});
40 changes: 20 additions & 20 deletions src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
export * from './core';
export * from './module';

export * from './button/button';
export * from './button-toggle/button-toggle';
export * from './card/card';
export * from './checkbox/checkbox';
export * from './dialog/dialog';
export * from './grid-list/grid-list';
export * from './icon/icon';
export * from './input/input';
export * from './list/list';
export * from './menu/menu';
export * from './progress-bar/progress-bar';
export * from './progress-circle/progress-circle';
export * from './radio/radio';
export * from './select/select';
export * from './sidenav/sidenav';
export * from './slider/slider';
export * from './slide-toggle/slide-toggle';
export * from './tabs/tabs';
export * from './toolbar/toolbar';
export * from './tooltip/tooltip';
export * from './button/index';
export * from './button-toggle/index';
export * from './card/index';
export * from './checkbox/index';
export * from './dialog/index';
export * from './grid-list/index';
export * from './icon/index';
export * from './input/index';
export * from './list/index';
export * from './menu/index';
export * from './progress-bar/index';
export * from './progress-circle/index';
export * from './radio/index';
export * from './select/index';
export * from './sidenav/index';
export * from './slider/index';
export * from './slide-toggle/index';
export * from './tabs/index';
export * from './toolbar/index';
export * from './tooltip/index';
79 changes: 27 additions & 52 deletions src/lib/system-config-spec.ts
Original file line number Diff line number Diff line change
@@ -1,61 +1,36 @@
/***********************************************************************************************
* User Configuration.
**********************************************************************************************/

const angularDeps = [
// Angular specific barrels.
'@angular/core',
'@angular/common',
'@angular/compiler',
'@angular/http',
'@angular/forms',
'@angular/router',
'@angular/platform-browser',
'@angular/platform-browser-dynamic',
];

const barrels: string[] = [
// Thirdparty barrels.
'rxjs',

// App specific barrels.
'demo-app',
'button-toggle',
'gestures',
'live-announcer',
'portal',
'overlay',
];


const angularPackages: any = angularDeps.reduce((config: any, pkg: string) => {
const name = pkg.replace('@angular/', '');
const main = `bundles/${name}.umd.js`;
const testMain = `../bundles/${name}-testing.umd.js`;

config[pkg] = { main };
config[`${pkg}/testing`] = { main: testMain };
return config;
}, {});
barrels.forEach((barrelName: string) => {
angularPackages[barrelName] = { main: 'index' };
});

const angularMaps: any = angularDeps.reduce((config: any, pkg: string) => {
config[pkg] = `vendor/${pkg}`;
return config;
}, {});

/** Type declaration for ambient System. */
declare var System: any;

// Apply the CLI SystemJS configuration.
System.config({
map: Object.assign({
map: {
'rxjs': 'vendor/rxjs',
'main': 'main.js',
}, angularMaps),
packages: Object.assign({

// Angular specific mappings.
'@angular/core': 'vendor/@angular/core/bundles/core.umd.js',
'@angular/core/testing': 'vendor/@angular/core/bundles/core-testing.umd.js',
'@angular/common': 'vendor/@angular/common/bundles/common.umd.js',
'@angular/common/testing': 'vendor/@angular/common/bundles/common-testing.umd.js',
'@angular/compiler': 'vendor/@angular/compiler/bundles/compiler.umd.js',
'@angular/compiler/testing': 'vendor/@angular/compiler/bundles/compiler-testing.umd.js',
'@angular/http': 'vendor/@angular/http/bundles/http.umd.js',
'@angular/http/testing': 'vendor/@angular/http/bundles/http-testing.umd.js',
'@angular/forms': 'vendor/@angular/forms/bundles/forms.umd.js',
'@angular/forms/testing': 'vendor/@angular/forms/bundles/forms-testing.umd.js',
'@angular/router': 'vendor/@angular/router/bundles/router.umd.js',
'@angular/router/testing': 'vendor/@angular/router/bundles/router-testing.umd.js',
'@angular/platform-browser': 'vendor/@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser/testing':
'vendor/@angular/platform-browser/bundles/platform-browser-testing.umd.js',
'@angular/platform-browser-dynamic':
'vendor/@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/platform-browser-dynamic/testing':
'vendor/@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js',
},
packages: {
// Thirdparty barrels.
'rxjs': { main: 'index' },
'@angular/material': {
format: 'cjs',
main: 'material.umd.js'
Expand All @@ -65,5 +40,5 @@ System.config({
'.': {
defaultExtension: 'js'
}
}, angularPackages)
}
});
34 changes: 22 additions & 12 deletions tools/gulp/tasks/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as path from 'path';

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

// No typings for these.
const inlineResources = require('../../../scripts/release/inline-resources');
Expand Down Expand Up @@ -53,24 +54,33 @@ task(':build:components:rollup', [':build:components:inline'], () => {
'rxjs/add/operator/share': 'Rx.Observable.prototype',
'rxjs/add/operator/finally': 'Rx.Observable.prototype',
'rxjs/add/operator/catch': 'Rx.Observable.prototype',
'rxjs/Observable': 'Rx',

// Angular Material
'@angular/material': 'md'
'rxjs/Observable': 'Rx'
};

// Build the all package.
return rollup({
entry: path.join(DIST_COMPONENTS_ROOT, 'index.js'),
context: 'this',
external: Object.keys(globals).filter(x => x != '@angular/material')
}).then((bundle: { write: any }) => bundle.write({
moduleName: 'ng.material',
format: 'umd',
globals,
sourceMap: true,
dest: path.join(DIST_COMPONENTS_ROOT, 'material.umd.js')
}));
external: Object.keys(globals)
}).then((bundle: { generate: any }) => {
const result = bundle.generate({
moduleName: 'ng.material',
format: 'umd',
globals,
sourceMap: true,
dest: path.join(DIST_COMPONENTS_ROOT, 'material.umd.js')
});

// Add source map URL to the code.
result.code += '\n\n//# sourceMappingURL=./material.umd.js.map\n';
// Format mapping to show properly in the browser. Rollup by default will put the path
// as relative to the file, and since that path is in src/lib and the file is in
// dist/@angular/material, we need to kill a few `../`.
result.map.sources = result.map.sources.map((s: string) => s.replace(/^(\.\.\/)+/, ''));

writeFileSync(path.join(DIST_COMPONENTS_ROOT, 'material.umd.js'), result.code, 'utf8');
writeFileSync(path.join(DIST_COMPONENTS_ROOT, 'material.umd.js.map'), result.map, 'utf8');
});
});

task(':build:components:inline', [
Expand Down

0 comments on commit c71e9b1

Please sign in to comment.