-
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
"ReferenceError: regeneratorRuntime is not defined" in v4 #8514
Comments
The solution is to pass |
Hey @TheDutchCoder do you happen to be using async/await in your code? |
Yes all over the place, so that shouldn't be an issue (e.g. signIn also uses that). So my reasoning is that it actually fails to signout first and then hits that retry where the bug is. The bigger problem is why it fails to sign me out in the first place and why 1 other colleague has the same problem and 1 other doesn't. We're all on the same versions of node, npm, amplify-cli, aws-amplify, etc. For reference: /**
* Signs in a user given en email addres.
* This will actually send an email with a verification code ('challenge') for
* the user to submit.
*/
export const signIn = async (email: string): Promise<any> => await Auth.signIn(email)
/**
* Signs out a user.
*/
export const signOut = async (): Promise<any> => await Auth.signOut() Funnily enough it works with a global signout: |
I'm digging into this some more, and it seems to have happened somewhere between version Going through all the commits, I've found this piece that is actually throwing the error: fa5cdb8#diff-4bea2f0020039d5275abe5c4e4747c1c7c1457e59abb4101f26230011834925d Also, the signout function changed here:fa5cdb8#diff-8645b6bfe673522e9f71ef69ab2dc9bc01f0e15c4fe41cb5766a3acef1749ca5 The new signOut changes look fishy, especially since it now can take a callback, but the TS definitions don't mention this at all (it still shows an option object). Yeah you didn't generate the esm lib: This is from aws-amplify 4.1.2, going into the esm lib the signout method looks like this: But in the actual dist folder it's: It looks like the ESM lib was not generated (along with the types). Tangentially related: you guys don't provide a list of release notes? This is a breaking change and should at least be mentioned somewhere in a release note and/or (even better) should have gotten a major release. cc: @chrisbonifacio |
Hi @TheDutchCoder, sorry for the delay. We do update the README with any breaking changes between versions. There are known issues with Vite which usually can be resolved through your project configuration but we are actively working towards making our libraries more compatible with Vite. You can track and/or contribute to the work being done to remedy these issues in PRs like this pertaining to Vite #7970 We also opened our own issue in the In the meantime, I was able to reproduce this issue pretty quickly and consistently with a fresh Vite + React app with Amplify so I labeled it a bug for the team and they are aware of the cause. This is a bandaid until we release the fix on our side but you can get past this issue currently by simply installing import "regenerator-runtime"; |
@TheDutchCoder Thank you for reporting this. Currently we are creating a quick fix, meanwhile you can follow the readme to import for reference: babel/babel#9849 (comment) |
Thanks for picking this up @chrisbonifacio and @hkjpotato ! Could you maybe shed some light onto why the ESM build differs from the transpiled JS build? Just to clarify: I'm not building for older browsers, nor is Vite setup to do so. We also don't use babel, so I have a feeling that the particular part of code that depends on the regeneratorRuntime comes pre-transpiled? Is that correct? Because async stuff shouldn't get transpiled by default, modern browsers support that natively so there's no need to transpile it (especially if I don't configure my bundler for it 😄 ) I guess what I'm asking is: is there a way force importing the ESM version of (aws internal) packages? |
@TheDutchCoder Normally, when we use a third party codebase, we seldomly use its "source code" or uncompiled code directly.
I haven't used vite yet, but I assume it still follow the normal node module resolving path to load the JS code? This might be a good question for the Vite community though.. |
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 |
Before opening, please confirm:
JavaScript Framework
Vue
Amplify APIs
Authentication
Amplify Categories
auth
Environment information
Describe the bug
When using
aws/amplify
and import the Auth part,Auth.signOut()
throws a "ReferenceError: regeneratorRuntime is not defined" error when using Vite as the builder.Expected behavior
Not to throw an error
Reproduction steps
Auth.signOut()
Code Snippet
// Put your code below this line.
Log output
aws-exports.js
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
The error doesn't occur with any v3 version. I'll see if any of the old v4 versions also work, but I have my doubts.
The text was updated successfully, but these errors were encountered: