-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Description
Feature Request
V8 exposes a number of intrinsics when the --allow-natives-syntax flag is set. Examples include:
%DebugPrint(object);
%PrepareFunctionForOptimization(fn);Because we generally don't want to encourage the use of these intrinsics in production code, they rely on non-standard syntax; standard JS parsers (including Babel's) consider this to be a modulo operator without a left-hand side. Here's how V8 implements parsing support based on the flag.
However, some research projects intentionally make use of these V8-specific intrinsics, and of course the V8 code base itself makes use of them extensively in JS tests.
It would be great if Babel could optionally support this syntax extension, similar to how it supports JSX and Flow syntax.
Describe alternatives you've considered
If this seems more feasible as a Babel parser plugin, that'd be a good solution too! I just wanted to discuss this proposal with the core team first.
Teachability, Documentation, Adoption, Migration Strategy
I'd be happy to write some docs if the team decides this makes sense in babel/parser core.