Hi, I’ve been trying to use CodeMirror inside a WebComponent made with LitElement (demo here)and I somehow managed to make it work but there’s a couple of things I hoped you could evaluate adding to make life easier for people developing on es6 modules like me.
Since the CodeMirror core src folder is on npm and it’s already in modules it can be used just fine like that in other modules, but there’s a bit of a problem when trying to use any of the addons/modes provided here;
As far as I can tell, all addons/modes all asume that if you’re not using CommonJS/AMD you must be using a global script, but since es6 modules have local environments trying to import the addons/modes as they are right now in an es6 module ends up with a
CodeMirror is not defined error, e.g.:
For now, I’ve gotten this to work by using a function which fetches the addon/mode and then
evals it in the module’s context but that is far from ideal thinking of the risks and debugging troubles using
eval brings, so I was hoping you could release an es6 modules version of the addons/modes, it could be something as simple as changing:
If you like this way of doing things I can make a PR for this kind of behavior.
Now that Firefox joined every other major modern browser in supporting es6 modules I think it could be a great time to add this