Skip to content

Commit 95cbb1a

Browse files
committed
Fix karma build
1 parent 5d26341 commit 95cbb1a

File tree

3 files changed

+111
-29
lines changed

3 files changed

+111
-29
lines changed

gulpfile.js

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,23 @@ gulp.task(':build:components:ngc', ['build:components'], createExecTask(
136136
));
137137

138138

139+
/***************************************************************************************************
140+
* Vendor files Build Tasks.
141+
*/
142+
gulp.task(':build:vendor', function() {
143+
const npmVendorFiles = [
144+
'core-js/client', 'zone.js/dist', 'hammerjs', 'systemjs/dist', 'rxjs', '@angular', 'hammerjs'
145+
];
146+
147+
return gulpMerge(
148+
npmVendorFiles.map(function(root) {
149+
const glob = path.join(root, '**/*.+(js|js.map)');
150+
return gulp.src(path.join('node_modules', glob))
151+
.pipe(gulp.dest(path.join('dist/vendor', root)));
152+
}));
153+
});
154+
155+
139156
/***************************************************************************************************
140157
* DevApp Build Tasks.
141158
*/
@@ -153,22 +170,10 @@ gulp.task(':build:devapp:assets', function() {
153170
return gulp.src(path.join(devAppDir, '**/*'))
154171
.pipe(gulp.dest(outDir));
155172
});
156-
gulp.task(':build:devapp:vendor', function() {
157-
const npmVendorFiles = [
158-
'core-js/client', 'zone.js/dist', 'hammerjs', 'systemjs/dist', 'rxjs', '@angular', 'hammerjs'
159-
];
160-
161-
return gulpMerge(
162-
npmVendorFiles.map(function(root) {
163-
const glob = path.join(root, '**/*.+(js|js.map)');
164-
return gulp.src(path.join('node_modules', glob))
165-
.pipe(gulp.dest(path.join('dist/vendor', root)));
166-
}));
167-
});
168173

169174
gulp.task('build:devapp', [
170175
'build:components',
171-
':build:devapp:vendor',
176+
':build:vendor',
172177
':build:devapp:ts',
173178
':build:devapp:scss',
174179
':build:devapp:assets'
@@ -191,22 +196,10 @@ gulp.task(':build:e2eapp:assets', function() {
191196
return gulp.src(path.join(e2eAppDir, '**/*'))
192197
.pipe(gulp.dest(outDir));
193198
});
194-
gulp.task(':build:e2eapp:vendor', function() {
195-
const npmVendorFiles = [
196-
'core-js/client', 'zone.js/dist', 'hammerjs', 'systemjs/dist', 'rxjs', '@angular', 'hammerjs'
197-
];
198-
199-
return gulpMerge(
200-
npmVendorFiles.map(function(root) {
201-
const glob = path.join(root, '**/*.+(js|js.map)');
202-
return gulp.src(path.join('node_modules', glob))
203-
.pipe(gulp.dest(path.join('dist/vendor', root)));
204-
}));
205-
});
206199

207200
gulp.task('build:e2eapp', [
208201
'build:components',
209-
':build:e2eapp:vendor',
202+
':build:vendor',
210203
':build:e2eapp:ts',
211204
':build:e2eapp:scss',
212205
':build:e2eapp:assets'
@@ -311,13 +304,13 @@ gulp.task(':serve:e2eapp:stop', function() {
311304
/***************************************************************************************************
312305
* Tests.
313306
*/
314-
gulp.task('test', function(done) {
307+
gulp.task('test', [':build:vendor', 'build:components'], function(done) {
315308
new karma.Server({
316309
configFile: path.join(__dirname, 'test/karma.conf.js')
317310
}, done).start();
318311
});
319312

320-
gulp.task('test:single-run', function(done) {
313+
gulp.task('test:single-run', [':build:vendor', 'build:components'], function(done) {
321314
new karma.Server({
322315
configFile: path.join(__dirname, 'test/karma.conf.js'),
323316
singleRun: true

src/lib/system-config.ts

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/***********************************************************************************************
2+
* SystemJS Configuration used for the unittests.
3+
**********************************************************************************************/
4+
5+
const components = [
6+
'all',
7+
'button',
8+
'card',
9+
'checkbox',
10+
'dialog',
11+
'grid-list',
12+
'icon',
13+
'input',
14+
'list',
15+
'menu',
16+
'progress-bar',
17+
'progress-circle',
18+
'radio',
19+
'sidenav',
20+
'slider',
21+
'slide-toggle',
22+
'button-toggle',
23+
'tabs',
24+
'toolbar',
25+
'tooltip',
26+
];
27+
28+
29+
/** User packages configuration. */
30+
const packages: any = {
31+
'@angular2-material/core': {
32+
format: 'cjs',
33+
defaultExtension: 'js'
34+
},
35+
// Set the default extension for the root package, because otherwise the demo-app can't
36+
// be built within the production mode. Due to missing file extensions.
37+
'.': {
38+
defaultExtension: 'js'
39+
}
40+
};
41+
42+
components.forEach(name => {
43+
packages[`@angular2-material/${name}`] = {
44+
format: 'cjs',
45+
defaultExtension: 'js'
46+
};
47+
});
48+
49+
50+
////////////////////////////////////////////////////////////////////////////////////////////////
51+
/***********************************************************************************************
52+
* Everything underneath this line is managed by the CLI.
53+
**********************************************************************************************/
54+
const barrels: string[] = [
55+
// Angular specific barrels.
56+
'@angular/core',
57+
'@angular/common',
58+
'@angular/compiler',
59+
'@angular/http',
60+
'@angular/forms',
61+
'@angular/router',
62+
'@angular/platform-browser',
63+
'@angular/platform-browser-dynamic',
64+
65+
// Thirdparty barrels.
66+
'rxjs',
67+
68+
...components
69+
];
70+
71+
const _cliSystemConfig = {};
72+
barrels.forEach((barrelName: string) => {
73+
(<any> _cliSystemConfig)[barrelName] = { main: 'index' };
74+
});
75+
76+
/** Type declaration for ambient System. */
77+
declare var System: any;
78+
79+
// Apply the CLI SystemJS configuration.
80+
System.config({
81+
map: {
82+
'@angular': 'vendor/@angular',
83+
'rxjs': 'vendor/rxjs'
84+
},
85+
packages: _cliSystemConfig
86+
});
87+
88+
// Apply the user's configuration.
89+
System.config({ packages });

test/karma-test-shim.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ System.config({
2828
baseURL: distPath
2929
});
3030

31-
System.import('system-config.js').then(function() {
31+
System.import(distPath + '@angular2-material/system-config.js').then(function() {
3232
// Load and configure the TestComponentBuilder.
3333
return Promise.all([
3434
System.import('@angular/core/testing'),

0 commit comments

Comments
 (0)