Fork me on GitHub
#clojurescript
<
2016-11-27
>
langmartin00:11:34

hi! I'm stuck on a frustrating compilation problem; compilation is working fine, but actually attempting to call many procedures just produces an error like

#object[TypeError TypeError: undefined is not an object (evaluating 'adhoc.core.util')]

langmartin00:11:09

the missing code is in .cljc files, so I think I'm looking for a difference in a single file that could cause require to ignore others, maybe? the util namespace, for instance, is unchanged from an older version that both compiles and is usable. Is there a way to get a more specific error message in the case that a namespace fails to load?

langmartin00:11:15

calling require on that namespace does not return an error, but calling procedures defined inside it still fails

dnolen01:11:11

@langmartin each namespace ends up with a corresponding script tag in the DOM - you should be able to look at the DOM and verify that your namespace did in fact get loaded

dnolen01:11:42

if you see the script tag there - then perhaps you overwriting definitions (namespaces and vars can clash) - the compiler warns about this

langmartin01:11:06

@dnolen yes! I sorted that out. I think what happened is that rum/mount failed a bit, and was mounting to a div with the id adhoc, which is also the root of my namespaces

langmartin01:11:30

adhoc in the debug console certainly ends up bound to a dom object

dnolen01:11:54

yes that’s another way things can go wrong

langmartin01:11:06

in the case that it mostly works, I can still hit my namespaces. in the case that it fails, I end up with a dom object in place of it

langmartin01:11:11

that part I don't understand

dnolen01:11:24

just avoid it

dnolen01:11:34

don’t give your DOM nodes ids that clash with your namespaces

langmartin01:11:39

@dnolen thanks, that helps

dnolen01:11:43

sadly that’s not really a case that's easy for us to detect

langmartin01:11:05

sure, it makes sense why it'd be difficult to detect

dnolen01:11:19

we just defer to Google Closure for the namespace stuff

langmartin01:11:06

If I didn't just miss a note in the docs to that effect, it might belong on a list of gotchas somewhere. I might have missed a doc

dnolen01:11:38

it’s a known thing but I don’t know if it’s really written down anywhere

dnolen01:11:50

would be a good thing for a FAQ of some kind on the http://clojurescript.org website though

ericnormand03:11:02

when I compile a simple "Hello World!" in ClojureScript with advanced optimizations, it compiles to 94k or ungzipped code

ericnormand03:11:13

is this expected?

ericnormand03:11:40

why doesn't it eliminate most of it to turn into just console.log("Hello, World!") ?

martinklepsch04:11:14

@ericnormand: if you use str case without an else case and stuff like that this can be pretty significant when trying to produce really small builds

martinklepsch05:11:32

@dnolen: @langmartin there's this discussion no the Closure library mailing list which has a bit more context on that problem: https://groups.google.com/forum/m/#!searchin/closure-library-discuss/cRYwOSIzALg

thheller10:11:57

@ericnormand it is somewhat expected yes, not a goal to optimize this as any program that actually uses cljs.core will retain this much anyways

ewen13:11:19

Hi there. I did en emacs mode for clojure, it supports compiling clojurescript at the repl, no file watcher needed. It also support cljs autocompletion, eldoc style documentation and jump to definition. I would love for someone to try and give me feedback. https://github.com/EwenG/replique.el

gklijs14:11:26

I just started playing around with clojurescript. It's a game, which runs only in js, now I want to make a back-end run with clojure, so multiple users can be in the same environment. Would it be best to try to make it one project, or two seperate ones? Eventually I wanted to make it one project, but looking at https://8thlight.com/blog/andrew-zures/2014/03/08/combining-clj-and-cljs-libraries.html it seems a little harder then I thought, also some logic will be moved to the back-end, but I think little to none of the logic will be shared.

kauko14:11:24

@gklijs that blog post uses .cljx. I believe you should use .cljc nowadays if you want to write code that runs in both clojure and cljs

kauko14:11:16

