babel-plugin-filter-imports
This babel plugin is used to removed references to imports within a module. This can be useful for removing debugging statements when doing a production build of your code. It is often used in conjunction with other tools like Uglify that perform dead code elimination.
Installation
$ yarn add --dev babel-plugin-filter-imports
This plugin is for Babel 7. If you need to support:
Example
Given the .babelrc
the module
; { if argumentslength > 2 ; return args;}
will be transformed to
{ if argumentslength > 2 return args;}
Configuration
options[keepImports]
[Boolean]
: An flag that indicates imports removal from header.options[imports]
[Object]
: An object whose keys are names of modules.options[imports][moduleName]
[String]
: An array of names of imports frommoduleName
to be removed. You can include'default'
for default export and'*'
for a namespace export.
1.x
/2.x
Upgrade to There were breaking changes in the plugin configuration, you must update it to work correctly.
1.x
Before
After