Fork me on GitHub
#clojurescript
<
2020-12-27
>
Sam Ritchie03:12:29

In clojure i can extend APersistentMap, but no base class is available here of course

Dan Maltbie21:12:39

I'm using Shadow-cljs for my compiler and am trying to track down a problem with npm version mismatches (two modules requiring a different version of another module). I wanted to verify that the code would compile with a different cljs compiler and tried `cljsbuild`. It appears that it does not like reader conditionals (.i.e., `#?(clj:`). Does this only work with Shadow-cljs or is there another compiler that handles reader conditionals? I saw the note in the user guide (sec 6.8) saying it was not a standard feature but it is really useful so I hate to give it up. I'm finding that cljsbuild only complains about conditionals in the project.clj file. Do I need to rename this to .cljc? If I remove the Java specific require statements from the project.clj file my code compiles fine.

Sam Ritchie22:12:29

@dmaltbie I think your condition is backwards -

Sam Ritchie22:12:52

ie, use the keyword :clj instead of the form clj: that you have in that example

Dan Maltbie22:12:00

sorry. my comment was wrong. actual code in project.clj is :dependencies [[org.clojure/clojure "1.10.1"] [org.clojure/clojurescript "1.10.764"] [org.clojure/core.async "1.3.610"] #?(:clj [mvxcvi/alphabase "2.1.0"]) #?(:clj [mvxcvi/multihash "2.0.3"]) #?(:clj [net.named-data/jndn "0.24"]) #?(:clj [org.clojure/java.jdbc "0.7.8"]) #?(:clj [org.postgresql/postgresql "42.2.5.jre7"]) #?(:clj [org.clojure/tools.reader "1.3.2"]) #?(:clj [com.github.serceman/jnr-fuse "0.5.4" :exclusions [org.ow2.asm/asm]]) ;; 0.5.2.1 #?(:clj [org.clojure/data.xml "0.0.8"]) #?(:clj [nio "1.0.4"]) #?(:clj [bytebuffer "0.2.0"]) #?(:clj [clojure-msgpack "1.2.1"]) #?(:clj [org.clojure/math.numeric-tower "0.0.4"]) #?(:clj [org.clojure/java.classpath "1.0.0"]) #?(:clj [clj-http "3.9.1"]) ]

Sam Ritchie22:12:19

and also yes, I believe it needs to be .cljc

Sam Ritchie22:12:50

(maybe I am actually misunderstanding, I see now that this is in project.clj, and I understand less why you need a conditional there!)

Dan Maltbie22:12:36

i'm trying to use the same project.clj file for both JVM and JS version of the code. Is there a better way to do this?

Dan Maltbie22:12:59

so you think that the reader conditional syntax should work with cljsbuild?

Dan Maltbie22:12:43

If I rename project.clj to project.cljc lein compile fails with error message Couldn't find project.clj, which is needed for compile

dpsutton22:12:03

What would be different between the two?

Dan Maltbie22:12:44

for instance java specific modules (.clj only) would not be loaded when compiling for javascript. And the import statement would not be relevant for javascript since it is importing java libraries.