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.
The
processmethod would apply a new set of plugins to the node and its descendants.This may require changes to
magic-stringto work properly. We'll want a "slice" of theMagicStringobject that applies changes based on a character offset (where our node starts). The originalMagicStringobject would inherit any changes we make to the "slice".The
pluginsargument must be an array with at least one element.The
stateargument 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.