VS2015 + TypeScript + Cordova + Angular2 + SystemJS

主宰稳场 提交于 2019-12-12 03:18:54

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/32893436/vs2015-typescript-cordova-angular2-systemjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!