feat: introduce source maps for templates (#15011)
The main use case for the generated source maps is to give errors a meaningful context in terms of the original source that the user wrote. Related changes that are included in this commit: * renamed virtual folders used for jit: * ng://<module type>/module.ngfactory.js * ng://<module type>/<comp type>.ngfactory.js * ng://<module type>/<comp type>.html (for inline templates) * error logging: * all errors that happen in templates are logged from the place of the nearest element. * instead of logging error messages and stacks separately, we log the actual error. This is needed so that browsers apply source maps to the stack correctly. * error type and error is logged as one log entry. Note that long-stack-trace zone has a bug that disables source maps for stack traces, see https://github.com/angular/zone.js/issues/661. BREAKING CHANGE: - DebugNode.source no more returns the source location of a node. Closes 14013
This commit is contained in:

committed by
Chuck Jazdzewski

parent
1c1085b140
commit
cdc882bd36
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import {Injector} from '../di';
|
||||
import {RenderDebugInfo} from '../render/api';
|
||||
import {DebugContext} from '../view/index';
|
||||
|
||||
export class EventListener { constructor(public name: string, public callback: Function){}; }
|
||||
|
||||
@ -19,7 +19,7 @@ export class DebugNode {
|
||||
listeners: EventListener[];
|
||||
parent: DebugElement;
|
||||
|
||||
constructor(nativeNode: any, parent: DebugNode, private _debugInfo: RenderDebugInfo) {
|
||||
constructor(nativeNode: any, parent: DebugNode, private _debugContext: DebugContext) {
|
||||
this.nativeNode = nativeNode;
|
||||
if (parent && parent instanceof DebugElement) {
|
||||
parent.addChild(this);
|
||||
@ -29,19 +29,24 @@ export class DebugNode {
|
||||
this.listeners = [];
|
||||
}
|
||||
|
||||
get injector(): Injector { return this._debugInfo ? this._debugInfo.injector : null; }
|
||||
get injector(): Injector { return this._debugContext ? this._debugContext.injector : null; }
|
||||
|
||||
get componentInstance(): any { return this._debugInfo ? this._debugInfo.component : null; }
|
||||
get componentInstance(): any { return this._debugContext ? this._debugContext.component : null; }
|
||||
|
||||
get context(): any { return this._debugInfo ? this._debugInfo.context : null; }
|
||||
get context(): any { return this._debugContext ? this._debugContext.context : null; }
|
||||
|
||||
get references(): {[key: string]: any} {
|
||||
return this._debugInfo ? this._debugInfo.references : null;
|
||||
return this._debugContext ? this._debugContext.references : null;
|
||||
}
|
||||
|
||||
get providerTokens(): any[] { return this._debugInfo ? this._debugInfo.providerTokens : null; }
|
||||
get providerTokens(): any[] {
|
||||
return this._debugContext ? this._debugContext.providerTokens : null;
|
||||
}
|
||||
|
||||
get source(): string { return this._debugInfo ? this._debugInfo.source : null; }
|
||||
/**
|
||||
* @deprecated since v4
|
||||
*/
|
||||
get source(): string { return 'Deprecated since v4'; }
|
||||
}
|
||||
|
||||
/**
|
||||
@ -56,8 +61,8 @@ export class DebugElement extends DebugNode {
|
||||
childNodes: DebugNode[];
|
||||
nativeElement: any;
|
||||
|
||||
constructor(nativeNode: any, parent: any, _debugInfo: RenderDebugInfo) {
|
||||
super(nativeNode, parent, _debugInfo);
|
||||
constructor(nativeNode: any, parent: any, _debugContext: DebugContext) {
|
||||
super(nativeNode, parent, _debugContext);
|
||||
this.properties = {};
|
||||
this.attributes = {};
|
||||
this.classes = {};
|
||||
|
Reference in New Issue
Block a user