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}}}
You can't do this (compile-it)
until the above init
has completed
so you are just calling it too early
init
will already call it when its done
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)
Hi. I have an Expo app that I just ejected to bare workflow, so now it's plain React Native. I am wondering what is the best way to create an App.js in my directory. Can I automate it with shadow-cljs?
well you removed a couple things from the config
so I'm guessing your server isn't setup correctly
NVM, I figured it out. I need to point shadow-cljs.edn to the. App/ build dir.
by default it expects to load stuff from /bootstrap
but seems like you are loading it in node?
oh right I missed that
I'm guessing your paths aren't quite right?
sorry I don't have a clue what an ejected app looks like
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)?
:path "out/extension/bootstrap"
how do you run the stuff anyways? from "extension" I gather its not regular node?
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
hmm yeah no clue if the bootstrap.node will work there
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
maybe you need a similar path/resolve
call
Yea, I could try that
That worked! I removed the :path
and it is working 🙂
So many thanks for the help 🙂