Fork me on GitHub
#shadow-cljs
<
2021-03-15
>
Karol Wójcik10:03:22

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.

thheller10:03:37

currently there is no easy answer to this API wise

thheller10:03:01

you can technically reconstruct it from the build data but no readymade function currently

Karol Wójcik11:03:18

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

jacekschae15:03:44

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

👍 6
wombawomba22:03:23

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 ()
   at Object.env.evalLoad ()
   at 
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?

wombawomba22:03:25

Like, is there a way to eval the statements in the file one by one?

thheller22:03:49

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

thheller22:03:52

messing each other up

thheller22:03:35

could also be one instance but two builds using the same :output-dir

wombawomba22:03:43

I did do that yesterday

thheller22:03:57

you can set :devtools {:loader-mode :script} in the build config

wombawomba22:03:01

how do I clean this up? should deleting the output directory suffice?

thheller22:03:22

first identify that there is only one instance running

wombawomba22:03:52

yeah there are zero instances right now :)

thheller22:03:36

and you only have one build writing to the output-dir? and no other processes modifying that output in any way?

wombawomba22:03:54

but like I said, I had two earlier

thheller22:03:28

restarting will recreate all the files properly but if you want you can clean out the output-dir as well

thheller22:03:44

unlikely to change anything

wombawomba22:03:54

I did restart a few times afterwards, so maybe something else is going on here

thheller22:03:00

the :loader-mode will load things as one script at a time, instead of all at once

thheller22:03:26

but normally the eval loader should also tell you which file failed at least

wombawomba22:03:45

yeah it does tell me, but it's not helpful because that file is huge

wombawomba22:03:16

yeah no, still fails

wombawomba22:03:23

I'll try the loader-mode thing next

thheller22:03:50

which server is serving :8281?

wombawomba22:03:45

alright, :loader-mode :script gave me a much nicer error, albeit in a different file...

wombawomba22:03:13

I'll try to solve that one and see if I can get to the other thing that was failing 🙂

thheller22:03:28

:script will not abort loading if one file fails. so it likely just creates a cascade of other errors

wombawomba22:03:43

oh wait, duh

wombawomba22:03:56

yeah, the original error is there — I just missed it

wombawomba22:03:13

it's telling me which line is failing now though

wombawomba22:03:29

it's a bad regex

wombawomba22:03:37

thanks for the help!

thheller22:03:47

interesting. good to know.

wombawomba22:03:41

BTW, is there a way to get something like lein checkouts with shadow-cljs?

wombawomba22:03:49

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

wombawomba22:03:48

...which seems pretty far from optimal 🙂

thheller22:03:11

well the obvious answer is use lein checkouts 😉 or deps.edn via :local/root

thheller22:03:10

or just adding the :source-paths might work too (thats what I usually do)

wombawomba22:03:29

huh 🙂 I didn't realize I could use lein and shadow-cljs together