Fork me on GitHub

I'm curious on whether ES6 Modules will simplify how clojurescript will handle modules in the future. It seems to have it's own system of handling CommonJS modules and similar modules


What is the conventional way to export clojurescript code as a node.js module? That works with require()


is there a way to get the current route using secretary to set an active class on a link?


actually never mind, came up with a different way to do this


@dominicm I do not think core provides something more than ^:export, I might be wrong though


So you can expose symbols that become JS vars, what is your use case?


@richiardiandrea I found a blog post saying I needed to write some "shim" javascript to re-flatten things out. I've ended up with:

var clj_refactor = require('./compiled.js')

module.exports = clj_refactor.clj_refactor.main._main


@dominicm yes that is what I do in my lamdbas as well. In comparison, shadow-cljs has more options regarding JS consumption, one explicitly for node library.


Maybe I shall give that a shot later then 🙂 thanks


I'm using a clojurescript library that i need to modify. Is there a good way of doing this? like can i fork the repo and point the project.clj dependency somehow at a local folder while i fix the issues?


With shadow-cljs you can shadow single files locally that will override anything from a jar.


hi all, is default-destructuring supported on namespaced keywords?

(let [{:keys [foo/bar] :or {foo/bar 2}} something])


@levitanong (let [{:keys [foo/bar] :or {bar 2}} something])


Or, if you prefer the symmetry: (let [{:foo/keys [bar] :or {bar 2}} something])


@mfikes whoa, i didn’t know the latter was even possible. The former didn’t seem to work for me.


@levitanong So, for example (let [{:keys [foo/bar] :or {bar 2}} {:foo/bar 42}] bar) doesn't evaluate to 42 for you?


(let [{:keys [foo/bar] :or {bar 2}} {}] bar) -> 2


i just realized something… if the object being destructured is {:foo/bar nil}, then it shouldn’t be 2, because the value was explicitly stated to be nil


@mfikes so if the latter is a thing, then does that mean that, given:

(def thing {:foo/bar 2 :baz/rutten 3})

(let [{:foo/keys [bar] :baz/keys [rutten]} thing])
;; bar = 2
;; rutten = 3


Sure; (let [{:foo/keys [bar] :baz/keys [rutten]} thing] [bar rutten]) -> [2 3]


holy moly, that is so cool!


anyway, thanks for your help @mfikes!


are there any debugging / logging libraries out there that deal with javascript objects and clojurescript datastructures with equal ease?


i’m so tired of getting [Object object] or whatever as output when i’m confused about the type of the variables i’m trying to debug


js/console.log with cljs-devtools has no problems with either


right that’s a good point. i sure would like a pretty printer though. it is much easier than drilling down


the other thing with that approach is that it only works if you pass the object unchanged to console.log so when used with spy macros and other types of logging conveniences (like using color output in the console) it is hard to get that to work right


to see [Object object] someone must be calling toString on your javascript objects, probably calling str on them


I think if your logging library was written properly it would serialise javascript objects via pr-str which goes through pr-writer machinery which tries to drill into #js objects and print them as cljs maps, here is a proof:


yes that’s exactly what’s happening because I’m trying to get fully expanded logging in certain circumstances. sometimes with deeply nested structures, it is simply nicer to have it expanded out so I don’t have to drill down with the mouse


i’ve also been trying to experiment with the color output features of chrome, because it can be really handy to selectively print stuff in red so that i can find it quickly. but to do that, you have to get to a string representation


Hi all. I'm trying to interop with a JS lib, and have had to write a really basic externs file and an accompanying foreign lib:

var SlateAutoReplace = {
  "AutoReplace": function() {}
When I require the lib and try to use the loaded JS, the AutoReplace fn exists as a default attribute in the SlateAutoReplace module object. In order to call the fn I have to do:
(.default js/SlateAutoReplace args...)
But the following fails:
(js/SlateAutoReplace.AutoReplace args...)


I'm guessing this is because AutoReplace was export default, but I've never seen this form of interop and I'm wondering if I've missed a step.