babel-plugin-remove-code
Remove any code from your project.
Supported removals
Example
Debugger
In
// Debugger...debugger;
Out
// Debugger...
Var
In
const stripA = 'foo';const keepA = 'foo';const stripBPattern = 'foo';const keepBPattern = 'foo'; let stripC;let keepC;let stripFPattern;let keepFPattern; stripC = 'foo';stripC = {};keepC = 'foo';stripFPattern = 'foo';stripFPattern = {};keepFPattern = 'foo'; const stripG = {};const keepG = {};const stripHPattern = {};const keepHPattern = {}; ;;;; stripA keepA stripBPattern keepBPattern ; console;console;console;console; if stripA === 'foo' {}if keepA === 'foo' {}if stripBPattern === 'foo' {}if keepBPattern === 'foo' {} if stripC === 'foo' && keepC === 'foo' {}if stripFPattern === 'foo' && keepFPattern === 'foo' {} keepA = stripA;keepB = stripB && keepB;
Out
const keepA = 'foo'; const keepBPattern = 'foo'; let keepC; let keepFPattern; keepC = 'foo'; keepFPattern = 'foo'; const keepG = {}; const keepHPattern = {}; ; ; keepA keepBPattern ; console; console; if keepA === 'foo' {} if keepBPattern === 'foo' {} if keepC === 'foo' {}if keepFPattern === 'foo' {} keepB = keepB;
Export
In
const stripA = {};const keepA = {};const stripBPattern = {};const keepBPattern = {}; ;;;; stripE keepE stripFPattern keepFPattern ;
Out
const keepA = {}; const keepBPattern = {}; ; ; keepE keepFPattern ;
Import
In
;;;;;; ;;console;console; ;;const fsDVar = fsD;const fkDVar = fkD; ;;;; ;;;; const keepI = ;const keepJ = ;
Out
; ; ; ; console; ; const fkDVar = fkD; ; ; ; ; const keepI;const keepJ = ;
Function
In
{} {}const keepB = {}; ;console;consolekeepC;console;consolestripD; ;;
Out
{}const keepB; console; ;
Installation
npm install --save-dev babel-plugin-remove-code
Usage
.babelrc
(Recommended)
Via .babelrc
Note:
Regex patterns work but the .
is escaped.