chore(build): Remove circular dependency in Angular 2 ES5 output.
Remove couple of circular dependency between modules in Angular 2 ES5 output caused by exception_handler.ts and router_providers.ts. Fix the build/checkCircularDependency gulp task to call madge properly to detect the circular deps. Closes #7287
This commit is contained in:
parent
7d44b8230e
commit
9936e347ff
@ -344,9 +344,8 @@ gulp.task('lint', ['build.tools'], function() {
|
|||||||
gulp.task('build/checkCircularDependencies', function(done) {
|
gulp.task('build/checkCircularDependencies', function(done) {
|
||||||
var madge = require('madge');
|
var madge = require('madge');
|
||||||
|
|
||||||
var dependencyObject = madge(CONFIG.dest.js.dev.es5, {
|
var dependencyObject = madge([CONFIG.dest.js.dev.es5], {
|
||||||
format: 'cjs',
|
format: 'cjs',
|
||||||
paths: [CONFIG.dest.js.dev.es5],
|
|
||||||
extensions: ['.js'],
|
extensions: ['.js'],
|
||||||
onParseFile: function(data) { data.src = data.src.replace(/\/\* circular \*\//g, "//"); }
|
onParseFile: function(data) { data.src = data.src.replace(/\/\* circular \*\//g, "//"); }
|
||||||
});
|
});
|
||||||
|
17
modules/angular2/src/facade/base_wrapped_exception.dart
Normal file
17
modules/angular2/src/facade/base_wrapped_exception.dart
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
library angular.core.facade.base_wrapped_exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A base class for the WrappedException that can be used to identify
|
||||||
|
* a WrappedException from ExceptionHandler without adding circular
|
||||||
|
* dependency.
|
||||||
|
*/
|
||||||
|
class BaseWrappedException extends Error {
|
||||||
|
BaseWrappedException();
|
||||||
|
|
||||||
|
get originalException => null;
|
||||||
|
get originalStack => null;
|
||||||
|
|
||||||
|
String get message => '';
|
||||||
|
String get wrapperMessage => '';
|
||||||
|
dynamic get context => null;
|
||||||
|
}
|
15
modules/angular2/src/facade/base_wrapped_exception.ts
Normal file
15
modules/angular2/src/facade/base_wrapped_exception.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
/**
|
||||||
|
* A base class for the WrappedException that can be used to identify
|
||||||
|
* a WrappedException from ExceptionHandler without adding circular
|
||||||
|
* dependency.
|
||||||
|
*/
|
||||||
|
export class BaseWrappedException extends Error {
|
||||||
|
constructor(message: string) { super(message); }
|
||||||
|
|
||||||
|
get wrapperMessage(): string { return ''; }
|
||||||
|
get wrapperStack(): any { return null; }
|
||||||
|
get originalException(): any { return null; }
|
||||||
|
get originalStack(): any { return null; }
|
||||||
|
get context(): any { return null; }
|
||||||
|
get message(): string { return ''; }
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
import {isPresent, isBlank, print} from 'angular2/src/facade/lang';
|
import {isPresent, isBlank, print} from 'angular2/src/facade/lang';
|
||||||
import {BaseException, WrappedException} from 'angular2/src/facade/exceptions';
|
import {BaseWrappedException} from 'angular2/src/facade/base_wrapped_exception';
|
||||||
import {ListWrapper, isListLikeIterable} from 'angular2/src/facade/collection';
|
import {ListWrapper, isListLikeIterable} from 'angular2/src/facade/collection';
|
||||||
|
|
||||||
class _ArrayLogger {
|
class _ArrayLogger {
|
||||||
@ -80,7 +80,8 @@ export class ExceptionHandler {
|
|||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
_extractMessage(exception: any): string {
|
_extractMessage(exception: any): string {
|
||||||
return exception instanceof WrappedException ? exception.wrapperMessage : exception.toString();
|
return exception instanceof BaseWrappedException ? exception.wrapperMessage :
|
||||||
|
exception.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
@ -92,7 +93,7 @@ export class ExceptionHandler {
|
|||||||
/** @internal */
|
/** @internal */
|
||||||
_findContext(exception: any): any {
|
_findContext(exception: any): any {
|
||||||
try {
|
try {
|
||||||
if (!(exception instanceof WrappedException)) return null;
|
if (!(exception instanceof BaseWrappedException)) return null;
|
||||||
return isPresent(exception.context) ? exception.context :
|
return isPresent(exception.context) ? exception.context :
|
||||||
this._findContext(exception.originalException);
|
this._findContext(exception.originalException);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -103,10 +104,10 @@ export class ExceptionHandler {
|
|||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
_findOriginalException(exception: any): any {
|
_findOriginalException(exception: any): any {
|
||||||
if (!(exception instanceof WrappedException)) return null;
|
if (!(exception instanceof BaseWrappedException)) return null;
|
||||||
|
|
||||||
var e = exception.originalException;
|
var e = exception.originalException;
|
||||||
while (e instanceof WrappedException && isPresent(e.originalException)) {
|
while (e instanceof BaseWrappedException && isPresent(e.originalException)) {
|
||||||
e = e.originalException;
|
e = e.originalException;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,13 +116,13 @@ export class ExceptionHandler {
|
|||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
_findOriginalStack(exception: any): any {
|
_findOriginalStack(exception: any): any {
|
||||||
if (!(exception instanceof WrappedException)) return null;
|
if (!(exception instanceof BaseWrappedException)) return null;
|
||||||
|
|
||||||
var e = exception;
|
var e = exception;
|
||||||
var stack = exception.originalStack;
|
var stack = exception.originalStack;
|
||||||
while (e instanceof WrappedException && isPresent(e.originalException)) {
|
while (e instanceof BaseWrappedException && isPresent(e.originalException)) {
|
||||||
e = e.originalException;
|
e = e.originalException;
|
||||||
if (e instanceof WrappedException && isPresent(e.originalException)) {
|
if (e instanceof BaseWrappedException && isPresent(e.originalException)) {
|
||||||
stack = e.originalStack;
|
stack = e.originalStack;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
library angular.core.facade.exceptions;
|
library angular.core.facade.exceptions;
|
||||||
|
|
||||||
|
import 'base_wrapped_exception.dart';
|
||||||
import 'exception_handler.dart';
|
import 'exception_handler.dart';
|
||||||
export 'exception_handler.dart';
|
export 'exception_handler.dart';
|
||||||
|
|
||||||
@ -15,7 +16,7 @@ class BaseException extends Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class WrappedException extends Error {
|
class WrappedException extends BaseWrappedException {
|
||||||
final dynamic _context;
|
final dynamic _context;
|
||||||
final String _wrapperMessage;
|
final String _wrapperMessage;
|
||||||
final originalException;
|
final originalException;
|
||||||
@ -27,7 +28,7 @@ class WrappedException extends Error {
|
|||||||
this.originalStack,
|
this.originalStack,
|
||||||
this._context]);
|
this._context]);
|
||||||
|
|
||||||
get message {
|
String get message {
|
||||||
return ExceptionHandler.exceptionToString(this);
|
return ExceptionHandler.exceptionToString(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import {BaseWrappedException} from './base_wrapped_exception';
|
||||||
import {ExceptionHandler} from './exception_handler';
|
import {ExceptionHandler} from './exception_handler';
|
||||||
|
|
||||||
export {ExceptionHandler} from './exception_handler';
|
export {ExceptionHandler} from './exception_handler';
|
||||||
@ -15,7 +16,7 @@ export class BaseException extends Error {
|
|||||||
/**
|
/**
|
||||||
* Wraps an exception and provides additional context or information.
|
* Wraps an exception and provides additional context or information.
|
||||||
*/
|
*/
|
||||||
export class WrappedException extends Error {
|
export class WrappedException extends BaseWrappedException {
|
||||||
private _wrapperStack: any;
|
private _wrapperStack: any;
|
||||||
|
|
||||||
constructor(private _wrapperMessage: string, private _originalException, private _originalStack?,
|
constructor(private _wrapperMessage: string, private _originalException, private _originalStack?,
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
// import {ROUTER_PROVIDERS_COMMON} from './router_providers_common';
|
import {ROUTER_PROVIDERS_COMMON} from './router_providers_common';
|
||||||
import {ROUTER_PROVIDERS_COMMON} from 'angular2/router';
|
|
||||||
import {Provider} from 'angular2/core';
|
import {Provider} from 'angular2/core';
|
||||||
import {CONST_EXPR} from 'angular2/src/facade/lang';
|
import {CONST_EXPR} from 'angular2/src/facade/lang';
|
||||||
import {BrowserPlatformLocation} from './location/browser_platform_location';
|
import {BrowserPlatformLocation} from './location/browser_platform_location';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user