Skip to content

transform-react-constant-elements => Acorn: SyntaxError: Unexpected token #5325

@slorber

Description

@slorber

Input Code

Here's the exact input code I'm using: gist

I've tried to reduce/isolate the problematic part but was unable to find it. It seems that removing code blocks can somehow randomly make the compilation step pass successfully, don't know why.

Note that removing the whole component StampleDescriptionMainMediaAndText does make the error disappear, but I'm unable to identify which part of it is problematic, and surprisingly, removing other code blocks might also work!

Expected Behavior

Enabling plugin transform-react-constant-elements (latest) should work.

Current Behavior

ERROR in ./src/components/stample/stampleDescription/stampleDescription.js
Module parse failed: /Users/sebastienlorber/Desktop/Stample-react/node_modules/react-hot-loader/index.js!/Users/sebastienlorber/Desktop/Stample-react/node_modules/babel-loader/lib/index.js!/Users/sebastienlorber/Desktop/Stample-react/src/components/stample/stampleDescription/stampleDescription.js Unexpected token (348:85)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (348:85)
    at Parser.pp$4.raise (/Users/sebastienlorber/Desktop/Stample-react/node_modules/acorn/dist/acorn.js:2221:15)
    at Parser.pp.unexpected (/Users/sebastienlorber/Desktop/Stample-react/node_modules/acorn/dist/acorn.js:603:10)
    at Parser.pp$2.parseBindingAtom (/Users/sebastienlorber/Desktop/Stample-react/node_modules/acorn/dist/acorn.js:1417:12)
    at Parser.pp$2.parseMaybeDefault (/Users/sebastienlorber/Desktop/Stample-react/node_modules/acorn/dist/acorn.js:1455:25)
    at Parser.pp$2.parseBindingList (/Users/sebastienlorber/Desktop/Stample-react/node_modules/acorn/dist/acorn.js:1440:27)
    at Parser.pp$1.parseFunctionParams (/Users/sebastienlorber/Desktop/Stample-react/node_modules/acorn/dist/acorn.js:1072:24)
    at Parser.pp$1.parseFunction (/Users/sebastienlorber/Desktop/Stample-react/node_modules/acorn/dist/acorn.js:1064:10)
    at Parser.pp$3.parseExprAtom (/Users/sebastienlorber/Desktop/Stample-react/node_modules/acorn/dist/acorn.js:1810:19)
    at Parser.pp$3.parseExprSubscripts (/Users/sebastienlorber/Desktop/Stample-react/node_modules/acorn/dist/acorn.js:1715:21)
    at Parser.pp$3.parseMaybeUnary (/Users/sebastienlorber/Desktop/Stample-react/node_modules/acorn/dist/acorn.js:1692:19)
 @ ./src/components/stample/stampleMainContentReadOnly/stampleMainContentReadOnly.js 29:26-93

Your Environment

    "babel-core": "6.23.1",
    "babel-loader": "6.3.2",
    "babel-plugin-transform-react-constant-elements": "6.23.0",
    "babel-plugin-transform-react-inline-elements": "6.22.0",
    "babel-plugin-transform-react-pure-class-to-function": "1.0.1",
    "babel-plugin-transform-react-remove-prop-types": "0.3.2",
    "babel-preset-react-app": "2.1.0",
    "babel-preset-stage-0": "6.22.0",
{
  "presets": [
    "react-app",
    "stage-0"
  ],
  "env": {
    "production": {
      "plugins": [
        "transform-react-constant-elements",
        "transform-react-inline-elements",
        "transform-react-remove-prop-types",
        "transform-react-pure-class-to-function"
      ]
    }
  },
  "sourceMaps": false
}

Maybe related to #5315 ? cc @STRML @existentialism

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: reactoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions