Fork me on GitHub
#clojurescript
<
2020-03-11
>
andrea.crotti11:03:26

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

andrea.crotti11:03:22

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)

p-himik11:03:35

What do you use to build and reload CLJS?

p-himik11:03:32

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

andrea.crotti11:03:05

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

andrea.crotti11:03:30

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

p-himik11:03:40

What's "non-basic compilation"?

p-himik11:03:36

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

andrea.crotti11:03:40

the :none, so the default

andrea.crotti11:03:20

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.

andrea.crotti11:03:30

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

p-himik11:03:22

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.

andrea.crotti11:03:08

uhm it didn't actually work anyway

andrea.crotti11:03:17

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

andrea.crotti11:03:29

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

andrea.crotti11:03:41

which would make it just disk reads

juri15:03:49

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>

thheller15:03:02

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

juri15:03:32

It worked, thanks! 🙂

souenzzo15:03:18

@juri yeah, take a look at https://shadow-cljs.github.io/docs/UsersGuide.html#js-deps (vanilla cljs also support it, by other methods)

juri15:03:44

Ok thanks @souenzzo, will take a look!

rgm17:03:42

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?

kszabo17:03:11

the latter

rgm18:03:28

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 https://clojurescript.org/news/2017-07-10-code-splitting#_cross_module_code_motion

lilactown18:03:04

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
lilactown18:03:58

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

rgm18:03:06

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

rgm18:03:28

(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

dominicm21:03:59

I think GCC is best in class here

thheller21:03:22

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

kaosko22:03:15

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