I integrated tldraw v3 into my re-frame app. It's working but I have no idea whether it's a whack job. 🙂 The thing is, shadow-cljs was giving me so many compilation issues related to ES6 modules and others. I ended up compiling it with webpack and imported it. Do you guys do this? Is this common? Are there better ways?
what issues did you see with shadow-cljs?
It's been a while but here's a summary from my notes:
What broke w/ shadow-cljs:
• Parser choked on transitive deps (e.g. Radix UI) using ES2022 private fields → build/runtime errors.
• React gotchas: duplicate React → “invalid hook call”; portals failing → createPortal not found.
• Tried ESM + :resolve tweaks → shadow still analyzes modern syntax in deps.
What worked:
• Prebundle tldraw with a JS bundler (I used Webpack; Vite/Rollup would do).
• Externalize React/React-DOM so there’s exactly one React.
• Load the bundle from CLJS (tiny wrapper), done.
you can just offload the JS processing to webpack using this method https://shadow-cljs.github.io/docs/UsersGuide.html#js-provider-external
simplifies the setup a bit I guess
otherwise private fields should be supported in the latest version. duplicate react happens when your dependency structure demands it, so you'll need to resolve that on the npm side. a build report usually helps with debugging that
if you want to setup a small repro I can take a look
I never tried the package myself, so can't comment much on what the issues may be
Thanks @thheller. I faced the same issue with excalidraw actually. The code is integrated inside my larger project, I will setup a separate repo for review. Thanks. But, if the external bundler path is available inside cljs, I guess it's not too much of a hack?
well apart from having to run webpack yes, that method is well supported, but has its limits. packages that do a lot of dynamic imports then to cause issues, then its best to go with :target :esm and :js-provider :import and running everything through webpack https://shadow-cljs.github.io/docs/UsersGuide.html#_third_party_tool_integration
Thanks a lot. I'll take a look