Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/runtime/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Polyfills must be imported first to ensure compatibility with Hermes
import './polyfills.js';
import './globals.d.ts';

export { UI as ReactNativeHarness } from './ui/index.js';
Expand Down
16 changes: 16 additions & 0 deletions packages/runtime/src/polyfills.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Polyfills for Hermes JavaScript engine compatibility.
*
* Hermes (React Native's default JS engine) doesn't support all ES2022+ features.
* This file provides polyfills for features used by harness dependencies.
*/

/**
* Object.hasOwn (ES2022)
* Used by @vitest/expect v4.x for property checking.
* @see https://github.com/facebook/hermes/issues/1875
*/
if (typeof Object.hasOwn !== 'function') {
Object.hasOwn = (obj: object, prop: PropertyKey): boolean =>
Object.prototype.hasOwnProperty.call(obj, prop);
}