amplify-js: Broken import for datastore-storage-adapter on fresh Expo RN app
Before opening, please confirm:
- I have searched for duplicate or closed issues and discussions.
- I have read the guide for submitting bug reports.
- I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
JavaScript Framework
React Native
Amplify APIs
Authentication, REST API, DataStore, Storage
Amplify Version
v6
Amplify Categories
auth, storage, api, Not applicable
Backend
Amplify CLI
Environment information
# Put output below this line
System:
OS: macOS 13.4.1
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 38.96 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.19.0 - ~/.nvm/versions/node/v18.19.0/bin/node
Yarn: 1.22.21 - ~/.nvm/versions/node/v18.19.0/bin/yarn
npm: 10.2.3 - ~/.nvm/versions/node/v18.19.0/bin/npm
Watchman: 2023.12.04.00 - /usr/local/bin/watchman
Browsers:
Chrome: 120.0.6099.199
Safari: 16.5.2
npmPackages:
@aws-amplify/datastore-storage-adapter: ^2.1.10 => 2.1.10
@aws-amplify/react-native: ^1.0.10 => 1.0.10
@babel/core: ^7.20.0 => 7.23.7
@react-native-async-storage/async-storage: 1.18.2 => 1.18.2
@react-native-community/netinfo: 9.3.10 => 9.3.10
HelloWorld: 0.0.1
aws-amplify: ^6.0.10 => 6.0.10
aws-amplify/adapter-core: undefined ()
aws-amplify/analytics: undefined ()
aws-amplify/analytics/kinesis: undefined ()
aws-amplify/analytics/kinesis-firehose: undefined ()
aws-amplify/analytics/personalize: undefined ()
aws-amplify/analytics/pinpoint: undefined ()
aws-amplify/api: undefined ()
aws-amplify/api/server: undefined ()
aws-amplify/auth: undefined ()
aws-amplify/auth/cognito: undefined ()
aws-amplify/auth/cognito/server: undefined ()
aws-amplify/auth/enable-oauth-listener: undefined ()
aws-amplify/auth/server: undefined ()
aws-amplify/datastore: undefined ()
aws-amplify/in-app-messaging: undefined ()
aws-amplify/in-app-messaging/pinpoint: undefined ()
aws-amplify/push-notifications: undefined ()
aws-amplify/push-notifications/pinpoint: undefined ()
aws-amplify/storage: undefined ()
aws-amplify/storage/s3: undefined ()
aws-amplify/storage/s3/server: undefined ()
aws-amplify/storage/server: undefined ()
aws-amplify/utils: undefined ()
expo: ~49.0.15 => 49.0.21
expo-status-bar: ~1.6.0 => 1.6.0
react: 18.2.0 => 18.2.0
react-native: 0.72.6 => 0.72.6
react-native-get-random-values: ~1.9.0 => 1.9.0
react-native-sqlite-storage: ^6.0.1 => 6.0.1
npmGlobalPackages:
corepack: 0.22.0
ignite-cli: 9.2.0
npm: 10.2.3
yarn: 1.22.21
Describe the bug
Using a newly generated application, following the Datastore web guide the app fails to load the bundle with a missing reference to the library aws-amplify-datastore-sqlite-adapter-expo
Looking in the directory mentioned, ./node_modules/@aws-amplify/datastore-storage-adapter/dist/ I don’t see the the expected file, aws-amplify-datastore-sqlite-adapter-expo[.min].js, but I do see them in datastore-storage-adapter/dist/umd. Changing the require string to umd at least stops the error, and allows the app to load, but I haven’t tried using the datastore service yet.
Expected behavior
The application to successfully load in Expo Go.
Reproduction steps
- Run commands as per guide, and load app in emulator
npx create-expo-app AmplifyDataStoreExpo
cd AmplifyDataStoreExpo
expo install aws-amplify @aws-amplify/react-native @react-native-community/netinfo @aws-amplify/datastore-storage-adapter react-native-sqlite-storage @react-native-async-storage/async-storage react-native-get-random-values
yarn ios
- Add code to
App.js
import { DataStore } from 'aws-amplify/datastore';
import { ExpoSQLiteAdapter } from '@aws-amplify/datastore-storage-adapter/ExpoSQLiteAdapter';
DataStore.configure({
storageAdapter: ExpoSQLiteAdapter
});
- Reload app in Expo Go
- Receive error seen in log output
Code Snippet
// Put your code below this line.
Log output
// Put your logs below this line
ERROR [Error: undefined Unable to resolve module ../dist/aws-amplify-datastore-sqlite-adapter-expo.min.js from /XXX/AmplifyDataStoreExpo/node_modules/@aws-amplify/datastore-storage-adapter/ExpoSQLiteAdapter/index.js:
None of these files exist:
* node_modules/@aws-amplify/datastore-storage-adapter/dist/aws-amplify-datastore-sqlite-adapter-expo.min.js(.native|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json|.ios.cjs|.native.cjs|.cjs)
* node_modules/@aws-amplify/datastore-storage-adapter/dist/aws-amplify-datastore-sqlite-adapter-expo.min.js/index(.native|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json|.ios.cjs|.native.cjs|.cjs)
4 |
5 | if (process.env.NODE_ENV === 'production') {
> 6 | module.exports = require('../dist/aws-amplify-datastore-sqlite-adapter-expo.min.js');
| ^
7 | } else {
8 | module.exports = require('../dist/aws-amplify-datastore-sqlite-adapter-expo.js');
9 | }]
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
iPhone14 Emulator
Mobile Operating System
iOS16.4
Mobile Browser
Expo Go
Mobile Browser Version
No response
Additional information and screenshots
No response
About this issue
- Original URL
- State: open
- Created 6 months ago
- Reactions: 4
- Comments: 17 (3 by maintainers)
Experiencing the same issue. After several version tests, only version 2.0.30 seems to work . All others are in this Path: datastore-storage-adapter/dist/umd not datastore-storage-adapter/dist/ and when you manually change it, it fails when you they to build the app.
I can confirm we’ve also run into this exact same error, and so have temporarily removed using that adapter in our internal testing of our v5 -> v6 migration.
Would love to switch back to the Sqlite adapter soon as I believe query performance in particular is much better in an RN app.
I currently have a PR open to fix the broken subpaths, but I also wanted to note that Expo Go is currently not officially supported by Amplify V6. However, Expo and React Native CLI apps are supported.
@chrisbonifacio When do you (team) plan to fix the issue related to the path? Also, switching to 2.0.40 is worth in terms of performance?
Apologies for the delay. We’re able to reproduce this internally.
Here’s a minimum repro app for the team: https://github.com/chrisbonifacio/amplify-expo-app
In the meantime, please use
@aws-amplify/datastore-storage-adapter@2.0.40. Not sure if necessary, might just be something I did wrong, but I also had to installexpo-sqlitealongside it to work.I kept getting
requireNativeModuleExpoSQLite errors otherwise.Temporary Fix:
npm install @aws-amplify/datastore-storage-adapter@2.0.40In addition to fixing this broken import, Expo has just released SDK 50 which introduces a big update to their
sqlitecapability (see their release notes here).I don’t want to muddy the waters with this ticket, but other than say I hope DataStore supports sqlite well on Expo platforms for a long time and that the above Expo change helps this over time.
Looking forward to updates to this ticket with a fix.