These are chat archives for systemjs/systemjs

11th
May 2016
Ben Sandwick
@ben657
May 11 2016 10:23
Is there a way to have bundles export a certain module in them by default when they're imported?
Rather than then having to import src/whatever.js
niabot
@niabot
May 11 2016 11:53
In which order are the paths, maprules applied? And which part of the module name/path is looked up in packages?
niabot
@niabot
May 11 2016 13:03
I'm nearly at the point of giving up. How the ** do i tell SystemJS to import a single module from a bundle/library (System.register('mod1', ...) System.register('mod2', ...) ...). No matter what i try it just loads the file and returns an empty module.
Ben Sandwick
@ben657
May 11 2016 14:16
load the bundle then load a file that you bundled into it e.g:
System.import('mybundle.js').then(function() {
  System.import('thinginmybundle.js').then(function(thinginmybundle) {
    console.log(thinginmybundle);
  }
}
@niabot
niabot
@niabot
May 11 2016 14:25
OK, that seams to work a bit better. Now i have the module. But now i run into the issue that this module 'asysshop' depends on a second bundle asysform.js which contains the module 'asysform/i18n'. So SystemJS now tries to load 'asysform/i18n.js' and does not use the module defined in 'asysform.js'.
Ben Sandwick
@ben657
May 11 2016 14:26
are both bundles loaded?
niabot
@niabot
May 11 2016 14:28
No. Only 'asysshop.js' is loaded, then it tries to load 'asysform/i18n.js' (import {I18n} from 'asysform/i18n';)
Ben Sandwick
@ben657
May 11 2016 14:29
just need to make sure both are loaded then, either nest another import.then or you could use Promise.all to load all of your bundles or something similar
niabot
@niabot
May 11 2016 14:29
I must tell it somehow that it should load all modules starting with 'asysform' from 'asysform.js'.
Ben Sandwick
@ben657
May 11 2016 14:29
import all the bundles first, that will load all the modules into memory, then load whichever is your first module
niabot
@niabot
May 11 2016 14:30
That might be a way. But i wonder if we are supposed to do so.
Eugenio Arosteguy
@euginio
May 11 2016 14:33

Hi all I can't load jquery... my system.config.js looks like

var map = {
        'jquery': 'node_modules/jquery/dist/js/jquery.js'
};
    var packages = {
        'jquery': { defaultExtension: 'js' },
};

do you figure out what I'm doing wrong?

niabot
@niabot
May 11 2016 14:35
@ben657 Can't this be done with the configuration? I hoped that this could be configured in some way to tell SystemJS that it has to view the bundle files as a bundle and to load all modules from it automatically. It downloaded the entire source code anyway.
Eugenio Arosteguy
@euginio
May 11 2016 14:37
maybe I must add some typing?
niabot
@niabot
May 11 2016 14:42
@ben657 What could be wrong with this, it still loads the asysform/i18n.js:
System.config({
    baseURL: 'lib',
    paths: {
        '*': '*.js'
    },
    map: {
        'jquery':   'jquery-2.1.4'
    },
    meta: {
        'asysform': {
            scriptLoad: true,
            format: 'register'
        },
        'asysshop': {
            scriptLoad: true,
            format: 'register'
        }
    }
});

(function() {
    var config = {
        apibase: 'http://silex.asys'
    };

    Promise.all([System.import('asysshop'), System.import('asysform')])
    .then(function () {
        System.import('asysshop')
        .then(function(shop) {
            shop.start(config);
        });
    }).catch(function (err) {
        console.log('err1:', err);
    });
})();
@euginio Did you look which files SystemJS tries to load? Sometimes you have situations where it tries to load jquery.js.js (which fails) or something.
Eugenio Arosteguy
@euginio
May 11 2016 14:44
mmm how do that? debugging?
(I don't have any 404 trying to load a wrong filename)
niabot
@niabot
May 11 2016 14:45
Yes you can view the files/urls loaded inside the debuggers. In Chrome it is the Network tab.
Eugenio Arosteguy
@euginio
May 11 2016 14:46
nope, all attemps to load files are loaded correctly (but has no attempt to load jquery :( )
niabot
@niabot
May 11 2016 14:48
How do you use jquery within your project? If there is never a System.import('jquery'), then it will never be loaded, because nothing depends on it.
Eugenio Arosteguy
@euginio
May 11 2016 14:48
it's true, but its required by bootstrap JS
I don't have any import jquery
niabot
@niabot
May 11 2016 14:49
Then you should add it as a dependency to that library
Eugenio Arosteguy
@euginio
May 11 2016 14:50
oohhh .... I don't know how to do that, but, before to learn how to add the dependency I must add twitter bootstrap as a systemjs package (now I have a script tag in my index.html)
but I think it would have conflicts with bootstrap import for Angular 2
Eugenio Arosteguy
@euginio
May 11 2016 14:53
ok, and do you know how to add bootstrap with no conflicts with "the other" A2 bootstrap package?
niabot
@niabot
May 11 2016 14:56
That can be controlled with the packages and a nested map option. See: https://github.com/systemjs/systemjs/blob/master/docs/config-api.md#packages
It allows you define different libraries for the same dependency name depending from which package it is required/imported.
Eugenio Arosteguy
@euginio
May 11 2016 14:56
thank you !
Dixit Thareja
@dixitthareja
May 11 2016 14:59
anybody knows about the loading of angular 2 apps because for me it is taking so much time with this new rc1 implementation and I am using system.src.js
but earlier with the old implementation it was really fast...
Eugenio Arosteguy
@euginio
May 11 2016 15:22

some minutes ago from the angular2 gitter chat:

miha- @miha- 11:38
HI, am trying right now "angular 2.0.0-rc.1" and it take around 2 to 3 seconds to load hello world page, why so slow? from console i can see that it loading so much files

Stabzs @Stabzs 11:40
@miha- because of the number of http requests. You should bundle your requests to improve page load time (and because it's a good practice)

miha- @miha- 11:41
@Stabzs ok noob question. How to do that :smile:?

Stabzs @Stabzs 11:41
https://github.com/IgorMinar/new-world-test/blob/master/system-js/bundle.js
If using system.js and you want to use the system.js builder

Dominik Lenk @sqwk 11:44
@miha try the angular-cli. (I asked the same question yesterday:wink:
when appending --prod to the build command it bundles and tree shakes everything

very active chat room : https://gitter.im/angular/angular
BahKoo
@BahKoo
May 11 2016 16:25
In this systemjs example , the index.html needs different code depending on whether it's a bundled or not: https://github.com/IgorMinar/new-world-test/blob/master/system-js/index.html
Anyone know how to automate the difference with a gulp task so that I can build both a debug and release version?
BahKoo
@BahKoo
May 11 2016 16:43
hmm gulp-useref might be what I'm looking for
Joel Hernández
@lifenautjoe
May 11 2016 20:25
is there no watch option on the new builder#bundle method?
whoops wrong chat