Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CLJS Advanced Compilation #412

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Fix CLJS Advanced Compilation #412

wants to merge 8 commits into from

Conversation

dgtized
Copy link
Contributor

@dgtized dgtized commented Feb 15, 2024

Release https://github.com/quil/quil/releases/tag/v4.3.1563 broke CLJS Advanced compilation because of a JSC_DUPLICATE_EXTERN error.

SEVERE: ERROR - [JSC_DUPLICATE_EXTERN_INPUT] Duplicate extern input: file:/home/runner/.m2/repository/quil/quil/4.3.1572/quil-4.3.1572.jar!/cljsjs/p5/common/p5.ext.js

Feb 15, 2024 1:44:53 AM com.google.javascript.jscomp.LoggerErrorManager printSummary
WARNING: 1 error(s), 0 warning(s)
ERROR: JSC_DUPLICATE_EXTERN_INPUT. Duplicate extern input: file:/home/runner/.m2/repository/quil/quil/4.3.1572/quil-4.3.1572.jar!/cljsjs/p5/common/p5.ext.js at (unknown source) line (unknown line) : (unknown column)
Unexpected error compiling at (REPL:1).
  • Add a test case to verify advanced compilation with the current build
  • Fix duplicate extern error

Presumably, the problem is that the CLJS compiler is seeing an extern file from both the cljsjs/p5 dependency and the embedded copy of that jar inside of the quil uberjar. My hypothesis of why the previous release did not have this problem is that the pom file had no upstream dependencies listed, so the p5js dependency was incorporated directly into the uberjar. Now that the upstream dependencies are listed in the pom, it's causing a conflict between the deps.edn p5js reference and the copy in the uberjar. Unfortunately, simply excluding the cljsjs/p5 reference from the uberjar as below, does not appear to be sufficient to fix this.

modified   build.clj
@@ -112,8 +112,17 @@
     (b/uber {:class-dir class-dir
              :uber-file jar-file
              :basis @basis
-             ;; don't bundle clojure into the jar
-             :exclude ["^clojure[/].+"]})
+             :exclude
+             [;; don't bundle clojure into the jar
+              "^clojure[/].+"
+              ;; exclude p5js to avoid JSC_DUPLICATE_EXTERN_INPUT during CLJS
+              ;; advanced optimized compilation. Without this, the far-jar copy
+              ;; of cljsjs/p5 and the mvn coordinate conflict and both provide
+              ;; the an extern file.
+              ;;
+              ;; TODO: add an advanced compilation cljs example depending on a
+              ;; jar to verify
+              "cljsjs/p5.*"]})
     (println "release:" jar-file
              (format "(%.1f kb)" (/ (.length (io/file jar-file)) 1024.0)))))

The alternative, to exclude the p5js reference from the pom is possible but seems like the wrong path to follow for this dependency?

@dgtized
Copy link
Contributor Author

dgtized commented Feb 18, 2024

Confirmed that quil/quil 4.3.1323 listed no dependencies using clj -Stree, so p5js was only showing up in the uberjar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant