Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-mix-import-module-exports

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-mix-import-module-exports

Fix mixed use ES6 imports and Common.js exports

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

babel-plugin-mix-import-module-exports

Why we use it

When mixed use import and module.exports:

import A from 'a';
// ...
module.exports = 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

https://stackoverflow.com/questions/42449999/webpack-import-module-exports-in-the-same-module-caused-error

How it works

This plugin makes things work by transforming the code into:

var __MIX_IMPORT_MODULE_EXPORTS__;
import A from 'a';
// ...
__MIX_IMPORT_MODULE_EXPORTS__ = A;
export default __MIX_IMPORT_MODULE_EXPORTS__;

or sometimes maybe we have multiple module.exports in our module:

var __MIX_IMPORT_MODULE_EXPORTS__;
import A from 'a';
import B from 'b';
// ...
if (B) {
  __MIX_IMPORT_MODULE_EXPORTS__ = B;
} else {
  __MIX_IMPORT_MODULE_EXPORTS__ = A;
}
export default __MIX_IMPORT_MODULE_EXPORTS__;

Important Note

This plugin is just for compatibility with old projects, you should not use it in your new projects.

Keywords

FAQs

Package last updated on 31 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc