Skip to content

How to add custom syntax/operators/keywords to JavaScript with Babel? #11575

Answered by hzoo
abalter asked this question in General
Discussion options

You must be logged in to vote

Great question @abalter! Short answer with Babel at the moment is you need to fork the parser itself + use the parserOverride option in a plugin to parse it differently. (we made it rather difficult to extend on purpose, although I would like people to experiment at least to learn about parsers/ASTs/languages). And you can definitely do this with other parsers (esprima/acorn) as well.

(I would like to experiment with making it easier to at least try some things, like make a codesandbox to test (I made one recently that helps you write a babel plugin online), without necessarily making an npm package for it)

There was a good, older article about this, where that day we removed the abilit…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@abalter
Comment options

Answer selected by JLHwung
Comment options

You must be logged in to vote
1 reply
@hzoo
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #11575 on May 19, 2020 20:31.