Socket
Socket
Sign inDemoInstall

babel-plugin-transform-modules-commonjs-immutable

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-transform-modules-commonjs-immutable

transform immutable es6 module to commonjs module


Version published
Maintainers
1
Created
Source

#babel-plugin-transform-modules-commonjs-immutable

transform immutable es6 module to commonjs module

##transform ES6

import { log , warn } from './a';
log('init');
log('now is:'+Date.now());
warn('a warning');

when transformed, the imported variables will be convert to property access of the imported object. Normally, we don't mangle property name which is a bad case if we know the propety is immutable.

Instead of transform like

var _a=require('./a');
_a.log('init');
_a.log('now is:'+Date.now());
_a.warn('a warning');

we can refer the imported varibles as local variables if they are immutable. Just like

var _a=require('./a');
var _a$log=_a.log;
_a$log('init');
_a$log('now is:'+Date.now());
_a.warn('a warning');

When the code is mangled,the local variable names will be shortened.For the once-used imported variables, keep it as a property.

Usage

Install

npm install babel-plugin-transform-modules-commonjs-immutable --save-dev

In code

babel.transform(code,{
  plugins:[
    "babel-plugin-transform-modules-commonjs-immutable"
  ]
});

This plugin may cause conflict with "babel-plugin-transform-es2015-modules-commonjs"

FAQs

Package last updated on 23 Feb 2016

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