Giter VIP home page Giter VIP logo

babel-plugin-transform-dead-code-elimination's Introduction

babel-plugin-transform-dead-code-elimination

Babel 6 fork of babel-plugin-dead-code-elimination.

Incorporates fixes from achicu/babel-plugin-dead-code-elimination.

Installation

npm install --save-dev babel-plugin-transform-dead-code-elimination

Usage

.babelrc:

{
  "plugins": [
    "transform-dead-code-elimination"
  ]
}

Or, with options (note: experimentalInlining will almost definitely break your code):

{
  "plugins": [
    ["transform-dead-code-elimination", {
      "experimentalInlining": true
    }]
  ]
}

babel-plugin-transform-dead-code-elimination's People

Contributors

achicu avatar erikdesjardins avatar sebmck avatar seeekr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

babel-plugin-transform-dead-code-elimination's Issues

`flushing` var in asap is erroneously removed

https://www.npmjs.com/package/asap

function rawAsap(task) {
    if (!queue.length) {
        requestFlush();
        flushing = true;
        // ^^^ used here
    }
    // Equivalent to push, but avoids a function call.
    queue[queue.length] = task;
}

var queue = [];
// Once a flush has been requested, no further calls to `requestFlush` are
// necessary until the next `flush` completes.
var flushing = false;
// ^^^ removed from here

With [email protected], erroneously eliminates some if statements

For example (from graphql-js):

var MAX_INT = 2147483647;
var MIN_INT = -2147483648;
function coerceInt(value) {
  var num = Number(value);
  if (num === num && num <= MAX_INT && num >= MIN_INT) {
    return (num < 0 ? Math.ceil : Math.floor)(num);
  }
  return null;
}

becomes:

var MAX_INT = 2147483647;
var MIN_INT = -2147483648;
function coerceInt(value) {
  var num = Number(value);
  return null;
}

Not yet sure if it's a bug with this transform or Babel itself.
Will be fixed by babel/babel#3557

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.