Would this help with AngularJS modules, as described here: https://groups.google.com/forum/#!topic/clojurescript/i_4ssofJdIo
? Am Donnerstag, 13. Juni 2013 21:25:45 UTC+2 schrieb Thomas Heller: > Hey, > > this started out as me looking for an optimization (see > https://groups.google.com/forum/?fromgroups=#!topic/clojurescript/BjQ2BfB-9Vc > ) but Herwig pointed me towards a feature of the Closure Compiler which > basically splits the output into multiple files. Thus still allowing Advanced > Compilation but enabling on-demand loading of source that isn't frequently > used. > > It turns out that this solves about every issue I have had so far and also > eliminates all the nasty tricks I currently have to do to achieve multiple > builds. > > So I sketched out an idea which ended up like this: > > Usual Compiler Options gain a :modules vector > > {:optimizations :advanced > :output-dir "target/cljs" > :modules [{:id :sub1 :include ["myapp.sub1"]} > {:id :admin :include ["myapp.admin" > "goog.something-exotic"] > :depends-on #{:sub1}} > {:id :sub2 :include ["myapp.sub2"]} > {:id :sub3 :include ["myapp.sub3"] :depends-on #{:sub1 > :sub2}} > ]} > > Now the compiler matches each "goog.provide" found in the sources to one > module by doing a prefix-match on the includes (eg. myapp.admin.some.other-ns > goes into :admin). If no module is chosen it is moved into the default module > (where cljs.core and most of the goog.* stuff will end up in unless you > specify it previously). If the :modules vector is empty or not present, we > end up with one file like we currently do. > > So in my example I end up with > > target/cljs/default.js > target/cljs/sub1.js > target/cljs/admin.js > target/cljs/sub2.js > target/cljs/sub3.js > > Every page includes <script src="cljs/default.js"> and the rest when needed > since not all pages always require every bit of javascript. In my real app I > end up with a nice 1.2mb default.js, and 3 smaller files at 478kb, 389kb and > 221kb (all with :optimization :whitespace, :advanced cuts that down a lot). > > This is a massive improvement for me, not only does it simplify my code > directory structure (no more multiple source paths) but also allows me to > serve more targeted code depending on where the user is. All in all it almost > halves the initial JS download, which alone is worth it. > > Anyways, I'm probably not making any sense here. I implemented it but since > the cljs compiler currently is geared toward compiling ONE file only, I > probably broke a bunch of stuff (most notably source maps). > > https://github.com/thheller/clojurescript/commit/ac764ec98b1e90af3667047cef8ca292e2a9eb58 > > My project compiles fine and if I can figure out how the source-map stuff > works I can probably cleanup the changes and submit a proper Patch/Issue. > > Just wanted to know if there is any interest in this at all or if I'm alone > here. > > Hope someone understood this :P > > Cheers, > /thomas -- Note that posts from new members are moderated - please be patient with your first post. --- You received this message because you are subscribed to the Google Groups "ClojureScript" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/clojurescript.