What do you mean by having multiple users in the same environment? Do you mean you want the game to use a server for multiplayer, or something else?

gklijs14:11:55

yes, multiplayer, so actually little to none code which will need to run on both sides

kauko15:11:41

So you'd run the cljs game in the client, and you have a server written in clojure. Just like a normal web application, or even just a web site 🙂 There's nothing difficult or strange about it.

kauko15:11:46

Keep them in the same project

gklijs15:11:31

And just use a seperate main folder for both?

kauko15:11:37

src/cljs, src/clj and src/cljc is a good way to split it

kauko15:11:39

You can look at any of the popular templates and see how they do it. You don't need to use the template if you don't want to, just use it as an example

kauko15:11:54

Luminus is a good one, though it may come with a lot of stuff you don't need 🙂

gklijs15:11:15

ok, I'll do that, thanks

gklijs15:11:30

It seems a good fit, I was already using bootstrap, but with the loose minified js files added as source to the html

ericnormand16:11:25

@martinklepsch @thheller the reason I ask is someone was asking me about splitting up their modules

ericnormand16:11:37

if each piece is 95k, it's not really worth it

thheller16:11:15

@ericnormand if you do modules only one will contain cljs.core

thheller16:11:44

the others start at 0kb

thheller16:11:04

oh what do you mean by modules though? closure modules or js modules? not the same thing 😛

Aron18:11:36

so here is my current problem with clojurescript (besides the obvious jvm), if I want to pick up Elm, the error messages help me. If I want to pick up React, Angular, the error messages do not help, but I can dive into the code. But if I want to learn clojurescript, I have nothing what to look for and the error message is not really helpful.

Aron18:11:26

at least if I google, i would expect to find some help, but no, even when it looks its relevant, it's not useful. how do clojurescript people find information? where do you search?

rauh18:11:24

I actually just click on the exception, and we have awesome source maps so you see right where the problem originated since you have the full stack available

rauh18:11:28

On a cljs day I have about ~10-15 Exceptions, and it usually takes me <1min to fix them.

bbloom18:11:59

i’ve been out of cljs land for a while - is piggieback/weasel still the preferred browser repl setup?

richiardiandrea19:11:48

@bbloom the alternative is dirac but you execute code in the google dev console

thheller19:11:34

@bbloom I would say figwheel is the preferred browser REPL ... no idea about the state of nREPL. I think figwheel does it but I don't know.

dnolen19:11:38

@bbloom piggieback and weasel haven’t developed much - figwheel is what most people use

bbloom19:11:53

i see that figwheel now has it’s own browser repl in it - but what about talking to my repl from a remote process? ie from vim? that still needs piggieback from what i can tell

dnolen19:11:12

@ashnur we try to produce informative error messages when we can and some tools do better (Cursive, Figwheel). This is also why wes spent so much time on decent source mapping - just set a breakpoint if you’re really lost.

dnolen19:11:47

@bbloom right, I haven’t been keeping up with the vim story for Clojure

bbloom19:11:14

i had all this stuff working at some point, but i have lost all this arcane knowledge

bbloom19:11:50

there’s still WAY TOO MANY things i need to add to my project to get a simple thing working

dnolen19:11:49

@bbloom I’ve been sticking with Maven + simple Clojure scripts and life is significantly less complicated

dnolen19:11:27

my impression is that Boot alleviates some of the issues - but I’m a Cursive person and the integration isn’t there yet for Boot

bbloom19:11:39

@dnolen yeah, i had project.clj w/ all the deps listed & NO PLUGINS, then just ran everything from a dev.clj file

bbloom19:11:47

i was looking at boot this morning

richiardiandrea19:11:07

depending on your editor also, figwheel uses piggieback underneath so in any case you need it in the dep vector, more info here: https://github.com/bhauman/lein-figwheel/wiki/Using-the-Figwheel-REPL-within-NRepl#launching-the-figwheel-cljs-repl

bbloom19:11:11

i’m done w/ opaque config files - just not interested any more

