Fork me on GitHub
#shadow-cljs
<
2021-03-08
>
Iheatu Wogu12:03:44

I’m trying to run

:test-ci {:target  :node-test
                          :output-to "out/node-test/js"
                          :autorun "true"
                          :js-options {:resolve {"devcards-marked" {:target :npm :require "marked"}
                                                 "devcards-syntax-highlighter" {:target :npm :require "highlight.js"}}}}}
but I get
[:test-ci] Compiling ...
The required namespace "devcards-marked" is not available, it was required by "devcards/util/markdown.cljs".
I’m quite unsure what I might have done wrong

Dan Maltbie14:03:43

I have two packages, one is the app and the other is a library on which it depends. This library is actually a dual CLJ/CLJS library. For development ease with Clojure using leiningen, I can set a soft link to the library package directory from the app package directory (in the checkouts subdirectory of the app package directory). Is there a way to do something like this for development purposes with shadow-cljs where the app is a CLJS program? Or other ways to simplify development with local package dependencies?

thheller20:03:07

well the easy answer is "just use lein" if you have that setup anyways

thheller20:03:27

shadow-cljs.edn itself doesn't support checkouts or so. you could just add :source-paths to the proper places

Dan Maltbie21:03:21

Sorry for confusion, I use lein for JVM code and Shadow-cljs for JS. I'll check out :source-paths and see if that can work for me. thanks!!

thheller21:03:47

just let lein manage the classpath I meant. CLJS related things will still be handled by shadow-cljs

Dan Maltbie18:03:28

It's like peeling the layers of an onion... Thanks for the pointer. Looks like something that should help.

Dan Maltbie18:03:49

shadow-cljs is awesome!

flowthing19:03:14

The simplest way that I know of to get a JVM ClojureScript REPL that I can connect my editor to (basically, just a REPL without a prompt) is to start a Clojure socket REPL (e.g. via the system property) and do something like this:

((requiring-resolve 'cljs.repl/repl)
  ((requiring-resolve 'cljs.repl.browser/repl-env))
  :need-prompt (constantly false)
  :prompt (constantly ""))
But what if I have shadow-cljs in the mix? Does shadow-cljs expose a repl-env that I can pass to cljs.repl/repl? The most straightforward method I know of is to start a Clojure socket REPL and call (shadow.api/repl :id), but there doesn't seem to be a way to disable the prompt. Also, promoting a Clojure REPL to a ClojureScript REPL is rather problematic as far as editor integrations go, because it's difficult for the editor to know whether it's in Clojure or ClojureScript mode. I'd rather have a whole separate socket connection for the ClojureScript REPL, but I haven't found a way to do that with shadow-cljs.

thheller19:03:45

@flowthing there is no cljs.repl/repl equivalent in shadow-cljs but I could add the :prompt config options. why do you not want a prompt? what editor did you use? most editors use nrepl and not many people use the socket repl at all

flowthing19:03:02

I use Sublime Text, I'm working on my own thing. I don't really want to use nREPL because: a) I don't actually need any of the features it offers b) I'd like to avoid the dependency if I can (and with Clojure, it's relatively easy to upgrade a Socket REPL to implement editor integration) c) it has the same problem regarding switching REPL modes

thheller19:03:41

c) is fairly straightforward to handle over nrepl though

thheller19:03:51

i can understand a+b. not a fan of nrepl myself.

thheller19:03:22

you could use prepl but that is somewhat ugly as well

flowthing19:03:37

prepl only has structured output, not structured input.

thheller19:03:53

:prepl {12345 :build-id} will start a prepl on port 12345 for the build-id

thheller19:03:10

the input is identical to socket repl and prepl? just clojure forms?

flowthing19:03:33

Or, well. This is a rather involved topic. 😛 Anyway, a :prompt option would be great, but I'm not yet sure whether I'd actually end up using it. What I'd really like is a way to run a ClojureScript REPL in a way that's agnostic to build tooling.

thheller19:03:38

given how vastly different the CLJS REPL is from CLJ thats difficult

thheller19:03:58

and the REPL impl in shadow-cljs is also very very different and supports many features that the default REPLs don't

thheller19:03:28

the shadow.remote stuff I built might be of interest for you but thats heavily under documented and not final yet

flowthing19:03:38

Indeed. I do realize it might be a pipe dream, but I think I'm still going to give it a go.

thheller19:03:08

I tried fixing all the REPL issues I could think of with shadow.remote and one day I'll document and publish it

thheller19:03:24

but so far its only used internally for everything shadow-cljs and the REPLs do

flowthing19:03:54

Sounds interesting. I'd like my thing to work with just out-of-the-box ClojureScript, though.

flowthing19:03:36

If I start a Clojure socket REPL and send this:

((requiring-resolve 'cljs.repl/repl)
             ((requiring-resolve 'cljs.repl.browser/repl-env))
             :need-prompt (constantly false)
             :prompt (constantly ""))
In a shadow-cljs project, I get this:
Execution error (IllegalArgumentException) at shadow.build.cljs-hacks/eval24027$fn (cljs_hacks.cljc:981).

thheller19:03:36

as I said .. cljs.repl/repl will never work with shadow-cljs

flowthing19:03:02

Well, you said there's no equivalent. 🙂 But okay, that's good to know.

flowthing19:03:02

I'll see where I end up with this thing, but I can make an issue about the :prompt thing if it comes to that. In any case, thanks for the help!

thheller19:03:15

yeah the REPL implementations are so drastically different that I can't provide a compatible repl-env stuff

thheller19:03:27

what is the issue with :prompt?

flowthing19:03:29

All right, that's very good to know.

thheller19:03:43

I mean why is the prompt a problem?

flowthing19:03:55

I just meant an option to disable the prompt when calling (shadow/api :app).

thheller19:03:34

yes, but why?

flowthing19:03:38

When I send forms to be evaluated from my editor, I don't want the prompt to show up in the evaluation results.

thheller19:03:07

2.11.22 has (shadow/repl :id {:prompt false})

flowthing19:03:21

Wow, thank you! 🙇:skin-tone-2:

flowthing20:03:06

Just to demonstrate what I meant: https://tutkain.flowthing.me/before.png https://tutkain.flowthing.me/after.png The first line with => is the "prompt" (really, the namespace indicator) my client prints (disregard the namespace there, it's WIP), the second line is the prompt shadow-cljs printed. The point is just that I'd like to be sure that what I'm getting from the server is just EDN and I can control when foo=> gets printed and how.

flowthing20:03:34

(Well, in this case it's not just EDN because it can also be whatever stdout gets, but anyway.)

flowthing20:03:54

I'll stop taking up more of your time -- thanks again!

az21:03:53

Hi all, I’m a little confused on how to best setup a new re-frame project with shadow. I used the re-frame template lein new re-frame <app-name> I see other projects set up differently and I’m wondering what is the consensus on setting this up, if any? Lastly, any reading material you could point out regarding deployment best practices.