Skip to content

Generator class throws an error in development build #4371

@robertedjones

Description

@robertedjones

Is this a bug report?

Yes

Did you try recovering your dependencies?

1.6.0

Which terms did you search for in User Guide?

Babel, Generator Functions

Environment

  1. node -v: 8.11.1
  2. npm -v: 5.6.0
  3. yarn --version (if you use Yarn): 1.6.0
  4. npm ls react-scripts (if you haven’t ejected): react-scripts@2.0.0-next.66cc7a90

Then, specify:

  1. Operating system: Windows 10
  2. Browser and version (if relevant): Chrome 65.0.3325.181, Firefox Quantum 59.0.2 (64-bit)

Steps to Reproduce

During a development build Babel does not correctly convert generator functions in a class. The exact issue I am experiencing is described in this issue facebook/regenerator#287 but that appears to have since been resolved. This issue only occurs in a development build and works correctly during a production build. It was working correctly in react-scripts 1.x. - react-scripts@2.0.0-next.66cc7a90 is the first 2.x build I have tried. This may be a Babel issue rather than a CRA issue.

  1. Create a generator class
export default class GeneratorClass {
  *getReply(msg) {
    yield msg;
  }
}
  1. Invoke the classs
const reply = new Reply();
var r = reply.getReply('Hello ');
console.log('gen', r.next());
  1. yarn start
  2. ReferenceError: _callee is not defined

Expected Behavior

Babel correctly transpiles generator functions in a class and no error is given

Actual Behavior

The error:

ReferenceError: _callee is not defined

Reproducible Demo

https://github.com/robertedjones/my-app

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions