Fork me on GitHub
#shadow-cljs
<
2024-04-09
>
mauricio.szabo23:04:08

Hi, I'm having an weird problem. I'm working with ClojureScript to do plug-ins for an editor - meaning I can have two, or more, Shadow-CLJS compiled code running at the editor. They are all running in release mode, but they are all compiled with --pseudo-names because it's easier to debug issues when they happened. But - one of the plug-ins don't work when I compile with --pseudo-names - it gives me the error Error: No protocol method IPromise.-merr defined for type object: [object Promise] (I'm using Promesa, double and triple checked that I don't have multiple Promesa versions in my path). Anyone had a similar problem?

mauricio.szabo23:04:14

I have no idea if that's related, but I remember having the same problem when I used Atom in the past (without Shadow) and I did solve by adding :output-wrapper true. Shadow's documentation says that this option is only relevant for the browser target, and I did try to add it in my config, and it didn't change the output; I also found that Shadow generates a var shadow$provide = {}; in the top-level; again, not sure if it's relevant...

thheller07:04:28

it is not supported to have two builds in the same context

thheller07:04:31

well, I guess it depends on the target? :target :esm should be fine

thheller07:04:10

:target :browser or whatever else that lives in the global scope will be a problem as some "glue" code such as shadow$provide needs to be global

mauricio.szabo14:04:52

So it seems that multiple release builds with pseudo-names are conflicting with each other? Is that possible?

thheller17:04:31

in :node-library no. assuming its actually getting loaded in node of course?

thheller17:04:08

there is also no shadow$provide in node builds? or do you use :js-provider :shadow?

thheller17:04:44

or are you trying to pass one CLJS object from one build to another? that'll not work since they are different "types"

mauricio.szabo17:04:07

Yes, I'm using :js-provider :shadow

mauricio.szabo17:04:56

(and no, I'm not trying to pass one CLJS object from one build to another, it's just two builds that use promesa in different versions that are somehow conflicting with each other because both extend the Promise Javascript object)

thheller18:04:00

well since its extending the js Promise type the protocol might override each other I guess

thheller18:04:20

guaranteed by the pseudo-names, since that ensures its the same protocol property

thheller18:04:18

and in cljs things use the cljs.core/PROTOCOL-SENTINEL to verify that something actually implements the protocol. since that will be different objects for each build, they basically overwrite each other

mauricio.szabo19:04:20

That makes a lot of sense, thanks for the help!

mauricio.szabo19:04:35

Never though about the implications of pseudo-names, good to know

thheller19:04:55

well it could totally happen for regular :advanced code too

thheller19:04:03

will definitely happen for :simple