Fork me on GitHub
#shadow-cljs
<
2022-04-19
>
thheller04:04:07

@zhuxun2 the asset path is not currently available in the code. goog.DEBUG depends on what you do, in theory it can allow to remove some code yes

pmooser07:04:04

When I am using shadow-cljs with some arbitrary npm, I often struggle a bit to try to figure out the right way to refer to elements in the javascript package. Once I do a basic require of something, is there any way to introspect or look inside it to see what it provides?

pmooser07:04:18

I often spend a fair bit of time fumbling around in the dark before I figure it out.

pmooser07:04:56

For example, I just installed an npm called rc-slider, and in their example, they do this (in js):

pmooser07:04:01

const Slider = require('rc-slider');
const createSliderWithTooltip = Slider.createSliderWithTooltip;
const Range = createSliderWithTooltip(Slider.Range);

pmooser07:04:11

I thought that would map to something like:

pmooser07:04:54

(require '["rc-slider" :as rcs])
(rcs/createSliderWithTooltip rcs/Range)

pmooser07:04:05

But rcs/createSliderWithTooltip is just nil, so I'm clearly reading this wrong.

pmooser07:04:32

Oh jeez, this looks like a bug with this stupid library.

pmooser13:04:12

I'm trying to use this reagent library reagent-mui, and when I import a specific namespace, I see some load failures from shadow-cljs in my console:

shadow-cljs - failed to load module$node_modules$$mui$material$node$styles$ThemeProvider
shadow-cljs - failed to load module$node_modules$$mui$material$node$styles$index
I looked at the related stack traces, and they mention the bootstrap build, so I tried to exclude the ns I imported from the bootstrap build, but with no effect.

pmooser13:04:15

Any suggestions?

thheller17:04:58

@pmooser if you are on an old shadow-cljs version you should upgrade. that error message should be clearer now. you are pasting irrelevant parts

pmooser08:04:02

Ok, I've updated to 2.18.0, and now here's a more complete error message: (It won't let me copy/paste the exception info as text, so here's an image)

pmooser08:04:59

There is a bit more to the exception as well ...

pmooser08:04:57

@U05224H0W Here is the rest of that stack trace from above:

pmooser08:04:04

Since updating, I'm also seeing this exception:

pmooser08:04:44

That occurs upon reloading CSS.

thheller09:04:27

you are still looking at the wrong error

thheller09:04:45

look for something red, yellow are warnings. ignore those.

thheller09:04:58

should be above the failed to load warnings

pmooser09:04:17

The load warnings occur before the errors.

pmooser09:04:19

Here are the errors:

pmooser09:04:40

@U05224H0W I see bootstrap again in those stack traces, but I haven't succeed so far at excluding things and making the error go away.

thheller09:04:06

what do you mean?

pmooser09:04:28

I mean the stack trace contains a line like this, that makes me wonder if the bootstrap build is implicated in causing this problem:

pmooser09:04:31

at Object.shadow$cljs$bootstrap$browser$script_eval [as script_eval] (browser.cljs:38:4)

pmooser09:04:59

Anyway, I can just not import this namespace. It's not vital, but it's just odd to have an import of a namespace break things.

pmooser09:04:35

If I can't figure out what is making it emit errors on every CSS reload, I'll probably have to revert to an older shadow-cljs too.

thheller09:04:36

I really cannot offer any comments without more information

thheller09:04:57

I don't know what you are doing so just looking at a trace doesn't tell me enough

thheller09:04:11

might be bootstrap related, might not be. I cannot tell

thheller09:04:50

maybe you are trying to hot-reload boostrap code?

thheller09:04:53

that doesn't work

pmooser09:04:17

@U05224H0W I know that hot-reloading bootstrap code doesn't work. I have a couple builds, one of which is a bootstrap build, but it's just for an embedded repl that I use in my application. What information would be useful, if the stack traces are all not sufficiently informative to figure out what the bugs are? I don't really need the bootstrap build to be compiling anything in my app that is related to the UI, so strictly speaking the namespace that is even loading this code isn't relevant at all to bootstrap.

thheller09:04:24

you mean you have 3 builds in your page? your regular app, your embedded REPL and the boostrap?

thheller09:04:38

or is the embedded REPL part of the regular app?

pmooser09:04:25

The embedded repl is part of my normal app. For development purposes, I have either 2 or 3 builds running. The simpler case is something like: shadow-cljs watch app-simple bootstrap

pmooser09:04:38

Where app-simple is a normal build, bootstrap is a bootstrap build.

thheller09:04:11

can you be more specific about the embedded REPL thing? self-hosted interacting with a regular watch is pretty much guaranteed trouble

thheller09:04:37

specifically why do you go full self-hosted?

pmooser09:04:25

I feel like every time there's an issue with bootstrap and I ask a question, it turns out that bootstrap is the source of all problems in the world.

pmooser09:04:32

Sorry to exaggerate, but it's extremely aggravating.

pmooser09:04:47

I think I'll just do the work to switch over to sci instead of using the bootstrap build,

pmooser09:04:52

and then hopefully this will become more reliable.

thheller09:04:06

just take 5 seconds to explain what you are trying to do

thheller09:04:29

self-host is just the most complicated thing you can do. so it is easy to make mistakes and screw something up

thheller09:04:42

if you just want a eval for development purposes you can use https://clojureverse.org/t/status-update-inspect-cljs-eval/6074#cljs_eval-2

thheller09:04:02

no need for sci either

pmooser09:04:11

I have an application - a fairly normal reagent-based cljs application. As part of that application, I have a window that will evaluate code that I type. This is not the core of the application, but it's an extremely useful capability in the app, for a variety of reasons. I use the bootstrap build because to my knowledge that's the way to support that.

pmooser09:04:38

This also happens to run in production, so I'm not sure that will work either.

pmooser09:04:53

But I haven't fully digested the link you just sent me ...

thheller09:04:59

ok cljs-eval will not be available in production

pmooser09:04:02

Yeah. So I think due I guess to the unfortunate nature of bootstrap, the best thing for me (and for you, so I stop bugging you with questions about a part of the cljs ecosystem that I suppose just doesn't work very well) is probably to migrate to sci. That way, there's no mysterious build happening anymore, which I imagine will eliminate most of these issues.

pmooser09:04:36

Any insight on what might be causing that error on CSS reload in shadow-cljs 2.18.0 that I mentioned above?

thheller09:04:42

it works just fine. just easy to make mistakes and use incorrectly. thats the nature of the system, if you use it correctly it works fine.

thheller09:04:01

no since I still don't have a clue what you are doing

pmooser09:04:12

Well, I've been using bootstrap like this for ... 2 years now? Generally it works. It's just that when it doesn't, it's not clear how to fix it.

thheller09:04:21

you might have the bootstrap parts load some code that is already loaded and overriding important parts

pmooser09:04:38

I have some things exluded from the build, but I don't even see :exclude mentioned in the docs anymore (?)

pmooser09:04:03

I don't understand what you mean that you have no idea what I'm doing.

pmooser09:04:06

Like, what I'm doing isn't that weird.

pmooser09:04:15

I've been using shadow-cljs like this for literally years.

pmooser09:04:19

Now I've upgraded, and there's a new error.

thheller09:04:23

I'm not saying that. I just don't know WHAT you are doing

thheller09:04:31

so I cannot just guess a random solution out of a hat

thheller09:04:42

it might be something extremely trivial

thheller09:04:46

it might be an actual bug

thheller09:04:49

or something inbetween

thheller09:04:51

I cannot say

pmooser09:04:03

I feel like I'm wasting your time.

pmooser09:04:19

I'll go ahead and revert to the old version and just forget about it.

thheller09:04:34

happy to look at some code to make better guesses

pmooser12:04:08

@U05224H0W So when I try to revert to the previous shadow-cljs version I get some errors, so I'm once again trying to fix this CSS reloading error I'm seeing with 2.18.0. You said before you didn't know "what I was doing", but I have a basic reagent application. I'm doing a shadow-cljs watch my-build bootstrap and basically if I modify my site.css file, I get a shadow-cljs exception in my console when it reloads my site.css file. It also doesn't overwrite or update an existing style, but seems to load/create duplicate styles (if I'm looking at elements in a chrome inspector). What kind of information could I provide that would help to debug this?

pmooser12:04:21

I will try to migrate away from the bootstrap build but that takes a little bit of work for me also.

thheller13:04:48

most likely you are trying to diagnose the wrong thing

thheller13:04:15

the css thing failing is most likely just a symptom of something else going wrong before that

pmooser13:04:41

How would you track it down, since there are no other errors or warnings appearing in the console, and the only place I've noticed a side effect of this error is in the element inspector in chrome (where it is visible that it is failing to replace styles) ?

pmooser13:04:51

There is also no error (css-related or otherwise) upon first page load.

thheller13:04:20

again, very likely not css related at all

thheller13:04:54

my guess is on the bootstrap stuff being loaded out of order or replacing the bootstrap compiled ns with one compiled by shadow-cljs

pmooser13:04:57

If the software fails silently, I have no idea what to do.

pmooser13:04:11

I guess I'll proceed along the path of trying to remove the bootstrap build and see if that helps anything.

thheller13:04:45

if the problem goes away if you just don't init the bootstrap stuff that should provide good information

thheller13:04:10

note that it could also be the bootstrap build completely replacing cljs.core

thheller13:04:23

lots of possible causes here. very hard to debug remotely without any code

pmooser13:04:07

Thank you, and understood. It sounds like this path isn't a bad idea regardless, and I'll be sure to update you if the problem disappears after removing bootstrap.

thheller13:04:19

I can't tell from the error excerpt you posted but is this log showing up just before the css is failing?

thheller13:04:19

(devtools-msg (str "call " fn-sym))

thheller13:04:51

or asked different do you have a :dev/asset-load hook anywhere in your code?

thheller13:04:23

if not it shouldn't even get to that line

thheller13:04:59

also are you sure you upgraded shadow-cljs properly and restarted it after? too often people just update the npm package while still having an old version in deps.edn/project.clj

pmooser13:04:47

• I'm not using :dev/asset-load anywhere in the code at all. • I'm sorry but I don't understand the question about the log showing up - at this point, the only error occurring is when I save my CSS file, and shadow-cljs reloads it - that's when these log messages show up, and there are no other errors or warnings before or after. Please help me understand what I'm failing to explain here. • Where should I put that (devtools-msg ... line?

thheller13:04:34

you should not put that anywhere. in your stacktrace of the css error it is pointing to browser.cljs line 141

pmooser13:04:47

I just forcibly removed the bootstrap build/etc and for now it appears the error may be gone.

pmooser13:04:59

(at least it doesn't occur immediately after reloading my page)

thheller13:04:16

that would be that line, which immediately before that has the log line that should show up in the console

thheller13:04:00

but that piece of code should only even be called when you have a :dev/asset-load hook

thheller13:04:10

since you don't I'm assuming you are not actually on 2.18.0

thheller13:04:27

or just something else is mucking arround

pmooser13:04:32

:aliases {:shadow-cljs {:extra-deps {thheller/shadow-cljs {:mvn/version "2.18.0"}}
                         :main-opts ["-m" "shadow.cljs.devtools.cli"]}

pmooser13:04:59

That's my alias I'm using to launch shadow-cljs - I don't see how that could not be 2.18.0 but I'm not super expert at deps.edn so maybe there's some way.

pmooser13:04:42

I didn't know that :dev/asset-load exists, so it definitely isn't in my code, and I've verified this by grepping everything in the project.

pmooser13:04:36

Given that the issue seems to be gone with the bootstrap build excised from this entire thing, maybe it's not something you have to worry about. Or, if you think the info could be of value to you, I could restore the bootstrap build to try to get some diagnostic information.

thheller13:04:43

assuming that alias is actually activated that should be fine then

pmooser13:04:24

I mean that's how I launch the build ...

thheller17:04:10

can't say whats wrong with the proper info

thheller17:04:26

also can't say whats wrong with rc-slider. translation looks correct.

ribelo20:04:41

is it possible to use shadow-cljs with deno and working repl?

ribelo20:04:00

shadow-cljs compile returns code that works

ribelo20:04:43

but shadow-cljs watch is already crashing

ribelo20:04:25

never mind, i found the answer