These are chat archives for systemjs/systemjs

1st
Aug 2015
Hua Do Gia Khanh
@khanhhua
Aug 01 2015 00:44
One quick question: How to choose between Webpack and SystemJS? Any overlap in features?
Micah Zoltu
@MicahZoltu
Aug 01 2015 01:01
@khanhhua If you are using JSPM for your dependency manager, then SystemJS is the obvious choice because of the tight integration between the two.
Also, SystemJS fully supports runtime transpilation, which means you can author ES6 or TypeScript and not have a compile step (just load TypeScript in the browser like it was JavaScript).
Hua Do Gia Khanh
@khanhhua
Aug 01 2015 01:10
@Zoltu Webpack supports loaders, so does SystemJS. Any difference between these loaders?
Micah Zoltu
@MicahZoltu
Aug 01 2015 01:11
I'll be honest, I haven't used webpack before so I am not a great person for depth details on the differences. I have used JSPM and SystemJS quite a bit so I can speak to them if you have questions.
I'm not sure what exactly a "loader" is in webpack terms though.
Hua Do Gia Khanh
@khanhhua
Aug 01 2015 01:13
In Webpack, the syntax for require() is overloaded. For example, require("text!mod.txt"), where text is a loader to load text content
I don't like overloading the standard function require tho
Such would cause vendor lock-in
Anyways, I am looking for solution to build a modular system (all the way from backend to front-end). SystemJS should be one
Webpack is too monolithic, IMHO
Micah Zoltu
@MicahZoltu
Aug 01 2015 01:17
Ah.
In ES6, you can do import 'bootstrap.css!';
Which will use the CSS plugin for loading CSS files.
SystemJS, in my opinion, is good for building and consuming small modules.
Hua Do Gia Khanh
@khanhhua
Aug 01 2015 01:19
My modular, I mean something like a CMS
Micah Zoltu
@MicahZoltu
Aug 01 2015 01:19
Ah.
Hua Do Gia Khanh
@khanhhua
Aug 01 2015 01:19
You would have an editor (which may not be needed all the time)
Micah Zoltu
@MicahZoltu
Aug 01 2015 01:19
Gotcha. SystemJS definitely supports running un-bundled.
Or you can do a partial or multiple bundles.
Hua Do Gia Khanh
@khanhhua
Aug 01 2015 01:20
OR a document management system (where a doc-viewer may not be needed)
Micah Zoltu
@MicahZoltu
Aug 01 2015 01:20
So you could bundle all the pieces of your editor and ship it to the browser as one chunk, but not ship it all the time.
A bundle for editor, a bundle for doc viewer, etc.
Alternatively, if your users are using HTTP/2 browsers and your server can serve HTTP/2 then you are probably better off not bundling at all.
Hua Do Gia Khanh
@khanhhua
Aug 01 2015 01:21
So duplicated bundle content would be unavoidable right?
Micah Zoltu
@MicahZoltu
Aug 01 2015 01:21
Not if you bundle right.
For example, lets say editor and doc-viewer both depend on some library Foo. You have 3 options.
Hua Do Gia Khanh
@khanhhua
Aug 01 2015 01:22
I am not trying to avoid such at all cost... My question is about a best practice in production
Micah Zoltu
@MicahZoltu
Aug 01 2015 01:22
  1. Ship foo by itself, don't bundle it into either editor or doc-viewer. When the editor or doc-viewer are loaded they'll go to the server for foo.
  2. Ship foo with your main bundle. When you load the editor it'll fetch the editor bundle and you'll already have foo from your main bundle.
  3. Bundle foo with both editor and doc-viewer.
HTTP/2 is the best practice long-term.
Hua Do Gia Khanh
@khanhhua
Aug 01 2015 01:23
Yeah, bundling and what not to me are like work-arounds.
Micah Zoltu
@MicahZoltu
Aug 01 2015 01:23
Short term, I think choosing one of the above 3 options that best fits your app is the right answer. The simplest solution is to just bundle everything together in one mega-bundle. If page download times are too high though, you could opt for 2 or 3.
Personally, I would start with unbundled, then evaluate performance and bundle the core pieces into a main-bundle and don't bundle the optional components. Then re-evaluate and repeat, bundling chunks of things as needed.
Hua Do Gia Khanh
@khanhhua
Aug 01 2015 01:24
(y)
Micah Zoltu
@MicahZoltu
Aug 01 2015 01:24
Bundling is pretty easy, so the iteration time on this process is pretty quick.
Hua Do Gia Khanh
@khanhhua
Aug 01 2015 01:25
Thanks for sharing @Zoltu . Gotta work now.
Micah Zoltu
@MicahZoltu
Aug 01 2015 01:28
No problem.