Closed krzysztof-miemiec closed 6 years ago
because mode and component didn't use a single instance of codemirror
That's an issue with your bundler/module loader, not CodeMirror. The various files require the main library through relative paths, which the loader should unify to load only a single instance unless you have multiple instances of the library in your node_modules. You didn't mention which bundler you're using, but this is a problem that's come up before.
We're planning a full rewrite that will completely change how any of this works, but in the meantime, the current approach should be workable enough.
It never happened with any other library I worked with, so I'd count it as a CodeMirror issue. 😕 Nevertheless, I'll be waiting for a rewrite!
CodeMirror is actively maintained, yet it's architecture looks as it's stuck in a JS world from a few years ago. I tried to integrate it with my project (Electron + Typescript + Webpack + React) and had a really hard time figuring out why it doesn't work with react-codemirror2.
First of all, for people having a similar issue, I created a separate file
codemirror.util.tsx
It seems that
require('codemirror)
doesn't work well in pure JS projects - I couldn't simply include a mode, css andreact-codemirror2
component, because mode and component didn't use a single instance of codemirror, plus I don't have control over<script>
tags beacuse ofelectron-webpack
layer.I'd really like to be able to manually register a mode out of the box, like:
This change could possibly be introduced in next major version? I can make a PR with modes changes.