Skip to content

rwjblue/babel-plugin-filter-imports

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

babel-plugin-filter-imports

Build Status

This plugin is for Babel 6. If you need to support Babel 5 use the v0.2.x branch.

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.

Example

Given the .babelrc

{
  "plugins": [["filter-imports", {
    "debugging-tools": [ "warn" ]
  }]]
}

the module

import { warn } from 'debugging-tools';

function join(args, sep) {
  if (arguments.length > 2) {
    warn("join expects at most 2 arguments");
  }
  return args.join(sep);
}

will be transformed to

import { warn } from 'debugging-tools';

function join(args, sep) {
  if (arguments.length > 2) {
  }
  return args.join(sep);
}

Configuration

  • options [Object]: An object whose keys are names of modules.
  • options[moduleName] [String]: An array of names of imports from moduleName to be removed. You can include 'default' for default export and '*' for a namespace export.

About

A babel transform for filtering out imports

Resources

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%