theKashey/rewiremock

TypeError: Cannot read property 'source' of null

langri-sha opened this issue · 4 comments

I'd like to leave this here to save someone time in case they run into the following.

Internal error
TypeError: Cannot read property 'source' of null  
rewiremock/lib/babel/index.js:60:27

See Dynamic import from Babel 7.5.0 release. Need to ensure rewiremock/babel comes before the module transformer like so:

module.exports = {
  plugins: [
    '@babel/plugin-proposal-dynamic-import',
    'rewiremock/babel',
    '@babel/plugin-transform-modules-commonjs
  ]
}

Anyway - it shall not lead to the error.

Ok, so that's the common issue - I am trying to read data from imports after they were transformed. However, this check could be done during traverse...

Should be fixed in 3.13.8

Rolling back. There is no way to play nicely together with @babel/plugin-transform-modules-commonjs except the right plugin order.

I am adding autodetection for this problem, but rolling the fix back.