Fork me on GitHub

Is there a recommended way to get started with a good cljs stack?

Piotr Roterski09:04:00

I’m in similar situation as you, coming from js spa world. My personal bet is on fulcro ( It’s a fullstack framework that js have been missing since meteor.js but without its compromises and locking you to mongodb. Fulcro solves all the mess with state-management/data normalisation that redux/graphql try to deal with but without much of its boilerplate complexity because it’s fullstack in clojure. I’m only starting with it so I don’t know how it works in practice and you could probably hack something similar using reframe, but fulcro seems more like a battery-included complete solution.


I recommend taking a look at which is nothing more that a collection of libraries commonly used in clj(s) world. otherwise, why not just taking a look at reagent and their template?

👍 4

Otherwise, since you have experience with redux, take a look at re-frame 😄


Interesting thanks for the suggestions!


Use shadow-cljs as your build tool to get many batteries included too.


Or getting started with cljs maybe


My familiarity level is about as follows: - familiar with FP concepts - a few years javascript / SPA experience using hacked together FP (i.e redux like stuff and various stream libs) - few years JVM experience, mainly Java and Kotlin - done some very basic Clojure Koans and such


I’ve watched a figwheel demo and it looks very convincing, and vdom diffing + persistent immutable datastructures seems very solid for SPAs

Frank Henard19:04:26

You will have to get to know the different build tools and make a decision there. Leiningen is good, and works with figwheel. That's what I use. There's also something called shadow-cljs which seems to be getting some attention lately

Frank Henard19:04:00

I'm somewhat of a beginner in CLJS myself, though I'm probably intermediate at Clojure

Frank Henard19:04:54

the CLJS quickstart linked above, I believe, is the most barebones. The goal with that is to help you understand what's really going on without the getting overwhelmed with the build tool

Frank Henard19:04:25

Unfortunately, it probably seems like there's too many tools options at the moment. Clojure(script)'s standard tooling has changed recently, so the surrounding community tooling is also changing

Frank Henard19:04:58

I just noticed the previous thread. Sorry about that


Thanks for the replies!


Mornin'! Anyone know which bindings I might be able to set to tell CLJS which file and line offset the code should be evaluated at? So that (def... meta data is set accordingly. There's things like *file* in Clojure but I wasn't sure if CLJS had an equivalent.


Clojure lets me do some fun things ( but I won't have access to eval in ClojureScript, so it needs to be configured in the current eval environment. Maybe that's impossible, even if I can only set the path to the current file is better than nothing 😄


I have a feeling cljs.analyzer/*cljs-file* might be the only hook open to me but I'm not sure.


The piggieback source might be useful


@U38J3881W do you eval a string or a clojure form?


This is a string being sent through a prepl, but we can think of it as any normal REPL eval.


So imagine trying to set the current file in a REPL eval, that's kinda the context I'm working with.


so this isn't self-hosted?


which exact API do you use then?


It's regular old REPL ClojureScript.


no such thing 🙂 there are many different impls




Ah, yes, in my current context it would be the node repl, sorry.


I think the best I will get is binding the current file path.


so you do not control the other end of the prepl? you just assume its a CLJS prepl?


Yup! Hence the lack of self hosting etc. I'm looking for a pretty generic binding which may not exist.


well it is determined at read time


so if you control the reader you can do pretty much anything


Oh interesting.


take a look at that fn impl. SourceLoggingPushbackReader. contructor accepts a line and column arg


although not exposed by default you do "cheat" and override it after construction 😛


or just construct manually


but this assumes you control the reader


the reader will attach the proper metadata to the read CLJS forms and that is that the analyzer/compiler uses


Haha, okay, interesting. I'm already using LineNumberingPushbackReader for the Clojure approach. My constraint is that I don't control the prepl / server side so it might not be possible but I'll have a play.


And the file / line changes potentially on each eval.


Since I'm sending forms from my editor.


yeah the default REPL impls have no way to control that


sad trombone


you could just go with the metadata route though. it might work


instead of sending "(def x ...)" over the wire you send "^{:line 123 :column 456} (def x ...)"


I'm not sure if that will work for CLJS though


Yeah, did consider that sort of thing but would like to avoid it if I can. A binding or something would be ideal, if I can't do it I can't do it. Not a massive deal. I'm trying to touch the contents of the eval and the remote end as little as possible to ensure compatibility with all envs and future setups.


Besides, it'll probably be mainly compiled by figwheel / shadow-cljs anyway, it's Clojure where I needed the line/file data really.


Is there any 2d drawing library that works nicely with reagent? I tried using quill, but I cannot get it to draw anything. Any ideas?

Eric Ervin19:04:31

there is a #quil channel if you ever need it


very cool! Thanks @U08E8UGF7


But will p5.js also work with reagent?


it seems to work with react


so I don’t see a point why not


thanks. sounds very difficult to implement. a lot of js wrappers needed 😞


I would try anyway, I usually found out I need way less wrappers if I do it myself in cljs 🙂


especially if you are already using shadow-cljs


I am really bad with js interop.


I was hoping to find something that works more out of the box.


And reagent would lend itself perfectly to this because of the state management and perhaps a few "normal html" components to add some controls.


Has anyone had luck getting Handsontable to work with advanced compilation via externs? It's on CLJSJS, but the version there is very old.


What does the error message Can't take value of a macro cljs.core/or mean?

Jimmy Miller18:04:16

or is a macro. It expands into other code. So if you try to do something like this:

(reduce or [false false false true])
You will get that error. This code is trying to treat or as a function, but it isn't. You can fix this by wrapping it in a function.
(reduce (fn [x y] (or x y)) [false false false true])


you're trying to pass it as a value


(partial or ...) or something like that


Sometimes Figwheel can accidentally trigger it too


was the patch ever applied?


Patch is merged but not released


May be available in the 2.0.1 snapshots


I’m seeing it in figwheel so that’s probably the case. The warning is coming from the line (if (or disabled? all-invoiced?) ...) where disabled? and all-invoiced? are booleans, I would think that would be OK.


are you on cljs 1.10.520?


try the 443 439 i think? it should go away. and if so its figwheel's fault


This worked, thank you


CLJS (`1.10.439`) should shim process.env.NODE_ENV, right? I'm setting :closure-defines {process.env/NODE_ENV "development"} and I see "process.env\/NODE_ENV":"development" in CLOSURE_UNCOMPILED_DEFINES in my generated output. Alas, I'm still seeing React throw up process is not defined when it checks for process.env.NODE_ENV. What am I missing?


You might need to pass in the munged name as a string, instead of the CLJS name.


Hi, I was hoping someone could help me with using react-dropzone from cljs. My (hyper-simple) code is here: - I'm using shadow-cljs, and the error I'm getting is

Uncaught TypeError: Cannot convert a Symbol value to a string
    at Array.join (<anonymous>)
    at Function.cljs$core$IFn$_invoke$arity$1 (cljs.core.js:10144)
    at Object.cljs$core$pr_writer_impl [as pr_writer_impl] (cljs.core.js:33441)
    at cljs$core$pr_writer (cljs.core.js:33472)
    at cljs.core.js:33992
    at Object.cljs$core$pr_sequential_writer [as pr_sequential_writer] (cljs.core.js:33163)
    at Object.cljs$core$print_prefix_map [as print_prefix_map] (cljs.core.js:33981)
    at cljs$core$print_map (cljs.core.js:34002)
    at Object.cljs$core$pr_writer_impl [as pr_writer_impl] (cljs.core.js:33371)
    at cljs$core$pr_writer (cljs.core.js:33472)


is that a common error? google doesn't seem to know much about it, unless my google fu is just broken


in the str function in core.cljs, x appears to be a Symbol(react.forward_ref)


Symbol has no toString method, you cannot print it


would that imply the bug is in the react-dropzone lib then?


sorry, this is kinda down further in the weeds than i'm used to


Would anyone know how to deal with a

Java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter
clojure.lang.Compiler$CompilerException: java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter, compiling:(org/httpkit/server.clj:1:1)
error? I'm working on the modern-cljs tutorial, and got a bare-bones web app to run, but whenever I try and run (start-repl) to run the boot-cljs-repl, I get that error. I've tried updating Clojure, ClojureScript, Adzerk and other related dependencies to their newest versions, and have tried $ echo $BOOT_JVM_OPTIONS to add it to the file (which I can open or cd into), to add it, along with "--add-modules" "java.xml.bind" from the CLI. I would add it in the project.clj(s) file, but there isn't one mentioned in the tutorial yet, and I don't want to add it and mess things up more.


cljs-http seems to be mangling binary data in the response (e.g. if i’m requesting a jpg). anyone know how i can avoid that, or is there a nice alternative library I can use? (i’m using node via shadow-cljs)


@wiseman there's that might be easy enough to use depending on what you're doing specifically


most of the cljs http libraries wrap that in some capacity


i’m doing totally basic http. cljs-http just came up at the top of a google search, but i can probably do whatever the popular approach is.


@hoopes did you ever figure that react-dropzone thing out? I have a cljs project that I was able to use react-dropzone in with your sample code, but cloning and running your repo I get your error :thinking_face: ;


@hoopes the issue it that you only depend on re-frame but not reagent. re-frame still seems to depend on [reagent "0.7.0"] which seems to have issues with the newer react stuff


adding [reagent "0.8.1"] seems to fix that problem, still fails elswhere though


funny enough it tries to tell you that but can't due to the unprintable Symbol instance 😛


Ah so that's why it still fails in react-dom with object after adding the [reagent "0.8.1"]; I couldn't find any difference between my and @hoopes’s shadow-cljs.edn and package-lock.json that was the magic bullet (I had also noticed the lack of reagent dependency and tried to match other dependency versions) so I'd be interested to learn what fixes that issue even though I am not facing it :thinking_face:. Good luck, @hoopes 😬