Fork me on GitHub
#clojurescript
<
2018-03-09
>
pmooser17:03:27

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?

pmooser17:03:07

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.

mfikes18:03:14

@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).

pmooser18:03:22

@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.

mfikes18:03:17

@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. https://github.com/ctford/klangmeister

pmooser18:03:05

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

mfikes18:03:24

(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.)

mfikes18:03:53

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

pmooser18:03:21

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.

mfikes18:03:57

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

mfikes18:03:21

But, be assured that it is possible 🙂

pmooser18:03:11

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.

mfikes18:03:23

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

mfikes18:03:16

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.

pmooser18:03:36

Ok great, that is very encouraging.

pmooser18:03:45

Thanks for your help @mfikes!

mfikes18:03:00

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

justinlee18:03:06

in this article: http://swannodette.github.io/2013/08/31/asynchronous-error-handling 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?

colindresj19:03:00

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

justinlee19:03:59

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

colindresj19:03:01

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)

colindresj19:03:33

I find https://github.com/fullcontact/full.async is a good set of useful functions when doing core async stuff

colindresj19:03:38

Includes a <? macro

colindresj19:03:58

The source is very readable too

justinlee19:03:25

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.

colindresj19:03:06

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

colindresj19:03:25

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

colindresj19:03:32

go-try aims to make it not

zentrope19:03:06

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

zentrope19:03:48

Yep. Something has definitely changed between 1.10.126 and 1.10.145.

zentrope19:03:11

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

mfikes20:03:08

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

dnolen21:03:17

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

zentrope22:03:49

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