ampproject / amphtml

The AMP web component framework.
https://amp.dev
Apache License 2.0
14.89k stars 3.89k forks source link

Lint enum usage so that they are fully DCE-able #36754

Open jridgewell opened 3 years ago

jridgewell commented 3 years ago

Description

Context: https://github.com/ampproject/amphtml/issues/36453

Currently, enum objects are left in the output binaries because we're using them as dynamic object values (eg, loop keys or performing dynamic Enum[key] lookups). In an ideal codebase, enums would be used via Enum.keyName lookups only, which means that the value associated with that key can be inlined directly in to output code.

We suspect this is one of the last issue with that causes Terser's outputs to be larger than Closure compiler.

samouri commented 2 years ago

Can this be closed now that all enums have been converted to static and the lint rule has been made?

jridgewell commented 2 years ago

We still need to convert extensions, and make the lint opt-out instead of opt-in.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.