babel-plugin-tester
babel-plugin-tester copied to clipboard
How to specify the ordering of the tested plugin
Hi.
I'm trying to write a babel plugin that transforms one decorator into a different one. For instance transform
class MyClass {
@injectIfEnabled('FEATURE') router
}
into
class MyClass {
@inject router
}
when that feature is enabled or into
class MyClass {
@inject router
}
when it's not.
I'm running these:
-
babel-plugin-tester9.2.0: -
node14: -
npm(oryarn) version: 6.14
The problem I'm facing is that since my plugin looks for class properties with a decorator named injectIfEnabled, I need the plugin to run before @babel/plugin-proposal-decorators has transpiled decorators.
I can't seem to find a way of specifying that the plugin under testing must run in a specific order:
pluginTester({
plugin: myPlugin,
pluginName: 'my-plugin',
babelOptions: {
plugins: [
['@babel/plugin-syntax-decorators', { legacy: true }],
// myPlugin should run here
['@babel/plugin-proposal-class-properties', { loose: true }]
]
},
})
Am I missing something or this is really not possible right now?