babel-plugin-strip-module
v1.1.0
Published
Babel plugin that strip certain module usage in code
Downloads
4
Maintainers
Readme
babel-plugin-strip-module
Babel plugin that will remove certain module usage from code.
Using this plugin might be dangourse as it will remove code that you might want to keep. Use at your own risk.
Examples
Suppose you would like to remove certain validation library in production code. Here is what this plugin can do:
In
import * as paramTypes from 'param-types';
const validation = paramTypes.validate(
'function validation',
paramTypes.string.isRequired,
paramTypes.number.isRequired
);
function regularFunction(paramA, paramB) {
validate(paramA, paramB);
console.log('do something normal here');
}
regularFunction('1', 1);
Out
/* import * as paramTypes from 'param-types'; */
/*
* const validation = paramTypes.validate(
* 'function validation',
* paramTypes.string.isRequired,
* paramTypes.number.isRequired
* );
*/
function regularFunction(paramA, paramB) {
/* validate(paramA, paramB); */
console.log('do something normal here');
}
regularFunction('1', 1);
Installation
$ npm install babel-plugin-strip-module
Usage
Via .babelrc
(Recommended)
.babelrc
{
"plugins": [["strip-module", { "modules": ["module name here"] }]]
}
Via Node API
require('babel-core').transform('code', {
plugins: [['strip-module', { modules: ['module name here'] }]],
});
License
MIT