Fork me on GitHub
#clojurescript
<
2017-09-04
>
vinai09:09:28

Has someone successfully set up a binaryage/devtools component so it get's started with the system, but only as part of the dev build?

vinai09:09:43

How did you do that @darwin? I'm running into the problem that the system map for the reloaded.nrepl methods is build on the Clojure side, even the figwheel-sidecar components. Since binaryage/devtools is cljs only, how can I add it as a component to the system map?

darwin09:09:55

I’m sorry, I don’t know what is the “system map”

vinai09:09:40

The map returned by com.stuartsierra.component/system-map

vinai09:09:19

Thanks for the pointer, I'll try to get the preloads working!

darwin09:09:14

under normal circumstances cljs has nothing to do with your server-side clojure stuff

darwin09:09:33

imagine your clojure backend to be written in another language, you can still use cljs on client-side

darwin09:09:42

component is out of the game completely

vinai10:09:18

Thanks, :preloads are working. The chestnut template uses component to initialize the view rendering, and figwheel-sidecar is a component, so it seems to be a popular thing on the browser side, too. But anyway, I'm happy to have the formatters working!

darwin10:09:04

AFAIK figwheel-sidecar is backend stuff so it makes sense to integrate it with backend code, cljs-devtools does not have anything to do with your backend

darwin10:09:40

You should not confuse “figwheel” as whole, “figwheel support” (client-side) and “figwheel sidecar” (server-side), btw. I wrote this a while ago: https://github.com/binaryage/dirac/blob/master/docs/about-repls.md#figwheel

vinai10:09:01

@darwin That is a very nice writeup! I can't claim I understand the complex relations in the bottom diagram though. Btw, unfortunately the :preloads compiler option only works on the first reload. Once reloaded.repl/reset (e.g. after the first figwheel reload) is called it's unloaded.

vinai11:09:06

Seems like the concept behind devtools is incompatible with the reloaded.nrepl idea of refreshing all namespaces that contain changes.

vinai11:09:17

I think I might just remove com.stuartsierra.component et all from the cljs side.

vinai11:09:29

Pitty though, chestnut had it set up nicely.

darwin11:09:36

no idea, I’m not familiar with reloaded.repl, I always thought it is again just server-side thing, so that your REPL reflects changes in your backend code

vinai11:09:11

The same is set up by default by the chestnut lein template for the frontend code, too.

darwin11:09:40

I don’t understand how it works with client-side and what “reset” means for cljs on client

vinai11:09:40

I'm still very much a beginner trying to follow what's currently accepted good practice.

vinai11:09:59

I wish @plexus where here, he wrote chestnut and could probably explain a lot better then me. I'm just beginning to grasp the wiring.

vinai11:09:13

I must admint that using com.stuartsierra.component doesn't seem to give a lot of benefit. But that might be my limited exposure talking.

darwin11:09:09

@vinai I was curious and tested chesnut-generated leiningen-based app with added devtools and it works just fine

darwin11:09:32

even when figwheel hot-reloads cljs code after changes

darwin11:09:51

how did you print that identity function?

darwin11:09:05

didn’t you stringify it first via cljs printing machinery?

vinai11:09:20

Once with prn and once with println

darwin11:09:30

that’s the problem

darwin11:09:45

you ask cljs to print it into string and then print the string via devtools

darwin11:09:21

for cljs-devtools to do the expandable visualization of data you have to pass cljs values into console.log

darwin11:09:25

not strings

vinai11:09:42

So... with pn or how?

darwin11:09:58

js/console.log

vinai11:09:08

Oh jezz, you are right!

vinai11:09:15

(facepalm me)

vinai11:09:31

Sorry for wasting your time.

darwin11:09:36

if you look at how prn and println and similar are implemented in cljs.core you would see that cljs code asks passed values to print into strings, for example via IPrintWithWriter protocol or via javascript, this way cljs-devtools gets strings on input and cannot do anything smart with it, it simply prints them as strings

vinai11:09:05

Looking at it right now

darwin11:09:21

typically I tend to write some macros to wrap console.log and friends, here you can see it with some fancy styling: https://github.com/binaryage/dirac/blob/master/src/background/dirac/background/logging.clj

vinai11:09:49

very nice, thank you

thheller13:09:52

@stvnmllr2 most likely missing :externs, you can try with the compiler option :pseudo-names true to confirm which name is missing from the externs

stvnmllr213:09:17

Thanks @thheller will try that.

stvnmllr213:09:58

var $contentWindow$jscomp$1$$ = $JSCompiler_StaticMethods_getIframeToken_$self_doc$jscomp$31$$.$iframe_$.contentWindow; Is that something that makes sense to anyone?

thheller13:09:52

@stvnmllr2 its a bit garbled but what pseudo-names does is basically wrap the original names it doesn know into $

thheller13:09:35

what was the error you got? it probably doesn’t know .$iframe_$.contentWindow which would be .iframe_.contentWindow in code

flyboarder22:09:51

@ericnormand thanks, so if I want localized state for the object I need to use reify and contain it within a function?

stvnmllr223:09:30

@thheller It looks like it's popper.js. Didn't realize I actually used it, but I guess bootstrap was trying to use it. Still trying to get it working since I couldn't figure out the webjars path to the file. I'll get it eventually.