lumo

:lumo: Standalone ClojureScript environment. Currently at version 1.9.0
anmonteiro 2017-07-05T00:00:30.746661Z

btw being on 1.6 means you can use -D / --dependencies (Lumo will look in your local Maven repo for JARs)

anmonteiro 2017-07-05T00:00:53.749607Z

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

ericnormand 2017-07-05T00:05:12.779656Z

huh

ericnormand 2017-07-05T00:05:13.779757Z

nice

ericnormand 2017-07-05T00:06:04.785406Z

😞

ericnormand 2017-07-05T00:06:06.785718Z

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)

anmonteiro 2017-07-05T00:07:52.797329Z

which namespaces are you requiring?

ericnormand 2017-07-05T00:08:36.801921Z

(require 'reagent.core)

anmonteiro 2017-07-05T00:09:23.806979Z

That’s odd, since I was able to require it just now

anmonteiro 2017-07-05T00:09:47.809783Z

can you wipe your caches?

anmonteiro 2017-07-05T00:09:50.810085Z

and try again

ericnormand 2017-07-05T00:09:56.810780Z

yeah

ericnormand 2017-07-05T00:11:34.821542Z

doing something different now

ericnormand 2017-07-05T00:12:08.825306Z

thanks!

ericnormand 2017-07-05T00:12:14.825915Z

looks like I can make progress now

anmonteiro 2017-07-05T00:12:18.826507Z

🎉

anmonteiro 2017-07-05T00:12:33.828225Z

awesome, let me know if I can do anything more to help

ericnormand 2017-07-05T00:13:45.836042Z

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)

ericnormand 2017-07-05T00:14:04.838255Z

is that because it's node?

anmonteiro 2017-07-05T00:14:04.838295Z

right. There’s no XMLHttpRequest in Node

ericnormand 2017-07-05T00:14:09.838779Z

hmm

ericnormand 2017-07-05T00:14:14.839349Z

it worked before

ericnormand 2017-07-05T00:14:16.839580Z

I wonder how

ericnormand 2017-07-05T00:19:23.874148Z

is there any way to output the cached namespace without evaling it?

anmonteiro 2017-07-05T00:26:24.919595Z

not that I can think of

ericnormand 2017-07-05T00:27:51.928629Z

has anything changed?

ericnormand 2017-07-05T00:28:00.929515Z

I'm sure I've required that before

ericnormand 2017-07-05T00:28:05.930044Z

Maybe the code has changed

ericnormand 2017-07-05T00:28:15.931132Z

thanks

ericnormand 2017-07-05T00:28:20.931657Z

I've got to grab dinner now

ericnormand 2017-07-05T00:28:22.931903Z

you rock!

anmonteiro 2017-07-05T00:30:03.943526Z

I don’t think anything has changed

anmonteiro 2017-07-05T00:30:48.949215Z

I can’t see how you required a file that depended on XMLHTTPRequest being there

anmonteiro 2017-07-05T00:31:10.951868Z

actually

anmonteiro 2017-07-05T00:31:17.952793Z

I think I remember this conversation 🙂

anmonteiro 2017-07-05T00:31:31.954350Z

you may have to polyfill e.g. through https://www.npmjs.com/package/xmlhttprequest

ericnormand 2017-07-05T01:46:53.559459Z

the reason I say it must have been generated is that it exists here in the cache:

anmonteiro 2017-07-05T02:04:47.725101Z

@ericnormand right. I think I had this conversation with @viebel before

anmonteiro 2017-07-05T02:05:20.730305Z

if you install the polyfill and (set! (.-XMLHttpRequest js/global) (.-XMLHttpRequest (js/require "xmlhttprequest"))) it’ll probably work

ericnormand 2017-07-05T02:06:32.741140Z

oh, I see

ericnormand 2017-07-05T02:06:36.741946Z

he has custom versions of stuff

ericnormand 2017-07-05T02:08:23.757915Z

I should have looked at it before

ericnormand 2017-07-05T02:08:25.758212Z

thanks again!

anmonteiro 2017-07-05T02:09:21.766491Z

np!

ericnormand 2017-07-05T03:06:47.287078Z

does this make any sense to you?

ericnormand 2017-07-05T03:06:49.287442Z

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)

ericnormand 2017-07-05T03:07:07.290032Z

something is trying to load in the macro namespace

ericnormand 2017-07-05T03:07:24.292364Z

buy why?

anmonteiro 2017-07-05T03:14:30.352815Z

looks very weird to me

anmonteiro 2017-07-05T03:14:45.354747Z

or actually

anmonteiro 2017-07-05T03:15:07.357843Z

I don’t really know what we should do in this case

anmonteiro 2017-07-05T03:15:20.359891Z

the poppea namespace is a macros namespace

anmonteiro 2017-07-05T03:16:14.367323Z

if this were JVM ClojureScript, you wouldn’t be able to load cljs.tools.reader.edn

anmonteiro 2017-07-05T03:16:59.373721Z

^ given cljs/tools/reader/edn.cljs

anmonteiro 2017-07-05T03:17:08.374902Z

because macros are written in Clojure

