似乎使用最新的 angular2 npm 包无法调试打字稿源。现存的在 stackoverflow 上回答 and 媒体上的文章已经过时了。我已经创建了一个 github 问题,请支持。
有两个问题:
1) TypeScript 源不再被硬编码为源映射内的数据 URI,而是实际上指向 npm 中某个不存在的位置(它实际上是 Angular git hub 源中的位置,但不是 npm 包内的某个位置):
{
"version":3,
"file":"application_ref.js",
"sourceRoot":"",
"sources":["../../../../modules/@angular/core/src/application_ref.ts"] <-------
我发现这条路径没有相关性,因为角度源是使用编译的--inlineSources
选项等*.map
文件包含sourcesContent
里面有原始内容的密钥。所以这不再是问题了。但第二个问题仍然存在。
2)即使我只是复制modules
从github来源的文件夹中,还有第二个问题,那就是js
npm包中的文件被编译成es6
模块语法在浏览器中尚不支持,而加载器(如 SystemJS)需要 Traceur。例如,common/index.j
:
export { NgLocalization, CommonModule, NgClass, NgFor, NgIf, NgPlural, NgPluralCase, NgStyle, NgSwitch, NgSwitchCase, NgSwitchDefault, NgTemplateOutlet, AsyncPipe, DatePipe, I18nPluralPipe, I18nSelectPipe, JsonPipe, LowerCasePipe, CurrencyPipe, DecimalPipe, PercentPipe, SlicePipe, UpperCasePipe, VERSION, Version, PlatformLocation, LocationStrategy, APP_BASE_HREF, HashLocationStrategy, PathLocationStrategy, Location } from './src/common';
但我不能使用traceur
,因为它很可能破坏为创建的现有源映射js
编译的文件tsc
.