Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: invalid code optimization with @babel/transform 7.17.10 #14534

Closed
1 task
mfukala opened this issue May 6, 2022 · 2 comments
Closed
1 task

[Bug]: invalid code optimization with @babel/transform 7.17.10 #14534

mfukala opened this issue May 6, 2022 · 2 comments
Labels
i: needs triage outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@mfukala
Copy link

mfukala commented May 6, 2022

馃捇

  • Would you like to work on a fix?

How are you using Babel?

Programmatic API (babel.transform, babel.parse)

Input code

`class Test {

foo() {

  var self = this;

  var checkWithUserPromise = new Promise(function (resolve) {

    self.userInputComplete = resolve;

    console.log('--------------');

    document.getElementById('Dialog').open();

  });

  return checkWithUserPromise;

}

}`

Configuration file name

No response

Configuration

No response

Current and expected behavior

Transpiled code used to be

checkWithUserForItemOrgAssociation(){var a=this,b=new Promise(function(b){a.userInputComplete=b,console.log("--------------"),document.getElementById("Dialog").open()});return b}

since @babel/transform 7.17.10 it is transpiled to

checkWithUserForItemOrgAssociation(){var a=new Promise(function(a){this.userInputComplete=a,console.log("--------------"),document.getElementById("Dialog").open()});return a}

which is obviously wrong.

Environment

node v16.13.0
npm 8.1.0
@babel/core 7.17.10
babel-preset-minify: 0.5.1

Possible solution

I had to use npm-shrinkwrap.json to enforce older @babel/transform sub dependency of @babel/core

Additional context

No response

@babel-bot
Copy link
Collaborator

Hey @mfukala! 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.

@JLHwung
Copy link
Contributor

JLHwung commented May 6, 2022

Duplicate of babel/minify#1028.

@JLHwung JLHwung closed this as completed May 6, 2022
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Aug 6, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: needs triage outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

No branches or pull requests

3 participants