Fork me on GitHub
#shadow-cljs
<
2022-02-18
>
Oliver George04:02:05

Based on https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external I'm switching to :js-provider :external because @react-pdf/renderer is incompatible (wasm) with the standard bunding approach. That means an extra step to run webpack after shadow-cljs compile to build a single js file. Wondering what the best way to handle the dev time case. Should I use :build-hooks to trigger the webpack after each build?

Oliver George04:02:40

Huh, got the PDF viewer working but broke everything else!

Module not provided: shadow.js.shim.module$react

thheller06:02:17

check the :internal-index generated by shadow-cljs. it should contain require("react")

thheller06:02:44

I strongly recommend NOT coupling anything webpack to your shadow-cljs build

thheller06:02:04

just run it separately

thheller06:02:20

if you don't change npm dependencies often you can usually just run it by hand

thheller06:02:48

it only needs to run if you actually change npm requires, it does not need to run when you only work on cljs sources

👍 1
thheller07:02:36

oh I just noticed "to build a single js file"

thheller07:02:47

this is intended as two separate files and must be used as such

thheller07:02:00

one for the webpack output and one for the shadow-cljs output

thheller07:02:36

webpack must never process the regular output of shadow-cljs, only the :external-index

Oliver George08:02:45

Ah, "one single file" was confusing. Was aiming at a lib.js and an app.js.

thheller08:02:27

ah ok. single file would cause errors like yours so that got me confused 🙂

Oliver George08:02:15

I'll do a simple repro and try and get a handle on it. It'd be lovely to keep shadow-cljs... this react-pdf lib just keeps sneaking in as a requirement (enterprise clients)

thheller08:02:39

I setup this repo a while ago showing how to use a cdn version of pdfjs

thheller08:02:19

maybe something similar works for you? all these pdf libs are kinda heavy

thheller08:02:50

dunno how much react-pdf actually wraps

Oliver George08:02:48

Thanks but no CDN for this one I know of

Oliver George08:02:39

Basics work :-)

Oliver George08:02:46

Will look into my other issue

Oliver George08:02:57

Hopefully unrelated