Fork me on GitHub
#shadow-cljs
<
2018-10-12
>
tobiasq12:10:50

Hi, I'm having a problem when using advanced compilation using the posh library (with rum) that does reactive queries from datascript. Code works fine when using :simple optimisation but reactions do not happen with :advanced. Does anyone know a way of setting a clojurescript library to not be included in the advanced optimisation (like using externs for js?)

gklijs12:10:37

@tobias291 I don’t think thats possible, ideally you find the problem and make a pr, could be something like https://github.com/oliyh/re-graph/issues/15 (oliyth mentions some differences in settings there which might fix your problem)

tobiasq12:10:40

@gklijs thankyou - I can't find anything obvious, I think I'll create a simple test case to track down further - do you know if it's possible to get optimisation information from the compiler?

gklijs13:10:29

I don’t really know, especially not for shadow-js, maybe you can have a source map with the advanced compilation and find out which function gives unexpected results?

thheller13:10:30

@tobias291 it is not possible to exclude certain CLJS code from :advanced. which posh version do you use? the default one uses an invalid :require and doesn't compile at all

tobiasq13:10:28

@thheller I'm using a branch I made with fixes here - https://github.com/tobiasquinn/posh/tree/master-rum - and a merge from pull request here - https://github.com/mpdairy/posh/pull/30 - I'm getting closer to the problem, something isn't being pushed through to the update analysis so I'm using console outputs to compare compiled and release builds and trace back

thheller14:10:39

it may just be missing the datascript externs? they are broken. I opened a PR quite some time ago https://github.com/tonsky/datascript/pull/216

Bravi14:10:36

can I just say what an awesome tool shadow-cljs is. I used it on 3 different cljs projects and it’s just pure awesomeness and I think there is no excuse for js devs not to switch to cljs forever

👍 2
❤️ 1
aaron5114:10:26

