babel-utils/babel-plugin-tester

How to specify the ordering of the tested plugin

cibernox opened this issue ยท 2 comments

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-tester 9.2.0:
  • node 14:
  • npm (or yarn) 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?

๐ŸŽ‰ This issue has been resolved in version 11.0.0-canary.1 ๐ŸŽ‰

The release is available on:

Your semantic-release bot ๐Ÿ“ฆ๐Ÿš€

๐ŸŽ‰ This issue has been resolved in version 11.0.0 ๐ŸŽ‰

The release is available on:

Your semantic-release bot ๐Ÿ“ฆ๐Ÿš€