These are chat archives for systemjs/systemjs

5th
Apr 2016
Dominik Ivosevic
@DominikDitoIvosevic
Apr 05 2016 07:15

Does anyone have experience with loading commonjs format files? I'm trying to load 2 very simple files (results of purescript compilation) but I'm having some troubles. I have specified

<script>
System.config({
meta: {
'/output/*': { format: 'cjs' }
}
});
</script>
<script>
//bootstrap the Angular2 application
System.import('output/Main');//.catch(console.log.bind(console));
console.log("ASD");
</script>

ASD gets printed but I get an error for importing output/Main:
Main:1 Uncaught SyntaxError: Unexpected token <
I get the html page returned instead of the file because Systemjs did not change the requested url to output/Main/index.js

Dominik Ivosevic
@DominikDitoIvosevic
Apr 05 2016 07:21
I'm having a hard time finding out how to properly import commonjs. I've been rereading the docs https://github.com/systemjs/systemjs/blob/master/docs/module-formats.md#commonjs but I do not understand what else do I need to do. I see that there is a mention of a need for additional preprocessing for systemjs+commonjs to work. Are there any instructions for this?
Peter Müller
@Munter
Apr 05 2016 09:01
Why would Systemjs change output/Main to output/Main/index.js?
You haven't pasted any configuration that would do so
Dominik Ivosevic
@DominikDitoIvosevic
Apr 05 2016 09:02
I have set that output is using commonjs for resolution. Isnt that it?
Peter Müller
@Munter
Apr 05 2016 09:02
Remember that unlike node, where it can just run auto discovery on the file system, these loads are http and slow. Systemjs will not run a brute force auto discovery to look for alternatives
Dominik Ivosevic
@DominikDitoIvosevic
Apr 05 2016 09:08
Doesnt commonjs specify that the actual file is in /index.js /foreign.js etc? I apologise if I'm asking a stupid question it's just that I do not have much experience with different formats. I'm trying to use my compiled purescript which is compiled so that in one file it says
var Other = require("Other"); while the actual files are in that Other/ folder
Peter Müller
@Munter
Apr 05 2016 09:12
The format is an indicator on how systemjs should interpret or possibly wrap the loaded file. Systemjs won't do autodiscovery. You will have to configure aliases so the loader knows what url to fetch
jspm does a lot of this work when you install commonjs modules at install time