The ProseMirror repository does too much, and it has been my intention, at least since half a year ago, to split it up into smaller repositories and modules. Two pieces that are definitely going to be split off are the markdown parsing/serializing and the menu code.
But now that the work for 0.8.0 (which I plan to release before doing any splitting) has greatly reduced the interconnectedness of the existing code, I am tempted to split more aggressively. Specifically, I am debating to create one package per âthing youâd importâ, rather than distributing, as I am now, a big module from which you include âsub modulesâ (dist/model, dist/transform, dist/edit, etc). The advantages of that would be:
-
It feels cleaner to have the library core entirely detached from further incidental complexity
-
The boundary between the stuff I donât want to support (for example the default menus) and the actual project core becomes clearer
-
Youâd only be installing the code you need (though in terms of wasted disk space, the additional README/LICENSE/etc files might undo the gains)
-
Providing pre-built client-side files in NPM packages becomes easier
-
Only having âtop-levelâ modules without sub-modules removes one piece of complexity (importing submodules).
-
By moving the default schema into a separate package, possibly multiple packages, it provides a good example of how people who want to provide additional schema elements should structure and distribute them
-
A lot of tangential stuff could be moved out of the core docs and into package READMEs
There are also downsides:
-
It might become harder to find the documentation youâre looking for
-
It might become harder to figure out which module you need
-
On NPM2 and lower, which doesnât deduplicate installed packages by default, youâre likely to end up with an ugly fractal tree of node_modules subdirectories
-
More work during publishing (though tools and scripts might mitigate most of that)
-
Setting up a trivial editor becomes harder, if you need to gather schemas, menus, etc from various modules. For this, I plan to set up a
prosemirror-basic
package, which gathers a default schema and menu into a convenient wrapper.
Before I commit to anything, Iâm looking for feedback from the community. I have a vague sense that tiny-module projects are often a bit harder to see through (Babel moving to that style was the point where I stopped understanding how it worked and started just googling for examples), but Iâm not sure if thereâs any problem that isnât solved by proper documentation.
In the extreme case, the list of modules would look something like this:
-
prosemirror
: The editor component -
prosemirror-model
: The document model + DOM parsing/serialization logic -
prosemirror-transform
: The transform abstraction + the basic step types + the primitive transformation functions -
prosemirror-ui
: The tooltip and prompt helpers -
prosemirror-menu
: The menu element abstractions, menu bar, and tooltip menu -
prosemirror-inputrules
: Functionality for defining transforms triggered by typing patterns of text. -
prosemirror-markdown
: A schema that implements all of standard Markdown, along with a parser and serializer for it, and functionality to help defining the same for extended dialects. -
prosemirror-schema-list
: Node class for lists, along with commands to manipulate it. -
prosemirror-schema-table
: An implementation of basic tables, along with commands to manipulate them. -
prosemirror-schema-misc
: The trivial nodes and marks that make up the current default schema. -
prosemirror-basic
: A helper that defines a schema similar to the current default schema, along with the menu items, key bindings, and input rules to produce a serviceable editor.
(I could have put every node and mark type in the current default schema into its own module, for consistency, but then weâre at the three-line-module level and that seems needlessly burdensome.)
Some of these (markdown, ui, menu) would end up in their own separate repository. The stuff more or less directly related to the core would be a single repository, versioned in lockstep, using Lerna or maybe custom scripts to automate publishing modules.
How does this sound? Any concerns, or ideas for alternate approaches?