Skip to content

for...of inside generator function causes transpilation failure #4627

Closed
@conartist6

Description

@conartist6

preset-react-app has the issue described here: https://github.com/leebenson/babel-preset-node5/issues/4

Is this a bug report?

Yes

Steps to Reproduce

set a browserslist in package.json which which includes only browsers which support for...of loops, e.g.

  "browserslist": {
    "production": ["last 1 chrome versions"]
  },

Attempt to build an application which contains a for...of loop inside a generator function, like so:

function* willFailCompilation(array) {
  for (const item of array) {
      yield item;
  }
}

Expected Behavior

The app does not fail compilation

Actual Behavior

This error is shown:
Failed to compile

Module build failed: Error: unknown Statement of type "ForOfStatement"
at Array.forEach ()

Reproducible Demo

[none]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions