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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
With no transforms enabled, top-level arrow functions get transformed (T7419) #4337
Comments
Actually, I can reproduce the problem I'm seeing in a less contrived example too, using Run this in the REPL in the babel dir:
You get:
Note that the
This happens because the first plugins pass has no plugins to operate on so it only uses the INTERNAL_PLUGINS list. |
I'm running into this problem as well and it breaks my scope in es6-classes. I'm running a plugin that adds class-properties before they get transformed. Simple test, copied from #4230: .babelrc: {
plugins: [
'babel-plugin-syntax-class-properties'
]
} Input: class Test {
onPress = () => {
console.log(this.id)
}
} Output: var _this = this;
class Test {
onPress = () => {
console.log(_this.id);
};
} |
…ue`) See README.md for documentation. This feature is blocked on the following Babel PRs/issues: * babel/babel#4500 * babel/babylon#121 * babel/babel#4337 * babel/babel#4230 (partially)
Was closed by #4502 |
Neat, happy to have a workaround. I would argue that the current code is still wrong though since Babel shouldn't change your code at all if you have no transforms enabled, and it still does get rid of arrows in other contexts. |
Yeah I guess it's because that shadow-function transform is always on as an internal transform - should look into that. |
…ue`) See README.md for documentation. This feature is blocked on the following Babel PRs/issues: * babel/babel#4500 * babel/babylon#121 * babel/babel#4337 * babel/babel#4230 (partially)
…ue`) See README.md for documentation. This feature is blocked on the following Babel PRs/issues: * babel/babel#4500 * babel/babylon#121 * babel/babel#4337 * babel/babel#4230 (partially)
…ue`) See README.md for documentation. This feature is blocked on the following Babel PRs/issues: * babel/babel#4500 * babel/babylon#121 * babel/babel#4337 * babel/babel#4230 (partially)
Bug information
Options
Input code
Description
If you have no transforms enabled, top-level arrow functions still get transformed by the shadow-functions internal plugin. For the input code above, you get this output:
Note that the top-level arrow function
x
is transformed (bad) buty
is not (good).Repros in the repl at http://babeljs.io/repl/#?evaluate=false&lineWrap=false&presets=stage-3&experimental=true&loose=false&spec=false&playground=false&code=var%20x%20%3D%20()%20%3D%3E%20this%3B%0A(function()%20%7B%20var%20x%20%3D%20()%20%3D%3E%20this%3B%20%7D)%3B.
The text was updated successfully, but these errors were encountered: