Fork me on GitHub
#shadow-cljs
<
2021-10-01
>
mattly04:10:47

I'm sorry if this is answered elsewhere but I really couldn't find it, but, if I'm targeting a node library for my shadow-cljs project, is there a way to tell the closure compiler that some of the dependencies are peer dependencies? Like, I'm making a React component that I want to be able to consume from regular JS, and I'd like for the consuming project to provide react

borkdude07:10:45

@mattly Yes, this is possible.

:js-options
   {:resolve {"react" {:target :global
                       :global "React"}}}}

🎉 1
thheller17:10:09

that seems unrelated to the question is only really relevant for browser builds wanting to use stuff from a CDN or so. definitely not node librries

borkdude18:10:37

Ah gotcha, I assumed browser

mattly18:10:10

Well, it’s going to end up in the browser

mattly18:10:20

I’m just thinking about how to reduce the asset sizes

cap10morgan17:10:48

Annoying question alert (b/c the fair answer is "just use shadow-cljs"): I'm trying to package my target-bundled CLJS into an ES module, but I keep running into ReferenceError: self is not defined from the very early assignment goog.global=this||self. I have "type": "module" in my package.json file and am trying to create an ES module package. Anyone have any pointers as to what is going on there?

cap10morgan17:10:52

Since shadow-cljs has an ES module output feature, was just curious if anyone knew or could point me towards the basic stuff it was doing there

thheller18:10:31

for example for development builds it replaces that line

thheller18:10:55

there are a few more things going on though to get it all working properly

borkdude18:10:32

@U06FS3DLH I have a working setup with :target :esm for node as well.

cap10morgan18:10:51

Awesome, thank you @U05224H0W!

cap10morgan18:10:31

@U04V15CAJ oh? you mean w/ shadow-cljs or just tools.deps?

cap10morgan18:10:11

interesting. didn't know :target :esm was an option

borkdude18:10:59

(@U05224H0W helped me with this a lot, thanks again)

cap10morgan18:10:01

right, I saw it was an option in shadow-cljs. didn't think it was one w/ just tools.deps (or, I guess, just the plain cljs compiler in that context)

thheller18:10:18

it is shadow-cljs only at this time

👍 1
thheller17:10:35

@mattly I'm assuming by "node library" you mean actual :target :node-library published to npm? that by default doesn't bundle any dependencies so no further configuration is required. whether you declare your dependency on react as a regular dependency or node peerDependency is up to you and doesn't matter from the shadow-cljs perspective

mattly18:10:32

Yes, though instead of publishing to npm I want to use it in a JS-based project locally