This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-05-01
Channels
- # announcements (1)
- # babashka (73)
- # bangalore-clj (7)
- # beginners (295)
- # calva (128)
- # chlorine-clover (3)
- # cider (9)
- # cljsrn (10)
- # clojure (63)
- # clojure-europe (11)
- # clojurescript (1)
- # clojureverse-ops (3)
- # conjure (3)
- # emacs (7)
- # fulcro (13)
- # graalvm (8)
- # honeysql (16)
- # jobs-discuss (14)
- # malli (21)
- # meander (8)
- # onyx (1)
- # pathom (7)
- # portkey (2)
- # quil (3)
- # re-frame (4)
- # reagent (31)
- # reitit (2)
- # rewrite-clj (40)
- # shadow-cljs (29)
- # sql (20)
- # xtdb (13)
Hi, I’m trying get the CLJS bootstrap repl to work via shadow.cljs.bootstrap.node
. I was checking the post here https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html for some tips. When I try to eval something I get
[:result {:error #error {:message "Could not eval [test]", :data {:tag :cljs/analysis-error}, :cause #error {:message nil, :data {:clojure.error/source nil, :clojure.error/line 1, :clojure.error/column 1, :clojure.error/phase :compilation}, :cause #error {:message "Cannot read property 'findInternedVar' of null at line 1 ", :data {:file nil, :line 1, :column 1, :tag :cljs/analysis-error}, :cause #object[TypeError TypeError: Cannot read property 'findInternedVar' of null]}}}}]
Can you see if there is something wrong with my configs or code:code:
require these:
[cljs.js :as cljs]
[cljs.env :as env]
[shadow.cljs.bootstrap.node :as shadow.bootstrap]
...
(defn print-result [{:keys [error value] :as result}]
(prn [:result result]))
(def code "(+ 1 2)")
(defonce compile-state-ref (env/default-compiler-env))
(defn compile-it []
(cljs/eval-str
compile-state-ref
code
"[test]"
{:eval cljs/js-eval
:load (partial shadow.bootstrap/load compile-state-ref)}
print-result))
(shadow.bootstrap/init compile-state-ref
{:path "out/extension/bootstrap"}
compile-it)
(compile-it)
And shadow-cljs.edn build section:
:builds
{:dev {:target :node-library
:output-to "out/extension/extension.js"
:output-dir "out/extension"
:exports-var prode.extension/exports
:devtools {:repl-pprint true}
:compiler-options {:source-map-detail-level :all
:output-wrapper false
:optimizations :simple}}
:bootstrap {:target :bootstrap
:output-dir "out/extension/bootstrap"
:entries [cljs.js]
:macros []
:exclude #{cljs.js}
:compiler-options {:warnings {:infer false}
:optimizations :simple}}}
I moved calling that function inside a comment block and evaluated it from there. This gives me the same error message. If shadow.bootstrap/init
is going to run the compile-it
, where should I see the result (it’s not printed to the REPL)?
I changed the call-back function to a new function that would print something, and now I see some errors in the node-env’s (it is actually a vscode debug instance) logs something
[2021-05-01 21:53:18.838] [renderer11] [error] transit-load failed: Error: transit-load failed
at new cljs$core$ExceptionInfo (/Users/janne/Dev/clojure/prode/out/extension/cljs-runtime/cljs/core.cljs:11455:1)
at Function.cljs$core$IFn$_invoke$arity$3 (/Users/janne/Dev/clojure/prode/out/extension/cljs-runtime/cljs/core.cljs:11484:1)
at Function.cljs$core$IFn$_invoke$arity$2 (/Users/janne/Dev/clojure/prode/out/extension/cljs-runtime/cljs/core.cljs:11484:1)
at ReadFileContext.callback (/Users/janne/Dev/clojure/prode/out/extension/cljs-runtime/shadow/cljs/bootstrap/node.cljs:38:9)
at FSReqCallback.readFileAfterOpen [as oncomplete] (fs.js:265:13)
at FSReqCallback.callbackTrampoline (internal/async_hooks.js:120:14)
It seems that one is coming from shadow (https://github.com/thheller/shadow-cljs/blob/6b662c0e05fb560216984746818d658fea8b2963/src/main/shadow/cljs/bootstrap/node.cljs#L38)
I won’t rule that option out 😄 I have been trying with different paths but I haven’t been able to find a working setup. The dev-build output the build stuff to out/extension
and the output is inside that one out/extension/bootstrap
. Did you mean that bootstrap should go actually on the same level as the out
folder (project root)?
This is something I have been experimenting. To create a VSCode extension that would execute cljs via the bootstrap repl. So the output js is loaded to vscode as an extension
it could work like a normal node env but it might have some differences. Maybe I try to get this working in normal node first. Then I can check if everything is okay on vscode side
maybe try not setting :path
at all? it defaults to this https://github.com/thheller/shadow-cljs/blob/015926609e1c070de57efa71646c46f92f08d7d9/src/main/shadow/cljs/bootstrap/node.cljs#L13
Yea, I could try that
So many thanks for the help 🙂