0

T'm trying to use redux-saga module.

However I have following error.

Uncaught ReferenceError: regeneratorRuntime is not defined
    at eval (saga.js:5)
    at Object../js/sagas/saga.js (saga.js:393)
    at __webpack_require__ (saga.js:20)
    at eval (configureStore.js:8)
    at Object../js/stores/configureStore.js 

saga.js is just simple.

export function* helloSaga(){
    console.log('Hello Sagas!');
}

And I have installed following module.

npm install @babel/polyfill --save

What is happening on it?

tajihiro
  • 1,633
  • 1
  • 24
  • 40

2 Answers2

0

Check your babel configuration.

For @babel/preset-env check the exclude and useBuiltIns options: https://babeljs.io/docs/en/babel-preset-env#exclude

For @babel/preset-transform-runtime check the regenerator option:
https://babeljs.io/docs/en/babel-plugin-transform-runtime#regenerator

Also @babel/polyfill has been deprecated in favor of directly using core-js and regenerator-runtime/runtime in babel 7.4:
https://babeljs.io/blog/2019/03/19/7.4.0#migration-from-core-js-2
https://babeljs.io/docs/en/babel-polyfill

Finally, try explicitly setting path to .babelrc in your babel-loader. I have a theory that babel is using different .babelrc name defaults to resolve it for some of its tasks.
https://babeljs.io/docs/en/options#configfile or
https://babeljs.io/docs/en/options#extends

Martin Kadlec
  • 2,777
  • 2
  • 17
  • 23
0

Finally I get to use @babel/polyfill even if it is duplicated.

npm install @babel/polyfill --save 
import '@babel/polyfill';

export function* helloSaga(){
    console.log('Hello Sagas!');
}

The error does not come out. It worked.

tajihiro
  • 1,633
  • 1
  • 24
  • 40