react-codemirror: Error: Unrecognized extension value in extension set ([object Object]). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks
Have this issue when passing css() extension for CodeMirror from here : https://www.npmjs.com/package/@codemirror/lang-css. This issue is not happening when downgrading to @uiw/react-codemirror 4.8.1. I also need @uiw/codemirror-themes package and it gives same unrecognized extension value error when using with an old version. I found this @uiw/codemirror-extensions-langs package that works fine but it’s size is very big and I need only certain things from there. Is there any solution to use @codemirror/lang-* packages with latest version of @uiw/react-codemirror ?
Unfortunately I couldn’t replicate that issue in sandbox as an example @codemirror/state/dist/index.cjs logs
Old version

New version

npm ls @codemirror/state gives same versions

About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 19 (4 by maintainers)
Commits related to this issue
- fix: fix dependencies issue. (#480) — committed to uiwjs/react-codemirror by jaywcjlove a year ago
- v4.19.10 fix: fix dependencies issue. (#480) 3232f4caeabb32b9debc75abbd0fe4a7626713ab — committed to uiwjs/react-codemirror by jaywcjlove a year ago
- released v4.19.11 (#480) — committed to uiwjs/react-codemirror by jaywcjlove a year ago
- v4.19.11 released v4.19.11 (#480) 20cce8e7b0af21c8d4d9bbb36c06151ea9c43c01 — committed to uiwjs/react-codemirror by jaywcjlove a year ago
I have successfully replicated this issue and created a repo with the minimal amount of steps taken to reproduce the error. View the commit history for detailed steps.
https://github.com/mbartisan/react-codemirror-issue
– Main points:
Created a new electron forge application: https://www.electronforge.io/templates/typescript-+-webpack-template
npm init electron-app@latest my-new-app -- --template=webpack-typescriptInstalled react and react-dom
npm i react react-domInstalled @uiw/react-codemirror and @codemirror/lang-javascript
npm i @uiw/react-codemirror @codemirror/lang-javascriptThen followed the basic usage from the @uiw/react-codemirror readme.
Uncaught Error: Unrecognized extension value in extension set ([object Object]). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.My issue was originating from webpack and I was able to adjust my webpack config to resolve it. My fix was to add this to the webpack config:
Edit: I continued to have some other various issues (mostly with Extensions) which were fixed by mapping to the entire codemirror dir like below. Not fully tested, so your milage may very as well as introduce side effects.
Clearing your package lock and reinstalling your dependencies often helps with this.
Can you put your code samples on codesandbox.io? I can help you troubleshoot the errors.
@zeleniucvladislav