From 221dd99ffd1990f8bd0392543af35e9b08d0fed8 Mon Sep 17 00:00:00 2001 From: Lenz Weber-Tronic Date: Fri, 8 Dec 2023 13:48:42 +0100 Subject: [PATCH] Allow usage of WeakMap in React Native Hermes (#10804) Co-authored-by: phryneas --- .changeset/unlucky-rats-decide.md | 5 +++++ .size-limits.json | 4 ++-- src/utilities/common/canUse.ts | 4 +++- 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 .changeset/unlucky-rats-decide.md diff --git a/.changeset/unlucky-rats-decide.md b/.changeset/unlucky-rats-decide.md new file mode 100644 index 00000000000..9be1d2d3961 --- /dev/null +++ b/.changeset/unlucky-rats-decide.md @@ -0,0 +1,5 @@ +--- +"@apollo/client": patch +--- + +use WeakMap in React Native with Hermes diff --git a/.size-limits.json b/.size-limits.json index e23614a183f..fb873241928 100644 --- a/.size-limits.json +++ b/.size-limits.json @@ -1,4 +1,4 @@ { - "dist/apollo-client.min.cjs": 38576, - "import { ApolloClient, InMemoryCache, HttpLink } from \"dist/index.js\" (production)": 32352 + "dist/apollo-client.min.cjs": 38589, + "import { ApolloClient, InMemoryCache, HttpLink } from \"dist/index.js\" (production)": 32365 } diff --git a/src/utilities/common/canUse.ts b/src/utilities/common/canUse.ts index 72e56c70388..217cc01158b 100644 --- a/src/utilities/common/canUse.ts +++ b/src/utilities/common/canUse.ts @@ -2,7 +2,9 @@ import { maybe } from "../globals/index.js"; export const canUseWeakMap = typeof WeakMap === "function" && - maybe(() => navigator.product) !== "ReactNative"; + !maybe( + () => navigator.product == "ReactNative" && !(global as any).HermesInternal + ); export const canUseWeakSet = typeof WeakSet === "function";