我正在使用 es6 modules
, TypeScript
和 SystemJS
作为模块加载器创建一个 Ionic
应用程序 . 这是我的设置:
tsconfig.json:
{
"compilerOptions": {
...
"target": "es5",
"module": "system",
...
}
}
index.html:
<script src="lib/system.js"></script>
<script src="systemjs.config.js"></script>
<script>System.import('js/app.js')</script>
example script (TypeScript):
import {IConfig} from "./app-config";
export class ConfigLoader {
...
}
Chrome中的一切都很棒 . 但是,在使用Safari的Web Inspector进行调试时,我无法在脚本中放置任何断点,因为Web Inspector仅显示直接从HTML加载的脚本(通过脚本标记),而不是XHR加载的脚本(在我的情况下,由SystemJS加载) . 这意味着我无法调试自己的脚本,这当然是不可接受的 .
我尝试像以前一样使用SystemJS解决这个问题,但也将脚本标记放在html中,如下所示:
<script src="lib/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="js/app-config.js"></script>
... other app scripts
<script>System.import('js/app.js')</script>
但是,这不起作用,因为SystemJS对此并不满意:
无效的System.register调用 . 匿名System.register调用只能由SystemJS.import加载的模块进行,而不能通过脚本标记进行 .
如何使用SystemJS并同时具备在Safari中调试的能力?我正在寻找比在每个脚本中放置调试器语句更复杂的解决方案......