This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-05-24
Channels
- # beginners (12)
- # cider (3)
- # clara (3)
- # cljs-dev (3)
- # cljsrn (19)
- # clojure (83)
- # clojure-android (1)
- # clojure-dev (15)
- # clojure-dusseldorf (1)
- # clojure-greece (30)
- # clojure-italy (10)
- # clojure-madison (1)
- # clojure-nl (6)
- # clojure-russia (274)
- # clojure-spec (51)
- # clojure-uk (31)
- # clojurescript (38)
- # core-async (7)
- # cursive (11)
- # datascript (1)
- # datomic (63)
- # emacs (10)
- # figwheel (1)
- # hoplon (27)
- # jobs (11)
- # klipse (4)
- # lein-figwheel (1)
- # lumo (6)
- # nyc (1)
- # off-topic (278)
- # om (12)
- # pedestal (10)
- # protorepl (31)
- # re-frame (13)
- # reagent (23)
- # remote-jobs (1)
- # spacemacs (9)
- # untangled (24)
- # yada (54)
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
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)
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 🙂
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
@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.
@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 :refer
s, 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.
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
@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 foo.bar
in JavaScriptIf 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