These are chat archives for assetgraph/assetgraph

10th
Aug 2016
Munawwar
@Munawwar
Aug 10 2016 20:12
Hey, I've got this crazy idea of injecting all dependencies of an app as inline script tags during dev/build on reading an html file (using fuse). Tell me if I've been drinking too much coffee.
Munawwar
@Munawwar
Aug 10 2016 20:17
Long ago (like 3-4 years ago) I had the same idea but writing such a thing as apache/ngnix module with lua. However the effort require would've been tremendous. But now there's fuse. Also it predates module systems..so in some ways it was easier on the requirements side. However I think even with all the new requirements it is theoretically possible to write such a tool. Advantage is that it would throw complexity of ordered fetching and in-browser transpiling etc.
And with skrin, the tool would be fast as well.
Peter Müller
@Munter
Aug 10 2016 20:26
Will source maps work for inline scripts?
Munawwar
@Munawwar
Aug 10 2016 20:29
That would be up to the transpiler.
When I say inline script tag i.e. -> <script src="typescript-file.js"></script>. And the file would have a sourceMapURL or whatever. Same as fusile in that regard.
btw, the tool would need to detect System.import()s, require()s and define()s.
Peter Müller
@Munter
Aug 10 2016 20:33
Assetgraph can do that. I even think there is already a transform to flatten out dependencies as HTML script tags.
But I'm not sure what the value would be compared to normal module loading
Munawwar
@Munawwar
Aug 10 2016 20:36
Can think of at least two - 1. It throws out the additional complexity of managing order of JS execution. Things are much easier on node.js. Just look at my systemjs-emulator...it's hardly 200 lines (without the plugin API though). Browsers have so many quirks I guess. and 2. avoids any in-browser transpiling.
^ It is still a guess though (I think it will reduce code complexity and manageability). Not worth working on the tool if that turns out to be false.
Munawwar
@Munawwar
Aug 10 2016 20:42
(btw the systemjs-emulator thing supports requirejs-ish plugins. So my guess may not be too far)
Also 3. It simplifies running the loader on node for purpose of tests. I think this one is a greater motivation. I really couldn't get systemjs to work on node.
Peter Müller
@Munter
Aug 10 2016 20:49
If you don't care about runtime loading, why not just go down the browserify route. Simple require statements, flattened in a bundle with fast incremental rebuilds
Munawwar
@Munawwar
Aug 10 2016 20:54
How would that work with ag-b?
i.e. can I configure ag-b to internally use browserify?
Peter Müller
@Munter
Aug 10 2016 20:55
no
just use browserify directly. You get one js bundle
I think it also knows about other asset types these days
Munawwar
@Munawwar
Aug 10 2016 20:59
hmm...seems like that would work. Although I'll lose ag-b image processing and i18n stuff.
Peter Müller
@Munter
Aug 10 2016 20:59
Or if you are ok with needing a tool for things to run, hook into the original legacy of assetgraph. INCLUDE('foo.js')
Munawwar
@Munawwar
Aug 10 2016 21:00
for html, I'll require() it as raw text.
Peter Müller
@Munter
Aug 10 2016 21:00
Those are the things we are removing now though
Munawwar
@Munawwar
Aug 10 2016 21:08
Or rather I'll wait for ag-b's webpack integration.
Andreas Lind
@papandreou
Aug 10 2016 21:17
@Munawwar It's available on master. Very curious to hear any feedback :)