babel-plugin-mix-import-module-exports
Why we use it
When mixed use import
and module.exports
:
;// ...moduleexports = A
it will lead to problems with bundling like this:
TypeError: Cannot assign to read only property 'exports' of object '#<Object>'
For more infomation, see these issues:
https://github.com/almende/vis/issues/2934
https://github.com/webpack/webpack/issues/4039#issuecomment-281136701
https://github.com/webpack/webpack/issues/3491
How it works
This plugin makes things work by transforming the code into:
var __MIX_IMPORT_MODULE_EXPORTS__;;// ...__MIX_IMPORT_MODULE_EXPORTS__ = A;;
or sometimes maybe we have multiple module.exports
in our module:
var __MIX_IMPORT_MODULE_EXPORTS__;;;// ...if B __MIX_IMPORT_MODULE_EXPORTS__ = B; else __MIX_IMPORT_MODULE_EXPORTS__ = A;;
Important Note
This plugin is just for compatibility with old projects, you should not use it in your new projects.