Skip to content

Add optional parsing support for V8 intrinsics #10104

@mathiasbynens

Description

@mathiasbynens

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    outdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions