Détail du package

babel-plugin-filter-imports

ember-cli688.9kMIT4.0.0

A babel transform for filtering out imports

babel, babel-plugin

readme

babel-plugin-filter-imports

Build Status npm Greenkeeper badge

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:

  • Babel 6 use the babel6 branch
  • Babel 5 use the v0.2.x branch

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/2.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" ]
    }
  }]]
}

changelog

Change Log

4.0.0 (2018-11-20)

  • Drop support of Node 6, Node 8 is required #255

3.0.0 (2018-04-12)

  • Stop adding the decorators Babel plugin #135

2.0.3 (2018-09-28)

Full Changelog

Closed issues:

  • An in-range update of babel7 is breaking the build 🚨 #44

Merged pull requests:

2.0.2 (2018-09-10)

Full Changelog

v2.0.1 (2018-08-31)

Full Changelog

Merged pull requests:

v2.0.0 (2018-04-30)

Full Changelog

Merged pull requests:

  • chore(package): update to Babel 7, drop NodeJS 4, use Yarn #39 (layershifter)

v1.1.2 (2018-04-30)

Full Changelog

Closed issues:

  • Version 10 of node.js has been released #37
  • An in-range update of eslint is breaking the build 🚨 #33

Merged pull requests:

v1.1.1 (2017-11-29)

Full Changelog

Closed issues:

  • TypeError: Cannot read property 'removed' of null #30

Merged pull requests:

v1.1.0 (2017-10-08)

Full Changelog

Merged pull requests:

v1.0.4 (2017-09-27)

Full Changelog

Closed issues:

  • Cannot find module package.json #19

Merged pull requests:

v1.0.3 (2017-09-08)

Full Changelog

Merged pull requests:

  • fix(remove): remove only body on ArrowFunctionExpression #17 (layershifter)

v1.0.2 (2017-09-08)

Full Changelog

v1.0.1 (2017-09-08)

Full Changelog

v1.0.0 (2017-09-08)

Full Changelog

Merged pull requests:

v0.3.1 (2017-03-14)

Full Changelog

Closed issues:

  • An in-range update of babel-core is breaking the build 🚨 #13
  • Make a readme #1

Merged pull requests:

v0.3.0 (2016-08-25)

Full Changelog

v0.2.1 (2016-08-10)

Full Changelog

Implemented enhancements:

  • Port plugin to Babel 6 plugin API #6 (Turbo87)

Merged pull requests:

v0.2.0 (2015-08-26)

Closed issues:

  • Add test to confirm import statement is removed if last specifier is removed. #4
  • Add test to confirm we only removed unneeded imports. #3

Merged pull requests:

  • New API; don't remove import declarations #5 (mmun)
  • Remove diff plusses from CODE_OF_CONDUCT.md #2 (xtian)

* This Change Log was automatically generated by github_changelog_generator