babel-plugin-transform-remove-polyfill
Install
npm i babel-plugin-transform-remove-polyfill -D
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
const arrayLike = { length: 2 }
console.log(Array.prototype.slice.call(arrayLike));
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