codemirror / lang-example

Example/template repository for building a language package
MIT License
69 stars 43 forks source link

Parser/runtime version mismatch #11

Closed Me1000 closed 2 years ago

Me1000 commented 2 years ago

I'm getting the following error when I try to run the output of this template as a play language using the latest CodeMirror:

Uncaught RangeError: Parser version (14) doesn't match runtime version (13)

I've tried it with the latest version of codemirror 6's individual packages:

"@codemirror/autocomplete": "^6.1.0",
"@codemirror/commands": "^6.0.1",
"@codemirror/lang-javascript": "^6.0.2",
"@codemirror/language": "^6.2.1",
"@codemirror/lint": "^6.0.0",
"@codemirror/search": "^6.0.1",
"@codemirror/state": "^6.1.0",
"@codemirror/view": "^6.1.2"

and with just codemirror@6.0.1.

Looks like some dependency in CodeMirror wasn't updated when this commit dropped but I didn't look into it enough to figure out exactly what needed to be updated.

marijnh commented 2 years ago

Did you try removing your package lock and reinstalling from scratch? Are you referencing any @lezer packages in your dependencies? If so, make sure those reference 1.x versions.

Me1000 commented 2 years ago

Ah, I see what's happening. Parcel has a sub-dependency on an older version of @lezer/lr and npm put that at the top level of my node_modules, so when I copied the built files to my project the imports were pulling in Parcel's version.

By adding the explicit dependency to @lzer/lr and @lzer/highlight to my project's package.json the import resolved correctly. This issue became rather obvious when I removed parcel and tried to build with rollup instead. I should have just read the built source file, that would have also probably made it obvious.