I propose the addition of annotations to specify which property access expressions are pure. These annotations will also be understood by Terser, but I want to discuss how they should look like, and this project's needs, instead of implementing them there and finding out they don't suit Rollup.
relevant twitter thread where this was brought up to my attention again and I reconsidered
Feature Use Case
- Library authors can annotate that their library's property accesses are all pure, or, at a granular level, that an individual property access is pure.
- Compilers like Babel may output this annotation as well, as they do with
/*#__PURE__*/ right now.
Feature Proposal
The addition of two annotations:
/*#__PUREGET__*/, which can be used at the start of a "property access chain", like this:
/*#__PUREGET__*/foo.bar.baz
And a /*#__PUREGETWITHIN__*/ annotation to be added just before a function or IIFE, like this:
/*#__PUREGETWITHIN__*/
function x() {
this.is.pure
}
/*#__PUREGETWITHIN__*/
;(function () {
this.is.also.pure
})()
Maybe it can also be possible to annotate a whole module or whole package (by way of a package.json field) but Terser does not read package.json fields, so Rollup would have to annotate what it gives to Terser by itself.
Hope this post finds you well, and thank you for making the internet a better place :)
I propose the addition of annotations to specify which property access expressions are pure. These annotations will also be understood by Terser, but I want to discuss how they should look like, and this project's needs, instead of implementing them there and finding out they don't suit Rollup.
relevant twitter thread where this was brought up to my attention again and I reconsidered
Feature Use Case
/*#__PURE__*/right now.Feature Proposal
The addition of two annotations:
/*#__PUREGET__*/, which can be used at the start of a "property access chain", like this:/*#__PUREGET__*/foo.bar.bazAnd a
/*#__PUREGETWITHIN__*/annotation to be added just before a function or IIFE, like this:Maybe it can also be possible to annotate a whole module or whole package (by way of a package.json field) but Terser does not read package.json fields, so Rollup would have to annotate what it gives to Terser by itself.
Hope this post finds you well, and thank you for making the internet a better place :)