feat(build): add an option to disable type checks when running tests

Since editors and IDEs do typechecking and show errors in place,
often there is no benefit to running type checking in our test pipeline.
This PR allows you to disable type checking:

gulp test.unit.js --noTypeChecks

This commit also makes es6 generation optional.

fix(build): removes unnecessary circular dependencies

Closes #5299
This commit is contained in:
vsavkin
2015-11-16 16:18:59 -08:00
committed by Victor Savkin
parent 94cf671c15
commit 4e585bca28
9 changed files with 103 additions and 72 deletions
+38 -14
View File
@@ -11,6 +11,13 @@ type ProjectMap = {
[key: string]: boolean
};
type Options = {
projects: ProjectMap;
noTypeChecks: boolean;
generateEs6: boolean;
}
;
/**
* BroccoliBuilder facade for all of our build pipelines.
*/
@@ -25,20 +32,20 @@ export class AngularBuilder {
constructor(public options: AngularBuilderOptions) { this.outputPath = options.outputPath; }
public rebuildBrowserDevTree(projects: ProjectMap): Promise<BuildResult> {
this.browserDevBuilder = this.browserDevBuilder || this.makeBrowserDevBuilder(projects);
public rebuildBrowserDevTree(opts: Options): Promise<BuildResult> {
this.browserDevBuilder = this.browserDevBuilder || this.makeBrowserDevBuilder(opts);
return this.rebuild(this.browserDevBuilder, 'js.dev');
}
public rebuildBrowserProdTree(projects: ProjectMap): Promise<BuildResult> {
this.browserProdBuilder = this.browserProdBuilder || this.makeBrowserProdBuilder(projects);
public rebuildBrowserProdTree(opts: Options): Promise<BuildResult> {
this.browserProdBuilder = this.browserProdBuilder || this.makeBrowserProdBuilder(opts);
return this.rebuild(this.browserProdBuilder, 'js.prod');
}
public rebuildNodeTree(projects: ProjectMap): Promise<BuildResult> {
this.nodeBuilder = this.nodeBuilder || this.makeNodeBuilder(projects);
public rebuildNodeTree(opts: Options): Promise<BuildResult> {
this.nodeBuilder = this.nodeBuilder || this.makeNodeBuilder(opts.projects);
return this.rebuild(this.nodeBuilder, 'js.cjs');
}
@@ -58,16 +65,30 @@ export class AngularBuilder {
}
private makeBrowserDevBuilder(projects: ProjectMap): BroccoliBuilder {
let tree = makeBrowserTree({name: 'dev', typeAssertions: true, projects: projects},
path.join(this.outputPath, 'js', 'dev'));
private makeBrowserDevBuilder(opts: Options): BroccoliBuilder {
let tree = makeBrowserTree(
{
name: 'dev',
typeAssertions: true,
projects: opts.projects,
noTypeChecks: opts.noTypeChecks,
generateEs6: opts.generateEs6
},
path.join(this.outputPath, 'js', 'dev'));
return new broccoli.Builder(tree);
}
private makeBrowserProdBuilder(projects: ProjectMap): BroccoliBuilder {
let tree = makeBrowserTree({name: 'prod', typeAssertions: false, projects: projects},
path.join(this.outputPath, 'js', 'prod'));
private makeBrowserProdBuilder(opts: Options): BroccoliBuilder {
let tree = makeBrowserTree(
{
name: 'prod',
typeAssertions: false,
projects: opts.projects,
noTypeChecks: opts.noTypeChecks,
generateEs6: opts.generateEs6
},
path.join(this.outputPath, 'js', 'prod'));
return new broccoli.Builder(tree);
}
@@ -128,11 +149,14 @@ function broccoliNodeToBuildNode(broccoliNode) {
return new BuildNode(tree.description || tree.constructor.name,
tree.inputPath ? [tree.inputPath] : tree.inputPaths, tree.cachePath,
tree.outputPath, broccoliNode.subtrees.map(broccoliNodeToBuildNode));
tree.outputPath, broccoliNode.selfTime / (1000 * 1000 * 1000),
broccoliNode.totalTime / (1000 * 1000 * 1000),
broccoliNode.subtrees.map(broccoliNodeToBuildNode));
}
class BuildNode {
constructor(public pluginName: string, public inputPaths: string[], public cachePath: string,
public outputPath: string, public inputNodes: BroccoliNode[]) {}
public outputPath: string, public selfTime: number, public totalTime: number,
public inputNodes: BroccoliNode[]) {}
}
+29 -22
View File
@@ -70,7 +70,9 @@ const kServedPaths = [
module.exports = function makeBrowserTree(options, destinationPath) {
var modules = options.projects;
const modules = options.projects;
const noTypeChecks = options.noTypeChecks;
const generateEs6 = options.generateEs6;
if (modules.angular2) {
var angular2Tree = new Funnel('modules/angular2', {
@@ -110,9 +112,6 @@ module.exports = function makeBrowserTree(options, destinationPath) {
var modulesTree = mergeTrees(
[angular2Tree, angular2MaterialTree, benchmarksTree, benchmarksExternalTree, playgroundTree]);
var clientModules = new Funnel(
'node_modules', {include: ['@reactivex/**/**', 'parse5/**/**', 'css/**/**'], destDir: '/'});
var es6PolyfillTypings =
new Funnel('modules', {include: ['angular2/typings/es6-*/**'], destDir: '/'});
@@ -139,20 +138,6 @@ module.exports = function makeBrowserTree(options, destinationPath) {
patterns: [{match: /\$SCRIPTS\$/, replacement: jsReplace('SCRIPTS')}]
});
// Use TypeScript to transpile the *.ts files to ES6
var es6Tree = compileWithTypescript(modulesTree, {
declaration: false,
emitDecoratorMetadata: true,
experimentalDecorators: true,
mapRoot: '', // force sourcemaps to use relative path
noEmitOnError: false,
rootDir: './',
rootFilePaths: ['angular2/manual_typings/globals-es6.d.ts'],
sourceMap: true,
sourceRoot: '.',
target: 'es6'
});
// Use TypeScript to transpile the *.ts files to ES5
var es5Tree = compileWithTypescript(es5ModulesTree, {
declaration: false,
@@ -161,7 +146,7 @@ module.exports = function makeBrowserTree(options, destinationPath) {
mapRoot: '', // force sourcemaps to use relative path
module: 'commonjs',
moduleResolution: 'classic',
noEmitOnError: true,
noEmitOnError: !noTypeChecks,
rootDir: './',
rootFilePaths: ['angular2/manual_typings/globals.d.ts'],
sourceMap: true,
@@ -274,10 +259,32 @@ module.exports = function makeBrowserTree(options, destinationPath) {
htmlTree = mergeTrees([htmlTree, scripts, polymer, react]);
}
es5Tree = mergeTrees([es5Tree, htmlTree, assetsTree, clientModules]);
es6Tree = mergeTrees([es6Tree, htmlTree, assetsTree, clientModules]);
// this is needed only for creating a bundle
// typescript resolves dependencies automatically
if (modules.bundle_deps) {
var nodeModules = new Funnel(
'node_modules', {include: ['@reactivex/**/**', 'parse5/**/**', 'css/**/**'], destDir: '/'});
}
var mergedTree = mergeTrees([stew.mv(es6Tree, '/es6'), stew.mv(es5Tree, '/es5')]);
if (generateEs6) {
// Use TypeScript to transpile the *.ts files to ES6
var es6Tree = compileWithTypescript(modulesTree, {
declaration: false,
emitDecoratorMetadata: true,
experimentalDecorators: true,
mapRoot: '', // force sourcemaps to use relative path
noEmitOnError: false,
rootDir: './',
rootFilePaths: ['angular2/manual_typings/globals-es6.d.ts'],
sourceMap: true,
sourceRoot: '.',
target: 'es6'
});
es6Tree = stew.mv(mergeTrees([es6Tree, htmlTree, assetsTree, nodeModules]), '/es6');
}
es5Tree = stew.mv(mergeTrees([es5Tree, htmlTree, assetsTree, nodeModules]), '/es5');
var mergedTree = mergeTrees([es6Tree, es5Tree]);
return destCopy(mergedTree, destinationPath);
};