1. babel-plugin-transform-remove-undefined
This removes rvals that are equivalent to undefined wherever possible
babel-plugin-transform-remove-undefined
Package: babel-plugin-transform-remove-undefined
Created by: babel
Last modified: Fri, 21 Jul 2023 15:42:46 GMT
Version: 0.5.0
License: MIT
Downloads: 1,761,500
Repository: https://github.com/babel/minify/tree/master/packages/babel-plugin-transform-remove-undefined

Install

npm install babel-plugin-transform-remove-undefined
yarn add babel-plugin-transform-remove-undefined

babel-plugin-transform-remove-undefined

For variable assignments, this removes rvals that evaluate to undefined
(vars in functions only).
For functions, this removes return arguments that evaluate to undefined.

Example

In

 let a = void 0;
function foo() {
  var b = undefined;
  return undefined;
}

Out

 let a;
function foo() {
  var b;
  return;
}

Installation

 npm install babel-plugin-transform-remove-undefined --save-dev

Usage

Via .babelrc (Recommended)

.babelrc

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

Via CLI

 babel --plugins babel-plugin-transform-remove-undefined script.js

Via Node API

 require("@babel/core").transform("code", {
  plugins: ["babel-plugin-transform-remove-undefined"]
});

Options

  • tdz - Detect usages before declaration/initialization in let/const(throws) and var(void 0)

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code