Open PEZ opened 2 years ago
OK. So it seems to be shadow-cljs that doesn't recompile the macro when loading a .cljs
file. I tried this:
$ npx shadow-cljs watch :app
------------------------------------------------------------------------------
WARNING: shadow-cljs not installed in project.
See https://shadow-cljs.github.io/docs/UsersGuide.html#project-install
------------------------------------------------------------------------------
shadow-cljs - config: /Users/pez/Projects/tests/sam-macro-weirdness/shadow-cljs.edn
shadow-cljs - starting via "clojure"
[2022-03-31 14:25:09.939 - WARNING] TCP Port 9630 in use.
[2022-03-31 14:25:09.962 - WARNING] TCP Port 9631 in use.
[2022-03-31 14:25:09.983 - WARNING] TCP Port 9632 in use.
[2022-03-31 14:25:12.742 - WARNING] TCP Port 8000 in use.
shadow-cljs - HTTP server available at http://localhost:8001
shadow-cljs - server version: 2.17.8 running at http://localhost:9633
shadow-cljs - nREPL server started on port 7999
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (128 files, 0 compiled, 0 warnings, 4.11s)
Loaded http://localhost:8001 in the browser, then:
% npx shadow-cljs clj-repl
------------------------------------------------------------------------------
WARNING: shadow-cljs not installed in project.
See https://shadow-cljs.github.io/docs/UsersGuide.html#project-install
------------------------------------------------------------------------------
shadow-cljs - config: /Users/pez/Projects/tests/sam-macro-weirdness/shadow-cljs.edn
shadow-cljs - connected to server
shadow-cljs - REPL - see (help)
To quit, type: :repl/quit
shadow.user=> (shadow/repl :app)
cljs.user=> (load-file "src/core.cljs")
[]
cljs.user=> (in-ns 'core)
nil
core=> e/bar
4
>
Then:
short.txt
to be 8 character in lengthnpx shadow-cljs
sessions.I expect: e/bar => 8
I get: e/bar => 4
Wiping .shadow-cljs
and repeating the processes, I get e/bar => 8
.
Why it works with example.cljc
in Calva connected to that CLJ2/CLJS
session, I don't quite understand, but at least you have a workaround there, @sam-pitch.
Hmmm, could the difference between loading example.cljc
and core.cljs
here be not the file extensions, but rather the inderection? example.cljc
is defining the macro...
I'm not completely sure about why this happens like it does, but jotting down my thoughts so maybe we can figure it out together.
Some background:
CLJ1
while be used for Clojure files, andCLJ2
(promoted toCLJS
) will be used or ClojureScript files.CLJC
session ”pointer” which will point toCLJ1
by. default. (This pointer can be toggled by the user by clicking thecljc/clj
button in the statusbar.)When you load
example.cljc
it will compile the macro inCLJ1
. Then when you loadcore.cljs
it will compile the macro usingCLJ2
. Then you update the file and recompile the macro inCLJ1
by loadingexample.cljc
. Then you loadcore.cljs
which doesn't seem to recompile the macro. I don't know why.I tried this: I toggled the
CLJC
pointer to becljc/cljs
and then I get the expected results loading files in the orderexample.cljc
(recompiles the macro usingCLJ2
)core.cljs
But if I load
core.cljs
first the recompile doesn't happen.So, maybe it is generally the case that loading a
.cljs
file does not trigger a recompile of macros... This could be a Calva bug, but I don't recall any code in Calva that cares about wether a file is.cljc
or.cljs
. It just has this mapping offile-extension -> nrepl-session
and sends the nREPL op to the session it picks up.I'll investigate it a bit further and see what I can figure out.