Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/loganfsmyth/babel-plugin-transform-builtin-extend
A plugin for Babel 6 supports extending from builtin types based on static analysis.
https://github.com/loganfsmyth/babel-plugin-transform-builtin-extend
Last synced: 3 months ago
JSON representation
A plugin for Babel 6 supports extending from builtin types based on static analysis.
- Host: GitHub
- URL: https://github.com/loganfsmyth/babel-plugin-transform-builtin-extend
- Owner: loganfsmyth
- License: mit
- Created: 2015-12-11T08:04:10.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2022-01-18T09:08:04.000Z (almost 3 years ago)
- Last Synced: 2024-07-16T15:41:40.551Z (4 months ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 148
- Watchers: 4
- Forks: 19
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-babel - transform-builtin-extend - Enable extending builtin types like `Error` and `Array`, which require special treatment and require static analysis to detect. (Plugins / General Plugins)
README
# 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__`.