Setup dependencies:
npm init -y
npm i codemirror @codemirror/lang-javascript
npm i rollup @rollup/plugin-node-resolve
Create an editor:
editor.js
import {EditorView, basicSetup} from "codemirror"
import {javascript} from "@codemirror/lang-javascript"
let editor = new EditorView({
extensions: [basicSetup, javascript()],
parent: document.body
})
Bundle the editor:
node_modules/.bin/rollup editor.js -f iife -o editor.bundle.js -p @rollup/plugin-node-resolve
Create an HTML page to load it:
index.html
<!doctype html>
<meta charset=utf8>
<h1>CodeMirror!</h1>
<script src="editor.bundle.js"></script>
Serve it using whatever:
browser-sync start --server --no-open --files "*.js" "demo/*.js" "*.css" "*.html" --serveStatic "./*" --port 8080 --host 0.0.0.0 --listen 0.0.0.0