Want to use Shadow with Expo (instead of Figwheel+Expo). Not looking to replace Metro bundler, would like to run that separately. Any examples or experiences of people doing this? (I know about thheller's clojureverse post, but that replaces Metro, which is more than I want to do)

tobiasq14:10:05

@thheller thankyou so much! That fixed it, I used the method in the PR comments of including the datascript externs.js in my compiler options

aaron5114:10:10

Thank you, we will give this a try!

thheller14:10:22

but I have virtually no experience with react-native and didn't get very far last time

thheller14:10:29

I failed getting source maps to work which kinda sucked

wilkerlucio17:10:52

hello, I'm trying to connect to a node-js repl with Shadow, I can run npx shadow-cljs node-repl and it starts fine, but that REPL runs on the terminal only, I want to connect and send commands from my editor, but when I connect to the nREPL I only get the Clojure one, how can I transition that to run from my editor targeting the node repl?

thheller17:10:36

same as always. over nrepl just call (shadow.cljs.devtools.api/repl :node-repl) so switch the nrepl session over

wilkerlucio17:10:45

ok, I think I just figured, running (shadow/node-repl) did the trick

thheller17:10:47

if the node-repl is already running that is

thheller17:10:55

otherwise yeah just node-repl

wilkerlucio17:10:08

that is simpler I think, I just start the server, connect nREPL and run that 🙂

thheller18:10:02

problem is output though

thheller18:10:11

prints only go to whereever the repl process was started

wilkerlucio18:10:31

I think that's fine, but taking the opportunity we are talking about REPL, in the Clojure REPL's when we send a form from the editor that form runs in the same NS as the file from where you ran it, but in CLJS it always use the current ns on the REPL, do you know why is the difference? and if we could have cljs to do the same as clj?

thheller18:10:48

thats a cursive thing and the way it does it for CLJ is not possible for CLJS no

thheller18:10:05

it would be trivial do add however if we just changed the nREPL middleware a bit

thheller18:10:22

but pretty doubtful that gonna happen anytime soon

wilkerlucio18:10:00

gotcha, thanks for clarifying

thheller18:10:34

FWIW this is what cursive sends if you eval a form

thheller18:10:36

"(in-ns 'shadow.cljs.devtools.api)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n(def ^:dynamic *nrepl-cljs* nil)"

thheller18:10:56

all the \n are there so that the error message matches the line of the actual file

thheller18:10:11

but it doesn't do that when you are in a CLJS REPL

wilkerlucio18:10:52

interesting, I had no idea about that

thheller18:10:45

{:file "(in-ns 'shadow.cljs.devtools.api)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n(def ^:dynamic *nrepl-cljs* nil)", :file-name "api.clj", :file-path "C:/Users/thheller/code/shadow-cljs/src/main/shadow/cljs/devtools/api.clj", :id "a2b09333-3223-4d43-9cb6-54236e79dbb8", :op "load-file"}

thheller18:10:23

its already kinda cheating since it uses load-file without an actual file (thats the full nrepl message that gets sent)

thheller18:10:33

so yeah I kinda blame Cursive 😉

thheller18:10:59

but having worked with nrepl myself I can totally understand why its done that way

thheller18:10:51

for cljs its just {:code "(prn :foo)", :id "549215c5-9e36-4eb9-9e8e-f17288de92bf", :ns "demo.browser", :op "eval"}

thheller18:10:38

doesn't it already use the file ns for eval? at least it seems so for me?

thheller18:10:34

hmm I think it may actually just be a bug?

thheller18:10:09

cursive does send the correct :ns but its just ignored

thheller18:10:19

yeah totally a bug

wilkerlucio18:10:53

nice, so we gonna get it to run in file ns? 🙂

thheller18:10:23

yeah should be doable. need to verify how emacs handles this though

thheller18:10:30

got completely distracted by the fact that a different nrepl message is sent for CLJ

thheller18:10:43

didnt even see the :ns for the CLJS message 😛

wilkerlucio18:10:35

glad you just revisited it 😛

thheller18:10:21

always ask questions if something doesn't work as you'd expect it to 🙂

markx19:10:04

Hi can someone show me how to connect to shadow repl with vim and fireplace?

haywood19:10:57

@markx when you boot shadow from the terminal, it'll start an nrepl server for you

haywood19:10:18

it prints the port the repl is on (configurable if you wanted). I'd just look up how to connect to a remote repl in fireplace

haywood19:10:30

it'll take localhost and whatever port was spit out

markx19:10:51

I know that port, but I just don’t know how to use fireplace to connect

markx19:10:28

because…I don’t need piggieback?

haywood19:10:57

uh, checking my deps, I am using a piggieback alias that's used when I boot shadow

haywood19:10:25

it's for cider though

haywood19:10:47

I highly recommend spacemacs 😂

markx19:10:24

Thanks, but not the answer I’m looking for 😂

haywood19:10:51

yea sorry I'm looking at the fireplace docs and not seeing anything about connecting to an nrepl, maybe my assumption about it was incorrect

markx19:10:10

It says to connect to cljs repl, I need to use piggieback. But then shadow doesn’t use piggieback, so I don’t know what to do now.

haywood19:10:19

are you using deps?

markx19:10:00

No, I’m using shadow-cljs

lilactown19:10:34

shadow-cljs I think provides a piggieback compatibility namespace

lilactown19:10:20

I haven't used vim-fireplace before, but however you would connect to a piggieback connection should work?

lilactown19:10:25

I wish I understood how to use vim and it's package management so I could explore more hehe

mj_langford19:10:39

TPope's Pathogen and related writings is a good resource Will.

lilactown19:10:12

sweet! thanks!

markx23:10:55

> If the popular cider-nrepl is found on the classpath it will be added automatically. No additional configuration required.

markx23:10:15

How can I find out whether cider-nrepl is found and run?

lilactown23:10:46

if you’re starting shadow-cljs from the terminal, you’ll need to add it to your dependencies