How can I check which dependency includes cljs.test and cljs.pprint? I can see in shadow-report both of those included, whereas I don't have explicit require for them in the application.
currently there is no easy answer to this API wise
you can technically reconstruct it from the build data but no readymade function currently
Hmm.. I think the fastest way would be to stub cljs.pprint with some ns which includes throw of an error and check stacktrace. Will check it out
If you wondering how to setup devcards with shadow-cljs here is an example: https://github.com/jacekschae/shadow-cljs-devcards also created a PR to add to the examples
So I have some code that compiles fine in shadow-cljs, but gives me the following error when I try to load it in the browser:
SyntaxError: Invalid or unexpected token
at eval (<anonymous>)
at Object.goog.globalEval (<http://localhost:8281/static/js/base.js:577:21>)
at Object.env.evalLoad (<http://localhost:8281/static/js/base.js:1670:12>)
at <http://localhost:8281/static/js/base.js:1946:12>
The error doesn't really tell me where the problem lies, and the compiled js file being loaded is >4000 lines. How can I figure out what's causing the error?Like, is there a way to eval the statements in the file one by one?
the only way I have seen this error before is when two shadow-cljs instances are running at the same time and writing to the same files
messing each other up
could also be one instance but two builds using the same :output-dir
I did do that yesterday
you can set :devtools {:loader-mode :script}
in the build config
how do I clean this up? should deleting the output directory suffice?
first identify that there is only one instance running
yeah there are zero instances right now :)
and you only have one build writing to the output-dir? and no other processes modifying that output in any way?
yeah
but like I said, I had two earlier
restarting will recreate all the files properly but if you want you can clean out the output-dir as well
alright
unlikely to change anything
I did restart a few times afterwards, so maybe something else is going on here
the :loader-mode
will load things as one script at a time, instead of all at once
but normally the eval loader should also tell you which file failed at least
yeah it does tell me, but it's not helpful because that file is huge
yeah no, still fails
I'll try the loader-mode thing next
which server is serving :8281
?
shadow-cljs
alright, :loader-mode :script
gave me a much nicer error, albeit in a different file...
I'll try to solve that one and see if I can get to the other thing that was failing 🙂
:script
will not abort loading if one file fails. so it likely just creates a cascade of other errors
oh wait, duh
yeah, the original error is there — I just missed it
it's telling me which line is failing now though
it's a bad regex
thanks for the help!
interesting. good to know.
BTW, is there a way to get something like lein checkouts with shadow-cljs?
right now my workflow when working on cljs/cljc libraries with my cljs project is basically 1. make a change to a library 2. quit shadow-cljs 3. reinstall the library to my local maven repo 4. start shadow-cljs again 5. find something I want to change, go back to 1
...which seems pretty far from optimal 🙂
well the obvious answer is use lein
checkouts 😉 or deps.edn
via :local/root
or just adding the :source-paths
might work too (thats what I usually do)
huh 🙂 I didn't realize I could use lein and shadow-cljs together
very cool