These are chat archives for systemjs/systemjs

4th
Aug 2016
requiemforameme
@requiemforameme
Aug 04 2016 15:03
How to use SystemJS to create bundled JS files? Looking at the systemjs-builder npm package at the moment...
Jeff
@Jefftopia
Aug 04 2016 15:09

@requiemforameme

Something like this

var path = require('path');
var Builder = require('systemjs-builder');

var builder = new Builder('', 'systembuild.config.js');

builder.bundle('entry-point', 'outfile.js')
.then(function() {
    console.log('build complete');
})
.catch(function(err) {
    console.log('build error', err);
});

builder.buildStatic('entry-point', 'outfile.min.js', {
     minify: true,
     mangle: true,
     rollup: true,
     sourceMaps: true,
     encodeNames: false
 }).then(function() {
     console.log('build complete');
 })
 .catch(function(err) {
     console.log('build error', err);
 });
requiemforameme
@requiemforameme
Aug 04 2016 15:11
@Jefftopia Thank you! Any special initialization needed in the HTML. Would this npm script work?
"start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" "
Jeff
@Jefftopia
Aug 04 2016 15:16

I assume the first sentence is a question. Yes, your HTML will be slightly different depending on whether you do a static build or a bundle; you shouldn't need to do a system.import in a static build. For a bundle, you will use the same import statment as you did before you bundled. For either build scenario, include the bundled js in a normal script tag.

RE: that npm script: I'm not sure what you're asking. Yes, that script will launch concurrently with tsc watch and lite server, it obviously won't build your files. You need to add a build step.

It looks like you're copying straight out of the Angular 2 Quickstart without bothering to learn what's going on. I recommend you take a step back and read about System JS and what those npm tasks are doing for you before you proceed.

requiemforameme
@requiemforameme
Aug 04 2016 15:29
Ok, I'm reading up on SystemJS, the builder and the starter page to see how everything fits together. Let me try to piece everything together and get a bundle built out. I'll post back here if I have any errors/successes.
Jeff
@Jefftopia
Aug 04 2016 15:29
Good luck
@requiemforameme You might find this article useful.
meltedspark
@meltedspark
Aug 04 2016 16:12
In case anyone is interested - I've found an answer to my question http://stackoverflow.com/a/38769670/1544364