Fork me on GitHub
#shadow-cljs
<
2021-07-20
>
kwrooijen09:07:37

Hello (not sure if this is the proper place to post this so apologies if that's not the case). I added a NPM package and I'm getting the following Closure Compiler error:

Closure compilation failed with 1 errors
--- node_modules/jspdf/dist/jspdf.es.min.js:10636
Duplicate let / const / class / function declaration in the same scope is not allowed.
I assume this is an issue with the library code itself (as the error states). I'm just wondering if there's a "quick and dirty" fix to solve this, or if my only option is to fork and fix the dependency? The dependency: https://github.com/MrRio/jsPDF

thheller14:07:46

no easy fix unfortunately. well besides using another "dist" they ship. maybe the commonjs version doesn't have that issue? assuming of course that they ship multiple versions

👍 3
sheluchin15:07:25

I'm getting this error after connecting my editor to my REPL:

e iced repl :main --force-shadow-cljs --with-cljs -A:dev
OK: CLJS option is enabled.
OK: shadow-cljs project is detected
OK: For shadow-cljs project, start watching instead of starting REPL.
shadow-cljs - config: /project/shadow-cljs.edn  cli version: 2.8.64  node: v12.18.0
shadow-cljs - starting via "clojure"
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.11.23 running at 
shadow-cljs - nREPL server started on port 9000
shadow-cljs - watching build :main
[:main] Configuring build.
[:main] Compiling ...
GUARDRAILS IS ENABLED. RUNTIME PERFORMANCE WILL BE AFFECTED.
Mode: :runtime  Async? false  Throw? false
Guardrails was enabled because the CLJS Compiler config enabled it
[:main] Build completed. (287 files, 0 compiled, 0 warnings, 9.00s)
[2021-07-20 11:27:28.995 - WARNING] :shadow.cljs.devtools.server.nrepl-impl/init-ns-ex - {:init-ns sheluchin.user}
Note: The following stack trace applies to the reader or compiler, your code was not executed.
CompilerException Unexpected error macroexpanding defrecord at (rewrite_clj/node/comment.clj:6:1). #:clojure.error{:phase :macroexpansion, :line 6, :column 1, :source "rewrite_clj/node/comment.clj", :symbol defrecord}
    clojure.lang.Compiler.macroexpand1 (Compiler.java:7019)
    clojure.lang.Compiler.macroexpand (Compiler.java:7075)
    clojure.lang.Compiler.eval (Compiler.java:7161)
    clojure.lang.Compiler.load (Compiler.java:7636)
    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--6839 (core.clj:6126)
    clojure.core/load (core.clj:6125)
    clojure.core/load (core.clj:6109)
    clojure.core/load-one (core.clj:5908)
Caused by:
NullPointerException 
    clojure.lang.Compiler.maybeResolveIn (Compiler.java:7424)
    clojure.core/ns-resolve (core.clj:4370)
    clojure.core/ns-resolve (core.clj:4359)
    clojure.core/resolve (core.clj:4372)
    clojure.core/resolve (core.clj:4372)
    clojure.core/map/fn--5866 (core.clj:2753)
    clojure.lang.LazySeq.sval (LazySeq.java:42)
    clojure.lang.LazySeq.seq (LazySeq.java:51)
    clojure.lang.RT.seq (RT.java:535)
    clojure.core/seq--5402 (core.clj:137)
    clojure.core/reduce1 (core.clj:930)
    clojure.core/set (core.clj:4113)
There is some suggestion that the issue is coming up because I'm including CLJ function calls in CLJS and shadow doesn't know what to do with it: https://clojurians.slack.com/archives/C68M60S4F/p1626790359069100?thread_ts=1625841427.419200&amp;cid=C68M60S4F Any suggestions for a fix? I can't seem to get around this one.

thheller15:07:54

shadow-cljs is nowhere on that stacktrace. no clue what your REPL is doing

thheller15:07:10

its not part of shadow-cljs compilation. that completed. so your REPL is trying to do something but I can't tell what

👍 4
ag19:07:35

I'm having hard time connecting to cljs REPL, I do this:

(require '[shadow.cljs.devtools.server :as server])
(require '[shadow.cljs.devtools.api :as shadow])
(server/start!)
(shadow/watch :app)
(shadow/nrepl-select :app)
and everything but the last step works fine. The last step fails with :missing-nrepl-middleware. Where should I dig?

thheller20:07:10

the nrepl server you connected do is missing the middleware

ag20:07:47

Oh, that's what I missed. Thank you Thomas!