Socket
Socket
Sign inDemoInstall

babel-plugin-filter-imports

Package Overview
Dependencies
Maintainers
4
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-filter-imports

A babel transform for filtering out imports


Version published
Weekly downloads
112K
decreased by-6.6%
Maintainers
4
Weekly downloads
 
Created
Source

babel-plugin-filter-imports

Build Status npm

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", {
    "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

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

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 from moduleName to be removed. You can include 'default' for default export and '*' for a namespace export.

Upgrade to 1.x

There were breaking changes in the plugin configuration, you must update it to work correctly.

Before 1.x
{
  "plugins": [["filter-imports", {
    "debugging-tools": [ "warn" ]
  }]]
}
After
{
  "plugins": [["filter-imports", {
    "imports": {
      "debugging-tools": [ "warn" ]
    }
  }]]
}

Keywords

FAQs

Package last updated on 30 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc