question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] when `ThisExpression` marked as `Purish`, deadcode plugin will remove arrowy function plugin build result

See original GitHub issue

Bug 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:closed
  • Created 3 years ago
  • Reactions:19
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
xqincommented, Nov 4, 2020

Please revoke this version!!!

2reactions
nicolo-ribaudocommented, Nov 4, 2020

I’ll release once CI on main finishes

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found