0

我在systemJS加载外部模块时遇到问题。我为 VS2015 创建了一个小示例项目。你可以在这里下载代码https://github.com/dbiele/TypeScript-Cordova-SystemJS

当我在 Ripple 或 BrowserSync 中构建项目并查看时,我收到以下错误:xhr_proxy. 看起来System正在寻找animate.jsregistry.jspm.io 上的外部文件,而应该在localhost.

有什么想法吗?GitHub 中的代码非常基础。注意:我认为这不是 Cordova 问题,因为我在浏览器中运行并产生波纹。

在此处输入图像描述

4

1 回答 1

0

发现了问题。TypeScript 在导入/导出外部模块时不使用.js扩展。例如:

打字稿

import * as Animate from './animate';

ES6

import * as Animate from './animate.js';

解决方案是添加defaultJSExtensions: true到 system.config 中。

例子:

System.config({
    baseURL: './scripts/',
    paths: { 'App': 'app.js' },
    defaultJSExtensions: true
});

我在这里更新了 VS2015 项目代码,效果很好。

https://github.com/dbiele/TypeScript-Cordova-SystemJS

@DatenMetzgerX 有同样的问题。发布信息: https ://github.com/systemjs/systemjs/issues/490

于 2015-10-02T21:11:57.907 回答