richiardiandrea19:11:19

I'd say boot's setup is easier

dnolen19:11:51

that said it’s possible to use Lein as a thin layer over Maven and mostly avoid the complications

dnolen19:11:10

still that doesn’t really help with the Vim integration

dnolen19:11:20

somebody should really get a minimal socket REPL thing going and avoid all the nREPL complications

richiardiandrea19:11:27

(I am kind of working on making the client a bit more figwheel-like though, the experience is different, aka, no very cool and nice error messages at the moment)

anmonteiro19:11:02

@bbloom a while ago I put together a minimal project just demoing how to get a (reloading) CLJS setup with Boot: https://github.com/anmonteiro/cljs-simple-reload

bbloom19:11:28

that’s what my build.boot script looks like almost so far

dnolen19:11:39

@ericnormand it’s always been like that - for like 5 years 🙂 we don’t really care though

anmonteiro19:11:07

if you can connect to nREPL in Vim, you should be able to get a CLJS REPL setup too

dnolen19:11:18

94k ungzipped is smaller than dropping jQuery or React onto a webpage which most people are doing

anmonteiro19:11:29

that said I can't really help with the Vim stuff as I don't use it

bbloom19:11:47

vim-fireplace works perfectly if i could just get a the weasel repl going

bbloom19:11:53

i forgot how i used to do all this

bbloom19:11:26

@anmonteiro thanks for that - that’s much simpler than the other cljs examples i’ve seen for boot

juhoteperi19:11:33

@bbloom @anmonteiro Boot-cljs-repl should work fine with Vim-fireplace, just run :Piggieback (adzerk.boot-cljs-repl/repl-env) once you have Boot running and the app open in browser

richiardiandrea19:11:53

^ oh cool didn't know that

bbloom19:11:06

oooh yeah, now i remember why i found boot so annoying - the insistence on all the commandline integration stuff

bbloom19:11:13

two ways to do EVERYTHING

richiardiandrea19:11:00

@bbloom you can execute tasks at the repl with (boot.core/boot (dev))

bbloom19:11:07

i’m using http-kit, but this serve script says to pass —httpkit

bhauman19:11:17

'vim-fireplace' doesn't have anywhere near the commitment that cider or cursive has ... just the way it is right now

bbloom19:11:31

that’s b/c vim-fireplace was done

bbloom19:11:35

it had exactly the features i wanted from it

bhauman19:11:41

No such thing

bbloom19:11:48

no, seriously, it was done 😛

bhauman19:11:15

Wow there's no more work for me to do then

bbloom19:11:40

all i want from vim integration is the ability to eval a form under the cursor

bhauman19:11:43

This world is in motion

bbloom19:11:45

that’s not a statement about external tooling

bhauman19:11:04

I get what you are saying

bhauman19:11:29

But nonetheless things have changed

juhoteperi19:11:50

Vim supports async operations nowadays, vim-fireplace doesn't

juhoteperi19:11:00

So to be honest, it is not perfect

dnolen19:11:26

Another problem I've perceived from feedback is that it appears momentum behind spacemacs is taking effort from where it might otherwise be applied to improving Vim integration

bbloom19:11:19

what i don’t understand is why i have so much problem with these sorts of things? am i wrong in perceiving everybody else as having this stuff all working fine?

bbloom19:11:33

it seems like no matter what what language/ecosystem i stumble in to, the standard tools fight me every step of the way

bbloom19:11:56

and then i just gut all the crazy stuff and replace it with a shell script & my life is better

bbloom19:11:35

except go - the tooling there is great 😛

dnolen19:11:29

Well at some point you're confined by taste and time - wanting to use vim and not wanting to contribute to fixing the tooling ;)

bhauman19:11:49

The complexity is real, and leaving the blessed paths is more painful

bbloom19:11:09

@dnolen i did contribute to fixing the tooling - i bought tpope beer and coached him through how vim fireplace should work 😉

richiardiandrea19:11:57

