These are chat archives for assetgraph/assetgraph

6th
Sep 2016
Andreas Lind
@papandreou
Sep 06 2016 20:49
Finally landed the system.js conditions work that Guy and I have been working on. Released in assetgraph 3.0.0-9 and assetgraph-builder 5.0.0-10. I should write some docs about it -- currently working on some plugins to support internal projects, might be good enough to serve as examples. We'll see.
Peter Müller
@Munter
Sep 06 2016 21:09
What is that about?
Andreas Lind
@papandreou
Sep 06 2016 21:10
The feature itself or the plugins?
Peter Müller
@Munter
Sep 06 2016 21:10
The feature
Andreas Lind
@papandreou
Sep 06 2016 21:12
Basically it is for bundleSystemJs to do something sensible when it encounters interpolation in a require/import/whatever, like require('inter.#{locale}.js');.
Or import 'styles-#{desktopOrTouch}.less';
For one thing, you can now specify the condition values you know via buildProduction --condition foo=bar -- that makes it do a build where #{foo} is simply replaced by bar in those conditions.
But the most interesting thing is the handling of conditions that you don't specify up front. Those are now traced individually by bundleSystemJs, which outputs separate bundles for all the possible combinations of condition values.
I've special cased a condition named locale or locale.js to play along with cloneForEachLocale so it will DTRT with the scripts and stylesheets that are only supposed to exist in a given locale, such as if require('inter.#{locale}.js'); is used.
Peter Müller
@Munter
Sep 06 2016 21:19
Awesome
Andreas Lind
@papandreou
Sep 06 2016 21:19
We can support fanning out and creating separate .html files based on other conditions as well (not implemented yet, but could be used to eg. create a desktop and a touch version of an app from the same source files). But just leaving the bundles with the different combinations in the build is also a very powerful feature, especially when not a lot of data is being pulled in.
Right now we make 4 different builds of eg. the One.com webmail to specialize it for 4 different environments. They're done in parallel, but still, it takes a long time. Since the byte size of each configuration is small, I plan on turning it into one build using a plugin and a #{environment} conditional. As long as I can create an environment.js that detects where the app is running, eg. based on the host name, it will be possible to get the config using something like require('#{environment}!configLoader');, which will just include all 4 variants in the build 8-)