-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Description
💻
- Would you like to work on this feature?
From #13843 (review):
Before merging, can we discuss whether mutating
BUILD_KEYSis actually an intentional API? For the Babel 8 breaking changes, we could stop doing this and perform much faster node building by specializing each builder function. Eg,t.identifer(name)can be (a little more than)function identifier(name) { return { type: 'Identifier', name } }.
We support swapping the parser and the generator, but not the other packages.
You can handle custom AST modifications by changingVISITOR_KEYS.On the other hand, I don't see why someone would want to change
BUILDER_KEYS(you can just directly create the node without using the builder function).
On the other hand, I don't see why someone would want to change BUILDER_KEYS (you can just directly create the node without using the builder function).
In our codebase we don't mutate
BUILDER_KEYS. I think we can expand builder keys in babel-types from Babel 8 and leave a note that theBUILDER_KEYSexport is for reference only, it does not change the builder behavior.On
VISITOR_KEYS, I think we can offer anoverrideVisit(originalVisit)API for those mutatingVISITOR_KEYS: So we can expandVISITOR_KEYSinbabel-traverse, too. It should remove the slow object access due to dynamic property access on different AST nodes. TS expands visitor keys, too.