问题描述
systemJS
加载外部模块时遇到问题.我为 VS2015 创建了一个小示例项目.您可以在此处下载代码
发现问题.导入/导出外部模块时,TypeScript 不使用 .js
扩展名.例如:
打字稿
import * as Animate from './animate';
ES6
import * as Animate from './animate.js';
解决办法是在system.config中加入defaultJSExtensions: true
.
示例:
System.config({baseURL: './scripts/',路径:{'应用':'app.js'},defaultJSExtensions: 真});
我在这里更新了 VS2015 项目代码,效果很好.
https://github.com/dbiele/TypeScript-Cordova-SystemJS
@DatenMetzgerX 也有同样的问题.发布信息:https://github.com/systemjs/systemjs/issues/490
I'm having problem with systemJS
loading external modules. I created a small sample project for VS2015. You can download the code here https://github.com/dbiele/TypeScript-Cordova-SystemJS
When I build the project and view in Ripple or BrowserSync I get the following error: xhr_proxy
. It looks like System
is looking for the external file animate.js
on registry.jspm.io when it should be finding it on the localhost
.
Any thoughts? The code in GitHub is really basic. Note: I don't think this is a Cordova issue because I'm running in a browser and ripple.
Found the issue. TypeScript does not use the .js
extension when importing/exporting external modules. For example:
TypeScript
import * as Animate from './animate';
ES6
import * as Animate from './animate.js';
The solution is to add defaultJSExtensions: true
into system.config.
Example:
System.config({
baseURL: './scripts/',
paths: { 'App': 'app.js' },
defaultJSExtensions: true
});
I updated the VS2015 project code here and it works well.
https://github.com/dbiele/TypeScript-Cordova-SystemJS
@DatenMetzgerX had the same problem. Posted info:https://github.com/systemjs/systemjs/issues/490
这篇关于VS2015 + TypeScript + Cordova + Angular2 + SystemJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!