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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect order of initialization variables #18

Closed
sirenkovladd opened this issue Jun 5, 2024 · 8 comments
Closed

Incorrect order of initialization variables #18

sirenkovladd opened this issue Jun 5, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@sirenkovladd
Copy link
Contributor

  • Version (npm -v): 10.5.2
  • Node Version node -v: v20.13.1
  • OS (uname -a on Linux): Darwin arm64

Incorrect order of initialization variables

import { minify } from "@putout/minify";

const source = `
const c = (e) => e.w;
const w = (c) => c;
function f(e) {
  const { n } = e;
  e.w = n;
  const q = c(e);
  return q && w(q)
}
console.log(f({n:1}))`;

eval(source);
const result = minify(source);
console.log(result);
eval(result);
❯ node test.js
1
var c=e=>e.w,w=c=>c;function f(e){var{n}=e,q=c(e);e.w=n;return q&&w(q)}console.log(f({n:1}));
undefined
@coderaiser coderaiser added the bug Something isn't working label Jun 7, 2024
@coderaiser
Copy link
Contributor

Fixed in #17 🎉. Is it works for you?

@sirenkovladd
Copy link
Contributor Author

sirenkovladd commented Jun 7, 2024

No, same result

"dependencies": {
    "@putout/minify": "^3.16.0"
  }

@coderaiser
Copy link
Contributor

Try to re-install @putout/minify.

@sirenkovladd
Copy link
Contributor Author

❯ node index.js
1
var c=e=>e.w,w=c=>c;function f(e){const{n}=e,q=c(e);e.w=n;return q&&w(q)}console.log(f({n:1}));
undefined

❯ cat node_modules/@putout/minify/package.json | jq '.version'
"3.17.1"

@coderaiser
Copy link
Contributor

Added ability to disable mergeVariables.

@sirenkovladd
Copy link
Contributor Author

But it's a useful feature I'd like to use
the problem is that it may not work correctly in such scenarios

@coderaiser
Copy link
Contributor

Here is the code, you can play with it, if you get any ideas how to make this work, I’ll merge.

@coderaiser
Copy link
Contributor

Fixed in latest version of @putout/minify 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants