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] ability to declare a static block as pure #1523

Open
bigopon opened this issue Apr 26, 2024 · 0 comments
Open

[Feature request] ability to declare a static block as pure #1523

bigopon opened this issue Apr 26, 2024 · 0 comments

Comments

@bigopon
Copy link

bigopon commented Apr 26, 2024

Version

Current latest

Complete CLI command or minify() options used

N/A

terser input

class Abc {
  /*@__PURE__*/static { doThis() }
}

console.log('hi abc');

terser output or error

class Abc {
  static { doThis() }
}

console.log('hi abc');

Expected result

console.log('hi abc');

Visual:
image

Context

Sometimes there' some groups of classes that share a common setup on their prototypes, so it's more reasonable to use some mixins to apply those methods. Prior to static block, the application of those mixins would have been in separate statements after the classes. But regardless where it is, those calls would mark the class as sideeffectful.
I was hoping with static block enabled this would allow us to treat static block as something "internal" to a class and won't affect the sideeffect analysis of it.

class O1 {
  static {
    mixinA(O1)
    mixinB(O1)
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant