Skip to content

Add the possibility for a plugin to modify the loaded source before processing (T7222) #4187

@babel-bot

Description

@babel-bot

Issue originally made by Alpha Page (alphapage)

Description

Hello,

Babylon is locked and don't provide any plugin system to interact like acorn for example. So, if you implement a new syntax, the parser throws an error because it doesn't know about the new syntax.

It would be very usefull to be able to preprocess the source via a plugin before babylon parser.

Something like this:

 export function load(source) {
    // optionally also set the sourceMap
    source.sourceMap = generatedSourceMap;
    // the modified code
    source.code = generatedCode;
    return source;
  }

I think this feature could improve Babel and hope this could help others.

Thanks in advance for your feedback.

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