diff --git a/gulpfile.js b/gulpfile.js index 8b7d82c07d..20007c54ff 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,6 +1,7 @@ var gulp = require('gulp'); var gulpPlugins = require('gulp-load-plugins')(); var runSequence = require('run-sequence'); +var madge = require('madge'); var merge = require('merge'); var gulpTraceur = require('./tools/transpiler/gulp-traceur'); @@ -465,6 +466,25 @@ gulp.task('build/format.dart', rundartpackage(gulp, gulpPlugins, { 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 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) { runSequence( ['build/transpile.js.dev', 'build/html.js.dev', 'build/copy.js.dev', 'build/multicopy.js.dev.es6'], + 'build/checkCircularDependencies', done ); }); diff --git a/modules/angular2/src/core/compiler/element_binder.js b/modules/angular2/src/core/compiler/element_binder.js index 66a3531b18..a58c1c0d93 100644 --- a/modules/angular2/src/core/compiler/element_binder.js +++ b/modules/angular2/src/core/compiler/element_binder.js @@ -2,7 +2,7 @@ import {int, isBlank, BaseException} from 'angular2/src/facade/lang'; import * as eiModule from './element_injector'; import {DirectiveMetadata} from './directive_metadata'; import {List, StringMap} from 'angular2/src/facade/collection'; -import {ProtoView} from './view'; +import * as viewModule from './view'; export class ElementBinder { protoElementInjector:eiModule.ProtoElementInjector; @@ -10,7 +10,7 @@ export class ElementBinder { viewportDirective:DirectiveMetadata; textNodeIndices:List; hasElementPropertyBindings:boolean; - nestedProtoView: ProtoView; + nestedProtoView: viewModule.ProtoView; events:StringMap; contentTagSelector:string; parent:ElementBinder; diff --git a/modules/angular2/src/core/compiler/pipeline/compile_element.js b/modules/angular2/src/core/compiler/pipeline/compile_element.js index 2ec4bb7bcf..a619b14e3e 100644 --- a/modules/angular2/src/core/compiler/pipeline/compile_element.js +++ b/modules/angular2/src/core/compiler/pipeline/compile_element.js @@ -5,7 +5,7 @@ import {DirectiveMetadata} from '../directive_metadata'; import {Decorator, Component, Viewport, DynamicComponent} from '../../annotations/annotations'; import {ElementBinder} from '../element_binder'; import {ProtoElementInjector} from '../element_injector'; -import {ProtoView} from '../view'; +import * as viewModule from '../view'; import {dashCaseToCamelCase} from './util'; import {AST} from 'angular2/change_detection'; @@ -34,7 +34,7 @@ export class CompileElement { _allDirectives:List; isViewRoot:boolean; hasBindings:boolean; - inheritedProtoView:ProtoView; + inheritedProtoView:viewModule.ProtoView; inheritedProtoElementInjector:ProtoElementInjector; inheritedElementBinder:ElementBinder; distanceToParentInjector:int; diff --git a/modules/angular2/src/core/compiler/pipeline/compile_step.js b/modules/angular2/src/core/compiler/pipeline/compile_step.js index 795e7b6aa8..0e06f955ce 100644 --- a/modules/angular2/src/core/compiler/pipeline/compile_step.js +++ b/modules/angular2/src/core/compiler/pipeline/compile_step.js @@ -1,10 +1,10 @@ import {CompileElement} from './compile_element'; -import {CompileControl} from './compile_control'; +import * as ccModule from './compile_control'; /** * One part of the compile process. * Is guaranteed to be called in depth first order */ export class CompileStep { - process(parent:CompileElement, current:CompileElement, control:CompileControl) {} + process(parent:CompileElement, current:CompileElement, control:ccModule.CompileControl) {} } diff --git a/modules/angular2/src/core/compiler/view_container.js b/modules/angular2/src/core/compiler/view_container.js index a2170ce0d8..cd7f3c226c 100644 --- a/modules/angular2/src/core/compiler/view_container.js +++ b/modules/angular2/src/core/compiler/view_container.js @@ -6,7 +6,7 @@ import {Injector} from 'angular2/di'; import * as eiModule from 'angular2/src/core/compiler/element_injector'; import {isPresent, isBlank} from 'angular2/src/facade/lang'; 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 @@ -16,12 +16,12 @@ export class ViewContainer { templateElement; defaultProtoView: viewModule.ProtoView; _views: List; - _lightDom: ldModule.LightDom; + _lightDom: LightDom; _eventManager: EventManager; elementInjector: eiModule.ElementInjector; appInjector: Injector; hostElementInjector: eiModule.ElementInjector; - hostLightDom: ldModule.LightDom; + hostLightDom: LightDom; constructor(parentView: viewModule.View, templateElement, @@ -43,7 +43,7 @@ export class ViewContainer { this._eventManager = eventManager; } - hydrate(appInjector: Injector, hostElementInjector: eiModule.ElementInjector, hostLightDom: ldModule.LightDom) { + hydrate(appInjector: Injector, hostElementInjector: eiModule.ElementInjector, hostLightDom: LightDom) { this.appInjector = appInjector; this.hostElementInjector = hostElementInjector; this.hostLightDom = hostLightDom; diff --git a/package.json b/package.json index 17234f5cc8..439061d0a5 100644 --- a/package.json +++ b/package.json @@ -64,6 +64,7 @@ "karma-dart": "^0.2.8", "karma-jasmine": "^0.2.2", "lodash": "^2.4.1", + "madge": "mlaval/madge#es6", "merge": "^1.2.0", "minimatch": "^2.0.1", "minimist": "1.1.x",