speedskater/babel-plugin-rewire

babel/plugin-transform-typescript and rewire

Opened this issue · 1 comments

Hi guys the babel plugin rewire doesn't seem to work with babel 7. Has this issue been previously raised?

"@babel/core": "^7.7.4",
"babel-plugin-rewire": "^1.2.0"

In karma config

{
  test: /\.(js|jsx|ts|tsx)$/,
  exclude: [/app\/lib/, /node_modules/],
  use: [
    {
      loader: 'babel-loader',
      options: {
        presets: ['@babel/preset-env'],
        plugins: ['rewire']
      }
    }
  ]
}

This problem is likely caused by another plugin injecting "_RewireAPI__" without registering it in the scope tracker. If you are the author of that plugin, please use "scope.registerDeclaration(declarationPath)". The exported identifier "_RewireAPI__" is not declared in Babel's scope tracker as a JavaScript value binding, and "@babel/plugin-transform-typescript" never encountered it as a TypeScript type declaration. It will be treated as a JavaScript value.

This has been driving us crazy and we'd love to see a fix for it! It does seem like this project is dead, though. We're working on switching to Jest and using its built-in mocks instead.