GithubHelp home page GithubHelp logo

applifier / babel-plugin-transform-builtin-extend Goto Github PK

View Code? Open in Web Editor NEW

This project forked from loganfsmyth/babel-plugin-transform-builtin-extend

0.0 6.0 0.0 10 KB

A plugin for Babel 6 supports extending from builtin types based on static analysis.

License: MIT License

JavaScript 100.00%

babel-plugin-transform-builtin-extend's Introduction

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__.

babel-plugin-transform-builtin-extend's People

Contributors

azu avatar loganfsmyth avatar samipussinen avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

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.