From e765e3ee3398a9441c6728e86cf3d17e9ac67ea3 Mon Sep 17 00:00:00 2001 From: Kyle McDonald Date: Wed, 8 Jul 2026 10:05:37 -0500 Subject: [PATCH] fix(react-native): order react-native export condition before require Metro resolves conditional exports by first match in object-key order. Because the `require` condition was listed before `react-native` in the `exports["."]` map, Metro (with package exports enabled by default since React Native 0.79) matched `require` first and resolved @knocklabs/react-native to the prebuilt `dist/cjs` bundle instead of the `react-native` -> `src/index.ts` source entry it is meant to serve. Reorder the map so `types` and `react-native` come first, matching @knocklabs/react-core and @knocklabs/client. Verified against metro-resolver: the package now resolves to `./src/index.ts` under RN's active conditions. Refs #838 --- .changeset/react-native-exports-ordering.md | 5 +++++ packages/react-native/package.json | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changeset/react-native-exports-ordering.md diff --git a/.changeset/react-native-exports-ordering.md b/.changeset/react-native-exports-ordering.md new file mode 100644 index 000000000..64884315b --- /dev/null +++ b/.changeset/react-native-exports-ordering.md @@ -0,0 +1,5 @@ +--- +"@knocklabs/react-native": patch +--- + +Fix the `exports` map ordering so React Native's Metro bundler resolves the package to its source entry point (`src/index.ts`) via the `react-native` condition instead of the prebuilt CommonJS bundle. The `require` condition was previously listed first, shadowing `react-native` under Metro's package-exports resolution (enabled by default since React Native 0.79). The ordering now matches the other `@knocklabs/*` packages. diff --git a/packages/react-native/package.json b/packages/react-native/package.json index 8cfb6e53e..e963b6a6a 100644 --- a/packages/react-native/package.json +++ b/packages/react-native/package.json @@ -11,10 +11,11 @@ "exports": { "./package.json": "./package.json", ".": { - "require": "./dist/cjs/index.js", "types": "./dist/types/index.d.ts", "react-native": "./src/index.ts", - "default": "./dist/esm/index.mjs" + "require": "./dist/cjs/index.js", + "import": "./dist/esm/index.mjs", + "default": "./dist/cjs/index.js" } }, "files": [