tooling and ide integration is hard, I am going through a lot of of pain trying to use emacs and java

dnolen19:11:14

If the old thing doesn't work that would be news to me - we haven't changed anything around REPLs in 2 years or so

bbloom19:11:21

but it’s stuff like this that blows my mind: https://github.com/pandeiro/boot-http/issues/25 - if i ^c the dev task in a boot repl, i have to kill & restart my repl to kill the http server

bbloom19:11:32

or forcibly close the port externally, causing a crash

bbloom19:11:15

@dnolen ok - i’m going to revive my old approach of manually running hte cljs compiler, weasel repl, etc

bbloom19:11:04

maybe? maybe in ny/bk

bbloom20:11:50

@dnolen you may have the right idea going full maven

juhoteperi20:11:44

If the tool is only used to manage (download) deps, it doesn't matter if it is Maven, Lein or Boot

bbloom20:11:40

yeah, that’s all i’m using it for.... in fact, just doing: export CLASSPATH=$(lein classpath) java -jar clojure.main ........

Aron20:11:57

@dnolen, i am not sure where i could set a breakpoint 🙂, i am not there yet. I just get a cryptic error message from figwheel that resource not found and i see zero leads what can be wrong

bbloom20:11:21

aaaaaand i have everything i want working now - took 15 minutes

richiardiandrea20:11:37

@bbloom what did you end up using?

bbloom20:11:06

manually run http-kit server, w/ manually configured wrap-file ring middleware, with manually run cljs.build.api/watch, with manually run weasel/nrepl server

bbloom20:11:29

< 15 lines of code total - no magic

richiardiandrea20:11:09

oh cool, with auto-refresh/auto-reload in the browser as well?

bbloom20:11:35

i just eval the file & it refreshes the browser

bbloom20:11:41

i prefer that over save-to-refresh

bbloom20:11:56

so i can eval individual forms

richiardiandrea20:11:54

yes that's is what I like as well, I would love to see your conf, would you mind sharing? 🙂

bbloom20:11:42

give me a few minutes - dealing with some project-specific stuff & then i’ll extract relevant bits

dnolen20:11:59

@ashnur: that means it can't find your file. You need to follow classpath conventions

richiardiandrea20:11:06

@bbloom ah ah no take all the time you want of course 😄

dnolen20:11:12

If you haven't read the Quick Start you really should

Aron20:11:31

@dnolen eh, i didn't see that i should load the file through the filesystem. I was trying the server through ssh. I just found out now because @bhauman bring it to my attention that i am trying something that is not expected to work.

bbloom20:11:01

@dnolen didn't you work with chas at somepoint to make piggieback work with the standard builtin browser websocket repl?

bbloom20:11:48

hm ok thought you guys did

dnolen20:11:06

it was weasel that worked that way

dnolen20:11:28

and I think you could integrate weasel + piggieback to get nREPL integration?

bbloom20:11:00

yeah, that’s what i’m doing now: running my clojure repl directly via java -jar and then starting an nrepl server for cljs use

dnolen20:11:48

I think I looked at it but too many moving parts for me

bbloom20:11:17

yeah, that’s more or less why i’ve never got involved w/ the tooling stuff - so much stuff going on that i just don’t have the patience to understand it all

dnolen20:11:01

like I said, Socket REPL really simple - people should consider rethinking tooling around it

bbloom20:11:28

yeah, that’s why i asked about it - i’d rather use that, but fireplace relies on nrepl (and hence piggieback for cljs)

anmonteiro20:11:52

definitely agreed with the socket REPL stuff

anmonteiro20:11:04

would also help e.g. Planck & Lumo downstream 🙂

bbloom20:11:05

also, i really dislike anything with middleware 😛

bbloom20:11:23

middleware is like callbacks bad - hey, let’s invert control b/c IT’S FUNCTIONAL!

anmonteiro20:11:06

Lumo has builtin support for a simple socket REPL - integrating with nREPL for example is just far beyond the scope

bbloom20:11:07

i have a great way to compose procedures, it’s called do 😛

anmonteiro20:11:20

I'm definitely not going to spend any time doing it

potetm20:11:03

Am I doing something wrong, or does cljs.build.api/build require that macro files be on the java classpath as opposed to in the passed source dir?

potetm20:11:12

It would make sense if that were the case. I just kind of assumed it would pick it up from either.

anmonteiro20:11:51

@potetm I'm pretty sure they need to be on the classpath, or else the ClojureScript compiler would have to mess with adding them dynamically

bbloom20:11:27

richiardiandrea thanks, but the problem isn’t understanding the concepts - it’s just dealing w/ the complexity of configuration

bbloom20:11:50

there’s numerous ports involved in doing even the simplest of things & they are all configured differently, run from different jvms, etc

richiardiandrea20:11:55

I think the middleware approach is not that bad. For instance I was looking at Java/Clojure mixed project and at how to use middleware on top of nrepl for providing functionalities. For instance there could be a jdk-middleware that provides stuff to Scala/Java/Clojure projects, then the cider-nrepl middleware only Clojure specific stuff

bbloom20:11:26

the middleware pattern is universally a bad idea

bbloom20:11:47

what benefit does it provide over function calls?

richiardiandrea20:11:06

yeah you are right there is no real advantage...the problem is that nrepl tooling was built that way

bbloom20:11:28

nrepl is excessively complex

richiardiandrea20:11:38

Yeah...compromise right? it is the eternal battle of declarative vs code/lein vs boot/ yada (that has interceptors) vs ring, I personally have always preferred coding...but I agree with you about the complexity

bbloom21:11:37

i don’t believe that “declarative” is a goal unto itself, nor do i believe it is at odds with “code"

richiardiandrea21:11:01

The real problem to solve probably is: given a repl server, what is the best way for devs to add functionality in there. What cider-repl and refactor-nrepl do is basically just provide functions and a layer of responses, potentially there could be a cursive-nrepl middleware (maybe there is one already). There probably is a better way then middleware but nobody has had time yet to work on it

bbloom21:11:37

there’s no functionality to be added to the repl server - the repl server shouldn’t do anything other than shuffle bits back and forth

bbloom21:11:45

it should do one and only one thing: eval

bbloom21:11:56

edn-in, edn-out

bbloom21:11:03

even simpler: text in, text out

bbloom21:11:22

that’s precisely the problem with nrepl: it has features

bbloom21:11:29

the socket repl does not

bbloom21:11:36

and yet it does precisley what people want from it: it evaluates code

bbloom21:11:43

.... from the network

bbloom21:11:46

hell, netcat + a non-networked repl should be able to do the job

mfikes21:11:47

Yes, the only small thing Socket REPL really does above netcat is “isolation” of things like *1, *2, in the event that you have multiple connections 🙂

bbloom21:11:14

^^ perfect 🙂

richiardiandrea21:11:16

I agree with this point as well. But at some point you would need to provide those features for "high-level" tooling like cider I guess

bbloom21:11:42

why can’t those high level tools evaluate function calls?

thheller21:11:14

@bbloom the problem with socket REPL i see is that it has absolutely no messaging semantics

thheller21:11:22

ie. javascript is completely async

thheller21:11:46

whereas in clojure you can have edn-in edn-out simply

thheller21:11:57

cljs has to deal with many more situation

thheller21:11:03

ie. no browser is connected

bbloom21:11:03

i don’t understand how that is a problem at all

bbloom21:11:07

it works… just fine

thheller21:11:08

multiple browsers are connected

bbloom21:11:13

that also works w/ socket repl

thheller21:11:18

data arrives async

thheller21:11:10

ie. in the jvm it is very easy to capture stdout/stderr

thheller21:11:17

that is not true for js

bbloom21:11:24

that’s totally unrelated to the problems of nrepl

thheller21:11:47

I'm talking about socket REPL, ... edn-in/edn-out as you suggested

thheller21:11:00

