Skip to content

[RFC] Node.prototype.process #4

@aleclarson

Description

@aleclarson

The process method would apply a new set of plugins to the node and its descendants.

This may require changes to magic-string to work properly. We'll want a "slice" of the MagicString object that applies changes based on a character offset (where our node starts). The original MagicString object would inherit any changes we make to the "slice".

// A plugin that applies its own plugins.
const plugin = {
  ClassBody(node) {
    node.process(plugins, state)
  }
}

The plugins argument must be an array with at least one element.

The state argument is an optional object, which defaults to the "parent" state.

This is very efficient when you want a subset of plugins to be used only if within a certain context.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions