btw being on 1.6 means you can use -D / --dependencies
(Lumo will look in your local Maven repo for JARs)
e.g. how I started lumo above:
lumo -D reagent:0.7.0,cljsjs/react:15.5.4-0,cljsjs/react-dom:15.5.4-0,cljsjs/create-react-class:15.5.3-0
huh
nice
😞
Could not parse ns form reagent.impl.batching in file reagent/impl/batching.cljs
(new)
Function.cljs.core.ex_info.cljs$core$IFn$_invoke$arity$3 (NO_SOURCE_FILE <embedded>:1935:200)
Function.cljs.analyzer.error.cljs$core$IFn$_invoke$arity$3 (NO_SOURCE_FILE <embedded>:2482:92)
(NO_SOURCE_FILE <embedded>:5860:394)
cljs.js.load_macros (NO_SOURCE_FILE <embedded>:5838:464)
(NO_SOURCE_FILE <embedded>:5835:384)
Function.cljs.js.require.cljs$core$IFn$_invoke$arity$5 (NO_SOURCE_FILE <embedded>:5793:38)
cljs.js.load_macros (NO_SOURCE_FILE <embedded>:5835:41)
(NO_SOURCE_FILE <embedded>:5835:384)
Function.cljs.js.require.cljs$core$IFn$_invoke$arity$5 (NO_SOURCE_FILE <embedded>:5793:38)
Invalid :refer, macro reagent.debug/assert-some does not exist in file reagent/impl/batching.cljs
(new)
Function.cljs.core.ex_info.cljs$core$IFn$_invoke$arity$3 (NO_SOURCE_FILE <embedded>:1935:200)
Function.cljs.analyzer.error.cljs$core$IFn$_invoke$arity$3 (NO_SOURCE_FILE <embedded>:2482:92)
Function.cljs.analyzer.error.cljs$core$IFn$_invoke$arity$2 (NO_SOURCE_FILE <embedded>:2481:92)
Function.cljs.analyzer.check_use_macros.cljs$core$IFn$_invoke$arity$3 (NO_SOURCE_FILE <embedded>:2819:314)
Function.cljs.analyzer.check_use_macros.cljs$core$IFn$_invoke$arity$2 (NO_SOURCE_FILE <embedded>:2816:114)
(NO_SOURCE_FILE <embedded>:5860:108)
cljs.js.load_macros (NO_SOURCE_FILE <embedded>:5838:464)
(NO_SOURCE_FILE <embedded>:5835:384)
Function.cljs.js.require.cljs$core$IFn$_invoke$arity$5 (NO_SOURCE_FILE <embedded>:5793:38)
which namespaces are you requiring?
(require 'reagent.core)
That’s odd, since I was able to require it just now
can you wipe your caches?
and try again
yeah
doing something different now
thanks!
looks like I can make progress now
🎉
awesome, let me know if I can do anything more to help
ERROR in file ajax/xml_http_request.cljs
(new)
Function.cljs.core.ex_info.cljs$core$IFn$_invoke$arity$3 (NO_SOURCE_FILE <embedded>:1935:200)
Function.cljs.analyzer.error.cljs$core$IFn$_invoke$arity$3 (NO_SOURCE_FILE <embedded>:2482:92)
(NO_SOURCE_FILE <embedded>:5947:100)
z (NO_SOURCE_FILE <embedded>:5948:13)
(NO_SOURCE_FILE <embedded>:5942:232)
(NO_SOURCE_FILE <embedded>:5862:482)
Object.cljs.js.load_macros (NO_SOURCE_FILE <embedded>:5838:464)
(NO_SOURCE_FILE <embedded>:5857:20)
Object.cljs.js.load_macros (NO_SOURCE_FILE <embedded>:5838:464)
XMLHttpRequest is not defined
(evalmachine.<anonymous>:5:1)
ContextifyScript.Script.runInThisContext (vm.cljs:44:33)
Object.runInThisContext (vm.cljs:116:38)
(Object.lumoEval)
lumo.repl.caching_node_eval (NO_SOURCE_FILE <embedded>:6211:68)
(NO_SOURCE_FILE <embedded>:5947:29)
z (NO_SOURCE_FILE <embedded>:5948:13)
(NO_SOURCE_FILE <embedded>:5942:232)
(NO_SOURCE_FILE <embedded>:5862:482)
Object.cljs.js.load_macros (NO_SOURCE_FILE <embedded>:5838:464)
is that because it's node?
right. There’s no XMLHttpRequest
in Node
hmm
it worked before
I wonder how
is there any way to output the cached namespace without evaling it?
not that I can think of
has anything changed?
I'm sure I've required that before
Maybe the code has changed
thanks
I've got to grab dinner now
you rock!
I don’t think anything has changed
I can’t see how you required a file that depended on XMLHTTPRequest
being there
actually
I think I remember this conversation 🙂
you may have to polyfill e.g. through https://www.npmjs.com/package/xmlhttprequest
the reason I say it must have been generated is that it exists here in the cache:
https://github.com/viebel/klipse/blob/master/docs/cache-cljs/day8_SLASH_re_frame_SLASH_http_fx.js
@ericnormand right. I think I had this conversation with @viebel before
if you install the polyfill and (set! (.-XMLHttpRequest js/global) (.-XMLHttpRequest (js/require "xmlhttprequest")))
it’ll probably work
oh, I see
he has custom versions of stuff
I should have looked at it before
thanks again!
np!
does this make any sense to you?
WARNING: poppea$macros is a single segment namespace at line 1 poppea.clj
WARNING: cljs.core$macros/bit-or, all arguments must be numbers, got [string number] instead. at line 121 cljs/tools/reader/edn.cljs
WARNING: cljs.core$macros/bit-or, all arguments must be numbers, got [string number] instead. at line 121 cljs/tools/reader/edn.cljs
WARNING: cljs.core$macros/bit-or, all arguments must be numbers, got [string number] instead. at line 122 cljs/tools/reader/edn.cljs
WARNING: cljs.core$macros/bit-or, all arguments must be numbers, got [string number] instead. at line 122 cljs/tools/reader/edn.cljs
No such macros namespace: cljs.tools.reader.edn, could not locate cljs/tools/reader/edn.clj or cljs/tools/reader/edn.cljc in file cljs/tools/reader/edn.cljs
(new)
Function.cljs.core.ex_info.cljs$core$IFn$_invoke$arity$3 (NO_SOURCE_FILE <embedded>:1935:200)
Function.cljs.analyzer.error.cljs$core$IFn$_invoke$arity$3 (NO_SOURCE_FILE <embedded>:2482:92)
Function.cljs.analyzer.error.cljs$core$IFn$_invoke$arity$2 (NO_SOURCE_FILE <embedded>:2481:92)
(NO_SOURCE_FILE <embedded>:5802:520)
Object.lumo.repl.load_other (NO_SOURCE_FILE <embedded>:6201:380)
lumo.repl.load (NO_SOURCE_FILE <embedded>:6205:106)
Function.cljs.js.require.cljs$core$IFn$_invoke$arity$5 (NO_SOURCE_FILE <embedded>:5804:390)
Object.cljs.js.load_macros (NO_SOURCE_FILE <embedded>:5835:41)
(NO_SOURCE_FILE <embedded>:5857:20)
something is trying to load in the macro namespace
buy why?
https://github.com/viebel/poppea/blob/master/src/poppea.clj#L1
looks very weird to me
or actually
I don’t really know what we should do in this case
the poppea
namespace is a macros namespace
if this were JVM ClojureScript, you wouldn’t be able to load cljs.tools.reader.edn
^ given cljs/tools/reader/edn.cljs
because macros are written in Clojure
hmm
ugh
how did this ever work?
does it work in klipse?
FWIW Planck throws the same error
lanck 2.5.0
ClojureScript 1.9.660
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Exit: Control+D or :cljs/quit or exit or quit
Results: Stored in vars *1, *2, *3, an exception in *e
cljs.user=> (require-macros 'poppea)
WARNING: poppea$macros is a single segment namespace at line 1 poppea.clj
WARNING: cljs.core/bit-or, all arguments must be numbers, got [string number] instead. at line 121 cljs/tools/reader/edn.cljs
WARNING: cljs.core/bit-or, all arguments must be numbers, got [string number] instead. at line 121 cljs/tools/reader/edn.cljs
WARNING: cljs.core/bit-or, all arguments must be numbers, got [string number] instead. at line 122 cljs/tools/reader/edn.cljs
WARNING: cljs.core/bit-or, all arguments must be numbers, got [string number] instead. at line 122 cljs/tools/reader/edn.cljs
No such macros namespace: cljs.tools.reader.edn, could not locate cljs/tools/reader/edn.clj or cljs/tools/reader/edn.cljc in file cljs/tools/reader/edn.cljs
cljs.user=>
Self-host compatible version of poppea
is in github but not deployed yet in clojars
@ericnormand @anmonteiro But you can take it from here - [viebel/poppea "0.2.1"]
I just asked the maintainer of poppea to deploy it to his clojars https://github.com/JulianBirch/poppea/issues/4
@viebel please read above. we were using that exact version
the problem is poppea$macros
can’t require a .cljs
file
because at that point you’re in a macros env
@anmonteiro in my local setup it works
➜ cache-cljs git:(master) ✗ lumo -k . -c $cp
Lumo 1.5.0
ClojureScript 1.9.542
Node.js v7.10.0
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Exit: Control+D or :cljs/quit or exit
cljs.user=> (require-macros 'poppea)
nil
cljs.user=>
try upgrading to Lumo 1.6 and deleting the cache
I wonder if I was doing something wrong
what’s your $cp
?
When I remove the cache, I get lots of warning but noe error
interesting
I wonder if something changed between Lumo 1.5 and 1.6
let me clone the repo
I think that the version of Lumo I’m using is the one you sent me
here on slack
what did that version have that’s special?
I think you sent me the binaries
It contains the fix of the foreign-libs stuff
gotcha
I get an error in 1.6
hmmm
just cloned the repo
Planck reports the same error
How nice that reagent 0.7.0 now works in lumo
I don't suppose you can include cljsjs packages like https://github.com/cljsjs/packages/tree/master/react-select ?
That is super great
@pesterhazy I think lumo can now resolve jars with -d
@richiardiandrea you mean resolve maven coordinates to jars?
if i understood the question up yes 😄
actually rereading now, it seems like he is asking if lumo works with cljsjs foreign-libs
Yeah, that's right @richiardiandrea
unfortunately I have never tried with cljsjs, I am always using yarn
for those deps
Good point, that might be easier
@pesterhazy you can use foreign libs with Lumo as long as they don't need browser globals
lumo -D cljsjs/react-select:1.0.0-rc.1,reagent:0.7.0,cljsjs/react:15.5.4-0,cljsjs/react-dom:15.5.4-0,cljsjs/create-react-class:15.5.3-0
(require 'cljsjs.react-select)
Could not require cljsjs.react-select
Cannot read property 'source' of null
(NO_SOURCE_FILE <embedded>:6189:190)
(NO_SOURCE_FILE <embedded>:990:207)
(NO_SOURCE_FILE <embedded>:990:220)
cljs.core.LazySeq.sval (NO_SOURCE_FILE <embedded>:704:154)
cljs.core.LazySeq.cljs$core$ISeqable$_seq$arity$1 (NO_SOURCE_FILE <embedded>:710:255)
Object.cljs.core.seq (NO_SOURCE_FILE <embedded>:414:172)
cljs.core.Cons.cljs$core$INext$_next$arity$1 (NO_SOURCE_FILE <embedded>:682:335)
Object.cljs.core.next (NO_SOURCE_FILE <embedded>:416:416)
Function.clojure.string.join.cljs$core$IFn$_invoke$arity$2 (NO_SOURCE_FILE <embedded>:1973:225)
Object.lumo.repl.load_foreign_lib (NO_SOURCE_FILE <embedded>:6189:518)
by the way the use case is a bit silly, not sure why I'd want to require react-select in real life
@pesterhazy I broke foreign libs in 1.5
make sure you’re on 1.6
yeah it's 1.6
hrm
like I said it's not a big deal, I can't use react components inside node anyway 🙂
(defn create-http-server [ctx]
(let [app (un/express)]
(.listen app 9999)
(.get app
"/action"
(partial handle ctx)
;; #(apply handle ctx %&)
)))
this snippet, which creates an express server, doesn't work - the express server returns a 404
however if I replace (partial handle ctx)
with #(apply handle ctx %&)
, it works
@pesterhazy what if you move listen
to below the .get
call?
@anmonteiro doesn't make a difference
seems like it's about partial
😕
(partial handle ctx)
and #(apply handle ctx %&)
should be completely equivalent, right?
I think so
unless there’s some this
binding stuff happening behind the scenes
not on my side
javascript, you're being weird!
😞
(defn create-http-server [ctx]
(let [app (un/express)]
(.get app "/action1" #(apply handle ctx %&))
(.get app "/action2" #(handle ctx %1 %2))
(.get app "/action3" #(handle ctx %1 %2 %3))
(.get app "/action4" (fn [x y] (handle ctx x y)))
(.get app "/action5" (fn [x y & args] (handle ctx x y z args)))
(.get app "/action6" (partial handle ctx))
(.get app "/action7" (fn
([x y] (handle ctx x y))
([x y z] (handle ctx x y z))
([x y z & args] (handle ctx x y z args))))
(.get app "/action8" (fn [x y z & args] (handle ctx x y z args)))
(.listen app 9999)))
the plot thickens.... action1-5 work, but action6-8 don't work
ooooops
:fn-invoke-direct
maybe
wait, no, that’s not on by default
just tried with lumo 1.5.0 and 1.6.0 - same behavior
(.get app "/action9a" (fn
([x y] (handle ctx x y))))
(.get app "/action9b" (fn
([x y] (handle ctx x y))
([x y z m] (handle ctx x y z m))))
action9a works, action9b breaks
even though neither of the arities in 9b get called
so it must be express looking at the function and somehow deciding it's unworthy
I'm giving up - the expressjs code is too weird to follow
the simple workaround is not to use partial
here 🙂
@pesterhazy My guess is that Express looks at the function length == # of arguments and then does different stuff. The dispatcher in CLJS will have the fixed args + rest-arg. So (.-length (partial #() 1))
is 4.
Would explain why 5 works, but 8 doesn't. Maybe express does something special if it sees 4 argument function as the handler... No clue
That's what I thought too, but didn't find any relevant occurrence of length
@rauh ^^ the express source is somewhat opaque so I didn't manage to trace
Maybe I'll try with a debugger
Maybe this... No clue though: https://github.com/expressjs/express/blob/9722202df964bfbfc0f579e4baeb5a4e1b43b344/lib/router/layer.js#L89-L92
Oh that looks relevant
Goes without saying... This is terrible programming style (or API design). GCC --for instance-- will remove unused arguments.
I agree, never seen anything like that in cljs
@rauh, just checked it, your suspicion was right. Express gets confused because the partial has length == 4
on a side note, all partials have length 4, except for partials with > 3 partially applied arguments -- those have length 1
more generally, it seems borderline crazy to check fn.length instead of checking whether args are nil
Yeah, but that might change... I'm working on getting central dispatchers into CLJS core, in which case they'd all be length 0.
I agree, it's super dumb. And not even documented really.
right, it's not in docs as far as I can see
I guess the practical conclusion is to watch out for javascript APIs that reflect on functions when using partial
Yeah best to only use single arity non-variadic fns, they compile down to normal JS fns.
ok. thanks for your help!
apparently this behavior is "designed": https://github.com/expressjs/express/issues/2289#issuecomment-51511610
Haha I could go on rambling about JS/Node ecosystem. But I'll just leave it at "super dumb". 🙂
Lol this made my day 😀