These are chat archives for systemjs/systemjs

20th
Jul 2015
Owain Cleaver
@lor3
Jul 20 2015 10:38
Hello
Nikita
@Metallium
Jul 20 2015 14:35
This message was deleted
Charles Patton Jr
@buddyp450
Jul 20 2015 14:47
My es6-module-loader is making server requests for things like /jspm_modules/someModule@vX.X.X/something.js for every module that I use... am I mistaken or shouldn't these dependencies be bundled in after running bundling for self-execution? Ideally I want to serve everything from a single build.js file. Apologies for the noobness, I'm not sure whether or not it's good practice to be serving jspm_modules from my own server like that.
Guy Bedford
@guybedford
Jul 20 2015 15:21
@buddyp450 yes if the bundle contains those modules, you shouldn't be seeing the requests. Perhaps inspect the bundle file and ensure you can see a System.register or System.registerDynamic statement for npm:someModule@x.y.z or whatever. Then you can also ensure it is set in the list Object.keys(System.defined)
Bret Little
@blittle
Jul 20 2015 15:23
@guybedford are absolute paths still in a future release?
or are they currently supported at all?
Guy Bedford
@guybedford
Jul 20 2015 15:24
@blittle yes they are fully supported in SystemJS 0.18
Nikita
@Metallium
Jul 20 2015 15:41
can I somehow force System.import not to parse internal dependencies
(it parses and extracts paths from commented out require expressions) in cjs file?
Guy Bedford
@guybedford
Jul 20 2015 15:44
@Metallium it would be interesting to see the commented out requires being parsed - we do remove comments via a regular expression, although there are a few edge cases this breaks down.
It's not possible to remove dependencies, but it is possible to map dependencies to @empty.
Peter Müller
@Munter
Jul 20 2015 15:50
@guybedford I've been skimming the whole systemjs source code yesterday. First of all, it's really high quality imo, so kudos. I'm playing with the idea of having the ability to instruct systemjs that all translation should happen on the server. My idea is to basically disable all translate hooks in all plugins and assume the server did it already. The server would then run an instance of systemjs and run the translate hooks on that end before sending the reponse back. Does that makes sense in any way, and what are the obvious problem I'll run into?
Charles Patton Jr
@buddyp450
Jul 20 2015 15:50
@guybedford thanks for confirming
Guy Bedford
@guybedford
Jul 20 2015 15:52
@Munter thanks. Yes exactly that is the solution I think would be best as well.
It would have to run the translate hooks, followed by the module format conversion
including the module format detection etc, everything identically to SystemJS in the browser
I've been meaning to open up this API for a single file build in SystemJS builder, which is currently tracking at systemjs/builder#226
Peter Müller
@Munter
Jul 20 2015 15:53
I want this server or middleware to just figure everything out by itself. from package.json to config.js to possibly even amending system.js when it goes over the wire. It should be 100% seamless and work without the server so it just becomes a plug an play thing that instantly makes things faster because of better caching
Guy Bedford
@guybedford
Jul 20 2015 15:54
definitely
Peter Müller
@Munter
Jul 20 2015 15:54
I don't think the builder is even needed. The server could run an instance of systemjs
Guy Bedford
@guybedford
Jul 20 2015 15:54
the builder is needed as it can do the conversion of CommonJS into System.register
that is exactly what the builder does
which makes the entire app CSP-compatible
which is important
Peter Müller
@Munter
Jul 20 2015 15:55
Ah. I need to look at more of the ecosystem
Guy Bedford
@guybedford
Jul 20 2015 15:55
it is possible via the private APIs currently
  var Builder;
  try {
    Builder = require('jspm').Builder;
    Builder = require('systemjs-builder');
  } catch(e) { throw 'No builder found'; }
  var builder = new Builder();
  bulider.build('[moduleName]').then(function(output) {
    // output.source, output.sourceMap
  });
that may well do it I think
in addition there is a build cache as well
Peter Müller
@Munter
Jul 20 2015 15:58
If it's that easy... :)
How can I unhook the runtime translation on the browser end?
Guy Bedford
@guybedford
Jul 20 2015 15:59
it will automatically unhook if the modules are System.register
the plugin and module format config would need to be parsed out of the configuration file though
  System.config({ meta: '/*': { format: 'register' } });
@Munter the alternative would be to use the CSP build of SystemJS which doesn't support plugins anyway
Peter Müller
@Munter
Jul 20 2015 16:02
Doable. It sounds like I have enough information to start some experiments with an express middleware
Guy Bedford
@guybedford
Jul 20 2015 16:02
there are some bugs in that build currently though
Peter Müller
@Munter
Jul 20 2015 16:02
I still need plugins to possibly run the locate hook, right?
Guy Bedford
@guybedford
Jul 20 2015 16:03
there are two classes of plugins - plugins which build themselves out and plugins which are always required
plugins that are always necessary in production are indicated via export var build = false
it probably should be documented somewhere
I don't think anyone except the official plugins do that
but that is the principle
Bret Little
@blittle
Jul 20 2015 16:04
Thx @guybedford turns out I was running an older version of systemjs
Guy Bedford
@guybedford
Jul 20 2015 16:04
build = false plugins turn up in the trace tree, while normally plugins don't for example
such plugins are entirely ignored from a build perspective
@Munter see https://github.com/systemjs/builder/blob/master/lib/builder.js#L219 for builder caching between Builder instances (a new instance is required on a code change, but invalidations are handled automatically). Not an official API yet, wondering if something more stateful would be better (System.setCache(cacheObj)).
Peter Müller
@Munter
Jul 20 2015 16:15
@guybedford I was thinking of just hooking into the lower levels of http server caching. I've done something like this before in https://github.com/Munter/express-compile-sass/blob/master/lib/index.js#L142-L152
But if the builder gives me a leg up there so I could just ignore caching myself, that would be wonderful :)
Charles Patton Jr
@buddyp450
Jul 20 2015 18:27
@guybedford the problem module from earlier was the plugin-jsx from floatdrop, it doesn't get bundled in
Charles Patton Jr
@buddyp450
Jul 20 2015 20:35
I think I found my mistake, I was trying to bundle my SystemJS project using JSPM instead of the SystemJS builder..
Davis Kim
@davis
Jul 20 2015 21:29
jspm uses the systemjs builder
Charles Patton Jr
@buddyp450
Jul 20 2015 21:30
:o
good to know, lol
Davis Kim
@davis
Jul 20 2015 21:30
just make sure your versions match up if you've installed jspm globally
Charles Patton Jr
@buddyp450
Jul 20 2015 21:33
do they need to match 1:1? my version of jspm is 0.15.7 and systemjs is 0.18.4.
or can systemjs just be > jspm or vice versa?
Sorry, you must mean systemjs inside the jspm module... that's actually 0.16.11.
Guy Bedford
@guybedford
Jul 20 2015 22:00
@buddyp450 jspm 0.15 goes with SystemJS 0.16 and SystemJS builder 0.11
jspm 0.16 goes with SystemJS 0.18 and SystemJS builder 0.12