ericnormand 2017-07-05T03:40:26.574592Z

hmm

ericnormand 2017-07-05T03:40:55.578597Z

ugh

ericnormand 2017-07-05T03:41:04.579754Z

how did this ever work?

anmonteiro 2017-07-05T03:44:35.608817Z

does it work in klipse?

anmonteiro 2017-07-05T04:10:50.834937Z

FWIW Planck throws the same error

anmonteiro 2017-07-05T04:10:59.836154Z

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=>

Yehonathan Sharvit 2017-07-05T05:00:12.262222Z

Self-host compatible version of poppea is in github but not deployed yet in clojars

Yehonathan Sharvit 2017-07-05T05:00:13.262513Z

https://github.com/JulianBirch/poppea/commits/master

Yehonathan Sharvit 2017-07-05T05:01:09.271859Z

@ericnormand @anmonteiro But you can take it from here - [viebel/poppea "0.2.1"]

Yehonathan Sharvit 2017-07-05T05:02:51.287646Z

I just asked the maintainer of poppea to deploy it to his clojars https://github.com/JulianBirch/poppea/issues/4

anmonteiro 2017-07-05T05:05:43.313873Z

@viebel please read above. we were using that exact version

anmonteiro 2017-07-05T05:06:02.316915Z

the problem is poppea$macros can’t require a .cljs file

anmonteiro 2017-07-05T05:06:10.318122Z

because at that point you’re in a macros env

Yehonathan Sharvit 2017-07-05T05:08:01.334320Z

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

anmonteiro 2017-07-05T05:08:39.340162Z

try upgrading to Lumo 1.6 and deleting the cache

anmonteiro 2017-07-05T05:08:58.343201Z

I wonder if I was doing something wrong

anmonteiro 2017-07-05T05:09:13.345335Z

what’s your $cp?

Yehonathan Sharvit 2017-07-05T05:11:27.366089Z

When I remove the cache, I get lots of warning but noe error

anmonteiro 2017-07-05T05:11:55.370405Z

interesting

anmonteiro 2017-07-05T05:12:06.372194Z

I wonder if something changed between Lumo 1.5 and 1.6

anmonteiro 2017-07-05T05:12:08.372598Z

let me clone the repo

Yehonathan Sharvit 2017-07-05T05:12:18.374059Z

I think that the version of Lumo I’m using is the one you sent me

Yehonathan Sharvit 2017-07-05T05:12:28.375732Z

here on slack

anmonteiro 2017-07-05T05:12:36.376977Z

what did that version have that’s special?

Yehonathan Sharvit 2017-07-05T05:12:37.377008Z

I think you sent me the binaries

Yehonathan Sharvit 2017-07-05T05:13:04.381244Z

It contains the fix of the foreign-libs stuff

anmonteiro 2017-07-05T05:13:25.384680Z

gotcha

anmonteiro 2017-07-05T05:13:30.385439Z

I get an error in 1.6

Yehonathan Sharvit 2017-07-05T05:13:37.386439Z

hmmm

anmonteiro 2017-07-05T05:13:47.387934Z

just cloned the repo

anmonteiro 2017-07-05T05:13:52.388757Z

Planck reports the same error

pesterhazy 2017-07-05T10:52:56.599811Z

How nice that reagent 0.7.0 now works in lumo

pesterhazy 2017-07-05T10:57:04.678274Z

I don't suppose you can include cljsjs packages like https://github.com/cljsjs/packages/tree/master/react-select ?

richiardiandrea 2017-07-05T12:37:51.692875Z

That is super great

richiardiandrea 2017-07-05T12:47:57.936373Z

@pesterhazy I think lumo can now resolve jars with -d

dominicm 2017-07-05T12:49:17.969249Z

@richiardiandrea you mean resolve maven coordinates to jars?

richiardiandrea 2017-07-05T12:49:59.987111Z

if i understood the question up yes 😄

richiardiandrea 2017-07-05T12:51:11.017567Z

actually rereading now, it seems like he is asking if lumo works with cljsjs foreign-libs

pesterhazy 2017-07-05T12:52:35.054190Z

Yeah, that's right @richiardiandrea

richiardiandrea 2017-07-05T12:55:20.128770Z

unfortunately I have never tried with cljsjs, I am always using yarn for those deps

pesterhazy 2017-07-05T13:01:36.307033Z

Good point, that might be easier

anmonteiro 2017-07-05T15:15:50.126955Z

@pesterhazy you can use foreign libs with Lumo as long as they don't need browser globals

pesterhazy 2017-07-05T15:17:42.200188Z

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)

pesterhazy 2017-07-05T15:18:41.237425Z

by the way the use case is a bit silly, not sure why I'd want to require react-select in real life

anmonteiro 2017-07-05T15:20:56.325668Z

@pesterhazy I broke foreign libs in 1.5

anmonteiro 2017-07-05T15:20:59.327421Z

make sure you’re on 1.6

pesterhazy 2017-07-05T15:21:11.335156Z

yeah it's 1.6

anmonteiro 2017-07-05T15:21:31.348548Z

hrm

pesterhazy 2017-07-05T15:21:57.365384Z

