Registry / serialization / babel-plugin-transform-object-hasown

babel-plugin-transform-object-hasown

JSON →
library1.1.0jsnpmunverified

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-hasown
INSTALL
IMPORT
SIG · BABEL-PLUGIN-TRANS
B
babel-plugin-transform-object-hasown
serializationjavascriptv1.1.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

plugin
✓ module.exports = { plugins: ['babel-plugin-transform-object-hasown'] };
✗ module.exports = { plugins: ['transform-object-hasown'] };
Full npm package name required in .babelrc or babel.config.js.

Shows installation, Babel config setup, and code transformation of Object.hasOwn() to a polyfill.

// Install: npm install --save-dev babel-plugin-transform-object-hasown // .babelrc { "plugins": ["babel-plugin-transform-object-hasown"] } // Input const obj = {}; if (Object.hasOwn(obj, 'prop')) { console.log('has prop'); } // Output: object.hasOwn replaced with a helper that uses Object.prototype.hasOwnProperty.call
Debug
Known issues
gotchaOnly transforms exact patterns Object.hasOwn or Object['hasOwn'] — not Object['hasOwn']() with computed call or module aliases.
fix
Always use Object.hasOwn or Object['hasOwn'] in source code.
affects: >=1.0.0
gotchaUses a custom _objectHasOwn helper function; not a true runtime polyfill. The helper is defined per file, not shared.
fix
If you need a shared polyfill, consider using @babel/polyfill or core-js.
affects: >=1.0.0
gotchaPlugin does not check for existing runtime polyfill; if Object.hasOwn is already natively supported, transform still applies.
fix
Use with browserslist or @babel/preset-env to avoid unnecessary transforms.
affects: >=1.0.0
Errors
Common errors & fixes
ReferenceError: _objectHasOwn is not defined
Plugin not configured or plugin is not transforming the code (maybe source file not processed by Babel).
fix
Ensure the plugin is added to your Babel config and the file is processed by Babel.
TypeError: Cannot convert undefined or null to object
Plugin's custom helper throws this error exactly as Object.hasOwn would — it's intentional, but may surprise developers expecting silent false.
fix
Guard the call: if (obj != null && Object.hasOwn(obj, 'prop')) ...
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
28 hits · last 30 days
node
24
OpenAI (training)
1
Resources
babel-plugin-transform-object-hasown — npm install babel-plugin-transform-object-hasown · libregistry