Fork me on GitHub

uhm on a relatively single SPA for a personal project it's doing 2148 http requets, to get the gazillion small JS files it needs


I wonder if: • I should try to reduce that massive number (a problem in local dev not prod of course) • how do I let it cache everything except the files that are actually under my control? (I guess if I update a dependency for example I would have to break the cache myself maybe)


What do you use to build and reload CLJS?


Ah, no idea then, sorry. Shadow-cljs solves this problem by loading it all as a single file.


I use shadow for a few other projects, and well if I do the non basic compilation I probably get the same with figwheel-main


or maybe I should use figwheel-main ring server instead of my own


What's "non-basic compilation"?


FWIW, with shadow-cljs it works with any server, not just the built-in one.


the :none, so the default


As we noted before the :none level does not produce a single self-contained compiled artifact, but rather creates an artifact that loads all of the separately compiled namespaces.

All the other levels (:whitespace, :simple, and :advanced) produce a single compiled artifact to the :output-to file. These are often used for producing your final deployable asset when you use these optimizations settings.


from that page, so yeah maybe I can just try with that


I'm not sure that the :optimizations option by itself has anything to do with the way the code is loaded. At least, nothing is stated about that at the CLJS compiler options page or at the GCC optimizations page. And yet, shadow-cljs creates a single file with :none optimizations as well, so it works just fine for development.


uhm it didn't actually work anyway


well I'll switch to shadow this project as well at some point


but would be nice to at least just make sure they are all cached


which would make it just disk reads


I want to use SignalR with a clojurescript app. And I have gotten it to work like this: 1. npm install @microsoft/signalr 2. Copy signalr.js from node_modules/@microsoft/signalr/dist/browser to resources/public/js/lib/signalr 3. In index.html: <script src="js/lib/signalr/signalr.js"></script> 4. In cljs file: (new js/signalR.HubConnectionBuilder) etc. Is there a better way to access signalR, preferably using :require ? And preferrably without copying from node_modules. I'm using the default project created by lein new re-frame <name>


not sure if that template uses shadow-cljs by default? you can just (:require ["@microsoft/signalr" :as signalr]) if you use shadow-cljs


It worked, thanks! 🙂


@juri yeah, take a look at (vanilla cljs also support it, by other methods)


Ok thanks @souenzzo, will take a look!


I have a code splitting question re: dead-code elimination. If I split into module A and module B, I'll end up with a cljs_base.js , plus an A.js and a B.js . Does the cljs_base.js have all of Clojurescript, or would an advanced compile trim it down to only the parts called by module A and module B?


the latter


further I think I'm understanding this to mean if only module A uses eg. cljs.core/map then map ends up in module A, not cljs_base.js O_o


technically correct, but that also means that module B doesn’t use anything in cljs.core that calls map , which isn’t usually the case

👍 4

IME the majority of cljs.core gets included and shared between modules, since so much code relies on code in cljs.core, and it’s pretty self referential


sure, maybe cljs.core/promise is a better example.


(or maybe not ... I'm just fascinated by the potential).

Jamie Rumbelow21:03:17

Has anybody tried to get ClojureScript compiling down to non-GCC JS? Discussions above re code splitting, tree shaking etc makes me suspect we might benefit from being able to use Webpack


I think GCC is best in class here


we have plenty of code splitting with the closure compiler, we'd only lose in that area as webpack is much less "advanced" in that area


is there a way to provide an alias or something similar for npm module in leiningen :npm-deps? The reason I'm asking is that there's a another version of a library available with different name but other third party code refers to the library with the the older name