1. babel-plugin-transform-builtin-extend
A plugin for Babel 6 supports extending from builtin types based on static analysis.
babel-plugin-transform-builtin-extend
Package: babel-plugin-transform-builtin-extend
Created by: loganfsmyth
Last modified: Mon, 13 Jun 2022 04:04:05 GMT
Version: 1.1.2
License: MIT
Downloads: 172,391
Repository: https://github.com/loganfsmyth/babel-plugin-transform-builtin-extend

Install

npm install babel-plugin-transform-builtin-extend
yarn add babel-plugin-transform-builtin-extend

Babel Builtin Constructor extension plugin

This is a Babel 6 plugin to enable extending builtin types like "Error" and "Array" and such,
which require special treatment and require static analysis to detect.

Usage

In your Babel 6 configuration, for example in a .babelrc you might have

{
    "plugins": [
        ["babel-plugin-transform-builtin-extend", {
            globals: ["Error", "Array"]
        }]
    ]
}

which would enable the plugin and configure it to look for any class extending Error or Array globals.

IE<=10

On older browsers that do not support reassigning the prototype of an existing object, you will need to
enable the approximate mode, which will fall back to the Babel 5 behavior of using simple ES5 inheritance
to approximate extending a class, though your results may vary depending on your goals.

{
    "plugins": [
        ["babel-plugin-transform-builtin-extend", {
            globals: ["Error", "Array"],
            approximate: true
        }]
    ]
}

Limitations

This plugin will only reles on assigning __proto__ for static property inheritance from parent constructors.
If you are relying on this, it will not work on IE<=10 and any other browsers that don't support __proto__.

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