Fork me on GitHub
#shadow-cljs
<
2018-05-28
>
bupkis10:05:41

Hello. Does anybody else have issues with Vim and the latest shadow-cljs (2.3.28). I upgraded from 2.3.23 to make use of the build hooks, and my vim-fireplace setup stopped working. When I do "Piggieback :build-id" from Vim, with 2.3.23 everything works, but with 2.3.28 I get the following error:

bupkis10:05:48

in vim:

Error detected while processing function <SNR>28_piggieback[1]..fireplace#platform:
line   32:
E605: Exception not caught: Fireplace: :Connect to a REPL or install classpath.vim

bupkis10:05:42

in shadow-cljs console:

[2018-05-28 13:02:24 - SEVERE] Unhandled REPL handler exception processing message {:id fireplace-lap1-1527501741-5, :op clone}
java.net.SocketException: Socket closed
        at java.base/java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:118)
        at java.base/java.net.SocketOutputStream.write(SocketOutputStream.java:155)
        at java.base/java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:81)
        at java.base/java.io.BufferedOutputStream.flush(BufferedOutputStream.java:142)
        at clojure.tools.nrepl.transport$bencode$fn__20978.invoke(transport.clj:103)
        at clojure.tools.nrepl.transport.FnTransport.send(transport.clj:28)
        at clojure.tools.nrepl.middleware.session$register_session.invokeStatic(session.clj:144)
        at clojure.tools.nrepl.middleware.session$register_session.invoke(session.clj:137)
        at clojure.tools.nrepl.middleware.session$session$fn__22346.invoke(session.clj:188)
        at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__21967.invoke(middleware.clj:22)
        at shadow.cljs.devtools.server.nrepl$start$fn__22599.invoke(nrepl.clj:344)
        at clojure.tools.nrepl.server$handle_STAR_.invokeStatic(server.clj:19)
        at clojure.tools.nrepl.server$handle_STAR_.invoke(server.clj:16)
        at clojure.tools.nrepl.server$handle$fn__22419.invoke(server.clj:28)
        at clojure.core$binding_conveyor_fn$fn__5476.invoke(core.clj:2022)
        at clojure.lang.AFn.call(AFn.java:18)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:844)

bupkis10:05:05

vim-fireplace is the latest version, cider-nrepl is 0.17.0

thheller10:05:31

did you restart the server properly? I don't use vim-fireplace so I can't say what happens on that side

bupkis10:05:50

yes, I also tried on a clean empty project from scratch

bupkis10:05:19

and I can reproduce that 2.3.23 works, and 2.3.28 doesn't

thheller10:05:19

nrepl is driving me crazy. I suspect its caused by a change I did to try an fix https://github.com/thheller/shadow-cljs/issues/273

thheller10:05:20

although I have no idea how that has any effect at all in clone

thheller10:05:07

but all the messages tell me is that a socket was closed

thheller10:05:28

are you positive that the close is not initiated by vim-fireplace?

bupkis10:05:41

it probably is, but why does it work with the older shadow-cljs version?

thheller10:05:42

not a clue. unfortunately I don't have a vim-fireplace setup to test any of it

thheller10:05:33

is there a quick an easy way to set that up without doing a million things?

thheller10:05:59

assuming ZERO vim config present?

bupkis10:05:08

would a container do? if yes I can write a dockerfile for you to run vim in

thheller10:05:57

dunno I'm on windows and docker-compose stuff seems to require windows pro

bupkis10:05:09

how can I run a dev build of shadow-cljs itself? maybe it would be easier if I try to isolate the changes you mentioned above than try to setup vim on windows

bupkis10:05:13

(i don't have windows at all)

thheller10:05:49

you can clone the repo and run lein with-profiles +cljs repl and then (require 'repl) (repl/go)

thheller10:05:11

the connect to the started nrepl server at localhost port 8202

thheller10:05:27

(not the nrepl provided by lein)

thheller10:05:59

that setup has a bunch of debug stuff enabled. among other things it prints all nrepl messages to the console

thheller10:05:41

might need to bump cider-nrepl in project.clj first. its still v16

bupkis10:05:47

thanks. cloning now. i'll try with 16 first, then bump to 17, etc. until I isolate it.

tianshu10:05:04

@thheller is that if use tools.deps or leiningen for dependency management, shadow-cljs will ignore -d command line argument?

tianshu10:05:42

is this designed?

thheller10:05:36

well when either of those the classpath is constructed by them

thheller10:05:09

so you should probably be using them directly if you need stuff like that

thheller10:05:12

if you use lein the command is printed on startup, you can literally just use that instead

tianshu10:05:50

for editor users (like emacs cider), it will inject dependencies by using -d, this will not work if I use leiningen or tools.deps.

thheller10:05:32

if you are using lein use the emacs built-in support for lein?

tianshu10:05:14

cider now has built-in support for shadow-cljs.

thheller10:05:26

I guess it should be possible to modify https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/npm/cli.cljs#L272-L293 to inject dependencies for lein as well (or tools.deps)

tianshu10:05:02

I'll take a look, to see If I can make a PR for it.

thheller10:05:12

I know but with :lein you are effectively using lein not shadow-cljs

thheller10:05:15

it just delegates

bupkis10:05:11

@thheller 8bb0cf436a928a804e42ec094e77b7e774a5aac3 is where it breaks fireplace.

thheller10:05:30

if you tell me the the command line for lein to add those deps I can add it

thheller10:05:35

@samuel.wagen hmm I guess that makes sense

bupkis10:05:28

Successful session:

user=> [13:38:34,327] nrepl-receive {:id "fireplace-lap1.local-1527503914-1", :op "clone"}
[13:38:34,332] nrepl-receive {:id "fireplace-lap1.local-1527503914-2", :op "describe", :verbose? 1}
[13:38:34,367] nrepl-receive {:code "[(System/getProperty \"path.separator\") (System/getProperty \"fake.class.path\")]", :id "fireplace-lap1.local-1527503914-3", :op "eval"}
[13:38:34,373] nrepl-receive {:id "fireplace-lap1.local-1527503914-4", :op "classpath"}
[13:38:36,086] nrepl-receive {:id "fireplace-lap1.local-1527503914-5", :op "clone"}
[13:38:36,089] nrepl-receive {:id "fireplace-lap1.local-1527503914-6", :op "describe", :verbose? 1}
[13:38:36,119] nrepl-receive {:code "[(System/getProperty \"path.separator\") (System/getProperty \"fake.class.path\")]", :id "fireplace-lap1.local-1527503914-7", :op "eval"}
[13:38:36,125] nrepl-receive {:id "fireplace-lap1.local-1527503914-8", :op "classpath"}
[13:38:36,132] nrepl-receive {:id "fireplace-lap1.local-1527503914-9", :op "clone"}
[13:38:36,135] nrepl-receive {:code "((or (resolve 'cider.piggieback/cljs-repl)(resolve 'cemerick.piggieback/cljs-repl)) :browser)", :id "fireplace-lap1.local-1527503914-10", :op "eval"}
[13:38:37,311] nrepl-receive {:id "fireplace-lap1.local-1527503914-11", :op "close"}
[13:38:37,314] nrepl-receive {:id "fireplace-lap1.local-1527503914-12", :op "close"}
[13:38:37,316] nrepl-receive {:id "fireplace-lap1.local-1527503914-13", :op "close"}
Bye for now!

bupkis10:05:50

Failed session:

user=> [13:39:21,353] nrepl-receive {:id "fireplace-lap1.local-1527503961-1", :op "clone"}
[13:39:21,357] Unhandled REPL handler exception processing message {:id fireplace-lap1.local-1527503961-1, :op clone}
java.net.SocketException: Socket closed
	at java.base/java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:118)
	at java.base/java.net.SocketOutputStream.write(SocketOutputStream.java:155)
	at java.base/java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:81)
	at java.base/java.io.BufferedOutputStream.flush(BufferedOutputStream.java:142)
	at clojure.tools.nrepl.transport$bencode$fn__724.invoke(transport.clj:103)
	at clojure.tools.nrepl.transport.FnTransport.send(transport.clj:28)
	at clojure.tools.nrepl.middleware.session$register_session.invokeStatic(session.clj:144)
	at clojure.tools.nrepl.middleware.session$register_session.invoke(session.clj:137)
	at clojure.tools.nrepl.middleware.session$session$fn__1254.invoke(session.clj:188)
	at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__903.invoke(middleware.clj:22)
	at shadow.cljs.devtools.server.nrepl$start$fn__20723.invoke(nrepl.clj:344)
	at clojure.tools.nrepl.server$handle_STAR_.invokeStatic(server.clj:19)
	at clojure.tools.nrepl.server$handle_STAR_.invoke(server.clj:16)
	at clojure.tools.nrepl.server$handle$fn__1327.invoke(server.clj:28)
	at clojure.core$binding_conveyor_fn$fn__5476.invoke(core.clj:2022)
	at clojure.lang.AFn.call(AFn.java:18)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:844)

