Welcome! Please see the About page for a little more info on how this works.

0 votes
in ClojureScript by
When trying to package a javascript library using `:global-exports` I'm getting an error:


Exception in thread "main" java.lang.IllegalArgumentException: contains? not supported on type: clojure.lang.Cons
        at clojure.lang.RT.contains(RT.java:846)
        at clojure.core$contains_QMARK_.invokeStatic(core.clj:1484)
        at clojure.core$contains_QMARK_.invoke(core.clj:1476)
        at cljs.analyzer$dep_has_global_exports_QMARK_.invokeStatic(analyzer.cljc:782)
...


Library repository: https://github.com/colinkahn/deckgl-cljs

To reproduce:


clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.339"} org.clojars.protocol55/deckgl {:mvn/version "0.1.1"}}}' -m cljs.main -e "(require 'com.uber.deckgl) (println com.uber.deckgl/DeckGL)"


Same library with `:global-exports` removed:


clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.339"} org.clojars.protocol55/deckgl {:mvn/version "1.0.0"}}}' -m cljs.main -e "(require 'com.uber.deckgl) (println js/deck.DeckGL)"

5 Answers

0 votes
by

Comment made by: mfikes

Thank-you Colin!

Can you include any relevant files directly in the description?

(See https://clojurescript.org/community/reporting-issues)

0 votes
by

Comment made by: mfikes

Oh, never mind. I see to repro you only need to issue a {{clj}} command.

0 votes
by
_Comment made by: mfikes_

Root cause is that, even though the name of the file is {{deps.cljs}} it is read by the compiler as if it were an EDN file. In other words, symbols should not be quoted.

The file included in the JAR looks like:


{:foreign-libs [{:file "deckgl/deckgl.min.js"
                 :provides ["com.uber.deckgl"]
                 :global-exports '{com.uber.deckgl deck}}]
 :externs ["deckgl/externs/deckgl.js"]}


This causes {{contains?}} to be applied to {{(quote \{com.uber.deckgl deck\})}} with the stacktrace seen.

Hey David, what's your opinion on this one? Should we handle this via documentation on clojurescript.org, clarifying that {{deps.cljs}} is actually meant to contain EDN?
0 votes
by

Comment made by: colinkahn

Ouch, yeah that is pretty unintuitive, especially if you already know the rules for each file type. I was using cljsjs as a reference too, but now realizing that the outputted result must be just edn: https://github.com/cljsjs/packages/blob/master/react/build.boot#L31

deps.cljs is a bit mysterious, would be nice to have a thorough explanation of what are the valid options inside of it.

Supporting an alternate name like jslibs.edn would probably add some clarity.

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJS-2858 (reported by colinkahn)
...