2.0.0 • Published 8 years ago

babel-plugin-remove-module-hot v2.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

babel-plugin-remove-module-hot

npm version Build Status

Remove module.hot conditions.

Example

in

console.log('Do something always');

if (module.hot) {
  console.log('Do something, when hot reload available');
}

if (module.hot) {
  console.log('Do something, when hot reload available');
} else {
  console.log('Do something, when hot reload unavailable');
}

if (!module.hot) {
  console.log('Do something, when hot reload unavailable');
}

const variable = module.hot ? 'hot' : 'not hot';

out

console.log('Do something always');

if (true) {
  console.log('Do something, when hot reload unavailable');
}

if (!module.hot) {
  console.log('Do something, when hot reload unavailable');
}

const variable = 'not hot';

Warning

This plugin removes only simple condition like in example, and doesn't process more complex expressions.

Installation

$ npm install babel-plugin-remove-module-hot

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": ["remove-module-hot"]
}

Via CLI

$ babel --plugins remove-module-hot script.js

Via Node API

require('babel-core').transform('code', {
  plugins: ['remove-module-hot']
});