【发布时间】:2017-01-14 15:49:53
【问题描述】:
似乎使用最新的 angular2 npm 包无法调试打字稿源。现有的 answer on stackoverflow 和 the article on medium 已过时。我创建了a github issue,请支持。
有两个问题:
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) 即使我只是从 github 源中复制 modules 文件夹,还有第二个问题,即 npm 包中的 js 文件被编译成 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 转译。
【问题讨论】:
-
说调试 JS 对于大多数情况来说“足够好”。你想看这个吗? i.stack.imgur.com/ZWg0g.gif 可以在 angular2 的最新版本中实现。但是你有很棒的 es-2015 源代码
-
@yurzui,谢谢,是的,我想调试 ts 文件。我需要什么最新版本?我正在使用来自 npm 的最新版本
标签: angular typescript