I am adding Prosemirror 1.0.0 to a project and including it in the project’s build steps. It is unclear to me how best to build Prosemirror such that I end up with ES5 js file(s) at the end to later be concatenated and minified with the rest of the project’s javascript.
While I think I can make something that can build Prosemirror I want to make sure I do it right. I want it to be easy to update Prosemirror in the future and not have to update the Prosemirror build steps more than necessary going forward.
As best as I can tell rollup is used to compile the javascript from the /src to the /dist directory of each module. Should I rollup each module in my project build system? After which point can the module files be included in any order? I noticed the output of those files have a ‘use strict’ statement at the top. Since I plan on concatenating the files together I’d have to wrap the files in an iife first.
Is this a good approach? Also once I do have the javascript figured out I still have the CSS to build.
We use grunt for our build process and I did not think webpack could be used with it. But it looks like a grunt webpack plugin does exist so maybe webpack is an option.
I ended up using grunt-rollup in our Grunt build. The main reason I went with rollup is that Prosemirror uses it internally for building. I modeled my rollup config off of Prosemirror’s website/bin/build-library.js.
// Used as input to Rollup to generate the prosemirror js file
import * as model from 'prosemirror-model';
import * as transform from 'prosemirror-transform';
import * as state from 'prosemirror-state';
import * as view from 'prosemirror-view';
import * as keymap from 'prosemirror-keymap';
import * as inputrules from 'prosemirror-inputrules';
import * as history from 'prosemirror-history';
import * as commands from 'prosemirror-commands';
import * as schemaBasic from 'prosemirror-schema-basic';
import * as schemaList from 'prosemirror-schema-list';
import * as dropcursor from 'prosemirror-dropcursor';
import * as gapcursor from 'prosemirror-gapcursor';
import * as menu from 'prosemirror-menu';
import * as tables from 'prosemirror-tables';
import * as exampleSetup from 'prosemirror-example-setup';
import * as OrderedMap from 'orderedmap';
window.pm = {
model, transform, state, view, keymap, inputrules, history, commands,
schemaBasic, schemaList, dropcursor, menu, tables, exampleSetup, gapcursor,
OrderedMap
};
Thanks everyone for the help and suggestions. It looks like we have quite a few examples of how to build Prosemirror using different build systems now.