shadow-cljs

seancorfield 2026-03-23T17:18:38.092079Z

Okay, I think I may have run into another complication with Polylith and Shadow-cljs... Details in ๐Ÿงต

seancorfield 2026-03-23T17:22:27.559049Z

poly test builds the full classpath for all the directories that contain source and tests. The per-project "build" process would only have access to the (source) dependencies, libraries, and potentially any project-specific tests -- because tools.deps isn't transitive, the test files in bases/components in Polylith are not visible directly to anything running in a project. Test runners for Polylith accept all those paths and build their own classpath for any Java processes they would run. This seems at odds with running shadow-cljs via npx even with shadow-cljs.edn having :deps {:aliases [:shadow :test]} (for example) since Shadow is relying on tools.deps style logic and the "brick" tests are not deducible from that.

seancorfield 2026-03-23T17:23:54.904379Z

So, it seems like I would be forced to run shadow-cljs as a Java process in the context of a dynamically constructed classpath that includes all of those "brick" test files? @thheller

seancorfield 2026-03-23T17:24:40.364069Z

LMK if you need more context for this. BTW, the dynamically-constructed --config-merge works beautifully! Which is how I figured out the classpath wasn't right ๐Ÿ™‚

thheller 2026-03-23T17:33:57.634469Z

if you have a constructed classpath just use java

thheller 2026-03-23T17:34:18.849479Z

or am I missing something?

thheller 2026-03-23T17:34:46.400689Z

java -cp $(get-classpath) clojure.main -m shadow.cljs.devtools.cli compile test

seancorfield 2026-03-23T17:35:50.108779Z

Yeah, I think that's the way I have to go, and specify the path to the project's shadow edn file...

seancorfield 2026-03-23T17:36:20.489539Z

Since the test runner assumes it runs in the root in terms of how it builds the class path

thheller 2026-03-23T17:36:33.424879Z

I know next to nothing about polylith, so not really sure what brickes/bases/components are

thheller 2026-03-23T17:37:04.763269Z

so shadow-cljs.edn in the "root" is no option?

seancorfield 2026-03-23T17:37:53.141199Z

There can be multiple cljs projects in a repo, so multiple shadow config files

seancorfield 2026-03-23T17:38:44.783849Z

I assume I can tell shadow to use a specific edn file (in another folder)?

thheller 2026-03-23T17:39:08.132049Z

no, that is hardcoded to the directory the JVM was started in

seancorfield 2026-03-23T17:39:28.592829Z

Hmm, that might make this impossible then

thheller 2026-03-23T17:41:50.171089Z

do you have an example app for how this would actually all look?

seancorfield 2026-03-23T17:43:05.507099Z

Not really. But the test runner itself is a Polylith app: https://github.com/seancorfield/polylith-external-test-runner

seancorfield 2026-03-23T17:43:36.839649Z

Each projects/* folder that is building a cljs app would have a shadow-cljs.edn file for that build.

thheller 2026-03-23T17:44:38.259939Z

so you are starting shadow-cljs in that folder?

seancorfield 2026-03-23T17:45:35.594169Z

poly test figures out which "modules" need to be tested based on what code has changed since a specific git tag. Then it builds a classpath etc from the repo (workspace) root -- which includes the project being tested -- and the test runner is executed in the root of the repo. That works for Cognitect's test-runner and Olical's cljs-test-runner.

seancorfield 2026-03-23T17:46:46.940269Z

The shadow-cljs.edn file in the project is being read (by my test runner) to figure out builds and targets and a few other options, and I would have to run Shadow in that project folder for it to pick up the config file.

seancorfield 2026-03-23T17:48:18.265429Z

However, the classpath is relative to the repo root, not the project root, so Shadow still can't find the test nses. I guess I could add ../../ to each piece of the classpath that is a directory, rather than a JAR file...

thheller 2026-03-23T17:49:44.071369Z

ah so you are using relative paths. well yeah would need to rewrite those

thheller 2026-03-23T17:50:20.515139Z

well this is how shadow-cljs finds its config (io/file "shadow-cljs.edn")

seancorfield 2026-03-23T17:50:31.434579Z

Success!!!!!

Running ClojureScript tests...
[:test] Compiling ...
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::arrayBaseOffset has been called by com.google.javascript.jscomp.jarjar.com.google.protobuf.UnsafeUtil$MemoryAccessor (file:/home/sean/.m2/repository/com/google/javascript/closure-compiler/v20250407/closure-compiler-v20250407.jar)
WARNING: Please consider reporting this to the maintainers of class com.google.javascript.jscomp.jarjar.com.google.protobuf.UnsafeUtil$MemoryAccessor
WARNING: sun.misc.Unsafe::arrayBaseOffset will be removed in a future release
[:test] Build completed. (53 files, 9 compiled, 0 warnings, 10.82s)
no "source-map-support" (run "npm install source-map-support --save-dev" to get it)

This is a ClojureScript test file.

Common test running as ClojureScript.

Testing org.corfield.external-test-runner.ignored-test

Testing org.corfield.external-test-runner.interface-test

Ran 2 tests containing 2 assertions.
0 failures, 0 errors.

thheller 2026-03-23T17:50:44.156659Z

wasn't there a JVM option to adjust what it uses for reference ๐Ÿ˜›

seancorfield 2026-03-23T17:51:02.207469Z

Not within the Polylith machinery that builds the paths, no.

seancorfield 2026-03-23T17:51:55.862449Z

(because it isn't using tools.deps directly, because every "module" in a Polylith repo has its own deps.edn that only has some dependencies -- and Polylith merges them all together to build the full classpath)

seancorfield 2026-03-23T17:52:06.466639Z

At work, our repo has over 200 deps.edn files ๐Ÿ™‚

thheller 2026-03-23T17:52:12.103169Z

yikes ๐Ÿ˜›

seancorfield 2026-03-23T17:52:35.084419Z

We build 24 different apps from that, and poly test gives us incremental testing.