ES Modules Demo


I made a demo that loads the basic ProseMirror demo using native ES modules from the browser! No bundling!

Try it out…


It uses the ES modules support from the UNPKG CDN.

I had to fork all the ProseMirror modules used so I could add the “module” property to the package.json in order to resolve the top-level source module for unpkg.

The imports now look like this (from index.js):

import {EditorState} from ""
import {EditorView} from ""
import {Schema, DOMParser} from ""
import {schema} from ""
import {addListNodes} from ""
import {exampleSetup} from ""

Supporting native ES modules from the browser would be nice for people who just want to quickly experiment without having to set up a whole toolchain on their computer.

I also had to fork crel, orderedmap, rope-sequence and w3c-keyname in order to convert them to have ES exports.

As opposed to using a bundler, this results in a lot of HTTP requests (but HTTP/2, QUIC and WebPackage should reduce that penalty over time). Personally, I have some applications in mind that use ES modules with IPFS and Dat.



(But, as I mentioned on twitter, not practical enough to adjust the main distributed packages for—I’m keeping an eye on the way node and browsers are dealing with ES modules, and will move to conform to what they decide on when there’s a practical solution, but they aren’t there yet, and them getting there is taking an unexpectedly long time.)


The nice thing about unpkg is that the only modification needed for the prosemirror-* modules is the addition of a “module” property to the package.json to point at the top level source file.