-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uncaught ReferenceError: require is not defined #7901
Comments
Which browser/platform are you getting this error in? Which framework or build tool are you using? |
I'm using Snowpack bundler, which uses esbuild. It uses the |
I see. We're using |
What is the reasoning for importing them conditionally? Is it the file size? Or do they have a side effect or something? |
Mainly file size, as AsyncStorage has upstream dependencies that are not needed on web |
The main issue for me here is that this is not standards compliant ESM. There are two compilation targets for this project. If you were to use But the developers who target ESNext now have no other choice but to fork the project to use DataStore. |
That's fair. Most of our customers rely on Webpack (via CRA, @angular/cli, etc.), and by default the ESM modules with those get transpiled further, so it's not an issue in most cases. I would be resistant to changing the conditional However, it looks like ESM Dynamic Imports are now supported by > 3 major versions in all major browsers, so we should be able to start using that feature. We'll look into refactoring any conditional |
Is there any update on this? I'm having same problem when using Svelte Kit, Vite, and AWS Amplify DataStore. |
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |
Describe the bug
There are several
require
s in DataStore source code. It causes this error:Here is a screenshot from the Dev Tools:
What is Configured?
I'm using the latest version of amplify-js, i.e. 3.3.22.
This is the file where it is coming from:
https://github.com/aws-amplify/amplify-js/blob/8fa348b8ba708434992d97557b0fceebbf7abe9a/packages/datastore/src/storage/adapter/getDefaultAdapter/index.ts
The text was updated successfully, but these errors were encountered: