Fork me on GitHub
#shadow-cljs
<
2019-08-05
>
tianshu10:08:42

@thheller do you mean if use loader-mode :eval, source map problem is already fixed?

tianshu10:08:12

I also want to know what is the down side or limitation of eval loader-mode, for it is not the default loader-mode.

thheller10:08:19

@doglooksgood no. master has the switch to eval as a default but it is incomplete and cannot be used yet

thheller10:08:41

:loader-mode is only a thing for browser builds currently

thheller10:08:54

react-native is still a work in progress

tianshu10:08:58

that's make sense. The vote is for how to handle image only?

thheller10:08:27

the vote is how to handle require in general but mostly affects images yes

thheller10:08:54

but with the eval stuff in master it is currently not possible to use images so that needs to be solved before I can release that

tianshu11:08:55

ok, I'm go for a vot

tianshu11:08:09

I think most people is considering js/require is the non-magic way. But it is the magic in React-Native.

alexeiz18:08:07

Hi. I have a problem with setting up emacs/cider with shadow-cljs following this doc: https://shadow-cljs.github.io/docs/UsersGuide.html#_launch_the_clojurescript_repl after cljs.repl> prompt appears, if I try to call anything I get 'no applicaiton has connected to the repl server' it looks like it can be a problem with my app type, :node-script any ideas?

thheller19:08:00

@alexeiz you need to run the actual :node-script yourself to REPL into into

thheller19:08:12

if you just want a node REPL you can run shadow-cljs node-repl

thheller19:08:20

but I don't know how that is integrated with emacs

thheller19:08:51

your config is fine and you'd just need to run node target/main.js

thheller19:08:58

once that is running you can eval things in the REPL

alexeiz19:08:30

sorry, it doesn't make sense to me. I ran shadow-cljs node-repl in another terminal, it said shadow-cljs - connected to server, but emacs REPL still gives the same error

thheller19:08:27

@alexeiz I'm sorry but I don't know how cider works either. It should ask you which build to connect to and in this case it would be :node-repl

alexeiz19:08:56

I just tried it, the error I get is 'no build with id: :node-repl'. The only thing that works is ':app' because it's defined in my shadow-cljs.edn

alexeiz19:08:01

and in fact this is what the user guide says too

thheller19:08:21

yes and that will work if you just run the node process manually

thheller19:08:45

I really cannot comment on the cider side of things

alexeiz20:08:50

how exactly will that work? can you be more specific?

alexeiz20:08:51

what you suggested earlier does not work, I get 'no build with id: :node-repl' error.

thheller20:08:01

more specific on what? if you want to REPL into :app you need to run node target/main.js manually elsewhere

thheller20:08:18

if you want to REPL into node-repl I can't help you since I have no clue how cider handles that

thheller20:08:03

the error you get might be from cider trying to start a node-repl build which would be incorrect

alexeiz20:08:12

my current main does nothing (defn main []), node target/main.js immediately exits

alexeiz20:08:44

remind you it's a nodejs script

thheller20:08:53

well ok the you probably want node-repl but I cannot comment about the cider parts

thheller20:08:09

you'll see that if you run shadow-cljs node-repl you get a REPL right away

thheller20:08:20

you can switch to that via nrepl but I have no clue how to do that in cider

thheller20:08:35

(I commented in #cider)

lilactown20:08:36

@alexeiz it doesn’t sound like shadow-cljs node-repl is what you want. What should happen is: 1. Run cider-jack-in-cljs, choose shadow for repl type, and then enter your node app build ID. If it asks you to open a browser window, say no. 2. Once you see the “build completed” message for the first time in the CIDER REPL buffer, in a terminal session run node <path/to/output.js> like configured in your shadow-cljs.edn If you have devtools enabled, it should start the app and keep it open, hot loading your changes while you develop your app

thheller20:08:10

@lilactown it is better to just use node-repl since there is no point linking to a specific build if you just want a REPL

Chris20:08:08

Is there a trick to getting node_modules to be accessible in a CLJS repl for a :browser configuration? I'm trying to use the aws-sdk and I keep getting a module$node_modules$aws_sdk$lib$aws error

Chris20:08:56

Er, ReferenceError: module$node_modules$aws_sdk$lib$aws is not defined

colinkahn20:08:17

This maybe my own misunderstanding about how macros get compiled, but I put together a gist for a usecase I have that won’t recompile when I change a .clj file that .cljc file depends on that exports a macro I’m using: https://gist.github.com/colinkahn/2bbeac1573f923e187301704a7283cd3 What I’m seeing is that if you change something in settings, like the foo def, no matter which file you save that won’t be recompiled with project.module or project.core.

thheller20:08:39

@colinkahn yes macro dependencies are not tracked properly and trigger no recompiles. see https://github.com/thheller/shadow-cljs/issues/495

colinkahn20:08:00

@thheller what’s the difficulty of tackling something like that? I’d be interested in trying to fix it if you think it’s not too hard.

thheller18:08:19

the macro reload issue should be fixed in 2.8.45

thheller20:08:46

hard to say. I'm not sure how I'm gonna address this myself yet

thheller20:08:04

but I'll do it in the next few weeks as part of the CT funding

thheller20:08:23

its not a super easy problem though so i'd say medium to hard maybe

colinkahn20:08:24

If it helps I can create a reproduction repo and add to that ticket

thheller20:08:45

no need thx

Chris20:08:37

@thheller - if we're building a :browser target can we still access the NPM modules automatically? The docs seem to suggest that should be straightforward - but for some reason I can't get things to work in my REPL - is there a :browser example with npm dependencies anywhere that I could take a look at?

thheller20:08:21

@chris547 yes that generally should work. just fire up shadow-cljs browser-repl and run (require '["whatever-from-npm" :as x])

👍 4
thheller20:08:12

not 100% of all packages work though so look at the console log if something throws on load or so

thheller20:08:19

may need some additional config sometimes

Chris20:08:29

Okay great, thanks for responding - I'll try that right now

Chris20:08:17

@thheller - that appears to work - thanks! That wasn't working with a watch but the browser-repl seems to be much better

thheller20:08:10

it should be working normally with watch

thheller20:08:25

browser-repl is just a watch with a default config

Chris20:08:13

okay, let me take a closer look now that I have somethign working to compare with

Chris20:08:59

@thheller - I think the problem is that when I try to connect via Cursive to the nREPL port - things don't work well - but running shadow-cljs browser-repl does from the resulting prompt

thheller20:08:22

that shouldn't make the difference at all

thheller20:08:30

it certainly doesn't affect the npm processing in any way

Chris21:08:58

@thheller - thank you for your patience - it looks like if i connect with Cursive and then run (shadow/watch :browser-repl) (shadow/repl :browser-repl) then I can connect like the prompt

Chris21:08:15

I had named my target :frontend and was trying to use those commands with :frontend

thheller21:08:24

well you should connect to the REPL for your build if you have one

thheller21:08:44

so if you have a watch for :frontend running you should REPL into that too

thheller21:08:01

(shadow/watch :browser-repl) won't work if its not already running

Chris21:08:30

I think I have my :frontend configuration somehow different than :browser-repl - is there an example configuration you can point me to for browser+npm dependencies?

thheller21:08:54

there is no configuration you need to set

thheller21:08:32

the absolute most basic :browser config should just work out of the box

Chris21:08:42

@thheller - okay it seems to be there's a difference between `(ns io.foo.organization (:require ["aws-sdk" :as AWS]))` and (require '["aws-sdk" :as AWS]) - when I run the latter it seems to load the module, but the ns require seems to not load the AWS var properly

thheller21:08:35

is there a stacktrace in the browser console?

thheller21:08:00

the ns require should be fine since it does exactly the same

Chris21:08:50

No stacktrace when I execute ns however, when I try to reference AWS I get this:

ReferenceError: module$node_modules$aws_sdk$lib$aws is not defined
    at eval (eval at <anonymous> (), <anonymous>:1:1)
    at 
    at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] ()
    at Object.shadow$cljs$devtools$client$browser$repl_invoke [as repl_invoke] ()
    at shadow$cljs$devtools$client$browser$handle_message ()
    at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] ()
    at WebSocket.<anonymous> ()

Chris21:08:52

but then I can execute (require '["aws-sdk" :as AWS]) in the same namespace and then the AWS reference begins to work properly

thheller21:08:04

ah you execute ns in the REPL?

thheller21:08:09

I thought you were loading the file normally

thheller21:08:20

totally possible that there is a bug related to ns in the REPL

Chris21:08:30

Yes, I connect, then open the file in Cursive and execute the ns s-expression in the REPL

thheller21:08:33

and that works in a freshly launched shadow-cljs browser-repl but not in a regular :browser build?

Chris21:08:22

let me verify

thheller21:08:11

I'm off to bed now, will take a look tomorrow

Chris21:08:18

The result is the same - the ns command returns nil but does not create the AWS references in the :brower-repl version

Chris15:08:04

@thheller - just closing the loop on this - the namespace I was working in was in a file that wasn't referenced by anything in my app namespace. I was starting a REPL then trying to load this new ns in the REPL - at that point it wouldn't load npm references in the ns macro and so I had to use the (require..) function in the namespace. Thinking on it overnight I realized that this new ns wasn't referenced by the app and so I added it to the app's ns and now things work. So, I don't know if that's intended or not but it looks like there just has to be a path to the desired ns at repl startup or else things get a little off. Thanks for your help and for making such a great tool.

thheller15:08:56

it is already fixed in master. there was a race condition. so it would try to create the variable for the aws import before they were loaded

thheller15:08:16

will make a release later today where everything should be working as expected

Chris15:08:51

🤯 - wow - amazing that it's fixed already. Thanks for caring so much about it!

thheller16:08:38

2.8.43 is out. let me know if things still don't work right

Chris16:08:51

Great, will update and try again - thanks!

Chris18:08:47

Yes, that seems to have fixed it - thanks again for the quick turn around!

Chris21:08:18

okay, thanks @thheller - appreciate your time!