Hi there. I recently discovered that CodeMirror is behaving differently when running from a CDN (tested with jsDelivr’s ESM CDN). When run via the normal NPM installation and imports, the text is tokenized just fine. When run from the CDN, the text is not tokenized (I used Markdown for this example).
The CDN version is enabled in the linked demo, but you can see the normal installation by swapping the commented import statements.
A lot of stuff in CodeMirror doesn’t work when loading through a CDN, because those tend to load multiple versions of packages that are depended on from multiple other packages.
Following up here, esm.sh seems to work without any extra configuration or specialized bundling.
I tried to look into things in more detail, comparing UNPKG, JSDelivr, esm.sh and Skypack.
Thus far only I only got esm.sh to work.
Full details available at: Loading CodeMirror through a CDN · GitHub
I managed to get JSDeliver working as well: JSDelivr CodeMirror Example
For skypack there is an open issue.