guybedford / es-module-lexer

Low-overhead lexer dedicated to ES module parsing for fast analysis
MIT License
917 stars 48 forks source link

Parse error when ImportsList contains comment with closing curly brace #92

Closed aomarks closed 2 years ago

aomarks commented 2 years ago

If there is a comment inside of an ImportsList, and that comment contains a }, then es-module-lexer v0.9.2 currently throws a parse error:

import { /** @type{HTMLElement} */ LionCombobox } from './src/LionCombobox.js';
//                              ^ Parse error

If there is no } inside the comment, then there is no parse error.

Found in the wild here: https://unpkg.com/@lion/combobox@0.8.4/lion-combobox.js

(Love this library by the way! We are using it in https://github.com/google/playground-elements which powers https://lit.dev/playground/ to do super fast bare module resolution. You can see the parse error as an inline red squiggly error in this example).

aomarks commented 2 years ago

Update: this doesn't occur in v0.9.1, so seems to be a recent regression. https://github.com/guybedford/es-module-lexer/pull/89 perhaps?

guybedford commented 2 years ago

Hi @aomarks thanks for the report here, and glad to hear it's in use there. You're exactly right this was a 0.9.1 regression, I'm releasing a fix via https://github.com/guybedford/es-module-lexer/pull/93 in 0.9.2 0.9.3 now.