From b50c8c792ab1ae51c0c0fd6e61e11e7c00660cd5 Mon Sep 17 00:00:00 2001 From: juribolotko-cmd Date: Fri, 14 Aug 2026 13:56:43 +0200 Subject: [PATCH] fix(react-native): make expo-file-system a peer dependency The hard pin "expo-file-system": "18.*.*" forces npm to install a second, nested copy of expo-file-system in apps on Expo SDK 54+, where the app itself uses 19.x or newer. Expo autolinking then mixes the two versions' native code and the app crashes at launch (NoClassDefFoundError: expo.modules.filesystem.FilePermissionModule). Moving the dependency to peerDependencies (">=18.0.0") lets the host app own the version, so only one copy is ever installed. The new ambient shim (same pattern as react-native-shim.d.ts) keeps the generated SDK compiling under "npm ci --omit=peer", where peer packages are not installed. Fixes appwrite/sdk-for-react-native#114 Co-Authored-By: Claude Opus 5 --- src/SDK/Language/ReactNative.php | 5 +++++ templates/react-native/package-lock.json.twig | 3 ++- templates/react-native/package.json.twig | 2 +- .../src/expo-file-system-shim.d.ts.twig | 22 +++++++++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 templates/react-native/src/expo-file-system-shim.d.ts.twig diff --git a/src/SDK/Language/ReactNative.php b/src/SDK/Language/ReactNative.php index 7fac1234dd..fe405ad36a 100644 --- a/src/SDK/Language/ReactNative.php +++ b/src/SDK/Language/ReactNative.php @@ -36,6 +36,11 @@ public function getFiles(): array 'destination' => 'src/react-native-shim.d.ts', 'template' => 'react-native/src/react-native-shim.d.ts.twig', ], + [ + 'scope' => 'default', + 'destination' => 'src/expo-file-system-shim.d.ts', + 'template' => 'react-native/src/expo-file-system-shim.d.ts.twig', + ], [ 'scope' => 'default', 'destination' => 'src/service.ts', diff --git a/templates/react-native/package-lock.json.twig b/templates/react-native/package-lock.json.twig index e5a6ed3f99..046f5df448 100644 --- a/templates/react-native/package-lock.json.twig +++ b/templates/react-native/package-lock.json.twig @@ -9,7 +9,6 @@ "version": "{{ sdk.version }}", "license": "{{ sdk.license }}", "dependencies": { - "expo-file-system": "18.*.*", "json-bigint": "1.0.0" }, "devDependencies": { @@ -26,6 +25,7 @@ }, "peerDependencies": { "expo": "*", + "expo-file-system": ">=18.0.0", "react-native": ">=0.76.7 <1.0.0" }, "overrides": { @@ -3655,6 +3655,7 @@ "resolved": "https://registry.npmjs.org/expo-file-system/-/expo-file-system-18.1.11.tgz", "integrity": "sha512-HJw/m0nVOKeqeRjPjGdvm+zBi5/NxcdPf8M8P3G2JFvH5Z8vBWqVDic2O58jnT1OFEy0XXzoH9UqFu7cHg9DTQ==", "license": "MIT", + "peer": true, "peerDependencies": { "expo": "*", "react-native": "*" diff --git a/templates/react-native/package.json.twig b/templates/react-native/package.json.twig index 9f9a5ae6a2..f1a0c9a7a2 100644 --- a/templates/react-native/package.json.twig +++ b/templates/react-native/package.json.twig @@ -41,11 +41,11 @@ "typescript": "5.9.3" }, "dependencies": { - "expo-file-system": "18.*.*", "json-bigint": "1.0.0" }, "peerDependencies": { "expo": "*", + "expo-file-system": ">=18.0.0", "react-native": ">=0.76.7 <1.0.0" }, "overrides": { diff --git a/templates/react-native/src/expo-file-system-shim.d.ts.twig b/templates/react-native/src/expo-file-system-shim.d.ts.twig new file mode 100644 index 0000000000..07777667fe --- /dev/null +++ b/templates/react-native/src/expo-file-system-shim.d.ts.twig @@ -0,0 +1,22 @@ +declare module 'expo-file-system' { + export enum EncodingType { + UTF8 = 'utf8', + Base64 = 'base64', + } + export const cacheDirectory: string; + export function readAsStringAsync( + fileUri: string, + options?: { + encoding?: EncodingType; + position?: number; + length?: number; + } + ): Promise; + export function writeAsStringAsync( + fileUri: string, + contents: string, + options?: { + encoding?: EncodingType; + } + ): Promise; +}