How can I offload ReactJS and various ReactJS components (not mine, but Bootstrap, leaflet etc.) to load from a CDN rather than be bundled with my app to keep the size of my app that I host as small as possible (bundled it's 500kb, calling scripts from CDN it's 13kb).
I did have this working by placing the ESM links to the CDN in the from section, but then on a rebuild started getting random errors where it seemed that code was being asked to run before it had finished downloading and parsing.
Having gone down nearly every rabbit hole and plugin available I now have a working solution for ReactJS 19.0.0.
with
import { createRoute } from 'https://esm.sh/react-dom@19.0.0/client''
Where the number is the version and create a service worker to cache off the requests as not to go over the esm.sh build limitation.
Lessons learnt do avoid others following the rabbit holes:
I hope this helps anyone who comes across this in the future since with so many legacy guides around and work arounds were this couldn't be done easily in the past what is exceptionally simple has wasted 3 days of my time!