These are chat archives for systemjs/systemjs

29th
Jun 2016
Dawid Karabin
@hinok
Jun 29 2016 10:03
What do you think about bundling code to chunks by Webpack and then using system.js to glue different chunks on website?
I had one big bundle so communicating between modules was super easy, right now I splitted code into few chunks (e.g. critical js at <head>, rest of code before </body>) and I have to solve problem with communication between those chunks.
I feel like I'm going to use a tank to kill a fly by using system.js, am I wrong?
Peter Müller
@Munter
Jun 29 2016 10:20
Doesn't webpack support require.ensure?
For all your lazy loading needs
Dawid Karabin
@hinok
Jun 29 2016 10:22
Hmmm yeap, but is it going to work in that case?
<html>
<head>
  <script src="critical.js">
</head>
<body>
  <script src="bundle.js" async>
</body>
</html>
critical is loaded sync, but bundle in the async way. I would like to require some modules from critical in the bundle
Peter Müller
@Munter
Jun 29 2016 10:23
You use the runtime to load the delayed chunk. Pretty much like you would in systemjs
Peter Müller
@Munter
Jun 29 2016 10:28
I wouldn't recommend combining sync and async script blocks and write your own script loading logic. Use systemjs or webpacks equivalent to load bundle.js when you need it
Dawid Karabin
@hinok
Jun 29 2016 10:29
I don't want write own loader ;)
In 2013 I would just use require.js :D
Today we have new tools
Munawwar
@Munawwar
Jun 29 2016 11:47
Guys, how do you write tests on node, on code that uses systemjs (without moving codebase from AMD to require()s)? With requirejs I had node-amd.
Peter Müller
@Munter
Jun 29 2016 11:49
var System = require('jspm').Loader();
var module;

before(function (done) {
  System.import('module-under-test').then(function (loadedModule) {
    module = loadedModule;
    done();
  });
});
This is purely from memory and I don't have access to the code base any more
Peter Müller
@Munter
Jun 29 2016 11:56
Found a gist. Fixed the code example
If you have ES7 available I guess you could do:
var System = require('jspm').Loader();
var module = await System.import('module-under-test');
Munawwar
@Munawwar
Jun 29 2016 12:13
hmm...the System.import() call doesn't seem to load the module.
Munawwar
@Munawwar
Jun 29 2016 12:25
^ ok that was due to baseURL change.
Peter Müller
@Munter
Jun 29 2016 13:59
It works now?
Munawwar
@Munawwar
Jun 29 2016 14:01
Nope, when using mocha, the .then() handlers doesn't get called at all
When using node directly, it seems to work though.
Giving up for the day. Will try it again.
Peter Müller
@Munter
Jun 29 2016 14:03
Always add a .catch() to check what went wrong
Munawwar
@Munawwar
Jun 29 2016 14:06
catach doesn't get called either.
Aha, mocha --delay option helped
Scott Bowers
@sbbowers__twitter
Jun 29 2016 15:58
Hello, I'm having issues using SystemJS with my angular2/typescript application. I want to do import "reflect-metadata", which I can in Typescript and it transpiles fine, emitting a require("reflect-metadata"). This does not work by default, so I had to add a map configuration in my systemjs.config.js file to map it: 'reflect-metadata': 'node_modules/reflect-metadata/Reflect.js'. This resolves that issue, but now, that triggers additional requires, that I then have to resolve. Is there "better" way to resolve all of this using SystemJS, or do I need to just slug through the dependencies? Additional info: I'm including reflect-metadata via a script tag prior to bootstrapping, so shouldn't all of this be unnecessary?
Jake Niemiec
@jakeNiemiec
Jun 29 2016 17:26
@sbbowers__twitter depcache? bundle arithmetic?
Scott Bowers
@sbbowers__twitter
Jun 29 2016 17:27
I solved it with /// <reference path="../../../node_modules/reflect-metadata/reflect-metadata.d.ts" />
I bootstraped it in via a script tag, and then resolved the typescript issues with the reference directive.
Jake Niemiec
@jakeNiemiec
Jun 29 2016 17:28
👌
Scott Bowers
@sbbowers__twitter
Jun 29 2016 17:29
So not really a systemJS issue, I guess.
Guy Bedford
@guybedford
Jun 29 2016 19:33
@Munawwar for Mocha support perhaps have a look at http://guybedford.com/systemjs-mocha-istanbul It's by no means the only way of going about it though, and feedback on other approaches is always good to hear.
Olajide Jr
@oojx_twitter
Jun 29 2016 20:06
guys I am bringing in a bundled jspm/system project into a legacy amd project, which has require js and some system import
the problem is System.import('react') makes hundreds of request
tried putting production: true and map react to a prod version in System config but still hundreds of request
is there an example of using a minified version of react in jspm 0.16?