thheller10:05:36

I suspect the added :greeting-fn maybe?

bupkis10:05:20

let me try removing it

thheller10:05:36

maybe vim-fireplace doesn't like receiving random out messages

thheller10:05:45

and just drops the socket

tianshu10:05:20

I'll post a issue for that

bupkis10:05:32

@thheller spot on, without greeting-fn HEAD works

thheller10:05:59

@samuel.wagen ok. I'll remove that, doesn't serve any real purpose anyways

bupkis10:05:13

cheers, thank you!

bupkis10:05:10

vim-fireplace is too fragile, but AFAIK there isn't a better alternative yet

bupkis10:05:33

stupid question - how can I use a shadow-cljs dev version with my code?

thheller10:05:43

its gone in master

thheller10:05:57

best option is probably just lein install

thheller10:05:11

that installs over the current 2.3.28

thheller10:05:23

then use as usual

bupkis10:05:31

i don't have it global, i only have it as a devDependency in packages.json and use npx shadow-cljs

thheller10:05:42

the npm part doesn't matter

thheller10:05:22

hang on, I can just make a release with the fix as well

bupkis10:05:28

works fine, vielen Dank!

bupkis10:05:42

I guess I ought to try Cursive, but too many years in Vim have damaged me I guess 😄

bupkis10:05:04

btw. the new build-hooks stuff is very useful!

bupkis11:05:29

I use it to expose the git commit hash (and dirty status) as a Closure define, which exposes it to the CLJS code in the browser. Enables me to have that hash in my telemetry so that when I report client exceptions from the browser, I also have a way to pinpoint the exact code revision.

tianshu11:05:43

https://github.com/thheller/shadow-cljs/issues/286 I just post a issue for this, If you don't have time, I think I can help:sunglasses:

heyarne11:05:38

is there a reason why #shadow-connection-error is position: absolute and not position: fixed?

👍 4
thheller11:05:57

not really 😛

Bravi13:05:55

I love how there’s a channel for everything 😄

thheller13:05:13

:http-host should just be the host, not a url.

thheller13:05:28

the websocket by default assumes you are running locally. it that not the case?

thheller13:05:04

deomens-l53.test is that your machine?

Bravi13:05:11

so I’ve got vagrant running and the virtual host is that yes

Bravi13:05:38

deomens-l53.test/admin
this page is served from php

thheller13:05:11

and shadow-cljs is running in vagrant or outside?

Bravi13:05:13

and within that page I have my div#application and then the <script> where my cljs app lives

Bravi13:05:18

it’s outside of vagrant

Bravi13:05:21

at the moment

thheller13:05:44

ok then you probably need to configure :devtools {:devtools-url ""} in your build config

thheller13:05:19

since the setup assumes everything is running on the same machine which it isn't when running in vagrant

Bravi13:05:15

and I guess now I need to redirect these requests to localhost, right?

thheller13:05:55

can you open ?

thheller13:05:25

if so you don't need anything else. :devtools-url just configures where the websocket tries to connect to

Bravi13:05:48

yep I can and it says shadow-cljs.. and then release snapshots

thheller13:05:21

it used because you are probably on ... somewhere

Bravi13:05:23

that’s the whole page basically

thheller13:05:29

yep, that is correct

thheller13:05:58

you can remove :http-port and :http-host from your config

thheller13:05:41

just set the :devtools {:devtools-url ""} and you should be good

thheller13:05:00

assuming of course that you are compiling the files somewhere the vagrant php server can see them?

thheller13:05:01

are you using laraval?

Bravi13:05:19

that solved it

Bravi13:05:23

and yes I’m using laravel

Bravi13:05:35

thank you so much 😄

Bravi13:05:01

so the first issue was that I had both - http-host and devtools-url as well

Bravi13:05:08

and when I removed http-host

Bravi13:05:29

I just had an extra forward slash in the end here ->

Bravi13:05:35

silly mistake

thheller13:05:27

ah right. I should probably validate that

Bravi13:05:49

this is so cool! finally! 😄

Bravi13:05:06

thank you for this awesome tool

Bravi13:05:31

and to use some third party react components, can I not do [:> some-react-class] anymore?

thheller13:05:36

sure you can

Bravi13:05:50

i’m getting Uncaught Error: Assert failed: Expected React component in: [:> #js {:DayPicker #object[b], :DateUtils #js...

thheller14:05:05

looks like you are passing the wrong thing? maybe [:> foo ..] instead of [:> foo/DayPicker ...]?

Bravi14:05:11

that’s it! I thought it was importing the actual component under foo but now I understand how it works

Bravi14:05:13

thank you again 😄

justinlee16:05:22

is there anyway to kick off an arbitrary shell action when running a watch? I just need to run a node-sass watch target to compile my sass. it seems like a lot of complexity to add lein in just to do that

thheller16:05:17

oh another watch

thheller16:05:10

well the idea for things with state is plugins. not yet documented or final. but the idea is this: https://github.com/thheller/shadow-cljs/blob/master/src/dev/demo/dummy_plugin.clj

thheller16:05:37

a plugin defining a clojure map with :start and :stop functions

thheller16:05:07

when server starts the :start function is called. whatever that returns will be called be passed to :stop on server shutdown

thheller16:05:56

so you could start a java.lang.Process in :start and .destroy that in stop

thheller16:05:29

enabled via :plugins [demo.dummy-plugin] in shadow-cljs.edn

thheller16:05:21

:depends-on can be used if you want access to some of the other shadow-cljs components

heyarne17:05:37

does anybody have an example for a .travis.yml with shadow-cljs & karma tests?

heyarne18:05:12

managed to set this up btw. You can find it here: https://github.com/heyarne/airsonic-ui

heyarne18:05:56

@lee.justin.m you can also check out https://github.com/heyarne/airsonic-ui. I've set up parallel builds w/ sass --watch and shadow-cljs watch using npm scripts

justinlee15:05:32

@arne-clojurians this is a much easier way of doing it and I learned about the run-p command. thanks!

kwladyka18:05:01

I have file /src/cm/theme.js

const theme = createMuiTheme({
  palette: {
    primary: purple,
    secondary: green,
  },
  status: {
    danger: 'orange',
  },
});
How to use theme in cljs?

kwladyka18:05:35

I tried ["/cm/theme.js" :refer [theme]] but it doesn’t work

thheller18:05:56

did you export it?

thheller18:05:04

export { theme };

kwladyka18:05:40

What do you mean? Export where, how?

thheller18:05:54

where does createMuiTheme come from?

thheller18:05:03

import or require?

kwladyka18:05:13

import { createMuiTheme } from '@material-ui/core/styles';
import purple from '@material-ui/core/colors/purple';
import green from '@material-ui/core/colors/green';

const theme = createMuiTheme({
  palette: {
    primary: purple,
    secondary: green,
  },
  status: {
    danger: 'orange',
  },
});
This is whole content of js file

kwladyka18:05:24

it is example from material-ui page

thheller18:05:25

either export const theme = ...

thheller18:05:34

or export { theme }; somewhere

kwladyka18:05:08

ok so unless export it I can’t use variable from there?

thheller18:05:09

only exported variables are visible to others

thheller18:05:33

normal ESM behaviour

kwladyka18:05:38

["/cm/theme.js" :refer [theme]] is ok to import it to cljs?

kwladyka18:05:59

I am weak about JS itself, I have a long break to code directly in JS

kwladyka18:05:18

it works 🙂

thheller19:05:38

the one thing that is a bit dangerous when doing JS directly is externs

thheller19:05:47

since externs inference only works for CLJS

thheller19:05:20

so release might get you into trouble

kwladyka19:05:37

There is one thing which make more in doubt if I want keep theme in js. I wrote text-decoration instead of testDecoration and error is visible only in console. Not in web browser. Because of that I will probably stay with cljs.

thheller19:05:23

yeah JS support is still pretty rough. I need to work on it a bit more but no time

kwladyka19:05:12

sure, just feedback

kwladyka19:05:19

you are doing great job

theeternalpulse21:05:36

how do I make React exposed as a global through the config? I'm using cljss and the macros expand to js/React calls.