Babel plugin for transforming Object.hasOwn() (ES2022 proposal) to a polyfill using Object.prototype.hasOwnProperty.call(). Current stable version: 1.1.0. Low release cadence, matches official polyfill behavior since v1.1.0. Key differentiator: targeted transform for the accessible Object.hasOwn proposal, only transforms exact 'Object.hasOwn' or 'Object["hasOwn"]' patterns.
npm install babel-plugin-transform-object-hasownVerified import paths — ran on the pinned version, not inferred.
Shows installation, Babel config setup, and code transformation of Object.hasOwn() to a polyfill.
Always use Object.hasOwn or Object['hasOwn'] in source code.
If you need a shared polyfill, consider using @babel/polyfill or core-js.
Use with browserslist or @babel/preset-env to avoid unnecessary transforms.
Ensure the plugin is added to your Babel config and the file is processed by Babel.
Guard the call: if (obj != null && Object.hasOwn(obj, 'prop')) ...
No dependency data recorded yet.