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
Babel rely on value returned by super() but this is not reliable with Edge #9020
Comments
Hey @JSteunou! We really appreciate you taking the time to report an issue. The collaborators If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack |
I forgot to say but if the arrow function does not contains rest/spread or default argument value the transpiled code is from export class App extends React.Component {
state = {
fruit: 'banana'
}
handleClick = (event) => {
this.setState({fruit: 'apple'})
}
render() {
const {fruit} = this.state
return (
<h1 onClick={this.handleClick}>I'm a {fruit}</h1>
)
}
} to class App extends react__WEBPACK_IMPORTED_MODULE_0___default.a.Component {
constructor() {
super(...arguments);
this.state = {
fruit: 'banana'
};
this.handleClick = event => {
this.setState({
fruit: 'apple'
});
};
}
render() {
const fruit = this.state.fruit;
return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("h1", {
onClick: this.handleClick,
__source: {
fileName: _jsxFileName,
lineNumber: 16
},
__self: this
}, "I'm a ", fruit);
}
} hence the emphasis on the possible solution to not transpile rest/spread and default argument for Edge |
I tracked down when & why this regression and I found that this fix #8926 introduced it Rolling back to @babel/preset-env@7.1.0 transpile to class App extends react__WEBPACK_IMPORTED_MODULE_0___default.a.Component {
constructor(...args) {
super(...args);
this.state = {
fruit: 'banana'
};
this.handleClick = (event, ...rest) => {
this.setState({
fruit: 'apple'
});
};
}
render() {
const fruit = this.state.fruit;
return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("h1", {
onClick: this.handleClick,
__source: {
fileName: _jsxFileName,
lineNumber: 16
},
__self: this
}, "I'm a ", fruit);
}
} I think the PR #8926 is to aggressive. If I understand well, the need was for object spread with default param, not classical rest/pread nor simple default param. Update: link correct PR |
We just ran into this too, and reverting back to |
no problem, I just hope someone like @nicolo-ribaudo @loganfsmyth or @hzoo will take a look at it, because I think it can be a serious bug, and a very difficult one to analyse to babel users |
We should just output |
I'm not sure about this, because there was already bugfix around it, and I think the real issue is around this PR #8926 and maybe babel-preset should have a more fine grain around this with Edge. |
Oops now I see the connection 👍 |
@JSteunou I just created #9060 which (hopefully) fixes this. This is my first contribution to babel, so I might be unaware of why my solution doesn't work or something, but am hoping it's alright :) About what you said earlier regarding |
I'm sorry I cannot get my hand on this old issue :( I was counting on @loganfsmyth memory Maybe by searching on some file history or tests |
Bug Report
Current Behavior
When using some transpiled code, babel rely on
_this
from_this = super()
but this bug on Edge is still present with latest version chakra-core/ChakraCore#4663Input Code
become with preset set on
targets: {esmodules: true}
Expected behavior/code
The initial behavior is that
_this
should not beundefined
but I think that is in the hands of ChakraCore team. Is this something babel can do? There is already this issue which is kinda similar #8019 but also this one which emphasis on the fact that_this
should user the value resturned bysuper()
#2279Environment
Possible Solution
Another possible solution would be to not transpile on rest/spread & default argument function when
targets: {esmodules: true}
ortargets: {browsers: 'Edge >= 14'}
because its seems they support itThe text was updated successfully, but these errors were encountered: