Fork me on GitHub

Anyone done much writing CLIs with ClojureScript to run with node? Curious if there’s anything to be done with stack traces — some kind of non-browser source map support, something/anything?


@gastove have you installed source-map-support?


npm install source-map-support


I did; I perhaps have misunderstood source maps — I thought they were browser-only?


Certainly… the stack traces I’m getting in my REPL are… on… the unfriendly side.


I'm also curious


Lumo 1.5 does print stacktraces for errors thrown.


Just tried it out myself, not great stack traces but better than none I suppose.....

(ns com.err)
(defn foo []
  (aget nil 0))
(defn -main [& args]
results in this:
Cannot read property '0' of null
	 com$err$foo (evalmachine.<anonymous>:3:13)$core$IFn$_invoke$arity$variadic (evalmachine.<anonymous>:26:20)
	 com$err$_main (evalmachine.<anonymous>:22:22)
	 cljs.core.Var.b (NO_SOURCE_FILE <embedded>:366:172)
	 cljs.core.Var.apply (NO_SOURCE_FILE <embedded>:377:461)
	 Function.cljs.core.apply.cljs$core$IFn$_invoke$arity$2 (NO_SOURCE_FILE <embedded>:771:448)
	 (NO_SOURCE_FILE <embedded>:6270:421)
	 (NO_SOURCE_FILE <embedded>:5373:221)
	 x (NO_SOURCE_FILE <embedded>:5374:13)


I wonder if source maps can be enabled somehow...


any strategies around step by step eval for cljs.js/eval for debugging?


I made a small demo project, showing how to wrap a staful JS object in a re-frame component: . Use case is the ace-editor Might come useful for someone 🙂


is :include-macros true still necessary when requiring from a .cljc file? I always need to load the cljc after initial compilation for macros to work


what are my options of hacking on a 3rd party cljs lib within my project?


@denik nothing has really changed with respect to loading macros - you always need :include-macros or :require-macros. Only in one case is :include-macros or :require-macros generated for you - if the macro library and runtime library share the exact same name and the runtime library requires (macro require) it.


only in that case will users get the macros implicitly by requiring the runtime ns.


i’ve seen boot has :checkouts, is that what people tend to use?


@dnolen exact same names would be the case for cljc files, correct? and yet I find myself having to load the entire file after initial compile. this doesn’t happen with :refers, only aliases, e.g [... :as util] and then util/my-macro is not readily compiled in cljs. could this be a bug?


@denik exact same name isn’t enough as I alluded above. You need to self-require for the macros.


@dnolen what’s the reasoning behind that?


@denik right you don’t have any context for why it works this way


first off .cljc is new


and the behavior I described is also relatively new


people writing .cljc files to represent both the macro ns and runtime ns is a new user pattern/convention


we simply haven’t special cased it - nor considered what the repercussions there might be if we chose to do so


@dnolen got it. thanks for the explanation


@denik feel free to open an enhancement ticket in JIRA for that - I can’t think of any obvious problems with doing that - and I’m sure someone will take it, it won’t be hard to do.


the reason we don’t do it automatically already is because it wasn’t safe to do so when macro files and runtime files were separate


in the past just because a .clj file and .cljs file had the same name didn’t mean anything all - implicitly loading the .clj file was not a good idea.


but given we have a new pattern where there’s one file - this concern doesn’t apply to this specific case.


Does anyone know how to add export correctly in this situation? It works without advanced compilation. `(def ^:export scale1 "basic lin scale green, blue, red" (let [mp 8 ;midpoint r (fn [x] (- (* mp mp (- x mp) 256))) g (fn [x] (- (* mp mp (- mp x) 256))) b (fn [x] (- 255 (* mp (- mp x) (- mp x)))) a (fn [_] 255)] [r g b a] ))` used in (vec (for [i is j js f scale1] (f (get-in mat [i j]))))


The :export metadata tag exports the fully namespace qualified symbol. For example

(ns foo)

(def ^:export bar)
would be in JavaScript


If you have scale1 defined in ClojureScript why are you exporting it and then re-importing in another ClojureScript function?


The problem was elsewhere (a missing namespace prefix). And regarding the question: It is called from an anonymous function that draws the heat map, that was created with react (in reagent-render) but you are right it works fine without export.


Howdy folks. I’m currently debugging what appears to be a cljs bug in js->clj, but I am still trying to find a minimal case. As of now, I have identified that the issue is caused because a js Object is returning true for (seq? x) but then when (map fn x) is called the following error is thrown: [object Object] is not ISeqable


This also only happens with advanced compiled code


when using whitespace or dev builds, the parser works fine. Anyone have any insights on how to dig into this further?