Skip to content

Commit b6efb28

Browse files
test(*): Remove karma-webpack. Hook up karma-systemjs.
chore(*): Fixed some grunt build stuff
1 parent 954c663 commit b6efb28

File tree

14 files changed

+113
-138
lines changed

14 files changed

+113
-138
lines changed

Gruntfile.js

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ module.exports = function (grunt) {
33

44
require('load-grunt-tasks')(grunt);
55
var files = require('./files').files;
6+
var systemjs = require('systemjs');
7+
//var jspm = require('jspm');
68

79
// Project configuration.
810
grunt.initConfig({
@@ -19,29 +21,15 @@ module.exports = function (grunt) {
1921
},
2022
clean: [ '<%= builddir %>' ],
2123
ts: {
22-
base: {
24+
es5: {
2325
src: files.src,
24-
outDir: '<%= builddir %>/ts2es5',
25-
options: {
26-
//target: "es6"
27-
//module: 'amd', //or commonjs
28-
module: 'commonjs'
29-
}
30-
}
31-
},
32-
concat: {
33-
options: {
34-
banner: '<%= meta.banner %>\n\n'+
35-
'/* commonjs package manager support (eg componentjs) */\n'+
36-
'if (typeof module !== "undefined" && typeof exports !== "undefined" && module.exports === exports){\n'+
37-
' module.exports = \'ui.router\';\n'+
38-
'}\n\n'+
39-
'(function (window, angular, undefined) {\n',
40-
footer: '})(window, window.angular);'
26+
outDir: '<%= builddir %>/es5',
27+
options: { module: 'commonjs'}
4128
},
42-
build: {
29+
es6: {
4330
src: files.src,
44-
dest: '<%= builddir %>/<%= pkg.name %>.js'
31+
outDir: '<%= builddir %>/es6',
32+
options: { target: "es6"}
4533
}
4634
},
4735
uglify: {
@@ -56,7 +44,7 @@ module.exports = function (grunt) {
5644
},
5745
webpack: {
5846
build: {
59-
entry: files.buildSrc,
47+
entry: files.commonJsEntrypoint,
6048
output: {
6149
path: '<%= builddir %>',
6250
filename: '<%= pkg.name %>.js',
@@ -84,7 +72,7 @@ module.exports = function (grunt) {
8472
},
8573
watch: {
8674
files: ['src/**/*.ts', 'src/**/*.js', 'test/**/*.js'],
87-
tasks: ['build', 'karma:unit']
75+
tasks: ['build', 'karma']
8876
},
8977
connect: {
9078
server: {},
@@ -97,38 +85,53 @@ module.exports = function (grunt) {
9785
},
9886
karma: {
9987
options: {
100-
configFile: 'config/karma-1.4.1.js',
88+
configFile: 'config/karma.js',
10189
singleRun: true,
10290
exclude: [],
103-
frameworks: ['jasmine'],
91+
frameworks: ['systemjs', 'jasmine'],
10492
reporters: 'dots', // 'dots' || 'progress'
10593
port: 8080,
10694
colors: true,
10795
autoWatch: false,
10896
autoWatchInterval: 0,
97+
// Serve and load angular files using regular Karma mode
98+
files: files.karmaServedFiles('1.4.1'),
99+
systemjs: {
100+
configFile: 'config/system.config.js',
101+
// These files are served by Karma, but loaded using SystemJS
102+
files: ['src/**/*.ts'].concat(files.testUtils, files.test),
103+
// This is turned into a regexp and used to load specs into Karma
104+
testFileSuffix: "/test/\\S+.[tj]s"
105+
},
109106
browsers: [ grunt.option('browser') || 'PhantomJS' ]
110107
},
108+
// Same as karma:base
111109
unit: {
112110
browsers: [ grunt.option('browser') || 'PhantomJS' ]
113111
},
112+
// Launch Karma in Chrome, click debug button, debug tests
114113
debug: {
115114
singleRun: false,
116115
background: false,
117116
browsers: [ grunt.option('browser') || 'Chrome' ]
118117
},
119-
onetwo: {
120-
configFile: 'config/karma-1.2.28.js'
118+
// Test with angular 1.2
119+
ng12: {
120+
options: { files: files.karmaServedFiles('1.2.28') }
121121
},
122-
onethree: {
123-
configFile: 'config/karma-1.3.16.js'
122+
// Test with angular 1.3
123+
ng13: {
124+
options: { files: files.karmaServedFiles('1.3.16') }
124125
},
125-
onefour: {
126-
configFile: 'config/karma-1.4.1.js'
126+
// Test with angular 1.4
127+
ng14: {
128+
options: { files: files.karmaServedFiles('1.4.1') }
127129
},
128130
background: {
129131
background: true,
130132
browsers: [ grunt.option('browser') || 'PhantomJS' ]
131133
},
134+
// PhantomJS in the console; watch for changes to tests/src
132135
watch: {
133136
configFile: 'config/karma.js',
134137
singleRun: false,
@@ -156,12 +159,11 @@ module.exports = function (grunt) {
156159
}
157160
});
158161

159-
grunt.registerTask('integrate', ['clean', 'build', 'karma:onetwo', 'karma:onethree', 'karma:onefour']);
162+
grunt.registerTask('integrate', ['clean', 'build', 'karma:ng12', 'karma:ng13', 'karma:ng14']);
160163
grunt.registerTask('default', ['build', 'karma:unit']);
161-
grunt.registerTask('build', 'Perform a normal build', ['ts', 'webpack', 'uglify']);
162-
grunt.registerTask('dist', 'Perform a clean build', ['clean', 'build']);
163-
grunt.registerTask('dist-docs', 'Perform a clean build and generate documentation', ['dist', 'ngdocs']);
164-
grunt.registerTask('release', 'Tag and perform a release', ['prepare-release', 'dist', 'perform-release']);
164+
grunt.registerTask('build', 'Perform a normal build', ['clean', 'ts', 'webpack', 'uglify']);
165+
grunt.registerTask('dist-docs', 'Perform a clean build and generate documentation', ['build', 'ngdocs']);
166+
grunt.registerTask('release', 'Tag and perform a release', ['prepare-release', 'build', 'perform-release']);
165167
grunt.registerTask('dev', 'Run dev server and watch for changes', ['build', 'connect:server', 'karma:background', 'watch']);
166168
grunt.registerTask('sample', 'Run connect server with keepalive:true for sample app development', ['connect:sample']);
167169

@@ -216,7 +218,7 @@ module.exports = function (grunt) {
216218
});
217219

218220
grunt.registerTask('perform-release', function () {
219-
grunt.task.requires([ 'prepare-release', 'dist' ]);
221+
grunt.task.requires([ 'prepare-release', 'build' ]);
220222

221223
var version = grunt.config('pkg.version'), releasedir = grunt.config('builddir');
222224
promising(this,

config/karma-1.2.28.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

config/karma-1.3.16.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

config/karma-1.4.1.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

config/karma.base.js

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,20 @@ module.exports = {
44
// base path, that will be used to resolve files and exclude
55
basePath: '..',
66

7-
// list of files / patterns to load in the browser
8-
_files: [].concat(files.testUtils, files.buildDest, 'test/tests.js'),
9-
preprocessors: {
10-
'lib/angular*.js': ['webpack'],
11-
'test/tests.js': ['webpack']
12-
},
7+
// Karma files available to serve is configured using files.karmaServeFiles() in each grunt task (e.g., karma:ng14)
8+
// Actual tests to load is configured in karma.options.systemjs.files block
139

1410
// level of logging
1511
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
1612
//logLevel: karma.LOG_DEBUG,
1713
frameworks: ['jasmine'],
1814
plugins: [
19-
require('karma-webpack'),
15+
require('karma-systemjs'),
2016
require('karma-jasmine'),
2117
require('karma-phantomjs-launcher'),
2218
require('karma-chrome-launcher')
2319
],
2420

25-
webpack: {
26-
resolve: {
27-
modulesDirectories: [
28-
"",
29-
"build/ts2es5",
30-
"node_modules"
31-
]
32-
}
33-
},
34-
3521
// Start these browsers, currently available:
3622
// - Chrome
3723
// - ChromeCanary

config/karma.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
// Karma configuration file
2-
var files = require('../files').files;
32
var config = require("./karma.base");
43

54
module.exports = function (karma) {
6-
config.files = files.angular('1.3.16').concat(config.files);
75
config.logLevel = karma.LOG_DEBUG;
86
karma.set(config)
97
};

config/system.config.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
System.config({
2+
transpiler: 'typescript',
3+
paths: {
4+
'babel': 'node_modules/babel-core/browser.js',
5+
'typescript': 'node_modules/typescript/bin/typescript.js',
6+
'systemjs': 'node_modules/systemjs/dist/system.src.js',
7+
'system-polyfills': 'node_modules/systemjs/dist/system-polyfills.js',
8+
'es6-module-loader': 'node_modules/es6-module-loader/dist/es6-module-loader.js',
9+
'phantomjs-polyfill': 'node_modules/phantomjs-polyfill/bind-polyfill.js',
10+
'ui-router': 'src/ui-router.ts'
11+
},
12+
packages: {
13+
'build/es6': {
14+
defaultExtension: 'js'
15+
},
16+
'src': {
17+
defaultExtension: 'ts'
18+
}
19+
}
20+
});

files.js

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,52 @@
11
routerFiles = {
2-
buildSrc: [
3-
'./build/ts2es5/ui-router.js'
4-
],
5-
buildDest: [
6-
'build/angular-ui-router.js'
7-
],
8-
src: [
9-
'src/ui-router.ts',
10-
'src/resolve.ts',
11-
'src/templateFactory.ts',
12-
'src/urlMatcherFactory.ts',
13-
'src/transition.ts',
14-
'src/urlRouter.ts',
15-
'src/state.ts',
16-
'src/view.ts',
17-
'src/viewScroll.ts',
18-
'src/viewDirective.ts',
19-
'src/stateDirectives.ts',
20-
'src/stateFilters.ts',
21-
'src/stateEvents.ts',
22-
'src/trace.ts'
23-
],
2+
commonJsEntrypoint: ['./build/es5/ui-router.js'],
3+
es6Entrypoint: ['./build/es6/ui-router.js'],
4+
5+
buildDest: ['build/angular-ui-router.js'], // The distribution file
6+
src: ['src/ui-router.ts'], // Main UI-Router module (imports everything else)
7+
8+
// Test helpers
249
testUtils: [
2510
'test/testUtils.js',
2611
'test/compat/matchers.js'
2712
],
13+
14+
// Tests to load
2815
test: [
2916
'test/commonSpec.js',
3017
'test/globSpec.js',
3118
'test/resolveSpec.js',
32-
//'test/stateDirectivesSpec.js',
19+
'test/stateDirectivesSpec.js',
3320
'test/stateEventsSpec.js',
3421
'test/stateFiltersSpec.js',
3522
'test/stateSpec.js',
3623
'test/templateFactorySpec.js',
3724
'test/transitionSpec.js',
3825
'test/urlMatcherFactorySpec.js',
3926
'test/urlRouterSpec.js',
40-
//'test/viewDirectiveSpec.js',
41-
//'test/viewScrollSpec.js',
27+
'test/viewDirectiveSpec.js',
28+
'test/viewScrollSpec.js',
4229
'test/compat/matchers.js'
4330
],
31+
32+
// Returns necessary files for a specific version of angular
4433
angular: function(version) {
4534
return [
4635
'lib/angular-' + version + '/angular.js',
4736
'lib/angular-' + version + '/angular-mocks.js',
4837
'lib/angular-' + version + '/angular-animate.js'
4938
];
39+
},
40+
41+
// This returns a Karma 'files configuration' for the files served by the Karma web server
42+
// http://karma-runner.github.io/0.8/config/files.html
43+
karmaServedFiles: function(version) {
44+
return [
45+
routerFiles.angular(version),
46+
{ watched: true, included: false, nocache: true, pattern: 'src/**/*.ts' },
47+
{ watched: true, included: false, nocache: true, pattern: 'test/**/*.ts' },
48+
{ watched: true, included: false, nocache: true, pattern: 'test/**/*.js' }
49+
]
5050
}
5151
};
5252

package.json

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,30 +45,36 @@
4545
"angular": "^1.2"
4646
},
4747
"devDependencies": {
48+
"babel-core": "^5.8.14",
49+
"es6-module-loader": "^0.17.3",
50+
"faithful-exec": "~0.1.0",
4851
"grunt": "~0.4.1",
52+
"grunt-contrib-clean": "~0.5.0",
53+
"grunt-contrib-connect": "~0.7.1",
4954
"grunt-contrib-uglify": "~0.4.0",
5055
"grunt-contrib-watch": "~0.5.3",
51-
"grunt-contrib-connect": "~0.7.1",
52-
"grunt-contrib-clean": "~0.5.0",
56+
"grunt-conventional-changelog": "~1.1.0",
5357
"grunt-karma": "~0.11.2",
58+
"grunt-ngdocs": "~0.1.7",
59+
"grunt-shell": "^1.1.2",
60+
"grunt-ts": "^4.2.0",
61+
"grunt-webpack": "^1.0.10",
62+
"jasmine-core": "~2.3.4",
5463
"jsdoc": "git://github.com/jsdoc3/jsdoc.git#v3.2.2",
55-
"shelljs": "~0.2.6",
56-
"faithful-exec": "~0.1.0",
57-
"karma-firefox-launcher": "~0.1.0",
64+
"karma": "~0.12.0",
5865
"karma-chrome-launcher": "~0.1.0",
66+
"karma-coffee-preprocessor": "~0.1.0",
67+
"karma-firefox-launcher": "~0.1.0",
5968
"karma-html2js-preprocessor": "~0.1.0",
6069
"karma-jasmine": "~0.3.6",
61-
"karma-script-launcher": "~0.1.0",
62-
"karma-coffee-preprocessor": "~0.1.0",
63-
"karma": "~0.12.0",
6470
"karma-phantomjs-launcher": "~0.1.0",
65-
"karma-webpack": "~1.5.1",
66-
"jasmine-core": "~2.3.4",
71+
"karma-script-launcher": "~0.1.0",
72+
"karma-systemjs": "^0.7.2",
6773
"load-grunt-tasks": "~0.4.0",
68-
"grunt-conventional-changelog": "~1.1.0",
69-
"grunt-ngdocs": "~0.1.7",
70-
"grunt-ts": "~4.2.0",
71-
"grunt-webpack": "^1.0.10"
74+
"phantomjs-polyfill": "0.0.1",
75+
"shelljs": "~0.2.6",
76+
"systemjs": "^0.18.4",
77+
"typescript": "^1.5.3"
7278
},
7379
"main": "release/angular-ui-router"
7480
}

src/common/trace.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {isNull, isPromise, is, invoke, not, val, pattern, parse, objectKeys} from "../common/common";
2-
import {isDefined, isObject, isString, isFunction, extend, forEach, isArray, identity} from "../common/common";
1+
import {isNull, isPromise, is, invoke, not, val, pattern, parse, objectKeys,
2+
isDefined, isObject, isString, isFunction, extend, forEach, isArray, identity} from "../common/common";
33
import Resolvable from "../resolve/resolvable";
44
import {Transition} from "../transition/transition";
55
import {TransitionRejection} from "../transition/rejectFactory";

0 commit comments

Comments
 (0)