Fork me on GitHub

what is the idiomatic way to create custom eventypes/dispatcher in clojurescript ? I follow this pattern but i sense there is place for deftype/protocol/reify here, althought i do not grasp the conspects clear


Hey guys, fairly new to clojure(script), did use it 2-3 years ago for a spell so not entirely a beginner. Just wondering about the up-to-date conventions in 2019 that people are using to build web apps?


hey, I think + shadow-cljs is the way to go nowadays. It works amazingly well for us


Hi all 👋 . Looking for some prior art: Has anyone built a CLI with subcommands (e.g. like you would with commander) in cljs? My use case is building something like this and then packaging with nexe for static binary deployment to macOS/Linux/Windows.

Mikko Koski12:05:53

Hi @damienstanton We're soon about to start a project to build a CLI with subcommands. We have built a quick proof-of-concept and done some initial technical design. We built the proof-of-concept with tools.cli, Chalk, Inquirer and shadow-cljs and planning to use that stack for the real thing

👍 4

anybody aware of a good "walkthrough" of clojurescripts dependence on goog? recently my production build started crashing on page load due to `Uncaught ReferenceError: goog is not defined at app.js:1`


@restenba production build should have no references to goog left


hm. does it have anything to do with :optimizations? i set them back to :none on the production build in order to see error messages, but the error persists with :advanced as well


yes :optimizations controls that and :advanced should not contain goog


:none is not a production build 😉


well no, but javascript errors are not human readable anymore with :advanced


typically compiling with :pseudo-names true provides some clues


or switch to :optimizations :simple


well, that got rid of the goog error. build still broken though, for whatever weird reason the deployed cljsbuild has decided to start having a problem with a specific library, despite there not being any version updates to that or the build itself lately


Wow, this must be the weirdest issue I've had. Some old library starting generating errors in the production build. Nothing I did got rid of it - not updating it's version, or other dependencies, or the build tools, compiler settings, nothing. In the end I had to get rid of it and just rewrite that portion of the code without using that library


Wasn't an obscure library either,

Steven Katz18:05:09

Is anyone using figmain integrated with cursive? I folowed the instructions here: But see this when the repl starts:

May 03, 2019 1:59:46 PM org.jline.utils.Log logr
WARNING: Unable to create a system terminal, creating a dumb terminal (enable debug logging for more information)
Unable to detect a system Terminal, you must not launch the Rebel readline
from an intermediate process.
If you are using `lein` you may need to use `lein trampoline`."
Is this normal?


@steven.katz It might be worth trying setting the REPL to be of clojure.main type instead of nREPL (assuming you have it at the nREPL default)


(This is in the Cursive REPL configuration dialog.)

Steven Katz18:05:08

thats what I am chosing

Steven Katz18:05:26

If I choose nREPL it does not work at all (wont take input)


I’ve been surprised by the behavior of doing an clojure.core/eval at macroexpansion-time in cljs. I made a small gist example to demonstrate. I’m curious if anyone could enlighten me to what is happening? I’m guessing that defs are not actually updating the state of the CLJ-ns that the macros are being expanded in. Is there any safe way to do an “eval” sort of op during macroexpansion in CLJS? In the example I just have a symbol, but I’m curious about arbitrary types of forms that have symbols to resolve as well.


@mikerod I think you probably just have the wrong expectations


clojure.core/eval is exactly that


has nothing to do with ClojureScript, doesn't know anything about ClojureScript


if you need it, expect to do a lot of work


@dnolen sure, I know it’s a stretch, but was curious if there are anyways to try to “do things” during macroexpansion that may involve eval-like behavior


there isn't


it's just Clojure eval


and I was at least a little surprised that the clj ns doesn’t have any def into it, I guess that is just all managed via the cljs compilation state instead


there's no way to magically make it know about ClojureScript stuff


it doesn't know about nses, vars, nothing


I know it isn’t cljs at all - wondering if cljs has any alternative way


Clojure eval is meaningless


you can do some weird things - but again not recommended


it’s like if I want a macro to use in cljs, and the macro receives a symbol - I want to resolve it, do something with it during expansion prior to emitting the forms from the macro


if it’s “just symbols” I guess I can just use some symbol resolve stuff from the cljs.analyzer


yes if you just need resolve then resolve


Yeah, this eval thing seems to have magically worked out in some cases I had before - I thought it looked like a bad idea, but then couldn’t figure out how it ever worked. I tried to simplify it down and it seems like it shouldn’t work


trying to make eval work is a losing battle


(as in, I didn’t write it, just discovered it)


if anything worked it was probably simple and you got lucky




thanks for the input though. at least I can now be sure it’s a bad idea


yeah trying to make it do something useful would make my brain hurt


Yep. I could see that.


Hi! In Clojure I rely on namespaced keywords a lot and in some cases use plain JSON for serialization. cheshire handles this well both ways. In clojurescript the ingress path works well (js->clj (.parse js/JSON some-string) :keywordize-keys true) has the same behavior


For egress, clj->js removes namespace info (since the output is a JS object it makes sense)


is there a way to go directly to JSON and preserve that info or will I be forced to pull in transit?


cljs.user=> (defn transform-keys
                #_=>   [m key-fn]
                #_=>   (walk/postwalk (fn [item]
                #_=>                    (if (map? item)
                #_=>                      (zipmap (mapv key-fn (keys item)) (vals item))
                #_=>                      item))
                #_=>                  m))
cljs.user=> (transform-keys {::foo 1} name)
{"foo" 1}
cljs.user=> (transform-keys {::foo 1} str)
{":cljs.user/foo" 1}


@pyr Transforming all of these keys to strings first allows them to go to JSON without a hitch. You'll then just need to transform them back on the way in, using (transform-keys data keyword).


With CLJS 1.10.439, I should be able to add a dep like :npm-deps {"@sentry/browser" "5.1.0"}, use :install-deps true, add :infer-externs true, and require the dep like (ns (:require ["@sentry/browser"])), right? This all compiles, but I see Undefined nameToPath for module$home$jeaye$projects$foo$node_modules$$sentry$browser$node_modules$$sentry$core$esm$integrations when executing.


@jeaye :npm-deps for X dep may or may not work, that's always been true


@dnolen That's ok. I just want to be sure the steps I've take are correct so that I can know it's the dep and not me.


I can fall back to cljsjs for this dep.


@jeaye it was definitely the case that scoped deps had issues


because of Closure Compiler


might be worth a try with the latest ClojureScript, I believe we have a newer GCC dep


Got it. Thanks, David.


@pyr see the clj->js docstring


:keyword-fn is a thing


@jeaye I recall at least a couple of reports that scoped deps started working again


@dnolen Same error with 1.10.520 for me. Will go to cljsjs for this one.


Thanks again.