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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

unknown Statement of type "ForOfStatement" #1269

Closed
BobBuehler opened this issue Apr 30, 2018 · 22 comments
Closed

unknown Statement of type "ForOfStatement" #1269

BobBuehler opened this issue Apr 30, 2018 · 22 comments

Comments

@BobBuehler
Copy link

馃悰 bug report

馃帥 Configuration (.babelrc, package.json, cli command)

package.json

{
    "scripts": {
        "dev": "parcel ./src/index.html -d build/ --target=browser"
    }
}

.babelrc

{
    "presets": ["react"],
    "plugins": ["react-hot-loader/babel"]
}

馃 Expected Behavior

It bundles and transpiles my es6 targetting node_module dependencies

馃槸 Current Behavior

regenerator-transform fails because it finds a for-of statement within a generator.

脳  C:\git\my_webapp\node_modules\@private\core\dist\iterables.js: C:/git/my_webapp/node_modules/@private/core/dist/iterables.js: unknown Statement of type "ForOfStatement"
    at Emitter.Ep.explodeStatement (C:\git\my_webapp\node_modules\regenerator-transform\lib\emit.js:648:13)
    at C:\git\my_webapp\node_modules\regenerator-transform\lib\emit.js:344:12
    at Array.forEach (<anonymous>)
    at Emitter.Ep.explodeStatement (C:\git\my_webapp\node_modules\regenerator-transform\lib\emit.js:343:22)
    at Emitter.Ep.explode (C:\git\my_webapp\node_modules\regenerator-transform\lib\emit.js:298:40)
    at PluginPass.exit (C:\git\my_webapp\node_modules\regenerator-transform\lib\visit.js:122:15)
    at newFn (C:\git\my_webapp\node_modules\babel-traverse\lib\visitors.js:276:21)
    at NodePath._call (C:\git\my_webapp\node_modules\babel-traverse\lib\path\context.js:76:18)
    at NodePath.call (C:\git\my_webapp\node_modules\babel-traverse\lib\path\context.js:48:17)
    at NodePath.visit (C:\git\my_webapp\node_modules\babel-traverse\lib\path\context.js:117:8)

馃拋 Possible Solution

According to facebook/regenerator#229 for-of statements need to be transformed before regenerator-transform can be applied. Maybe there is a way to force this.

馃實 Your Environment

Software Version(s)
Parcel 1.7.1
Node 9.11.1
npm/Yarn 1.6.0
Operating System Win 7 64bit
@lbittner-pdftron
Copy link

Also getting this.. no other solutions posted anywhere work

@Offirmo
Copy link

Offirmo commented Oct 4, 2018

[edited for clarification] I got this when migrating to babel 7. In the node_module which caused problem and which I own, I removed the .babelrc (which was no longer needed) and added the @babel/core: ^7 dependency and the error disappeared.

@devongovett
Copy link
Member

Is anyone still having this issue? Sounds like possibly an issue in Babel rather than parcel itself?

@raine
Copy link

raine commented Feb 28, 2019

I start getting this in parcel v1.11.0 if I import p-memoize.

import pMemoize from 'p-memoize'
馃毃  node_modules/map-age-cleaner/dist/index.js: unknown Statement of type "ForOfStatement"
    at Emitter.Ep.explodeStatement (node_modules/regenerator-transform/lib/emit.js:587:13)
    at node_modules/regenerator-transform/lib/emit.js:323:12
    at Array.forEach (<anonymous>)
    at Emitter.Ep.explodeStatement (node_modules/regenerator-transform/lib/emit.js:322:22)
    at Emitter.<anonymous> (node_modules/regenerator-transform/lib/emit.js:542:14)
    at LeapManager.LMp.withEntry (node_modules/regenerator-transform/lib/leap.js:143:14)
    at Emitter.Ep.explodeStatement (node_modules/regenerator-transform/lib/emit.js:541:24)
    at node_modules/regenerator-transform/lib/emit.js:323:12
    at Array.forEach (<anonymous>)
    at Emitter.Ep.explodeStatement (node_modules/regenerator-transform/lib/emit.js:322:22)

@mischnic
Copy link
Member

mischnic commented Mar 3, 2019

Sounds like possibly an issue in Babel rather than parcel itself?

Well, Parcel doesn't transpile node_modules (neither with an option) and @babel/plugin-transform-regenerator can't handle for of.
In @raine's case and in an ideal world, https://www.npmjs.com/package/map-age-cleaner wouldn't use a for of loop.

@Offirmo
Copy link

Offirmo commented Mar 4, 2019

@mischnic parced DOES transpile node_modules, provided the modules have a .babelrc

See my comment above.

@JoshyB
Copy link

JoshyB commented Mar 20, 2019

Has anyone made any progress with this? I just started running into this last night and cannot figure out a solution. I am using Parcel-bundler as an express middleware and cannot get it to build at all.

node_modules/parcel-bundler/src/Bundler.js: unknown Statement of type "ForOfStatement"
    at Emitter.Ep.explodeStatement (node_modules/regenerator-transform/lib/emit.js:587:13)
    at node_modules/regenerator-transform/lib/emit.js:323:12
    at Array.forEach (<anonymous>)
    at Emitter.Ep.explodeStatement (node_modules/regenerator-transform/lib/emit.js:322:22)
    at Emitter.Ep.explodeStatement (node_modules/regenerator-transform/lib/emit.js:510:12)
    at node_modules/regenerator-transform/lib/emit.js:323:12
    at Array.forEach (<anonymous>)
    at Emitter.Ep.explodeStatement (node_modules/regenerator-transform/lib/emit.js:322:22)
    at Emitter.<anonymous> (node_modules/regenerator-transform/lib/emit.js:542:14)
    at LeapManager.LMp.withEntry (node_modules/regenerator-transform/lib/leap.js:143:14)
error Command failed with exit code 1.

@BobBuehler
Copy link
Author

Closing was not what I meant to click. I'm surprised I had permission to do that. Sorry.

@BobBuehler BobBuehler reopened this Mar 20, 2019
@Offirmo
Copy link

Offirmo commented Mar 20, 2019

@JoshyB did my solution above help? #1269 (comment)

@raine
Copy link

raine commented Mar 20, 2019

It had no effect for me.

@JoshyB
Copy link

JoshyB commented Mar 20, 2019

@Offirmo I gave your solution a shot but it still wouldn't build. Same error.

@yuhr
Copy link

yuhr commented May 28, 2019

Same here, no one has resolved the issuee?

@yuhr
Copy link

yuhr commented May 29, 2019

I was facing into this error only when I use ipfs module, but FWIW now I found a workaround: in package.json setting like

  "browserslist": [
    "last 2 Chrome versions"
  ],

solved the issue for me (idea from https://github.com/ipfs/js-ipfs/blob/master/examples/browser-parceljs/package.json).

@pyrossh
Copy link

pyrossh commented Jun 4, 2019

@yuhr Thanks ran into the same problem when using ipfs. Almost switched to webpack after seeing this https://github.com/orbitdb/example-orbitdb-todomvc-updated

@tehraven
Copy link

I was facing into this error only when I use ipfs module, but FWIW now I found a workaround: in package.json setting like

  "browserslist": [
    "last 2 Chrome versions"
  ],

solved the issue for me (idea from https://github.com/ipfs/js-ipfs/blob/master/examples/browser-parceljs/package.json).

This fixed my issue. Cheers.

@guillaumepotier
Copy link

@tehraven @yuhr may have fixed the issue, but the code you're shipping would not be supported by IE11. I'm still struggling with this problem, and I really need to support IE. Any help here?

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs.

@github-actions github-actions bot added the Stale Inactive issues label Sep 15, 2020
@cymen
Copy link

cymen commented Jun 21, 2022

Sorry for the pollution but if you end up here due to googling, it's likely due to browserslist removing "IE 11" from the defaults (4 hours ago as of now) and the short term fix is to add back IE 11 to your list of browsers as it is no longer included in defaults.

@dep
Copy link

dep commented Oct 27, 2022

Sorry for the pollution but if you end up here due to googling, it's likely due to browserslist removing "IE 11" from the defaults (4 hours ago as of now) and the short term fix is to add back IE 11 to your list of browsers as it is no longer included in defaults.

That didn't solve things for me. My problem persists:

ERROR in /Users/dpeck/invoca/Titan/node_modules/d3-array/src/number.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: /Users/dpeck/invoca/Titan/node_modules/d3-array/src/number.js: unknown Statement of type "ForOfStatement"

@ruanltbg
Copy link

@dep to solve my issue I removed the browserslist file/or from the package.config.js

@keya129
Copy link

keya129 commented Oct 26, 2023

Adding "babel-plugin-transform-es2015-for-of": "^6.23.0" in package.json and compiling it first in babel config 馃憤 plugins: [
'@babel/plugin-transform-for-of',
....
worked

@techiekarthick
Copy link

techiekarthick commented Apr 24, 2024

Updating your .browserlistrc file to include support for IE11

defaults IE 11

It worked fine for me,

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

No branches or pull requests