在Angular 2项目中用typescript编写并与webpack打包我添加了例如关注throw
到welcome.ts
文件:
@Page({
templateUrl: 'build/views/welcome/welcome.html'
})
export class Welcome{
constructor(){
throw('something went wrong')
}
}
在JS控制台中,我看到以下错误和stacktrace:
EXCEPTION: Error: Uncaught (in promise): EXCEPTION: Error during instantiation of Welcome!.
ORIGINAL EXCEPTION: something went wrong
ERROR CONTEXT:
[object Object]BrowserDomAdapter.logError @ browser_adapter.js?f9d6:77
BrowserDomAdapter.logGroup @ browser_adapter.js?f9d6:87
ExceptionHandler.call @ exception_handler.js?1ee2:57
(anonymous function) @ application_ref.js?7cf8:194
EventEmitter.subscribe.schedulerFn @ async.js?563f:123
SafeSubscriber.__tryOrUnsub @ VM2136:166SafeSubscriber.next @ VM2136:115
Subscriber._next @ VM2136:74Subscriber.next @ VM2136:51
Subject._finalNext @ VM2130:124Subject._next @ VM2130:116
Subject.next @ VM2130:73EventEmitter.emit @ async.js?563f:112
_a._zoneImpl.ng_zone_impl_1.NgZoneImpl.onError @ ng_zone.js?c886:120
_a.inner.inner.fork.onHandleError @ ng_zone_impl.js?4233:66
ZoneDelegate.handleError @ zone.js?fad3:327Zone.runGuarded @ zone.js?fad3:233
_loop_1 @ zone.js?fad3:487drainMicroTaskQueue @ zone.js?fad3:494cancelFn.invoke @ zone.js?fad3:426
browser_adapter.js?f9d6:77
STACKTRACE:BrowserDomAdapter.logError @ browser_adapter.js?f9d6:77
ExceptionHandler.call @ exception_handler.js?1ee2:59
(anonymous function) @ application_ref.js?7cf8:194
EventEmitter.subscribe.schedulerFn @ async.js?563f:123
SafeSubscriber.__tryOrUnsub @ VM2136:166SafeSubscriber.next @ VM2136:115
Subscriber._next @ VM2136:74
Subscriber.next @ VM2136:51
Subject._finalNext @ VM2130:124
Subject._next @ VM2130:116
Subject.next @ VM2130:73
EventEmitter.emit @ async.js?563f:112
_a._zoneImpl.ng_zone_impl_1.NgZoneImpl.onError @ ng_zone.js?c886:120_
a.inner.inner.fork.onHandleError @ ng_zone_impl.js?4233:66
ZoneDelegate.handleError @ zone.js?fad3:327
Zone.runGuarded @ zone.js?fad3:233
_loop_1 @ zone.js?fad3:487drainMicroTaskQueue @ zone.js?fad3:494
cancelFn.invoke @ zone.js?fad3:426
是否可以配置typescript编译器和webpack,以便stacktrace还具有我的welcome.ts
文件? e.g:
constructor @ welcome.ts:7
到目前为止,我尝试了webpack devtool option中的所有选项,而tsconfig.js
compilerOptions.sourceMap
中的所有选项都设置为true
,但没有一个帮助。