These are chat archives for systemjs/systemjs

19th
Dec 2015
Davis Kim
@davis
Dec 19 2015 00:44
how do i write a library that works on node and in the browser in es6 using system js?
so they could do a <script src="">
or a require()
Davis Kim
@davis
Dec 19 2015 00:57
or is that just a sfx bundle? how do expose an object in the global space?
Bnaya Peretz
@Bnaya
Dec 19 2015 02:44
i believe you can make SFX, and in your entry module place the code that expose global variable
Michiel Westerbeek
@happylinks
Dec 19 2015 16:14
Hi guys, I'm trying to fix a jpsm-hot-loader issue I'm having (capaj/systemjs-hot-reloader#31). Summary: I need to reload .jst files but these arent in System._loader.moduleRecords, instead they are in System._loader.modules. I'm having some trouble understanding the difference and how I would be able to System.delete a module in System._loader.modules
The jst templates are already included using the meta configuration.
A
@dizzyone
Dec 19 2015 17:03
@davis, I think for node you should use JSPM and not standalone systemJS, AFAIK systemjs does not recognize native node imports, or atleast it didn't out of the box last time I tried
other than that, you should be able to create universal packages no different from how you would do it with commonjs for browser vs node
Aaron Roberson
@aaronroberson
Dec 19 2015 20:09
Hey group, I'm having issues getting System.js working with Babel (without gulp, webpack, etc.)
If I add the babel browser.js file to maps I get an error saying require is not defined:
map: {
     'babel': 'node_modules/babel-core/lib/api/browser.js'
 }
If I remove the map I get a 404 because babel.js is not in the path of my base root
What file am I supposed to point System.js to for Babel?
Peter Uithoven
@peteruithoven
Dec 19 2015 20:11
@aaronroberson why not try jspm and init in a folder? this automatically sets that up
Aaron Roberson
@aaronroberson
Dec 19 2015 20:12
I've used jspm before and it added a lot of complexity and I spent more time trying to get packages to work with it then it was worth
Peter Uithoven
@peteruithoven
Dec 19 2015 20:13
that's weird, doing it by hand doesn't really seem like a solution?
Aaron Roberson
@aaronroberson
Dec 19 2015 20:13
In fact, I returned to that project a couple months later and had a hell of a time trying to figure out how some packages loaded vs others, and how to shim when needed, etc.
Am I wrong in thinking I can have System.js load my main file and from there I can import whatever I need and not worry about it thereafter?
With Babel transpiling to ES5 at the same time
Peter Uithoven
@peteruithoven
Dec 19 2015 20:15
you would also need to load systemjs and config.js and then you could System.import etc
Aaron Roberson
@aaronroberson
Dec 19 2015 20:15
I'm doing that
<!-- 1. Load libraries -->
    <script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
    <script src="node_modules/systemjs/dist/system.src.js"></script>
    <script src="node_modules/rxjs/bundles/Rx.js"></script>
    <script src="node_modules/angular2/bundles/angular2.dev.js"></script>

    <!-- 2. Configure SystemJS -->
    <script>
      System.config({
          baseURL: '/',
        defaultJSExtensions: true,
        map: {
          'babel': 'node_modules/babel-core/lib/api/browser.js'
        },
        transpiler: 'babel',
        babelOptions: {
          sourceMaps: true,
          presets: ['es2015', 'stage-0', 'stage-1', 'stage-2', 'stage-3'],
          plugins: ['transform-es2015-modules-systemjs']
        }
      });
      System.import('app/boot')
        .then(console.info.bind(console), console.error.bind(console));
    </script>
Maybe it is incompaitble with Babel 6?
Peter Uithoven
@peteruithoven
Dec 19 2015 20:19
I'm not babel expert but maybe you need babel core and that browser.js? JSPM normally installs with babel-core and babel's runtime.
Aaron Roberson
@aaronroberson
Dec 19 2015 20:20
Babel core defaults to node.js and it also uses require
Peter Uithoven
@peteruithoven
Dec 19 2015 20:21
Then I'm afraid I can't help. But I'm very curious what you will do for production, without jspm, gulp, webpack etc.
Aaron Roberson
@aaronroberson
Dec 19 2015 20:27
For production I would bundle. What I'm trying to accomplish is loading the transpiled source files during development
Apart from jspm which was extremely kludgy 6 months ago, everything I'm seeing bundles during development
Peter Uithoven
@peteruithoven
Dec 19 2015 20:31
But, if you're not using jspm (systemjs builder) for bundling you would need to configs?
Aaron Roberson
@aaronroberson
Dec 19 2015 20:38
I'll have to give jspm another look. In 0.17 there were multiple configs as well. One in package.json, one in index.html and if I recall there was one in the dot files (although some of it got generated, it still had to be edited manually and maintained on account of shims, maps and other configuration to try and get various packages to work.
Oh yeah there was system.config.js with the System.config
Then there was package.json with package dependencies, overrides, etc.
And there was the dot file which resembled package.json but was an even bigger kludge. Has all this been udpated since?
Aaron Roberson
@aaronroberson
Dec 19 2015 20:44
I love the idea of jspm but it was the most friction I've ever encountered in stark contrast to the tagline
:(
Peter Uithoven
@peteruithoven
Dec 19 2015 20:55
Well there is no config in the index.html or dotfiles (anymore). package.json still describes all the dependencies (for jspm) and config.js describes the config for systemjs. Personally I think jspm is easier than other solutions out there, less manual work. Modern npm ready packages really just work.
Aaron Roberson
@aaronroberson
Dec 19 2015 21:47
Yeah a lot of the trouble stems from the huge variant in packaging in the wild and that varies even within a single repository.