feat(build): check circular depencies in Node.js

Closes #980
This commit is contained in:
Marc Laval 2015-03-16 18:48:14 +01:00 committed by Misko Hevery
parent d10df7de44
commit a46af9c41c
6 changed files with 32 additions and 10 deletions

View File

@ -1,6 +1,7 @@
var gulp = require('gulp'); var gulp = require('gulp');
var gulpPlugins = require('gulp-load-plugins')(); var gulpPlugins = require('gulp-load-plugins')();
var runSequence = require('run-sequence'); var runSequence = require('run-sequence');
var madge = require('madge');
var merge = require('merge'); var merge = require('merge');
var gulpTraceur = require('./tools/transpiler/gulp-traceur'); var gulpTraceur = require('./tools/transpiler/gulp-traceur');
@ -465,6 +466,25 @@ gulp.task('build/format.dart', rundartpackage(gulp, gulpPlugins, {
args: CONFIG.formatDart.args args: CONFIG.formatDart.args
})); }));
// ------------
// check circular dependencies in Node.js context
gulp.task('build/checkCircularDependencies', function (done) {
var dependencyObject = madge(CONFIG.dest.js.dev.es6, {
format: 'es6',
paths: [CONFIG.dest.js.dev.es6],
extensions: ['.js', '.es6'],
onParseFile: function(data) {
data.src = data.src.replace(/import \* as/g, "//import * as");
}
});
var circularDependencies = dependencyObject.circular().getArray();
if (circularDependencies.length > 0) {
console.log(circularDependencies);
process.exit(1);
}
done();
});
// ------------------ // ------------------
// web servers // web servers
gulp.task('serve.js.dev', jsserve(gulp, gulpPlugins, { gulp.task('serve.js.dev', jsserve(gulp, gulpPlugins, {
@ -642,6 +662,7 @@ gulp.task('build.dart', function(done) {
gulp.task('build.js.dev', function(done) { gulp.task('build.js.dev', function(done) {
runSequence( runSequence(
['build/transpile.js.dev', 'build/html.js.dev', 'build/copy.js.dev', 'build/multicopy.js.dev.es6'], ['build/transpile.js.dev', 'build/html.js.dev', 'build/copy.js.dev', 'build/multicopy.js.dev.es6'],
'build/checkCircularDependencies',
done done
); );
}); });

View File

@ -2,7 +2,7 @@ import {int, isBlank, BaseException} from 'angular2/src/facade/lang';
import * as eiModule from './element_injector'; import * as eiModule from './element_injector';
import {DirectiveMetadata} from './directive_metadata'; import {DirectiveMetadata} from './directive_metadata';
import {List, StringMap} from 'angular2/src/facade/collection'; import {List, StringMap} from 'angular2/src/facade/collection';
import {ProtoView} from './view'; import * as viewModule from './view';
export class ElementBinder { export class ElementBinder {
protoElementInjector:eiModule.ProtoElementInjector; protoElementInjector:eiModule.ProtoElementInjector;
@ -10,7 +10,7 @@ export class ElementBinder {
viewportDirective:DirectiveMetadata; viewportDirective:DirectiveMetadata;
textNodeIndices:List<int>; textNodeIndices:List<int>;
hasElementPropertyBindings:boolean; hasElementPropertyBindings:boolean;
nestedProtoView: ProtoView; nestedProtoView: viewModule.ProtoView;
events:StringMap; events:StringMap;
contentTagSelector:string; contentTagSelector:string;
parent:ElementBinder; parent:ElementBinder;

View File

@ -5,7 +5,7 @@ import {DirectiveMetadata} from '../directive_metadata';
import {Decorator, Component, Viewport, DynamicComponent} from '../../annotations/annotations'; import {Decorator, Component, Viewport, DynamicComponent} from '../../annotations/annotations';
import {ElementBinder} from '../element_binder'; import {ElementBinder} from '../element_binder';
import {ProtoElementInjector} from '../element_injector'; import {ProtoElementInjector} from '../element_injector';
import {ProtoView} from '../view'; import * as viewModule from '../view';
import {dashCaseToCamelCase} from './util'; import {dashCaseToCamelCase} from './util';
import {AST} from 'angular2/change_detection'; import {AST} from 'angular2/change_detection';
@ -34,7 +34,7 @@ export class CompileElement {
_allDirectives:List<DirectiveMetadata>; _allDirectives:List<DirectiveMetadata>;
isViewRoot:boolean; isViewRoot:boolean;
hasBindings:boolean; hasBindings:boolean;
inheritedProtoView:ProtoView; inheritedProtoView:viewModule.ProtoView;
inheritedProtoElementInjector:ProtoElementInjector; inheritedProtoElementInjector:ProtoElementInjector;
inheritedElementBinder:ElementBinder; inheritedElementBinder:ElementBinder;
distanceToParentInjector:int; distanceToParentInjector:int;

View File

@ -1,10 +1,10 @@
import {CompileElement} from './compile_element'; import {CompileElement} from './compile_element';
import {CompileControl} from './compile_control'; import * as ccModule from './compile_control';
/** /**
* One part of the compile process. * One part of the compile process.
* Is guaranteed to be called in depth first order * Is guaranteed to be called in depth first order
*/ */
export class CompileStep { export class CompileStep {
process(parent:CompileElement, current:CompileElement, control:CompileControl) {} process(parent:CompileElement, current:CompileElement, control:ccModule.CompileControl) {}
} }

View File

@ -6,7 +6,7 @@ import {Injector} from 'angular2/di';
import * as eiModule from 'angular2/src/core/compiler/element_injector'; import * as eiModule from 'angular2/src/core/compiler/element_injector';
import {isPresent, isBlank} from 'angular2/src/facade/lang'; import {isPresent, isBlank} from 'angular2/src/facade/lang';
import {EventManager} from 'angular2/src/core/events/event_manager'; import {EventManager} from 'angular2/src/core/events/event_manager';
import * as ldModule from './shadow_dom_emulation/light_dom'; import {LightDom} from './shadow_dom_emulation/light_dom';
/** /**
* @publicModule angular2/angular2 * @publicModule angular2/angular2
@ -16,12 +16,12 @@ export class ViewContainer {
templateElement; templateElement;
defaultProtoView: viewModule.ProtoView; defaultProtoView: viewModule.ProtoView;
_views: List<viewModule.View>; _views: List<viewModule.View>;
_lightDom: ldModule.LightDom; _lightDom: LightDom;
_eventManager: EventManager; _eventManager: EventManager;
elementInjector: eiModule.ElementInjector; elementInjector: eiModule.ElementInjector;
appInjector: Injector; appInjector: Injector;
hostElementInjector: eiModule.ElementInjector; hostElementInjector: eiModule.ElementInjector;
hostLightDom: ldModule.LightDom; hostLightDom: LightDom;
constructor(parentView: viewModule.View, constructor(parentView: viewModule.View,
templateElement, templateElement,
@ -43,7 +43,7 @@ export class ViewContainer {
this._eventManager = eventManager; this._eventManager = eventManager;
} }
hydrate(appInjector: Injector, hostElementInjector: eiModule.ElementInjector, hostLightDom: ldModule.LightDom) { hydrate(appInjector: Injector, hostElementInjector: eiModule.ElementInjector, hostLightDom: LightDom) {
this.appInjector = appInjector; this.appInjector = appInjector;
this.hostElementInjector = hostElementInjector; this.hostElementInjector = hostElementInjector;
this.hostLightDom = hostLightDom; this.hostLightDom = hostLightDom;

View File

@ -64,6 +64,7 @@
"karma-dart": "^0.2.8", "karma-dart": "^0.2.8",
"karma-jasmine": "^0.2.2", "karma-jasmine": "^0.2.2",
"lodash": "^2.4.1", "lodash": "^2.4.1",
"madge": "mlaval/madge#es6",
"merge": "^1.2.0", "merge": "^1.2.0",
"minimatch": "^2.0.1", "minimatch": "^2.0.1",
"minimist": "1.1.x", "minimist": "1.1.x",