Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-transform-remove-polyfill

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-remove-polyfill

[![CI](https://github.com/shoonia/babel-plugin-transform-remove-polyfill/actions/workflows/ci.yml/badge.svg)](https://github.com/shoonia/babel-plugin-transform-remove-polyfill/actions/workflows/ci.yml)

  • 0.24.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
38
increased by660%
Maintainers
1
Weekly downloads
 
Created
Source

babel-plugin-transform-remove-polyfill

CI

Install

npm i babel-plugin-transform-remove-polyfill -D
# or
yarn add babel-plugin-transform-remove-polyfill -D

Example

Before:

var __assign = Object.assign || function (t) {
  for (var s, i = 1, n = arguments.length; i < n; i++) {
    s = arguments[i];
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  }
  return t;
}

After:

var __assign = Object.assign;

Usage

With a configuration file babel.config.json

{
  "plugins": ["babel-plugin-transform-remove-polyfill"]
}

Transform options

transform

Set to true to enable all transformers

{
  "plugins": [
    [
      "babel-plugin-transform-remove-polyfill",
      {
        "transform": true
      }
    ]
  ]
}

or customization transform features

"unsafe:Array.from"

boolean, defaults to false.

{
  "plugins": [
    [
      "babel-plugin-transform-remove-polyfill",
      {
        "transform": {
          "unsafe:Array.from": true
        }
      }
    ]
  ]
}

Example:

- Array.prototype.slice.call(arguments)
+ Array.from(arguments)

⚠️ Warning: Unsafe transformation

// Object with a length property
const arrayLike = { length: 2 }

/**
 * Return empty array with length == 2
 *
 * [empty × 2]
 *   length: 2
 */
console.log(Array.prototype.slice.call(arrayLike));

/**
 * Return array with undefined values and length == 2
 *
 * [undefined, undefined]
 *   0: undefined
 *   1: undefined
 *   length: 2
 */
console.log(Array.from(arrayLike));

"optimize:Object.assign"

boolean, defaults to false.

{
  "plugins": [
    [
      "babel-plugin-transform-remove-polyfill",
      {
        "transform": {
          "optimize:Object.assign": true
        }
      }
    ]
  ]
}

Example:

- Object.assign(Object.assign({}, e), o);
+ Object.assign({}, e, o);

License

MIT

Keywords

FAQs

Package last updated on 18 Apr 2024

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