plasticine / inject-loader

💉📦 A Webpack loader for injecting code into modules via their dependencies.
https://www.npmjs.com/package/inject-loader
MIT License
482 stars 47 forks source link

Cannot mock default and named exports together #60

Open jPomeranz opened 5 years ago

jPomeranz commented 5 years ago

Repro: '../path/to/module': { default: someDefaultMock, named: someNamedMock },

This code works with just the default or named modules, however, using both in conjunction causes the default import to fail.

Temporary workaround: Instead of only using export default on your current default module, export it as both a default and named export, eg named2. Then you can import all your modules as named modules and the imports will work:

'../path/to/module': { named2: someDefaultMock, named: someNamedMock },

plasticine commented 5 years ago

Hey, thanks for this, I’ll take a look.