option-t icon indicating copy to clipboard operation
option-t copied to clipboard

Add `@__NO_SIDE_EFFECTS__` or `@__PURE__` annotations

Open tetsuharuohzeki opened this issue 1 year ago • 2 comments

Motivation

This helps to provide more information to a minifier for code reduction.

Implementation

  1. Add @__NO_SIDE_EFFECTS__ annotation for function definitions
  2. Add @__PURE__ annotation for callee site

Unresolved Questions

  1. We need to add them carefully.
    • If we supply them, a minifier trusts their information for code reduction. This means that this effort would lead a bug. It might be hard to reproduce or detect because an user would run minifier only in a production/release build.
  2. Testing.

See also

  • https://github.com/rollup/rollup/pull/5024
  • https://github.com/evanw/esbuild/issues/3149
  • https://github.com/swc-project/swc/issues/7525
  • https://github.com/mishoo/UglifyJS/issues/5234

tetsuharuohzeki avatar Jun 21 '23 12:06 tetsuharuohzeki