babel-plugin-prototype-prop-define
A babel plugin for working around javascript's "override mistake" when dealing with frozen Primordials (built-ins).
background
If your primordials are frozen, such as in SES, assigning keys that are found on the prototype will throw an error.
Object.freeze(Object.prototype)
const x = {}
x.toString = () => 'hello'
Since this is a common, this plugin is provided to transform code into a safe form using Object.defineProperty
:
Object.freeze(Object.prototype)
const x = {}
Object.defineProperty(x, 'toString', {
value: () => 'hello',
writable: true,
enumerable: true,
configurable: true,
})
x.toString()