That isn’t possible—a compiled LR parser (which is what package like @lezer/javascript contain) is a self-contained thing that can’t be modified anymore to support new syntax. Doing something like this requires forking the JavaScript grammar and rewriting it to add your extension.
In general, I’ve found that most JS parsers are in-extensible (Babel, SWC, tsc, etc), forcing things like JSX in to the core of the parser, kinda shutting everyone else out. not fun – would be much better of all language parsers were pluggable, esp since we’ve been dealing with embedded syntaxes for well over a decade now.
Sure, but I can’t afford to include every variant people use in my parser. As it stands, this doesn’t seem big enough to add to @lezer/javascript, sorry.
would it be worth while helping with tweaking the parsers to allow for extension or layering of some sort? so that way any language extension can be separate from what you maintain?
This would be technically very difficult and problematic, and is something I’ve decided during the design of Lezer to be out of scope for that system.