From 1c99b18193d9a70403b07d8e343d41757fea7b4f Mon Sep 17 00:00:00 2001 From: bheemreddy-samsara Date: Thu, 8 Jan 2026 21:21:10 -0600 Subject: [PATCH 1/2] fix(runtime): add Object.hasOwn polyfill for JSC compatibility JSC (JavaScriptCore) doesn't support Object.hasOwn (ES2022). This causes runtime errors when @vitest/expect v4.x initializes. The polyfill is loaded before any other runtime code to ensure Object.hasOwn is available when @vitest/expect initializes. --- packages/runtime/src/index.ts | 1 + packages/runtime/src/polyfills.ts | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 packages/runtime/src/polyfills.ts diff --git a/packages/runtime/src/index.ts b/packages/runtime/src/index.ts index dc03137..1dc1c6e 100644 --- a/packages/runtime/src/index.ts +++ b/packages/runtime/src/index.ts @@ -1,3 +1,4 @@ +import './polyfills.js'; import './globals.d.ts'; export { UI as ReactNativeHarness } from './ui/index.js'; diff --git a/packages/runtime/src/polyfills.ts b/packages/runtime/src/polyfills.ts new file mode 100644 index 0000000..df8ed18 --- /dev/null +++ b/packages/runtime/src/polyfills.ts @@ -0,0 +1,14 @@ +/** + * Polyfills for ES2022+ features not supported by JSC (JavaScriptCore). + * + * JSC, used in React Native when Hermes is disabled, doesn't support + * Object.hasOwn (ES2022). This causes runtime errors when @vitest/expect + * v4.x initializes. + * + * This polyfill must be loaded before any code that uses Object.hasOwn. + */ + +if (typeof Object.hasOwn !== 'function') { + Object.hasOwn = (obj: object, prop: PropertyKey): boolean => + Object.prototype.hasOwnProperty.call(obj, prop); +} From 85c5d3ebf3af467c7620169c4abd02cdda5e680a Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Mon, 12 Jan 2026 13:22:34 +0100 Subject: [PATCH 2/2] chore: add version plan --- .nx/version-plans/version-plan-1768220533507.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .nx/version-plans/version-plan-1768220533507.md diff --git a/.nx/version-plans/version-plan-1768220533507.md b/.nx/version-plans/version-plan-1768220533507.md new file mode 100644 index 0000000..4462d45 --- /dev/null +++ b/.nx/version-plans/version-plan-1768220533507.md @@ -0,0 +1,5 @@ +--- +__default__: prerelease +--- + +Adds Object.hasOwn polyfill to the runtime package for JSC (JavaScriptCore) compatibility.