Fork me on GitHub

If I am embedding a cljs repl in my application, and I already have something like reagent compiled into js as part of my app, should I be able to require reagent from my repl without having to do some kind of recompilation?


I'm struggling a bit with replumb because it is reloading and recompiling everything from files, although this could certainly be due to misconfiguration on my part.


@pmooser If you take the compiler analysis information associated with Reagent, and arrange to have it loaded into your compiler state at app launch time, then that will solve a big part of it. (In other words, the compiled JavaScript is insufficient because the self-hosted compiler will need to know information about the vars in the Reagent namespaces).


@mfikes Thank you! I'm trying to figure out if there's an easy way to do that with replumb. There are definitely hooks here if I provide a load-fn. I'm hoping I can just provide the base path of the compiler output, but I'm not quite there yet.


@pmooser It sounds like you want to bundle “precompiled” Reagent with your self-hosted app. One place for inspiration on how to do something like that might be how Klangmeister uses macros to bundle sources.


@mfikes Thanks for the link - I'll give it a look.


(You want to go a little farther and bundle compiler analysis information. This is in the *.edn or .cache.json files that the compiler emits.)


You could also look at the way Lumo and Planck work—they bundle AOT compiled namespaces for use with the self-hosted compiler.)


Yeah, those .cache.json files are all available, I just have to figure out how to make replumb look at it. And yeah, I need to take a look at planck or lumo and see what they do.


Yeah, I suspect you will end up doing something that Replumb doesn’t currently support. (I’m speculating.)


But, be assured that it is possible 🙂


Ok thanks. I have honestly been uncertain if I'm doing the right thing by using replumb (which was great for my initial integration), or if it would end up being easier just directly using cljs.js or whatever.


Self-hosted ClojureScript allows, as part of *load-fn* for you to return analysis cache, and compiled JS. So you have the hooks.


Oh, if you are just doing self-hosted code, like Klangmeister, cljs.js is fine. But if you are writing a self-hosted REPL it makes complete sense to look at or use Replumb.


Ok great, that is very encouraging.


Thanks for your help @mfikes!


No problem. Ping me if you get stuck on some aspect.


in this article: I’m having trouble understanding this line: <? is just a touch of macro sugar that expands into something like (throw-err (<! [expr])) I can’t find any information on the function throw-err. Does anyone know where this comes from?


@lee.justin.m throw-err would be something like:


@colindresj thanks. okay i get it now. this idea should have more mindshare.


I think there are a few different ideas around handling exceptions that end up on channels (I recall reading an article about using a transducer)


I find is a good set of useful functions when doing core async stuff


Includes a <? macro


The source is very readable too


I’m trying to figure out when you would not want to use go-try + <?. If you screw up and throw an uncaught exception with normal go block, the result is really hard to deal with, and the caller can’t clean up after you because exceptions obviously can’t cross go boundaries.


Sorry, forgot to hit enter @lee.justin.m


It’ll explain why in go dealing with excpetions is tricky


go-try aims to make it not


Has something changed in 1.10.145 that I’d suddenly get “goog.require could not found: cljsjs.react” after an optimized build?


Yep. Something has definitely changed between 1.10.126 and 1.10.145.


For 1.10.145 if I set :aot-cache false for the optimized build, it works.


@zentrope If you have a minimal repro, please file a JIRA


@zentrope also note if this is only with :parallel-build we have a report for that already


Not a parallel build, unless it defaults to one. I set aot-cache to false because I saw it removed in the latest commit.