Parcel: unknown Statement of type "ForOfStatement"

Created on 30 Apr 2018  路  17Comments  路  Source: parcel-bundler/parcel

馃悰 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 https://github.com/facebook/regenerator/issues/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 |

Bug Stale babel

Most helpful comment

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).

All 17 comments

Also getting this.. no other solutions posted anywhere work

[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.

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

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)

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.

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

See my comment above.

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.

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

@JoshyB did my solution above help? https://github.com/parcel-bundler/parcel/issues/1269#issuecomment-427158354

It had no effect for me.

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

Same here, no one has resolved the issuee?

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).

@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

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.

@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?

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.

Was this page helpful?
0 / 5 - 0 ratings