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

[Feature request] enclose global object static members to make code shorter #1456

Open
cuixiping opened this issue Oct 14, 2023 · 1 comment

Comments

@cuixiping
Copy link

Bug report or Feature request?

Currently enclose: 'Math:Math' is supported, but enclose: 'Math.floor:Math.floor' is not.
Is there a way to replace the Math.floor entirely?
Many builtin js object static memebers can be shorter via this method.
I know that it's not safe in some situations.

Version
latest

Complete CLI command or minify() options used

{
  enclose: 'Math.floor:Math.floor',
  mangle: {  },
  output: {
    beautify: true,
  },
  parse: {},
  rename: {},
}

terser input

  var q = Math.floor(1);
  var r = Math.floor(2);
  var s = Math.floor(3);
  console.log(q+r+s);

terser output or error

Unexpected token punc «.», expected punc «,»

Expected result

!function(n) {
    var o = n(1), a = n(2), c = n(3);
    console.log(o + a + c);
}(Math.floor);
@fabiosantoscode
Copy link
Collaborator

This makes a lot of sense!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants