Reputation: 67
I have the following code in my systemjs.config.js
(function(global) {
System.config({
map: {
'jquery': '//code.jquery.com/jquery-2.1.4.min.js'
}
})
})(this);
And the following code in my js/main.js
import $ from 'jquery';
console.log($('body'));
And the following code in my index.html
<!DOCTYPE html>
<html lang="en">
<head>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<script>
System.import('./js/main.js');
</script>
</body>
</html>
The error I get is:
Error: (SystemJS) XHR error loading file:///C:/www/systemjs/traceur
Error loading file:///C:/www/systemjs/traceur
Unable to load transpiler to transpile file:///C:/www/systemjs/js/main.js
Error loading file:///C:/www/systemjs/js/main.js
I'm not sure what I'm doing wrong here... I followed the guidelines from the systemjs github page
Upvotes: 1
Views: 3608
Reputation: 6496
In a typescript environment, using "module": "commonjs"
in tsconfig,
I found that specifying ".js" on my imports resulted in this error.
e.g.
import { simpleGrid } from "./mockData/simpleGrids.js";
fails with Error: (SystemJS) XHR error loading http://localhost:18300/specs/traceur.js
whereas
import { simpleGrid } from "./mockData/simpleGrids";
works.
also... and this may have been the real culprit:
If you have an import
within a multi-line comment (/**/
) it will result in a similar, if not the same, error.
Upvotes: 0
Reputation: 205
I had this issue when I updated to version 0.20.9 of systemjs. For me I was able to make it go away by reverting back to 0.19.42. So I suspect that the answer lies in whatever was changed between v19 and v20 which says in one of the points that "Default transpiler loading is removed. It is no longer possible to transpile sources without configuring one of the transpiler plugins" (you can read the full set of changes here: https://github.com/systemjs/systemjs/releases/tag/0.20.0)
It may not be possible for you to use the earlier version in which case you should probably investigate installing the Typescript plugin recommended on the systemjs GitHub page (linked here: https://github.com/frankwallis/plugin-typescript)
I hope that helps.
Upvotes: 2