I made a demo that loads the basic ProseMirror demo using native ES modules from the browser! No bundling!
Try it out…
https://prosemirror-es-modules.glitch.me/
Source:
- GitHub: jimpick/prosemirror-es-modules
- Glitch: prosemirror-es-modules
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 "https://unpkg.com/@jimpick/prosemirror-state?module"
import {EditorView} from "https://unpkg.com/@jimpick/prosemirror-view?module"
import {Schema, DOMParser} from "https://unpkg.com/@jimpick/prosemirror-model?module"
import {schema} from "https://unpkg.com/@jimpick/prosemirror-schema-basic?module"
import {addListNodes} from "https://unpkg.com/@jimpick/prosemirror-schema-list?module"
import {exampleSetup} from "https://unpkg.com/@jimpick/prosemirror-example-setup?module"
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.