Fork me on GitHub
#shadow-cljs
<
2023-08-16
>
seanstrom11:08:02

I have a question about splitting modules with shadow-cljs. I’ve noticed that shadow-cljs can output several module files for one build, and now I’m wondering how I can combine that with using :js-options {:js-provider :import} and something like Webpack. My goal is to let shadow-cljs handle building the cljs code, and then bundle the output JS with something like Webpack. If shadow-cljs outputs several modules (with a manifest), do I need to bundle each module with webpack (if they use npm dependencies)?

thheller12:08:02

yes. with :js-provider :import every module will contain a reference to the actual npm dependencies used in that module. technically you can skip those without any npm, but that seems risky to me 😛

😸 2
seanstrom13:08:48

Thanks for the reply, and you’re right I’ll be careful and try bundling each of them 😆

thheller13:08:50

note that webpack handles code splitting very differently than shadow-cljs, so there might be rough edges. I don't even know if its possible to let webpack handle modules and keep them as modules that way 😛

seanstrom13:08:21

Yeah I guess I’ll need to try experimenting and see what happens. I was thinking of trying vite or esbuild (since they seem simpler to configure) and hopefully it will be a simple process, but who knows with this kind of combination 😅