[Bug] when `ThisExpression` marked as `Purish`, deadcode plugin will remove arrowy function plugin build result
See original GitHub issueBug Report
@babel/types @7.12.5:
This pr marked ThisExpression
as Purish
, it will cause babel-plugin-minify-dead-code-elimination
removes @babel/plugin-transform-arrow-functions
compiled result.
For example:
<div onClick={() => {
this.a = 1;
} }></div>
It will be transformed by @babel/plugin-transform-arrow-functions
:
var _this = this
<div onClick={function() {
_this.a = 1;
} }></div>
After this pr, it will be transformed as:
<div onClick={function() {
this.a = 1;
} }></div>
So, the this
will be undefined
.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:19
- Comments:7 (2 by maintainers)
Top Results From Across the Web
[Bug]: @babel/traverse v7.17.10 broken `this` scope with dead ...
Current and expected behavior. Enabling babel-plugin-minify-dead-code-elimination plugin destroys this scope for arrow functions inside classes.
Read more >How to remove arrow functions from webpack output
As I know the babel-loader outputs good code I suspect it might be a plugin, but I can't just disable them to test...
Read more >babel/plugin-transform-arrow-functions
Intro. Babel is a tool that helps you write code in the latest version of JavaScript. When your supported environments don't support certain...
Read more >Arrow function expressions - JavaScript - MDN Web Docs
An arrow function expression is a compact alternative to a traditional function expression, with some semantic differences and deliberate ...
Read more >prefer-arrow-callback - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Please revoke this version!!!
I’ll release once CI on
main
finishes