Babel plugin (v0.6.1) that fixes extending built-in classes like Array, Error, HTMLElement, etc., which are notoriously broken in transpiled ES2015 classes. It patches the prototype chain so that instances created via `new MySubclass()` properly inherit from the subclass and its constructor. Requires `babel-plugin-transform-es2015-classes` as a prerequisite. Key differentiator: handles multiple globals, has a `logIfPatched` option, and works with Rollup (inverted plugin order). No known active development; last release was in 2017. Compatible with IE11+ and uses `Object.setPrototypeOf` or `__proto__` as fallback.
npm install babel-plugin-transform-builtin-classesVerified import paths — ran on the pinned version, not inferred.
Enables the plugin in Babel 6 configuration, targeting Array, Error, and HTMLElement globals. Shows a simple subclass of Array and verifies instance relationships.
Add 'babel-plugin-transform-es2015-classes' to plugins (or use babel-preset-es2015).
For Babel: order as ["transform-es2015-classes", ["transform-builtin-classes",...]]. For Rollup: invert order.
Consider using @babel/plugin-proposal-class-properties and modern Babel presets, or switch to native ES2015+ environments.
Ensure target browsers include IE11+ or polyfill Object.setPrototypeOf.
Always provide a globals array: e.g., ["Array", "Error"].
Add the built-in to the globals option: e.g., { "globals": ["Array"] }.Reorder plugins: ensure transform-es2015-classes comes before transform-builtin-classes (or after for Rollup).
Remove 'HTMLElement' from globals when running in Node, or conditionally configure.
Set logIfPatched: false or remove the option.