guybedford / es-module-lexer

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

Fails to parse usage of variable `of` #173

Closed privatenumber closed 6 months ago

privatenumber commented 6 months ago

Reproduction

import { init, parse } from 'es-module-lexer'

await init

parse('const of=1;console.log(of/1)')

StackBlitz: https://stackblitz.com/edit/stackblitz-starters-ku65d9?file=index.mjs

Although of is an identifier with a special meaning, it is not reserved: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#identifiers_with_special_meanings

This also runs fine in Node/Chrome: const of=1;console.log(of/1)

guybedford commented 6 months ago

Thanks for posting, I've posted a fix in https://github.com/guybedford/es-module-lexer/pull/174.

privatenumber commented 6 months ago

Thanks for the quick turn around! Really appreciate it 🙌

BTW while I have you here, do you take sponsorships for this project? I only see JSPM and SystemJS on your Open Collective.

guybedford commented 6 months ago

Released in 1.5.3.

You're always welcome @privatenumber. Sponsorships to JSPM are always a huge help as it subsidizes the server costs, and is done in a tax efficient way.