Fork me on GitHub
#shadow-cljs
<
2022-12-20
>
Jakub Holý (HolyJak)09:12:13

Hello! If I want to implement a custom :js-provider (for pnpm) and thus extend the s.b.resolve/find-resource-for-string* multimethod, https://github.com/thheller/shadow-cljs/issues/670#issuecomment-732788677, how do I do that? Can it be in my own code or do I need to clone shadow-cljs and then somehow use the local, extended version of it? (I guess via direct invocation with clj it would be possible.) Thank you!

thheller11:12:29

I'd start with just a function that does the pnp-resolve, as I wrote in that comment

thheller11:12:50

after that if you are working in the REPL you can just load your namespace with the defmethod

👍 1
thheller11:12:02

and it'll just be available for the build to use

Jakub Holý (HolyJak)11:12:05

Yes but I somehow need to get shadow to call the function,no?

thheller11:12:34

yes, as described in the comment above you take the impl for the defmethod for :shadow

thheller11:12:48

and modify it to use pnp-resolve instead of the built-in npm resolve

Jakub Holý (HolyJak)11:12:00

So my initial understanding that I defmethod s.b.resolve/find-resource-for-string* that calls my own resolve-pnpm was correct, and the way to go about it is to use REPL and run shadow build from there.

thheller11:12:15

well the build you can trigger from whereever

thheller11:12:27

just need to load your namespace with the defmethod in some way

👍 1
thheller11:12:43

and the easiest way for that is the repl