Approximately 2 years ago we started down the long path to ES6 modules. For a long time, I’d spent 30 minutes a day working on converting files, which eventually got replaced with my strategy of converting a file every time I had to open it.
Over time we got most of the way there, but with one big holdout: our text rendering engine. It was in standard ES5 modules because we used the same text rendering code on the server and client side of Discourse, and the server side didn’t have a way to parse the new module syntax.
New Markdown Bindings
In our latest release, we set aside some time to refactor the old markdown engine to ES6. While in there, I removed all of our dependencies on global state, so that when you render text you can just pass in all the options for various rendering features. This is a massive help in multi site environments where some features couldn’t be turned off when initialized on the server side.
This allows us a path forward to integrating commonmark in a future release of Discourse.
100% ES6 Modules
Once the markdown code was refactored to use ES6 modules, it turned out there were only a dozen outliers left over. I went in and upgraded all those files, so the next Discourse release will be 100% ES6 modules, which feels awesome after so many years of slowly working towards it.
N.B. there are still many references to modules like
Discourse.XYZ
which need to be replaced, but that should be pretty smooth sailing now that all the modules are hooked up and working.)
This new branch has MANY MANY changes, so we are very likely to experience some regressions over the next short while. I am only deploying meta.discourse.org to the branch right now, until we are sure it’s more or less stable. Then I’ll merge it into master.
Now is a good time to help us poke around the site and let us know if anything at all seems broken or weird. Please post your bugs in this topic, which I will update as issues get fixed!
If you are a plugin author, please try out your plugins with the branch and let me know if anything has broken. I will work quickly with you to fix issues before this ends up in a beta
branch of ours.
The branch with all the new ES6 fixes is called prettyes6