mauricioszabo / atom-chlorine

An Atom plugin to integrate with Socket-REPL over Clojure, ClojureScript, ClojureCLR, Joker, Babashka, Clojerl, Lumo and Plank
MIT License
176 stars 17 forks source link

Js module not found #213

Closed brmrodrigues closed 4 years ago

brmrodrigues commented 4 years ago

I'm making a POC with https://github.com/maxdome/swagger-combine. I tried to run the following


(ns mario.combine
    (:require ["swagger-combine" :as swagger-combine]
                    [promesa.core :as p]))

(def combine-try
  (-> (swagger-combine "swaggers/dummy/combined-swaggers.json")
      (p/handle  (fn [res _err]
                   (-> res js/JSON.stringify js/console.log)))))````

I got the following error indicating that the js module cannot be found when loading `combine-try`, but loading "swagger-combine" on REPL seems to be successful.

```java.lang.AssertionError
: 
"Assert failed: (symbol? module)"
in 
shadow.build.cljs-hacks/js-module-exists?
 (cljs_hacks.cljc:71)
in 
shadow.build.cljs-hacks/js-module-exists?
 (cljs_hacks.cljc:71)
in 
shadow.build.cljs-hacks/invokeable-ns?
 (cljs_hacks.cljc:109)
in 
shadow.build.cljs-hacks/invokeable-ns?
 (cljs_hacks.cljc:104)
in 
shadow.build.cljs-hacks/shadow-resolve-var
 (cljs_hacks.cljc:259)
in 
shadow.build.cljs-hacks/shadow-resolve-var
 (cljs_hacks.cljc:148)
in 
cljs.analyzer/resolve-existing-var
 (analyzer.cljc:1298)
in 
cljs.analyzer/resolve-existing-var
 (analyzer.cljc:1293)
in 
cljs.analyzer/analyze-symbol
 (analyzer.cljc:3795)
in 
cljs.analyzer/analyze-symbol
 (analyzer.cljc:3759)
in 
cljs.analyzer/analyze-form
 (analyzer.cljc:4189)
in 
cljs.analyzer/analyze-form
 (analyzer.cljc:4187)
in 
cljs.analyzer/analyze*
 (analyzer.cljc:4243)
in 
cljs.analyzer/analyze*
 (analyzer.cljc:4235)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4263)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4246)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4256)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4246)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4254)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4246)
in 
shadow.build.cljs-hacks/shadow-parse-invoke*
 (cljs_hacks.cljc:745)
in 
shadow.build.cljs-hacks/shadow-parse-invoke*
 (cljs_hacks.cljc:741)
in 
cljs.analyzer/parse-invoke
 (analyzer.cljc:3730)
in 
cljs.analyzer/parse-invoke
 (analyzer.cljc:3728)
in 
cljs.analyzer/analyze-seq*
 (analyzer.cljc:3975)
in 
cljs.analyzer/analyze-seq*
 (analyzer.cljc:3972)
in 
cljs.analyzer/analyze-seq*-wrap
 (analyzer.cljc:3979)
in 
cljs.analyzer/analyze-seq*-wrap
 (analyzer.cljc:3977)
in 
cljs.analyzer/analyze-seq
 (analyzer.cljc:4003)
in 
cljs.analyzer/analyze-seq
 (analyzer.cljc:3981)
in 
cljs.analyzer/analyze-form
 (analyzer.cljc:4190)
in 
cljs.analyzer/analyze-form
 (analyzer.cljc:4187)
in 
cljs.analyzer/analyze*
 (analyzer.cljc:4243)
in 
cljs.analyzer/analyze*
 (analyzer.cljc:4235)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4263)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4246)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4256)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4246)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4254)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4246)
in 
shadow.build.cljs-hacks/shadow-parse-invoke*/fn--10224/fn--10225
 (cljs_hacks.cljc:752)
in 
clojure.core/mapv/fn--8445
 (core.clj:6912)
in 
clojure.core.protocols/fn--8159
 (protocols.clj:168)
in 
clojure.core.protocols/fn--8159
 (protocols.clj:124)
in 
clojure.core.protocols/fn--8114/G--8109--8123
 (protocols.clj:19)
in 
clojure.core.protocols/seq-reduce
 (protocols.clj:31)
in 
clojure.core.protocols/fn--8144
 (protocols.clj:75)
in 
clojure.core.protocols/fn--8144
 (protocols.clj:75)
in 
clojure.core.protocols/fn--8088/G--8083--8101
 (protocols.clj:13)
in 
clojure.core/reduce
 (core.clj:6828)
in 
clojure.core/mapv
 (core.clj:6903)
in 
clojure.core/mapv
 (core.clj:6903)
in 
shadow.build.cljs-hacks/shadow-parse-invoke*/fn--10224
 (cljs_hacks.cljc:752)
in 
clojure.lang.Delay
.deref
 (Delay.java:42)
in 
clojure.core/deref
 (core.clj:2320)
in 
clojure.core/deref
 (core.clj:2306)
in 
shadow.build.cljs-hacks/shadow-parse-invoke*
 (cljs_hacks.cljc:867)
in 
shadow.build.cljs-hacks/shadow-parse-invoke*
 (cljs_hacks.cljc:741)
in 
cljs.analyzer/parse-invoke
 (analyzer.cljc:3730)
in 
cljs.analyzer/parse-invoke
 (analyzer.cljc:3728)
in 
cljs.analyzer/analyze-seq*
 (analyzer.cljc:3975)
in 
cljs.analyzer/analyze-seq*
 (analyzer.cljc:3972)
in 
cljs.analyzer/analyze-seq*-wrap
 (analyzer.cljc:3979)
in 
cljs.analyzer/analyze-seq*-wrap
 (analyzer.cljc:3977)
in 
cljs.analyzer/analyze-seq
 (analyzer.cljc:4003)
in 
cljs.analyzer/analyze-seq
 (analyzer.cljc:3981)
in 
cljs.analyzer/analyze-form
 (analyzer.cljc:4190)
in 
cljs.analyzer/analyze-form
 (analyzer.cljc:4187)
in 
cljs.analyzer/analyze*
 (analyzer.cljc:4243)
in 
cljs.analyzer/analyze*
 (analyzer.cljc:4235)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4263)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4246)
in 
cljs.analyzer/analyze-seq
 (analyzer.cljc:4004)
in 
cljs.analyzer/analyze-seq
 (analyzer.cljc:3981)
in 
cljs.analyzer/analyze-form
 (analyzer.cljc:4190)
in 
cljs.analyzer/analyze-form
 (analyzer.cljc:4187)
in 
cljs.analyzer/analyze*
 (analyzer.cljc:4243)
in 
cljs.analyzer/analyze*
 (analyzer.cljc:4235)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4263)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4246)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4256)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4246)
in 
cljs.analyzer/fn--1928/fn--1931
 (analyzer.cljc:1928)
in 
cljs.analyzer/fn--1928
 (analyzer.cljc:1926)
in 
cljs.analyzer/fn--1928
 (analyzer.cljc:1849)
in 
clojure.lang.MultiFn
.invoke
 (MultiFn.java:252)
in 
cljs.analyzer/analyze-seq*
 (analyzer.cljc:3974)
in 
cljs.analyzer/analyze-seq*
 (analyzer.cljc:3972)
in 
cljs.analyzer/analyze-seq*-wrap
 (analyzer.cljc:3979)
in 
cljs.analyzer/analyze-seq*-wrap
 (analyzer.cljc:3977)
in 
cljs.analyzer/analyze-seq
 (analyzer.cljc:4003)
in 
cljs.analyzer/analyze-seq
 (analyzer.cljc:3981)
in 
cljs.analyzer/analyze-form
 (analyzer.cljc:4190)
in 
cljs.analyzer/analyze-form
 (analyzer.cljc:4187)
in 
cljs.analyzer/analyze*
 (analyzer.cljc:4243)
in 
cljs.analyzer/analyze*
 (analyzer.cljc:4235)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4263)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4246)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4256)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4246)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4254)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4246)
in 
cljs.analyzer/fn--2025
 (analyzer.cljc:2276)
in 
cljs.analyzer/fn--2025
 (analyzer.cljc:2272)
in 
clojure.lang.MultiFn
.invoke
 (MultiFn.java:252)
in 
cljs.analyzer/analyze-seq*
 (analyzer.cljc:3974)
in 
cljs.analyzer/analyze-seq*
 (analyzer.cljc:3972)
in 
cljs.analyzer/analyze-seq*-wrap
 (analyzer.cljc:3979)
in 
cljs.analyzer/analyze-seq*-wrap
 (analyzer.cljc:3977)
in 
cljs.analyzer/analyze-seq
 (analyzer.cljc:4003)
in 
cljs.analyzer/analyze-seq
 (analyzer.cljc:3981)
in 
cljs.analyzer/analyze-form
 (analyzer.cljc:4190)
in 
cljs.analyzer/analyze-form
 (analyzer.cljc:4187)
in 
cljs.analyzer/analyze*
 (analyzer.cljc:4243)
in 
cljs.analyzer/analyze*
 (analyzer.cljc:4235)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4263)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4246)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4256)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4246)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4254)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4246)
in 
cljs.analyzer/analyze-let-binding-init
 (analyzer.cljc:2297)
in 
cljs.analyzer/analyze-let-binding-init
 (analyzer.cljc:2295)
in 
cljs.analyzer/analyze-let-bindings*
 (analyzer.cljc:2317)
in 
cljs.analyzer/analyze-let-bindings*
 (analyzer.cljc:2306)
in 
cljs.analyzer/analyze-let-bindings
 (analyzer.cljc:2351)
in 
cljs.analyzer/analyze-let-bindings
 (analyzer.cljc:2350)
in 
cljs.analyzer/analyze-let
 (analyzer.cljc:2377)
in 
cljs.analyzer/analyze-let
 (analyzer.cljc:2361)
in 
cljs.analyzer/fn--2057
 (analyzer.cljc:2415)
in 
cljs.analyzer/fn--2057
 (analyzer.cljc:2413)
in 
clojure.lang.MultiFn
.invoke
 (MultiFn.java:252)
in 
cljs.analyzer/analyze-seq*
 (analyzer.cljc:3974)
in 
cljs.analyzer/analyze-seq*
 (analyzer.cljc:3972)
in 
cljs.analyzer/analyze-seq*-wrap
 (analyzer.cljc:3979)
in 
cljs.analyzer/analyze-seq*-wrap
 (analyzer.cljc:3977)
in 
cljs.analyzer/analyze-seq
 (analyzer.cljc:4003)
in 
cljs.analyzer/analyze-seq
 (analyzer.cljc:3981)
in 
cljs.analyzer/analyze-form
 (analyzer.cljc:4190)
in 
cljs.analyzer/analyze-form
 (analyzer.cljc:4187)
in 
cljs.analyzer/analyze*
 (analyzer.cljc:4243)
in 
cljs.analyzer/analyze*
 (analyzer.cljc:4235)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4263)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4246)
in 
cljs.analyzer/analyze-seq
 (analyzer.cljc:4004)
in 
cljs.analyzer/analyze-seq
 (analyzer.cljc:3981)
in 
cljs.analyzer/analyze-form
 (analyzer.cljc:4190)
in 
cljs.analyzer/analyze-form
 (analyzer.cljc:4187)
in 
cljs.analyzer/analyze*
 (analyzer.cljc:4243)
in 
cljs.analyzer/analyze*
 (analyzer.cljc:4235)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4263)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4246)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4256)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4246)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4254)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4246)
in 
cljs.analyzer/fn--2025
 (analyzer.cljc:2286)
in 
cljs.analyzer/fn--2025
 (analyzer.cljc:2272)
in 
clojure.lang.MultiFn
.invoke
 (MultiFn.java:252)
in 
cljs.analyzer/analyze-seq*
 (analyzer.cljc:3974)
in 
cljs.analyzer/analyze-seq*
 (analyzer.cljc:3972)
in 
cljs.analyzer/analyze-seq*-wrap
 (analyzer.cljc:3979)
in 
cljs.analyzer/analyze-seq*-wrap
 (analyzer.cljc:3977)
in 
cljs.analyzer/analyze-seq
 (analyzer.cljc:4003)
in 
cljs.analyzer/analyze-seq
 (analyzer.cljc:3981)
in 
cljs.analyzer/analyze-form
 (analyzer.cljc:4190)
in 
cljs.analyzer/analyze-form
 (analyzer.cljc:4187)
in 
cljs.analyzer/analyze*
 (analyzer.cljc:4243)
in 
cljs.analyzer/analyze*
 (analyzer.cljc:4235)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4263)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4246)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4256)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4246)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4254)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4246)
in 
cljs.analyzer/fn--1874/fn--1898
 (analyzer.cljc:1790)
in 
cljs.analyzer/fn--1874
 (analyzer.cljc:1790)
in 
cljs.analyzer/fn--1874
 (analyzer.cljc:1737)
in 
clojure.lang.MultiFn
.invoke
 (MultiFn.java:252)
in 
cljs.analyzer/analyze-seq*
 (analyzer.cljc:3974)
in 
cljs.analyzer/analyze-seq*
 (analyzer.cljc:3972)
in 
cljs.analyzer/analyze-seq*-wrap
 (analyzer.cljc:3979)
in 
cljs.analyzer/analyze-seq*-wrap
 (analyzer.cljc:3977)
in 
cljs.analyzer/analyze-seq
 (analyzer.cljc:4003)
in 
cljs.analyzer/analyze-seq
 (analyzer.cljc:3981)
in 
cljs.analyzer/analyze-form
 (analyzer.cljc:4190)
in 
cljs.analyzer/analyze-form
 (analyzer.cljc:4187)
in 
cljs.analyzer/analyze*
 (analyzer.cljc:4243)
in 
cljs.analyzer/analyze*
 (analyzer.cljc:4235)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4263)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4246)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4256)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4246)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4254)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4246)
in 
cljs.analyzer/fn--2025
 (analyzer.cljc:2276)
in 
cljs.analyzer/fn--2025
 (analyzer.cljc:2272)
in 
clojure.lang.MultiFn
.invoke
 (MultiFn.java:252)
in 
cljs.analyzer/analyze-seq*
 (analyzer.cljc:3974)
in 
cljs.analyzer/analyze-seq*
 (analyzer.cljc:3972)
in 
cljs.analyzer/analyze-seq*-wrap
 (analyzer.cljc:3979)
in 
cljs.analyzer/analyze-seq*-wrap
 (analyzer.cljc:3977)
in 
cljs.analyzer/analyze-seq
 (analyzer.cljc:4003)
in 
cljs.analyzer/analyze-seq
 (analyzer.cljc:3981)
in 
cljs.analyzer/analyze-form
 (analyzer.cljc:4190)
in 
cljs.analyzer/analyze-form
 (analyzer.cljc:4187)
in 
cljs.analyzer/analyze*
 (analyzer.cljc:4243)
in 
cljs.analyzer/analyze*
 (analyzer.cljc:4235)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4263)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4246)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4256)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4246)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4254)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4246)
in 
cljs.analyzer/analyze-let-body*
 (analyzer.cljc:2354)
in 
cljs.analyzer/analyze-let-body*
 (analyzer.cljc:2353)
in 
cljs.analyzer/analyze-let-body
 (analyzer.cljc:2359)
in 
cljs.analyzer/analyze-let-body
 (analyzer.cljc:2356)
in 
cljs.analyzer/analyze-let
 (analyzer.cljc:2395)
in 
cljs.analyzer/analyze-let
 (analyzer.cljc:2361)
in 
cljs.analyzer/fn--2057
 (analyzer.cljc:2415)
in 
cljs.analyzer/fn--2057
 (analyzer.cljc:2413)
in 
clojure.lang.MultiFn
.invoke
 (MultiFn.java:252)
in 
cljs.analyzer/analyze-seq*
 (analyzer.cljc:3974)
in 
cljs.analyzer/analyze-seq*
 (analyzer.cljc:3972)
in 
cljs.analyzer/analyze-seq*-wrap
 (analyzer.cljc:3979)
in 
cljs.analyzer/analyze-seq*-wrap
 (analyzer.cljc:3977)
in 
cljs.analyzer/analyze-seq
 (analyzer.cljc:4003)
in 
cljs.analyzer/analyze-seq
 (analyzer.cljc:3981)
in 
cljs.analyzer/analyze-form
 (analyzer.cljc:4190)
in 
cljs.analyzer/analyze-form
 (analyzer.cljc:4187)
in 
cljs.analyzer/analyze*
 (analyzer.cljc:4243)
in 
cljs.analyzer/analyze*
 (analyzer.cljc:4235)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4263)
in 
cljs.analyzer/analyze
 (analyzer.cljc:4246)
in 
cljs.analyzer/analyze-seq
 (analyzer.cljc:4004)
in 
cljs.analyzer/analyze-seq
 (analyzer.cljc:3981)
in 
cljs.analyzer/analyze-form
 (analyzer.cljc:4190)
in 
cljs.analyzer/analyze-form
 (analyzer.cljc:4187)
in 
cljs.analyzer/analyze*
 (analyzer.cljc:4243)
in 
cljs.analyzer/analyze*
 (analyzer.cljc:4235)
in 
shadow.build.compiler/analyze/fn--12959
 (compiler.clj:251)
in 
shadow.build.compiler/analyze
 (compiler.clj:239)
in 
shadow.build.compiler/analyze
 (compiler.clj:198)
in 
shadow.cljs.repl/repl-compile/fn--14388/fn--14389
 (repl.clj:459)
in 
shadow.cljs.repl/repl-compile/fn--14388
 (repl.clj:432)
in 
shadow.cljs.repl/repl-compile
 (repl.clj:430)
in 
shadow.cljs.repl/repl-compile
 (repl.clj:427)
in 
shadow.cljs.repl/process-read-result
 (repl.clj:518)
in 
shadow.cljs.repl/process-read-result
 (repl.clj:494)
in 
shadow.cljs.repl/process-input
 (repl.clj:674)
in 
shadow.cljs.repl/process-input
 (repl.clj:658)
in 
shadow.cljs.devtools.server.worker.impl/fn--15145
 (impl.clj:755)
in 
shadow.cljs.devtools.server.worker.impl/fn--15145
 (impl.clj:745)
in 
clojure.lang.MultiFn
.invoke
 (MultiFn.java:234)
in 
shadow.cljs.devtools.server.util/server-thread/fn--14808/fn--14809/fn--14817
 (util.clj:285)
in 
shadow.cljs.devtools.server.util/server-thread/fn--14808/fn--14809
 (util.clj:284)
in 
shadow.cljs.devtools.server.util/server-thread/fn--14808
 (util.clj:257)
in 
clojure.lang.AFn
.run
 (AFn.java:22)
in 
java.lang.Thread
.run
 (Thread.java:832)```
mauricioszabo commented 4 years ago

In Shadow-CLJS (ClojureScript), you can't evaluate the namespace if it contains node/browser/string requires because Shadow becomes confused. I don't know if this is a ClojureScript issue or Shadow one. You can reproduce the issue with a cljs-repl by doing the following code on the REPL:

(let [res
      (ns mario.combine
          (:require ["swagger-combine" :as swagger-combine]
                    [promesa.core :as p]))

(def combine-try
  (-> (swagger-combine "swaggers/dummy/combined-swaggers.json")
      (p/handle  (fn [res _err]
                   (-> res js/JSON.stringify js/console.log)))))

The fix is simply do not evaluate the ns form - ever. On shadow-cljs, hot-reload plays a significant role so everytime you save your file, your namespace is already up-to-date - no need to re-eval it :smiley: