babel / babel

🐠 Babel is a compiler for writing next generation JavaScript.
https://babel.dev
MIT License
43.24k stars 5.65k forks source link

Using transform-react-inline-elements in combination with Babili results in an undefined variable. #5424

Open phyllisstein opened 7 years ago

phyllisstein commented 7 years ago

Hey there! I've been working to add Babili to a project of mine that uses transform-react-inline-elements and I'm running into a little trouble. When used in combination, the two are emitting code in which they've mangled a variable name, but then missed a reference later in the source and dropped in the original.

I'm not totally sure if I can reproduce it in another repo, since I'm not totally sure what about my source is causing the issue, but I've created a Gist with the original and the transformed code here: https://gist.github.com/phyllisstein/8647c8c3089dfc9699e3a298b2f6d541. The assignment happens on original.jsx:56, and the reference is on original.jsx:70; the line that throws is minified.js:96, after the mangled assignment on minified.js:90.

For the time being I've just removed the transform-react-inline-elements plugin, but if you all have any insight into the actual problem I'd be eager to hear it! Thanks in advance for taking a look.

Configuration
{
  "presets": [
    "babili",
    "react",
    ["env", {
      "targets": {
        "browsers": "last 4 versions"
      },
      "modules": false,
      "loose": true,
      "useBuiltIns": true
    }]
  ],
  "plugins": [
    "add-module-exports",
    "lodash",
    "transform-decorators",
    "syntax-dynamic-import",
    "transform-async-generator-functions",
    "transform-async-to-generator",
    "transform-class-properties",
    "transform-exponentiation-operator",
    "transform-export-extensions",
    "transform-function-bind",
    "transform-object-rest-spread",
    "transform-react-inline-elements",
    "transform-react-remove-prop-types"
  ]
}
Environment
software version
Babel v7.0.0-alpha.1
node v7.7.1
npm 4.3.0
Operating System macOS 10.12.4 Beta
babel-bot commented 7 years ago

Hey @phyllisstein! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.