a-tokyo / react-apple-signin-auth

 Apple signin for React using the official Apple JS SDK

Home Page:https://a-tokyo.github.io/react-apple-signin-auth

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ReferenceError: regeneratorRuntime is not defined at node_modules/react-apple-signin-auth/dist/utils/waitForVar.js:21:46

vanessamarely opened this issue · comments

when I tried to create a build on next.js application I got that error:

Build error occurred
ReferenceError: regeneratorRuntime is not defined
```
at node_modules/react-apple-signin-auth/dist/utils/waitForVar.js:21:46

at Object.<anonymous> /node_modules/react-apple-signin-auth/dist/utils/waitForVar.js:84:2)

at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object. (node_modules/react-apple-signin-auth/dist/appleAuthHelpers/index.js:8:42)
at Module._compile (node:internal/modules/cjs/loader:1101:14) {
type: 'ReferenceError'

@vanessamarely

This is related to Babel transpilation not really this repo ( :

To solve, Please add the following to your src/index.js

import 'regenerator-runtime/runtime';

also remember to run yarn add regenerator

I wonder if this is a transpilation issue by the library though because now you're forcing consumers of this library to include a polyfill for async/await support even if they only want to support browsers that have the async/await feature.

It seems like either this library should automatically include the regenerator code (so that it isn't the consumer's responsibility), or ship a version of the library that doesn't transpile and allow the consumer to decide whether it should be transpiled or not.

Thanks for your input @craigjennings11

Including the generator in the library would cause more problems than it solves. For instance: version conflicts, extra bundle size.

The second option sounds great, PRs are welcome!

BTW, another solution would be to remove async and await and use promises.

Thanks to @craigjennings11, The latest version 1.0.5 no longer requires regenerator runtime

#67