This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-31
Channels
- # announcements (1)
- # aws (4)
- # babashka (40)
- # beginners (89)
- # calva (13)
- # cider (3)
- # clj-kondo (36)
- # cljdoc (16)
- # clojure (74)
- # clojure-boston (1)
- # clojure-dev (7)
- # clojure-europe (30)
- # clojure-new-zealand (1)
- # clojure-nl (17)
- # clojure-uk (5)
- # clojurescript (16)
- # core-async (9)
- # cursive (16)
- # datahike (3)
- # datalog (6)
- # datascript (7)
- # datomic (15)
- # emacs (38)
- # events (2)
- # figwheel-main (3)
- # fulcro (6)
- # google-cloud (18)
- # graalvm (6)
- # gratitude (1)
- # honeysql (1)
- # introduce-yourself (1)
- # jobs (1)
- # leiningen (5)
- # lsp (6)
- # malli (11)
- # meander (2)
- # off-topic (4)
- # re-frame (6)
- # reitit (8)
- # releases (2)
- # remote-jobs (3)
- # reveal (4)
- # shadow-cljs (200)
- # sql (8)
- # tools-deps (16)
I’m trying to add entries to a module from a build hook (currently :compile-prepare
). I update [shadow.build/config :modules :main :entries]
and add the clojure namespaces there. I can confirm they are both on my build path and in the build config. However, when I make changes to these files, shadow-cljs does not recompile.
1. Is there something I need to do to add them to the watch?
2. The eventual goal is to set up different modules, but I was going for MVP by adding them to entries. Would it be possible to dynamically load different modules from a build hook?
For context, I’m trying to set up something similar to next.js with directory based routing. So as I add more files, I read the classpath, build all the route into, then add files to the build. Modules would be great for code-splitting in the future but not needed for now
sounds like what you are trying to do would require a custom :target
. build hooks are definitely not meant to do any additional compilation and are not setup to do so
Interesting. I guess I could spit to the shadow-cljs.edn
file and run the watch command with nodemon
- sounds like that might be the fastest solution?
In the meantime do you have any info on writing a custom :target
? I assume you mean a build would have :target :custom-browser
?
no info other than the implementation of the default targets https://github.com/thheller/shadow-cljs/tree/master/src/main/shadow/build/targets
I will go through this in detail later this week but do you have something in mind you can point me towards? function or variable name that dictates what is rebuild for example 😄
with a different :shadow.build/stage
where the target impl can decide what it needs to do
for example :node-library
generates a source and adds it to the build https://github.com/thheller/shadow-cljs/blob/8b7f3964e732bc13a9981ba390908dd90f70f2e0/src/main/shadow/build/targets/node_library.clj#L88-L103
> targets don’t control rebuilds I’m confused - I just want to inject some namespaces into the entries and rebuild the module when those files change. That sounds like a custom target would be best?
I think for my purposes it will just make better sense to write directly to the shadow-cljs.edn file and rebuild when that changes. It will only need to restart the process when a new file is added. If I need something more integrated it’s good to know where this is, thanks Quick question though - is it possible to specify a path to a shadow-cljs.edn file ? Or does it have to be in the dir that the command is run from
ie. you create a build {:target :browser :modules {:main {:init-fn
and then you generate either
or some file it includes
that way the build automatically retriggers if you regenerate the file or make and other changes
imho maybe you just need a macro? never look at how js tools do something and replicate that
I'm not sure I would actually recommend doing this but as an experiment for the shadow-cljs UI I did this
then have a separate macro that collects all of the functions with such metadata and generate some code arround it
from the build side it is just a regular :browser
build, nothing is ever generated elsewhere
the macro is a little more complicated since I wanted it to be aware of :modules
but it doesn't need to be
I have cljs files on the classpath, they are not retriggering a build. Presumably because they are not part of the module. Metadata or filepath work fine for me, just need to get the code in those cljs files into the build without an explicit require
well it needs to be part of the build. then it'll trigger a rebuild. it doesn't need to be directly part of the build config
back to the macro example I still have my main ns require all the namespaces that have that metadata
https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/ui/main.cljs#L16-L19
I guess I should say user-written require 😅 maybe the best way would be to just write to a manifest.cljs
with a bunch of require
statements
in your main app (:require [my.app.routes])
and then you generate (ns my.app.routes (:require [my.app.route-a] [my.app.route-b]))
with some tool?
this is a helper package to teach my friends how to code (starting with clojurescript). The time to first render is quite important for me - goal is to have a command to install then write a file and see it on the screen. Plenty of time to get to requires and metadata later 😄
> in your main app `(:require [my.app.routes])` and then you generate `(ns my.app.routes (:require [my.app.route-a] [my.app.route-b]))` with some tool? this seems like the best way to do it!
in the future if I wanted to support code splitting, could I add new modules to the build with a build hook, or would I need to adjust the shadow-cljs.edn file and restart the server?
modifications to the build config do not require restarts, they are just picked up and recompiled
so I could see a file exists, add a module (with entries) to the build config in the pre-compile
stage, and it would generate that new file?
"you create a file and then you run this other tool and wait for this other tool to pick it up" is that not simple in my view 🙂
I’ve got ideas 😎 I appreciate the feedback but I’m building out a very specific curriculum. I know it’s not the way of the clojure world but I think it has value
npm install captain-cljs
npx captain-cljs start
mkdir -p src/pages
echo "(ns pages.index) (defn +render [] [:div :hello-world])" > src/pages/index.cljs
goal is to get that to load the component, and a css file alongside it to load locally scoped css module. They can start building in clojurescript while I teach them html, css, clojurescript, and eventually namespaces and requires, servers, shadow-cljs, etc
I expect most people to graduate beyond the library but I’m trying to build as big of training wheel as possible for when they start so they can see something load from the get-go
good luck 😉 just don't go too far off road with this. hiding important implementation details for too long will actually just create more problems in the long run IMHO
I have talked to many create-react-app
users that came to CLJS and didn't have a single clue how react actually works
thanks, and thanks for all the support so far. I’ll try not to get too carried away but sometime I just like to make programming problems for myself 🤪
I’ll try to have an “offboarding” curriculum, would be interesting if one could gradually take off the training wheels. But make it work first and I’ll iterate! 😄
most people end up using a template that generates far too many files and never knowing what these files actually do
me too 😂 unless someone swoops in keep an eye out captain-cljs
, I’m sure I’ll post here with questions and updates
well if all goes well I’ll be funneling lots of members into the community to pester you with questions like “why do I have to require things?!”
Hi all, a few days ago we updated tools.deps.alhpa to the latest version (from 0.12.1109 to 0.12.1120). Now when I try to use shadow.cljs.devtools
in my code (to start a shadow-cljs server and watch a target), I get errors like these:
; Syntax error compiling at (shadow/build/js_support.clj:1:1).
; namespace 'shadow.build.closure' not found
and:
; Execution error (NoClassDefFoundError) at jdk.internal.reflect.NativeMethodAccessorImpl/invoke0 (NativeMethodAccessorImpl.java:-2).
; Could not initialize class com.google.javascript.jscomp.DiagnosticGroups
Does this sound familiar to anyone?looks like a dependency conflict to me? this error you usually get when using an incorrect closure compiler version
I haven’t done lots of dependency debugging before, but I can’t find the issue. The tools.deps.alpha dependency update was the only thing that changed. When comparing the deps tree with the old and new version of tools.deps.alpha, this is the change set:
That doesn’t seem to point to anything related to closure / jscomp. The dependencies that you explicitly mention in the manual are identical.
it might just be that the newer tools.deps version sorted things in a different order for some reason
what is the full stacktrace of the Could not initialize class com.google.javascript.jscomp.DiagnosticGroups
exception
guava is a common cause of issues and the closure compiler generally doesn't like having it on the classpath with any other version that it expects
I also see a bunch of dependencies that you definitely don't need for a CLJS build, those should not be on the classpath while building CLJS
putting all :backend
deps in the root :deps
and then adding CLJS stuff via alias is bad
Hmm maybe I’ll have to rethink my dev setup. I’m using polylith, which also adds some restrictions. But what I’m doing at the moment is that I start one single REPL running all backend servers and the (shadow-cljs-based) frontend. So basically something like:
(defn run-in-repl []
(server1/start)
(server2/start)
(shadow.cljs.devtools.server/start!)
(shadow-watch :frontend)
:ready)
you can do this but you have to deal with stuff like this conflict. its definitely fixable but you have to figure out where the problem comes from.
That requires having the jvm all dependencies at once if I understand things correctly, so that will then always (be likely to) cause such issues?
generally it is a dependency conflict. if you give me the full stacktrace of the exception I can confirm that.
I always recommend running CLJS stuff separately. you gain absolutely nothing by running it in the same JVM
Oh right sorry. I found the button in Calva to give it to me:
clojure.lang.Compiler/analyze (Compiler.java:6812)
clojure.lang.Compiler$InvokeExpr/parse (Compiler.java:3824)
clojure.lang.Compiler/analyzeSeq (Compiler.java:7113)
clojure.lang.Compiler/analyze (Compiler.java:6793)
clojure.lang.Compiler$BodyExpr$Parser/parse (Compiler.java:6124)
clojure.lang.Compiler$FnMethod/parse (Compiler.java:5471)
clojure.lang.Compiler$FnExpr/parse (Compiler.java:4033)
clojure.lang.Compiler/analyzeSeq (Compiler.java:7109)
clojure.lang.Compiler/analyze (Compiler.java:6793)
clojure.lang.Compiler/eval (Compiler.java:7178)
clojure.core/eval (core.clj:3202)
clojure.core/eval (core.clj:3198)
nrepl.middleware.interruptible-eval/evaluate (interruptible_eval.clj:87)
clojure.core/apply (core.clj:667)
clojure.core/with-bindings* (core.clj:1977)
nrepl.middleware.interruptible-eval/evaluate (interruptible_eval.clj:87)
clojure.main/repl (main.clj:437)
clojure.main/repl (main.clj:458)
clojure.main/repl (main.clj:368)
nrepl.middleware.interruptible-eval/evaluate (interruptible_eval.clj:84)
nrepl.middleware.interruptible-eval/evaluate (interruptible_eval.clj:56)
nrepl.middleware.interruptible-eval/interruptible-eval (interruptible_eval.clj:152)
nrepl.middleware.session/session-exec (session.clj:218)
nrepl.middleware.session/session-exec (session.clj:217)
java.lang.Thread/run (Thread.java:833)
user=> (require 'shadow.cljs.devtools.api)
Execution error (NoClassDefFoundError) at jdk.internal.reflect.NativeMethodAccessorImpl/invoke0 (NativeMethodAccessorImpl.java:-2).
Could not initialize class com.google.javascript.jscomp.DiagnosticGroups
user=>
#error {
:cause "Could not initialize class com.google.javascript.jscomp.DiagnosticGroups"
:via
[{:type clojure.lang.Compiler$CompilerException
:message "Syntax error macroexpanding at (closure.clj:77:5)."
:data #:clojure.error{:phase :execution, :line 77, :column 5, :source "closure.clj"}
:at [clojure.lang.Compiler$StaticMethodExpr eval "Compiler.java" 1742]}
{:type java.lang.NoClassDefFoundError
:message "Could not initialize class com.google.javascript.jscomp.DiagnosticGroups"
:at [jdk.internal.reflect.NativeMethodAccessorImpl invoke0 "NativeMethodAccessorImpl.java" -2]}]
:trace
[[jdk.internal.reflect.NativeMethodAccessorImpl invoke0 "NativeMethodAccessorImpl.java" -2]
[jdk.internal.reflect.NativeMethodAccessorImpl invoke "NativeMethodAccessorImpl.java" 77]
[jdk.internal.reflect.DelegatingMethodAccessorImpl invoke "DelegatingMethodAccessorImpl.java" 43]
[java.lang.reflect.Method invoke "Method.java" 568]
[clojure.lang.Reflector invokeMatchingMethod "Reflector.java" 167]
[clojure.lang.Compiler$StaticMethodExpr eval "Compiler.java" 1735]
[clojure.lang.Compiler$InvokeExpr eval "Compiler.java" 3705]
[clojure.lang.Compiler$DefExpr eval "Compiler.java" 457]
[clojure.lang.Compiler eval "Compiler.java" 7186]
[clojure.lang.Compiler load "Compiler.java" 7640]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6856 invoke "core.clj" 6115]
[clojure.core$load invokeStatic "core.clj" 6114]
[clojure.core$load doInvoke "core.clj" 6098]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5897]
[clojure.core$load_one invoke "core.clj" 5892]
[clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
[clojure.core$load_lib invokeStatic "core.clj" 5936]
[clojure.core$load_lib doInvoke "core.clj" 5917]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 5974]
[clojure.core$load_libs doInvoke "core.clj" 5958]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 5996]
[clojure.core$require doInvoke "core.clj" 5996]
[clojure.lang.RestFn invoke "RestFn.java" 551]
[shadow.build.js_support$eval15994$loading__6737__auto____15995 invoke "js_support.clj" 1]
[shadow.build.js_support$eval15994 invokeStatic "js_support.clj" 1]
[shadow.build.js_support$eval15994 invoke "js_support.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7181]
[clojure.lang.Compiler eval "Compiler.java" 7170]
[clojure.lang.Compiler load "Compiler.java" 7640]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6856 invoke "core.clj" 6115]
[clojure.core$load invokeStatic "core.clj" 6114]
[clojure.core$load doInvoke "core.clj" 6098]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5897]
[clojure.core$load_one invoke "core.clj" 5892]
[clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
[clojure.core$load_lib invokeStatic "core.clj" 5936]
[clojure.core$load_lib doInvoke "core.clj" 5917]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 5974]
[clojure.core$load_libs doInvoke "core.clj" 5958]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 5996]
[clojure.core$require doInvoke "core.clj" 5996]
[clojure.lang.RestFn invoke "RestFn.java" 619]
[shadow.build.resolve$eval14164$loading__6737__auto____14165 invoke "resolve.clj" 1]
[shadow.build.resolve$eval14164 invokeStatic "resolve.clj" 1]
[shadow.build.resolve$eval14164 invoke "resolve.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7181]
[clojure.lang.Compiler eval "Compiler.java" 7170]
[clojure.lang.Compiler load "Compiler.java" 7640]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6856 invoke "core.clj" 6115]
[clojure.core$load invokeStatic "core.clj" 6114]
[clojure.core$load doInvoke "core.clj" 6098]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5897]
[clojure.core$load_one invoke "core.clj" 5892]
[clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
[clojure.core$load_lib invokeStatic "core.clj" 5936]
[clojure.core$load_lib doInvoke "core.clj" 5917]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 5974]
[clojure.core$load_libs doInvoke "core.clj" 5958]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 5996]
[clojure.core$require doInvoke "core.clj" 5996]
[clojure.lang.RestFn invoke "RestFn.java" 2793]
[shadow.build.api$eval14156$loading__6737__auto____14157 invoke "api.clj" 1]
[shadow.build.api$eval14156 invokeStatic "api.clj" 1]
[shadow.build.api$eval14156 invoke "api.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7181]
[clojure.lang.Compiler eval "Compiler.java" 7170]
[clojure.lang.Compiler load "Compiler.java" 7640]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6856 invoke "core.clj" 6115]
[clojure.core$load invokeStatic "core.clj" 6114]
[clojure.core$load doInvoke "core.clj" 6098]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5897]
[clojure.core$load_one invoke "core.clj" 5892]
[clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
[clojure.core$load_lib invokeStatic "core.clj" 5936]
[clojure.core$load_lib doInvoke "core.clj" 5917]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 5974]
[clojure.core$load_libs doInvoke "core.clj" 5958]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 5996]
[clojure.core$require doInvoke "core.clj" 5996]
[clojure.lang.RestFn invoke "RestFn.java" 2793]
[shadow.build$eval13806$loading__6737__auto____13807 invoke "build.clj" 1]
[shadow.build$eval13806 invokeStatic "build.clj" 1]
[shadow.build$eval13806 invoke "build.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7181]
[clojure.lang.Compiler eval "Compiler.java" 7170]
[clojure.lang.Compiler load "Compiler.java" 7640]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6856 invoke "core.clj" 6115]
[clojure.core$load invokeStatic "core.clj" 6114]
[clojure.core$load doInvoke "core.clj" 6098]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5897]
[clojure.core$load_one invoke "core.clj" 5892]
[clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
[clojure.core$load_lib invokeStatic "core.clj" 5936]
[clojure.core$load_lib doInvoke "core.clj" 5917]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 5974]
[clojure.core$load_libs doInvoke "core.clj" 5958]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 5996]
[clojure.core$require doInvoke "core.clj" 5996]
[clojure.lang.RestFn invoke "RestFn.java" 3204]
[shadow.cljs.devtools.api$eval5278$loading__6737__auto____5279 invoke "api.clj" 1]
[shadow.cljs.devtools.api$eval5278 invokeStatic "api.clj" 1]
[shadow.cljs.devtools.api$eval5278 invoke "api.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7181]
[clojure.lang.Compiler eval "Compiler.java" 7170]
[clojure.lang.Compiler load "Compiler.java" 7640]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6856 invoke "core.clj" 6115]
[clojure.core$load invokeStatic "core.clj" 6114]
[clojure.core$load doInvoke "core.clj" 6098]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5897]
[clojure.core$load_one invoke "core.clj" 5892]
[clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
[clojure.core$load_lib invokeStatic "core.clj" 5936]
[clojure.core$load_lib doInvoke "core.clj" 5917]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 5974]
[clojure.core$load_libs doInvoke "core.clj" 5958]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 5996]
[clojure.core$require doInvoke "core.clj" 5996]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[user$eval5274 invokeStatic "NO_SOURCE_FILE" 1]
[user$eval5274 invoke "NO_SOURCE_FILE" 1]
[clojure.lang.Compiler eval "Compiler.java" 7181]
[clojure.lang.Compiler eval "Compiler.java" 7136]
[clojure.core$eval invokeStatic "core.clj" 3202]
[clojure.core$eval invoke "core.clj" 3198]
[nrepl.middleware.interruptible_eval$evaluate$fn__976$fn__977 invoke "interruptible_eval.clj" 87]
[clojure.lang.AFn applyToHelper "AFn.java" 152]
[clojure.lang.AFn applyTo "AFn.java" 144]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$with_bindings_STAR_ invokeStatic "core.clj" 1977]
[clojure.core$with_bindings_STAR_ doInvoke "core.clj" 1977]
[clojure.lang.RestFn invoke "RestFn.java" 425]
[nrepl.middleware.interruptible_eval$evaluate$fn__976 invoke "interruptible_eval.clj" 87]
[clojure.main$repl$read_eval_print__9110$fn__9113 invoke "main.clj" 437]
[clojure.main$repl$read_eval_print__9110 invoke "main.clj" 437]
[clojure.main$repl$fn__9119 invoke "main.clj" 458]
[clojure.main$repl invokeStatic "main.clj" 458]
[clojure.main$repl doInvoke "main.clj" 368]
[clojure.lang.RestFn invoke "RestFn.java" 1523]
[nrepl.middleware.interruptible_eval$evaluate invokeStatic "interruptible_eval.clj" 84]
[nrepl.middleware.interruptible_eval$evaluate invoke "interruptible_eval.clj" 56]
[nrepl.middleware.interruptible_eval$interruptible_eval$fn__1007$fn__1011 invoke "interruptible_eval.clj" 152]
[clojure.lang.AFn run "AFn.java" 22]
[nrepl.middleware.session$session_exec$main_loop__1075$fn__1079 invoke "session.clj" 202]
[nrepl.middleware.session$session_exec$main_loop__1075 invoke "session.clj" 201]
[clojure.lang.AFn run "AFn.java" 22]
[java.lang.Thread run "Thread.java" 833]]}
user=>
#object[java.net.URL 0x736dd229 "jar:file:/Users/stefanmm/.m2/repository/com/google/javascript/closure-compiler-unshaded/v20211006/closure-compiler-unshaded-v20211006.jar!/com/google/javascript/jscomp/DiagnosticGroups.class"]
#object[java.net.URL 0x60101212 "jar:file:/Users/stefanmm/.m2/repository/thheller/shadow-cljs/2.16.12/shadow-cljs-2.16.12.jar!/shadow/build.clj"]
I really need you to type this all out into a regular CLJ. no calva, no editor, nothing extra, just the command line stuff
Oh sorry that’s indeed when I run outside of vscode but with the ability to jack-in, sorry
Clojure 1.10.3
user=> (require 'shadow.cljs.devtools.api)
Execution error (NoSuchMethodError) at com.google.javascript.jscomp.deps.ModuleLoader/createRootPaths (ModuleLoader.java:257).
'java.util.stream.Collector com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet(java.util.Comparator)'
user=> *e
#error {
:cause "'java.util.stream.Collector com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet(java.util.Comparator)'"
:via
[{:type clojure.lang.Compiler$CompilerException
:message "Syntax error macroexpanding at (closure.clj:77:5)."
:data #:clojure.error{:phase :execution, :line 77, :column 5, :source "closure.clj"}
:at [clojure.lang.Compiler$StaticMethodExpr eval "Compiler.java" 1742]}
{:type java.lang.NoSuchMethodError
:message "'java.util.stream.Collector com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet(java.util.Comparator)'"
:at [com.google.javascript.jscomp.deps.ModuleLoader createRootPaths "ModuleLoader.java" 257]}]
:trace
[[com.google.javascript.jscomp.deps.ModuleLoader createRootPaths "ModuleLoader.java" 257]
[com.google.javascript.jscomp.deps.ModuleLoader <init> "ModuleLoader.java" 147]
[com.google.javascript.jscomp.deps.ModuleLoader <init> "ModuleLoader.java" 48]
[com.google.javascript.jscomp.deps.ModuleLoader$Builder build "ModuleLoader.java" 139]
[com.google.javascript.jscomp.deps.ModuleLoader <clinit> "ModuleLoader.java" 408]
[com.google.javascript.jscomp.DiagnosticGroups <clinit> "DiagnosticGroups.java" 182]
[jdk.internal.reflect.NativeMethodAccessorImpl invoke0 "NativeMethodAccessorImpl.java" -2]
[jdk.internal.reflect.NativeMethodAccessorImpl invoke "NativeMethodAccessorImpl.java" 77]
[jdk.internal.reflect.DelegatingMethodAccessorImpl invoke "DelegatingMethodAccessorImpl.java" 43]
[java.lang.reflect.Method invoke "Method.java" 568]
[clojure.lang.Reflector invokeMatchingMethod "Reflector.java" 167]
[clojure.lang.Compiler$StaticMethodExpr eval "Compiler.java" 1735]
[clojure.lang.Compiler$InvokeExpr eval "Compiler.java" 3705]
[clojure.lang.Compiler$DefExpr eval "Compiler.java" 457]
[clojure.lang.Compiler eval "Compiler.java" 7186]
[clojure.lang.Compiler load "Compiler.java" 7640]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6856 invoke "core.clj" 6115]
[clojure.core$load invokeStatic "core.clj" 6114]
[clojure.core$load doInvoke "core.clj" 6098]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5897]
[clojure.core$load_one invoke "core.clj" 5892]
[clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
[clojure.core$load_lib invokeStatic "core.clj" 5936]
[clojure.core$load_lib doInvoke "core.clj" 5917]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 5974]
[clojure.core$load_libs doInvoke "core.clj" 5958]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 5996]
[clojure.core$require doInvoke "core.clj" 5996]
[clojure.lang.RestFn invoke "RestFn.java" 551]
[shadow.build.js_support$eval10891$loading__6737__auto____10892 invoke "js_support.clj" 1]
[shadow.build.js_support$eval10891 invokeStatic "js_support.clj" 1]
[shadow.build.js_support$eval10891 invoke "js_support.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7181]
[clojure.lang.Compiler eval "Compiler.java" 7170]
[clojure.lang.Compiler load "Compiler.java" 7640]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6856 invoke "core.clj" 6115]
[clojure.core$load invokeStatic "core.clj" 6114]
[clojure.core$load doInvoke "core.clj" 6098]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5897]
[clojure.core$load_one invoke "core.clj" 5892]
[clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
[clojure.core$load_lib invokeStatic "core.clj" 5936]
[clojure.core$load_lib doInvoke "core.clj" 5917]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 5974]
[clojure.core$load_libs doInvoke "core.clj" 5958]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 5996]
[clojure.core$require doInvoke "core.clj" 5996]
[clojure.lang.RestFn invoke "RestFn.java" 619]
[shadow.build.resolve$eval9061$loading__6737__auto____9062 invoke "resolve.clj" 1]
[shadow.build.resolve$eval9061 invokeStatic "resolve.clj" 1]
[shadow.build.resolve$eval9061 invoke "resolve.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7181]
[clojure.lang.Compiler eval "Compiler.java" 7170]
[clojure.lang.Compiler load "Compiler.java" 7640]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6856 invoke "core.clj" 6115]
[clojure.core$load invokeStatic "core.clj" 6114]
[clojure.core$load doInvoke "core.clj" 6098]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5897]
[clojure.core$load_one invoke "core.clj" 5892]
[clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
[clojure.core$load_lib invokeStatic "core.clj" 5936]
[clojure.core$load_lib doInvoke "core.clj" 5917]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 5974]
[clojure.core$load_libs doInvoke "core.clj" 5958]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 5996]
[clojure.core$require doInvoke "core.clj" 5996]
[clojure.lang.RestFn invoke "RestFn.java" 2793]
[shadow.build.api$eval9053$loading__6737__auto____9054 invoke "api.clj" 1]
[shadow.build.api$eval9053 invokeStatic "api.clj" 1]
[shadow.build.api$eval9053 invoke "api.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7181]
[clojure.lang.Compiler eval "Compiler.java" 7170]
[clojure.lang.Compiler load "Compiler.java" 7640]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6856 invoke "core.clj" 6115]
[clojure.core$load invokeStatic "core.clj" 6114]
[clojure.core$load doInvoke "core.clj" 6098]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5897]
[clojure.core$load_one invoke "core.clj" 5892]
[clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
[clojure.core$load_lib invokeStatic "core.clj" 5936]
[clojure.core$load_lib doInvoke "core.clj" 5917]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 5974]
[clojure.core$load_libs doInvoke "core.clj" 5958]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 5996]
[clojure.core$require doInvoke "core.clj" 5996]
[clojure.lang.RestFn invoke "RestFn.java" 2793]
[shadow.build$eval8682$loading__6737__auto____8683 invoke "build.clj" 1]
[shadow.build$eval8682 invokeStatic "build.clj" 1]
[shadow.build$eval8682 invoke "build.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7181]
[clojure.lang.Compiler eval "Compiler.java" 7170]
[clojure.lang.Compiler load "Compiler.java" 7640]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6856 invoke "core.clj" 6115]
[clojure.core$load invokeStatic "core.clj" 6114]
[clojure.core$load doInvoke "core.clj" 6098]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5897]
[clojure.core$load_one invoke "core.clj" 5892]
[clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
[clojure.core$load_lib invokeStatic "core.clj" 5936]
[clojure.core$load_lib doInvoke "core.clj" 5917]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 5974]
[clojure.core$load_libs doInvoke "core.clj" 5958]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 5996]
[clojure.core$require doInvoke "core.clj" 5996]
[clojure.lang.RestFn invoke "RestFn.java" 3204]
[shadow.cljs.devtools.api$eval153$loading__6737__auto____154 invoke "api.clj" 1]
[shadow.cljs.devtools.api$eval153 invokeStatic "api.clj" 1]
[shadow.cljs.devtools.api$eval153 invoke "api.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7181]
[clojure.lang.Compiler eval "Compiler.java" 7170]
[clojure.lang.Compiler load "Compiler.java" 7640]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6856 invoke "core.clj" 6115]
[clojure.core$load invokeStatic "core.clj" 6114]
[clojure.core$load doInvoke "core.clj" 6098]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5897]
[clojure.core$load_one invoke "core.clj" 5892]
[clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
[clojure.core$load_lib invokeStatic "core.clj" 5936]
[clojure.core$load_lib doInvoke "core.clj" 5917]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 5974]
[clojure.core$load_libs doInvoke "core.clj" 5958]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 5996]
[clojure.core$require doInvoke "core.clj" 5996]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[user$eval149 invokeStatic "NO_SOURCE_FILE" 1]
[user$eval149 invoke "NO_SOURCE_FILE" 1]
[clojure.lang.Compiler eval "Compiler.java" 7181]
[clojure.lang.Compiler eval "Compiler.java" 7136]
[clojure.core$eval invokeStatic "core.clj" 3202]
[clojure.core$eval invoke "core.clj" 3198]
[clojure.main$repl$read_eval_print__9110$fn__9113 invoke "main.clj" 437]
[clojure.main$repl$read_eval_print__9110 invoke "main.clj" 437]
[clojure.main$repl$fn__9119 invoke "main.clj" 458]
[clojure.main$repl invokeStatic "main.clj" 458]
[clojure.main$repl_opt invokeStatic "main.clj" 522]
[clojure.main$main invokeStatic "main.clj" 667]
[clojure.main$main doInvoke "main.clj" 616]
[clojure.lang.RestFn invoke "RestFn.java" 397]
[clojure.lang.AFn applyToHelper "AFn.java" 152]
[clojure.lang.RestFn applyTo "RestFn.java" 132]
[clojure.lang.Var applyTo "Var.java" 705]
[clojure.main main "main.java" 40]]}
not actually sure which version you need since the closure compiler changed something in the way they bundle stuff
I’ll try some combinations of excluding/overriding it then. Pfff. Complicated stuff. Huge thanks for helping me out Thomas!!
FYI: excluding guava in the tools.deps.alpha dependency seems to fix this issue. Not sure what other issues that’ll cause, but we’ll see…
Hello. I’m running a next.js development server and a shadow-cljs watch on an :npm-module target build. I’m able to use my cljs output in my next.js files. However, as I am developing, the hot-module reload seems to pick up the cljs source files twice:
Error: Namespace "goog.debug.Error" already declared.
at Object.goog.module (webpack-internal:///./cljs/cljs_env.js:163:13)
at eval (webpack-internal:///./cljs/cljs_env.js:1891:8)
at Object.goog.loadModule (webpack-internal:///./cljs/cljs_env.js:404:27)
at eval (webpack-internal:///./cljs/cljs_env.js:1888:6)
I’ve seen similar issues other people have posted about and they all seem related to producing two cljs builds. This is not my current scenario, but rather using it in a js ecosystem with React Fast Refresh. Any tips on how to fix or debug here?Hey @U02V40G5P9C 👋 Did you manage to find a solution for this error? I'm experimenting a bit with shadow and next.js and I'm stuck on the same scenario: the first load works well, but as soon as I change some code and save the file fast refresh comes into play and I get the error you described.
I didn’t @U01CKU3HHFA
I actually don't know if this can work at all. I think the fast refresh refreshes too much all the time which basically breaks all your code
ie. it should never attempt to load goog.debug.Error
twice since that definitely never changes between compiles
@U05224H0W do you know, by any chance, a workaround for this error? I tried to use your suggestion above, but still couldn't get it to work. I followed your ⭐ proof of concept https://github.com/thheller/next-cljs and I can make shadow compile the pages as Next wants and works fine, but as soon as I change any CLJS I get the error Namespace "goog.debug.Error" already declared
, same error happens if there is more than one page and in that case, it happens during the compilation already.
in what context? I mean the error you fix by overriding what goog.provide
does as shown in the link above?
I'm not sure exactly how/where to override goog.provide as you mentioned. I tried to use the snippet you shared in the entry point of the application/where pages are generated, but couldn't make the error go still.
I think my question is more: do you think it is possible to handle this error and get next.js working with shadow at the current version? Reading your past messages I understood that you were not sure if it would be possible to get by. I also checked with Next.js to see if it would be possible to turn off their fast refresh as you suggested, but apparently, it's not possible. PS: I'm able to generate the pages from CLJS as Next expects, etc. the integration works well, I'm just stuck with the error above being thrown on hot reload.
yes, I think it is possible to get this working. shouldn't be much different from before
but without more context I really cannot give any suggestions for what you might need to do
The context is that I'm trying to do is to run your proof of concept next.js repo here https://github.com/thheller/next-cljs It works fine without the error if I keep shadow CLJS in the version that is locked in the repo: 2.6.10
, but as soon as I update the version, I'm using 2.19.8
now, I start to get the error above.
so I guess you are not talking about shadow-cljs doing the hot-reloading but webpack/next doing it?
Yes, the error starts when Next detects changes in the files generated by the hot reload from shadow-cljs. I'm unsure where/how I should install this patch. I tried to call this function in one of the entries of the application, but it doesn't seem to have any effect. Could you please elaborate where/how you imagine this patch is installed?
shadow-cljs does no hot-reload in the next-cljs
example repo you linked above. none. it will trigger a re-compile and I suspect that next is doing the hot-reload?
I cannot tell you how to install or handle the patch since I don't know what you are building
if you share the repo that has the stuff that didn't work I can maybe tell you why it didn't work
I'm working exactly with your repo. The only difference is that I updated shadow-cljs, other than that it's the same repo.
you probably also use a newer next.js? I mean otherwise the error should also happen with the older version?
Yes, I'm using a new version (12.2.3), the error doesn't happen with the version you used in the proof of concept (7.0.0).
You're right, they introduced what they call https://nextjs.org/docs/basic-features/fast-refresh as of version 9.4
Here's a fork with next and shadow-cljs versions updated: https://github.com/nathanqueija/next-cljs I updated the readme with instructions to run both shadow and next. What I'm doing to reproduce the error: • Start shadow build • Start next build • When all builds are ready and I go to localhost:3000 everything works fine • Change anything in the component, can be just a string that is being rendered • I assume that's when next hot reload comes into play and the error is thrown
I did, I added a new entry and called the function you shared there, but no luck. Also tried to call directly in the page component, but still no luck.
one option would be to add import "../src/cljs/shadow.cljs.devtools.client.browser.js")
here https://github.com/nathanqueija/next-cljs/blob/master/src/main/shadow/next_js.clj#L30
having two separate hot-reloads is not a good thing and they will interfere with each other
if there is a way to disable the hot-reload from next.js you should probably do that
I pushed a commit adding the patch in one of the entries and also adding the import you suggested in one of the pages but still got the error. From next perspective, it seems there is https://github.com/vercel/next.js/discussions/25712 to https://github.com/vercel/next.js/issues/13268#issuecomment-992463977.
error - src/cljs/shadow.cljs.devtools.client.websocket.js (26:14) @ shadow$cljs$devtools$client$websocket$start
error - ReferenceError: WebSocket is not defined
at shadow$cljs$devtools$client$websocket$start (webpack-internal:///./src/cljs/shadow.cljs.devtools.client.websocket.js:25:18)
at shadow.cljs.devtools.client.shared.Runtime.attempt_connect_BANG_ (webpack-internal:///./src/cljs/shadow.cljs.devtools.client.shared.js:549:135)
at Object.shadow$cljs$devtools$client$shared$init_runtime_BANG_ [as init_runtime_BANG_] (webpack-internal:///./src/cljs/shadow.cljs.devtools.client.shared.js:1117:20)
at eval (webpack-internal:///./src/cljs/shadow.cljs.devtools.client.browser.js:1358:40)
at ./src/cljs/shadow.cljs.devtools.client.browser.js (/mnt/c/Users/thheller/code/tmp/next-cljs/site/.next/server/pages/index.js:725:1)
at __webpack_require__ (/mnt/c/Users/thheller/code/tmp/next-cljs/site/.next/server/webpack-runtime.js:33:42)
at eval (webpack-internal:///./pages/index.js:5:106)
at ./pages/index.js (/mnt/c/Users/thheller/code/tmp/next-cljs/site/.next/server/pages/index.js:198:1)
at __webpack_require__ (/mnt/c/Users/thheller/code/tmp/next-cljs/site/.next/server/webpack-runtime.js:33:42)
at __webpack_exec__ (/mnt/c/Users/thheller/code/tmp/next-cljs/site/.next/server/pages/index.js:1268:39) {
page: '/'
}
24 | shadow.cljs.devtools.client.websocket.start = (function shadow$cljs$devtools$client$websocket$start(runtime){
25 | var ws_url = shadow.cljs.devtools.client.env.get_ws_relay_url();
> 26 | var socket = (new WebSocket(ws_url));
| ^
27 | (socket.onmessage = (function (e){
28 | return shadow.cljs.devtools.client.shared.remote_msg(runtime,e.data);
29 | }));
so the regular shadow-cljs devtools probably won't work due to it running in node and the browser I guess?
yes, if any browser APIs are used in the pages exported that wouldn't work because they go first through the server to be rendered by Next before being returned to the client.
Tried to add the hack as you suggested but I guess the problem persists because any file exported has this statement in the first line var $CLJS = require("./cljs_env");
and it's exactly this file that throws the error online 1448 in this statement goog.module("goog.debug.Error");
. So as soon as the file with the patch is loaded the error will be thrown before any of the actual code from the pages being executed.
just gotta keep digging. I mean you can just modify the emitted cljs_env.js
but not sure that changes anything

maybe its enough if you somehow do the same set!
replacements somewhere but I don't know
typically I'd say to just let shadow-cljs handle the reloading and have next ignore your CLJS output
Ok I’ll have to figure out how react fast refresh works. Thanks for the insight.
I'm having an interesting problem where I get a stack overflow in shadow.umd_helper.js
at Object.get [as test_query] (/home/zimablue/projects/kangrok-ui/.shadow-cljs/builds/node/dev/out/cljs-runtime/shadow.umd_helper.js:11:16)
don't know why it is, I was trying to stably depend upon a local typescript project using "yarn link", that's the last thing I did so I think it's somehow related
just putting here in case it's obvious that it can only be one thing, or for the posterity of this slack once I work it out
I’m having a problem with circular reference defining variables at compile time. I’m doing
:dev {:closure-defines {foo.core/DEV true}}
and inside src/cljs/foo/core.cljs
(ns foo.core)
(goog-define DEV false)
(def dev? (true? DEV))
Is working correctly but I cannot use dev?
inside components. Since the application is loaded from
that calls foo.core/init!
and inside foo.core
all the rest of the reagent components are loaded sequentially, if I (:require [foo.core :refer [dev?]])
inside a component is doing a circular reference.
So the question is, how can I define variables at compile time that I can use inside components without creating a circular reference?