Skip to content
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

regeneratorRuntime is not defined error on import #15

Closed
danieltott opened this issue Dec 8, 2016 · 3 comments
Closed

regeneratorRuntime is not defined error on import #15

danieltott opened this issue Dec 8, 2016 · 3 comments

Comments

@danieltott
Copy link

I'm getting this error on import (nothing else is able to run) when using the npm package:

Uncaught ReferenceError: regeneratorRuntime is not defined(…)
(anonymous function)	@	index.js:14

where index.js refers to node_modules/redux-form-saga/lib/index.js

I created a file in my src with the uncompiled contents of index.js from the repo, and it loads fine. Not exactly sure what to do here - any help would be appreciated.

I'm using create-react-app v0.8.2

@afitiskin
Copy link
Collaborator

You have to use babel-polyfill with redux-form-saga.

Install babel-polyfill first:

yarn add babel-polyfill

Then add it into your project (e.g. to src/index.js):

import 'babel-polyfill';

That's it!

@danieltott
Copy link
Author

Thank you so much for your quick reply and help!

So here's the issue - and I'm still very much learning about all of this. It seems like create-react-app includes the regenerator runtime (as well as other parts of babel-polyfill) automatically if you're using generator functions: facebook/create-react-app#190

I have verified that my normal generators/sagas work just fine in Safari, for example, which has no support for generator functions out of the box. This is also why if I just use the non-npm version of redux-form-saga as a file in /src it works just fine. So maybe it is importing the npm version of your file before the regenerator runtime is available?

This might even be an issue for create-react-app, I'm just trying to understand it all.

Thanks again for your time

@danieltott
Copy link
Author

OK I've got it working without having to import all of babel-polyfill - I added this line to my entry file:

import 'regenerator-runtime/runtime'

And that makes the regeneratorRuntime available globally, not just in ./src!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants