Fork me on GitHub
#shadow-cljs
<
2023-07-22
>
vemv10:07:22

Would you expect this code to work when shadow-cljs is running cider-nrepl? https://github.com/clojure-emacs/cider-nrepl/blob/6d3934eb665574af891e81ef5c11cf9c2b4e1d65/src/cider/nrepl/middleware/util/cljs.clj#L61-L65 I know that shadow-cljs has some sort of piggieback compat, but IDK if it's a no-op, or if it can actually provide a ClojureScript compiler environment

vemv10:07:42

...a little more context, a certain cider-nrepl feature doesn't work under shadow-cljs and I'd like to design the best course of action

thheller10:07:29

should be fine. which feature does not work?

vemv11:07:38

Thanks! Looks great. Will be checking things in detail before adding (possibly noisy) details

vemv11:07:21

(hopefully not too much of a FAQ) Given this build:

:builds {:app {:target :browser
                :output-dir "public/js"
                :asset-path "/js"
                :modules {:main {:entries []}}}}
And a ns that is not required at all by (transitively or not), can I get shadow-cljs to compile it on save anyway? ...I can imagine why it would not do that by default, but I'd find it very handy and analog to how JVM tools.namespace works.

thheller11:07:58

well you can add :entries [] :preloads [whatever.else] so it becomes part of the build without an actual require

thheller11:07:06

but otherwise no

vemv11:07:26

hmmm, ok, I'll try to simply adapt myself to this nuance Have you had that feature requested previously?

thheller11:07:54

I sort of also don't get it? why do you want to compile a namespace that isn't used by your build? is it for a secondary build?

vemv11:07:11

Some sort of user story: say I'm developing stuff, I want to develop feature "foo" I create a foo ns I haven't required it yet anywhere, I'm developing it / it's all pure functions shadow-cljs/similar tools create the expectation that saving a file will have it compiled It's not because of the lack of a require Then tools like CIDER will work worse until I eval stuff by hand or add the require elsewhere

vemv11:07:13

tldr I find there's an inconsistency in having users used to "compile on save" work only sometimes.

thheller11:07:27

but why not add the require? I assume the feature is ultimately for that build?

thheller11:07:56

but ultimately this comes more down to how tools like cider want to work

thheller11:07:02

versus what a build should do and look like

vemv11:07:25

> but why not add the require? I assume the feature is ultimately for that build? yes, but why add it? I'm only coding foo , playing with it, I have no reason to require it yet It feels like a workaround

thheller11:07:12

well I still don't know where exactly the issue is, so you are going to have to explain that

thheller11:07:23

I assume you work on foo from the REPL and eval accordingly

vemv11:07:28

> but ultimately this comes more down to how tools like cider want to work A more tooling-agnostic way to pose the problem: • I code (defn foo [] ,,,) • I hit save • I cannot invoke (foo) at the repl

thheller11:07:32

so I'm missing how auto compile on save helps

thheller11:07:13

to me its an odd expectation to assume its automatically available

thheller11:07:24

might be my workflow of hitting eval in the REPL though

thheller11:07:52

and honestly this is something cider can do without issue

thheller11:07:01

there is nothing shadow-cljs needs to add for this to be possible

thheller11:07:15

just on-save send a (load-file ...) over the repl. done.

thheller11:07:11

to be honest this has always bothered me with watch. watching hundreds of files, when the editor could just send us infos about which files it just modified 😛

vemv11:07:57

> to me its an odd expectation to assume its automatically available but it's how it works for the rest of the namespaces (i.e. for all namespaces that are descendants of the "build" ns) > might be my workflow of hitting eval in the REPL though I'm pretty sure most cljs devs don't eval forms by hand each time, they just save files?

thheller11:07:00

well, cursive has a "sync all files in REPL" action. which I press frequently and is automatically done for many other actions

thheller11:07:32

I actually prefer that over on-save, since it is sometimes tiresome when I start writing something that is invalid/incomplete code

thheller11:07:56

then I tab out to look something up or so and I get a compiler error, when I had no actual interest in compiling yet

thheller11:07:15

the question I ask you about this workflow: how do you deal with namespaces that can't be part of the build? ie. a react-native ns that can't run in the browser? or a node.js ns? how would you tell shadow-cljs what you want?

vemv12:07:28

> I actually prefer that over on-save I sympathize with this - would never do it in JVM clojure :) > how do you deal with namespaces that can't be part of the build? This can be very intentfully conveyed by placing non-buildable .cljs files outside of the source paths e.g. only files that are saved within a source path are compiled automatically

thheller12:07:10

but they are buildable files if you have more than one build? which is very common for many people?

thheller12:07:43

the shadow-cljs project is full of them since I have so many builds 😛

vemv12:07:46

It doesn't seem an exclusive concept to me Anyway it seems good to me to not request anything at this point, if it becomes a time-proven pain to me, I would create a sensible gh issue Thanks for all the info!