I was a bit disappointed by the lack of CDN support (auto-building ones such as esm.run fail due to the instanceof
issue), so I made a build that runs directly in the browser:
It’s not thoroughly battle-tested yet, but seems to be working fine. Here’s a minimal example of how to use it via deno.land/x, modified from the example at https://codemirror.net/try:
<div id="html-input"></div>
<script type="importmap">
{
"imports": {
"codemirror/": "https://deno.land/x/codemirror_esm@v6.0.1/esm/"
}
}
</script>
<script async type="module">
import { basicSetup, EditorView } from "codemirror/codemirror/dist/index.js"
import { javascript } from "codemirror/lang-javascript/dist/index.js"
new EditorView({
doc: "console.log('hello')\n",
extensions: [basicSetup, javascript()],
parent: document.body,
})
</script>
By far the simplest way to use CodeMirror for those who don’t want to faff around with build tools and NPM. Please open issues on the repo if you find bugs!