like I said it's not a big deal, I can't use react components inside node anyway 🙂

pesterhazy 2017-07-05T17:03:13.980103Z

(defn create-http-server [ctx]
  (let [app (un/express)]
    (.listen app 9999)
    (.get app
          "/action"
          (partial handle ctx)
          ;; #(apply handle ctx %&)
          )))

pesterhazy 2017-07-05T17:03:59.005763Z

this snippet, which creates an express server, doesn't work - the express server returns a 404

pesterhazy 2017-07-05T17:04:24.018651Z

however if I replace (partial handle ctx) with #(apply handle ctx %&), it works

anmonteiro 2017-07-05T17:04:44.030569Z

@pesterhazy what if you move listen to below the .get call?

pesterhazy 2017-07-05T17:05:27.053967Z

@anmonteiro doesn't make a difference

pesterhazy 2017-07-05T17:05:44.063769Z

seems like it's about partial 😕

pesterhazy 2017-07-05T17:12:00.268424Z

(partial handle ctx) and #(apply handle ctx %&) should be completely equivalent, right?

anmonteiro 2017-07-05T17:15:51.393119Z

I think so

anmonteiro 2017-07-05T17:16:07.401992Z

unless there’s some this binding stuff happening behind the scenes

pesterhazy 2017-07-05T17:17:52.458557Z

not on my side

pesterhazy 2017-07-05T17:18:26.477152Z

javascript, you're being weird!

anmonteiro 2017-07-05T17:26:10.730837Z

😞

pesterhazy 2017-07-05T17:43:59.332305Z

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

pesterhazy 2017-07-05T17:44:23.346215Z

the plot thickens.... action1-5 work, but action6-8 don't work

anmonteiro 2017-07-05T17:44:48.360764Z

ooooops

anmonteiro 2017-07-05T17:44:55.364196Z

:fn-invoke-direct maybe

anmonteiro 2017-07-05T17:45:23.380579Z

wait, no, that’s not on by default

pesterhazy 2017-07-05T17:49:51.530658Z

just tried with lumo 1.5.0 and 1.6.0 - same behavior

pesterhazy 2017-07-05T17:54:51.699951Z

(.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))))

pesterhazy 2017-07-05T17:55:01.705906Z

action9a works, action9b breaks

pesterhazy 2017-07-05T17:57:55.808587Z

even though neither of the arities in 9b get called

pesterhazy 2017-07-05T17:58:47.839406Z

so it must be express looking at the function and somehow deciding it's unworthy

pesterhazy 2017-07-05T18:19:52.554423Z

I'm giving up - the expressjs code is too weird to follow

pesterhazy 2017-07-05T18:20:12.565720Z

the simple workaround is not to use partial here 🙂

rauh 2017-07-05T19:19:55.526087Z

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

rauh 2017-07-05T19:21:01.559083Z

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

pesterhazy 2017-07-05T19:24:28.665418Z

That's what I thought too, but didn't find any relevant occurrence of length

pesterhazy 2017-07-05T19:25:35.700413Z

@rauh ^^ the express source is somewhat opaque so I didn't manage to trace

pesterhazy 2017-07-05T19:25:54.710279Z

Maybe I'll try with a debugger

pesterhazy 2017-07-05T19:27:48.768616Z

Oh that looks relevant

rauh 2017-07-05T19:28:08.778397Z

Goes without saying... This is terrible programming style (or API design). GCC --for instance-- will remove unused arguments.

pesterhazy 2017-07-05T19:28:51.800673Z

I agree, never seen anything like that in cljs

pesterhazy 2017-07-05T20:36:22.873709Z

@rauh, just checked it, your suspicion was right. Express gets confused because the partial has length == 4

pesterhazy 2017-07-05T20:37:39.912317Z

on a side note, all partials have length 4, except for partials with > 3 partially applied arguments -- those have length 1

pesterhazy 2017-07-05T20:38:16.931069Z

more generally, it seems borderline crazy to check fn.length instead of checking whether args are nil

rauh 2017-07-05T20:38:19.932667Z

Yeah, but that might change... I'm working on getting central dispatchers into CLJS core, in which case they'd all be length 0.

rauh 2017-07-05T20:38:51.948577Z

I agree, it's super dumb. And not even documented really.

pesterhazy 2017-07-05T20:39:07.956681Z

right, it's not in docs as far as I can see

pesterhazy 2017-07-05T20:39:24.965301Z

I guess the practical conclusion is to watch out for javascript APIs that reflect on functions when using partial

rauh 2017-07-05T20:40:04.985114Z

Yeah best to only use single arity non-variadic fns, they compile down to normal JS fns.

pesterhazy 2017-07-05T20:41:01.013769Z

ok. thanks for your help!

pesterhazy 2017-07-05T20:43:17.082373Z

apparently this behavior is "designed": https://github.com/expressjs/express/issues/2289#issuecomment-51511610

rauh 2017-07-05T20:45:09.138517Z

Haha I could go on rambling about JS/Node ecosystem. But I'll just leave it at "super dumb". 🙂

richiardiandrea 2017-07-05T21:02:30.664664Z

Lol this made my day 😀