Skip to main content
100%

Webpack ES6 Array Extend Bug Example

✓ Published0🌍 Public
SSigfried
Last edited Feb 1, 2016
Created on Feb 1, 2016

This example demonstrates a bug where Webpack’s Babel transpilation corrupts ES6 classes that extend the built-in Array constructor. It shows that a `ThingArray` instance, created via `new ThingArray(['baz', 42])`, loses its subclass identity when passed to a test function, even though the console displays `ThingArray` in the debugger. The code uses `babel-plugin-transform-builtin-extend` with the `globals: ["Array"]` option and `babel-preset-es2015` to compile the class, while comparing behavior between a browser running `webpack-dev-server` and plain Node execution. The page renders the array’s string representation into a div via `document.getElementById`.

AI-generated description
MIT Licensed

Similar vizzes