This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-07-22
Channels
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
...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
Thanks! Looks great. Will be checking things in detail before adding (possibly noisy) details
(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.well you can add :entries [
so it becomes part of the build without an actual require
hmmm, ok, I'll try to simply adapt myself to this nuance Have you had that feature requested previously?
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?
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
tldr I find there's an inconsistency in having users used to "compile on save" work only sometimes.
> 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
well I still don't know where exactly the issue is, so you are going to have to explain that
> 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
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 😛
> 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?
well, cursive has a "sync all files in REPL" action. which I press frequently and is automatically done for many other actions
I actually prefer that over on-save, since it is sometimes tiresome when I start writing something that is invalid/incomplete code
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
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?
I mean that is the reason why it works this way in the first place https://code.thheller.com/blog/shadow-cljs/2018/02/08/problem-solved-source-paths.html
> 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