问题
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