Fork me on GitHub
#clojurescript
<
2017-05-24
>
gastove02:05:40

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?

anmonteiro03:05:18

@gastove have you installed source-map-support?

anmonteiro03:05:22

npm install source-map-support

gastove03:05:13

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

gastove03:05:21

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

escherize04:05:03

I'm also curious

akiroz05:05:40

Lumo 1.5 does print stacktraces for errors thrown.

akiroz05:05:37

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]
  (foo))
results in this:
Cannot read property '0' of null
	 com$err$foo (evalmachine.<anonymous>:3:13)
	 Function.com.err._main.cljs$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.a)
	 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)

akiroz05:05:39

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

nikki06:05:55

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

fbielejec12:05:09

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

denik13:05:23

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

naomarik13:05:07

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

dnolen13:05:22

@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.

dnolen13:05:35

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

naomarik13:05:38

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

denik14:05:27

@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?

dnolen14:05:04

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

denik14:05:06

@dnolen what’s the reasoning behind that?

dnolen14:05:45

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

dnolen14:05:54

first off .cljc is new

dnolen14:05:03

and the behavior I described is also relatively new

dnolen14:05:57

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

dnolen14:05:26

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

denik14:05:16

@dnolen got it. thanks for the explanation

dnolen14:05:02

@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.

dnolen14:05:26

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

dnolen14:05:05

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.

dnolen14:05:35

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

wasserspiegel16:05:11

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]))))

spinningtopsofdoom16:05:18

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

(ns foo)

(def ^:export bar)
would be foo.bar in JavaScript

spinningtopsofdoom16:05:54

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

wasserspiegel17:05:52

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.

iandavis22:05:35

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

iandavis22:05:54

This also only happens with advanced compiled code

iandavis22:05:34

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