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

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

Closed
conartist6 opened this issue Jun 17, 2018 · 2 comments
Closed

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

conartist6 opened this issue Jun 17, 2018 · 2 comments

Comments

@conartist6
Copy link
Contributor

conartist6 commented Jun 17, 2018

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]

@conartist6
Copy link
Contributor Author

Directly including regenerator in preset-react-app's plugins list predates the existence of preset-env.

Preset-env will transpile generators if browserslist requires it.

Therefore I think the correct solution is simply to remove transform-regenerator here. However I am having a truly awful time trying to verify it, or even reliably reproduce the problem I was having in the first place.

@conartist6
Copy link
Contributor Author

OK I have been able to verify locally that removing regenerator does not eliminate transpilation of generator functions when preset-env dictates that they need to be transpiled.

conartist6 added a commit to conartist6/create-react-app that referenced this issue Jun 29, 2018
Regenerator is already included by preset-env.

Fixes facebook#4627
Timer pushed a commit that referenced this issue Sep 27, 2018
Regenerator is already included by preset-env.

Fixes #4627
@lock lock bot locked and limited conversation to collaborators Jan 12, 2019
LishuGupta652 pushed a commit to LishuGupta652/create-react-app-1 that referenced this issue Oct 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant