lezer-parser / html

An HTML parser for Lezer
MIT License
13 stars 10 forks source link

Upgrade @lezer/lr #8

Closed mattzeunert closed 1 year ago

mattzeunert commented 1 year ago

I'm using CodeMirror but I think the underlying issue is in the lezer language repos, so posting here.

This is my editor code:

import { html } from "@codemirror/lang-html"
import { EditorView } from "@codemirror/view"

let view = new EditorView({
    doc: `
    <script>
    /* <![CDATA[ */
    /* ]]> */
    </script>
    `,
    extensions: [
        html()
    ],
    parent: document.body
})

But when I run it I get this error:

main.js:1 Uncaught TypeError: Cannot read properties of undefined (reading 'from')
    at F.reset (main.js:1:35867)
    at D.reduceContext (main.js:1:30888)
    at D.reduce (main.js:1:26987)
    at ct.advanceStack (main.js:1:44950)
    at ct.advance (main.js:1:42836)
    at V.advance (main.js:1:20164)
    at main.js:1:261995
    at Pl.withContext (main.js:1:262699)
    at Pl.work (main.js:1:261734)
    at init (main.js:1:264689)

I had a hard time creating a stand-alone repro of the issue, but eventually I found that the error occurs with @lezer/lr@1.3.1 but not @lezer/lr@1.3.4.

I tried upgrading CodeMirror a couple times over the last few months but it didn't fix the issue so I had syntax highlighting disabled in the meantime. I didn't think of manually upgrading @lezer/lr or removing package-lock.json and reinstalling.

Currently @lezer/html depends on ^1.0.0 – would it be possible to upgrade to a newer version?

I think this would also apply to other repos like @lezer/css and @codemirror/language.

marijnh commented 1 year ago

Currently @lezer/html depends on ^1.0.0 – would it be possible to upgrade to a newer version?

No. ^1.0.0 matches 1.3.4. I have no interest in re-releasing every dependent package every time a package gets an update in order to restrict the version ranges to the latest version.

If you've found that the error doesn't occur with the latest @lezer/lr, then I'm not sure why you are reporting this here.

mattzeunert commented 1 year ago

I spent over 8 hours looking into the issue I was facing, so I wanted to report it in case others face the same problem and to see if there's some way to fix it so that when someone upgrades Codemirror they automatically get the working version of lr as well.

I don't usually reset package-lock.json. Would you recommend doing that when upgrading Codemirror?

marijnh commented 1 year ago

I don't usually reset package-lock.json. Would you recommend doing that when upgrading Codemirror?

Yes. Unfortunately, npm is really dumb about partial upgrades.