it's not quite that easy though

bbloom21:11:09

.... but it is, and it works ....

bbloom21:11:22

the problem i have is vim-fireplace is built on nrepl, which existed before the socket repl

thheller21:11:44

well yes.. nREPL is quite horrible

thheller21:11:56

but it solves many issues socket-repl does not solve

thheller21:11:17

and are somewhat harder to solve for cljs than clj

bbloom21:11:50

i’m not convinced that’s true, given how nicely the simpler cljs repl seems to work for me .... until i need vim integration

mfikes21:11:08

Does any IDE/editor yet support Socket REPL? (Just curious.)

thheller21:11:32

doesn't vim have something like inferior-lisp for emacs?

potetm21:11:33

I wish... ^ Would especially like to see it for Cursive soon.

thheller21:11:47

just spawn a process and use stdin/stdout?

mfikes21:11:17

I made a small “bridge” (Tubular), but I’d like to see tools directly support Socket REPL.

bbloom21:11:25

thheller: unfortunately, vim has long been ilequipped for these sorts of use cases

bbloom21:11:31

the assumption was that you would shell out to external tools

thheller21:11:43

so the problem really isn't on the cljs side

bbloom21:11:44

the latest vim has async functionality

thheller21:11:50

but the vim requires nrepl?

bbloom21:11:03

that’s my problem right now

thheller21:11:23

don't shoot me but ... did you ever try emacs + evil mode? (I was a vim-user myself before that)

juhoteperi21:11:28

Slimv should work like inf-lisp

bbloom21:11:55

i used slimv for a long time before fireplace

cfleming21:11:59

@mfikes Not that I’m aware of, no.

cfleming21:11:13

@potetm I’m definitely planning this, as part of adding CLJS REPL support.

juhoteperi21:11:30

Fireplace has been built with support for multiple protocols in mind, so adding Socket REPL support might be feasible. At least it shouldn't require complete rewrite.

juhoteperi21:11:27

And the low level connection code in Fireplace is already async, it just the "user interface" code that is synchronous.

richiardiandrea21:11:32

Talking about tooling @ewen came up with a nice one it seems, it was on #announcements earlier on

thheller21:11:36

one extra problem for a CLJS-REPL is that you kind of want 2 enpoints

thheller21:11:41

one to talk to the cljs side

thheller21:11:46

one to talk to the clj side

ewen21:11:28

speaking about socket repls, replique runs on a socket repl (https://github.com/EwenG/replique.el)

ewen21:11:18

to be more precise, one socket repl by repl session (stream oriented) + 1 extra socket for tooling stuff (message oriented)

bbloom21:11:45

i don’t think separate endpoints for clj and cljs makes sense - i want to be able to switch where evaluation happens just like in-ns lets me switch namespaces

bbloom21:11:02

i think the cljs repl should support a special form for that purpose

bbloom21:11:00

@bhauman i didn’t see any of this sidecar stuff, looking at it now - might be closer to what i want

potetm21:11:13

So related to cljs dev tooling: I just deployed this to clojars: https://github.com/potetm/tire-iron

potetm21:11:20

Would love to get some feedback on it.

potetm21:11:52

Literally just pressed the button on that, so pre-alpha. But it's not monstrously complicated, so I should hope it kind of works out of the box.

bbloom22:11:55

ooooh glorious - thank you @bhauman, your stuff actually works 🙂

bbloom22:11:20

finally: single jvm, headless cljs repl, w/o having to do it myself

bbloom22:11:25

+ vim works

bbloom22:11:19

lol oook so what was i trying to do ~5 hours ago?

kzeidler23:11:00

bbloom: do you have a link handy to the resource that helped you? I'd be interested to read it

bbloom23:11:16

there’s no one resource

kzeidler23:11:10

I have a figwheel repl going that has been indeed a terrific aid to me, but I'm currently working on a project that requires a lot of inspection of various clj/s-specific namespaces. I'm running into some barriers since I don't fully understand the clj/cljs interop