parcel: unknown Statement of type "ForOfStatement"

πŸ› 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

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 9
  • Comments: 22 (2 by maintainers)

Most upvoted comments

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

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.

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.

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

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

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"

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