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.
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);
$ npm install babel-plugin-strip-module
.babelrc
{
"plugins": [["strip-module", { "modules": ["module name here"] }]]
}
require('babel-core').transform('code', {
plugins: [['strip-module', { modules: ['module name here'] }]],
});
MIT