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
Extending the pure annotation for functions #1130
Comments
I've had the plan to do this for a while, but it has to be done carefully so as to not confuse other software using this. These annotations have caused a bunch of problems WRT parentheses and other inconsistencies. IMO it wouldn't be humans actually writing this, but instead compilers. For this to be implemented safely, it needs to precede a function statement or variable assignment with a function as its sole value. Any other case would get quite hairy. |
How would it confuse other software? For bundlers like Rollup that support pure annotations, it's a no-op when you use a pure annotation on anything but a
Seems unnecessary to me. Let's keep the scope as small as possible so other tools can implement it easier. See mishoo/UglifyJS#5234 (comment) for more details. |
Google Closure has a better solution for this problem than a pure annotation for functions. They do have a
|
Note: This is being called |
Note for anyone wondering (like me): They talk mostly about |
The feature in Rollup includes both |
Currently, the
/* @__PURE__ */
annotation must be used individually on every returned value for a given call.Could it be possible to allow using the annotation on a function, so all its executions and returned values are considered pure? Like in the following.
I started the same discussion on the esbuild repository, which leaded me here since @evanw prefers not to do any takes unless they are a standarised feature.
Also, there's the same discussion in the UglifyJS repository.
The text was updated successfully, but these errors were encountered: