You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello! I would like to propose enabling local objects to have their properties mangled based on the final mangle name.
The idea is that certain object properties can be safely renamed while others should remain intact. In cases where the property names are supplied by user input—making them potentially unknown—it’s important to preserve those names.
Conversely, when the object is used internally only (for example, accessed directly as sizes[x] rather than dynamically via an expression like sizes[x][y]), the property names are fair game for mangling.
Additionally, properties that are not used (such as a property named ununsed) could be considered for removal.
Here, A4 and Letter are provided by the user via the paper parameter; hence, these names should not be mangled because the received value is potentially unknown. However, since sizes is not exported or used abstractly, its internal properties can be safely mangled.
The ideal transformation, according to the proposal, might be:
letsizes={A4: {i: '21cm',t: '29.7cm'},Letter: {i: '8.5in',t: '11in'}};exportfunctionprintSize(e){let{ i, t }=sizes[e];console.log({width: i,height: i});}
This approach enhances optimization by renaming internal property names where possible without impacting properties that are exposed or provided by external sources.
Uh oh!
There was an error while loading. Please reload this page.
Describe the feature
Hello! I would like to propose enabling local objects to have their properties mangled based on the final mangle name.
The idea is that certain object properties can be safely renamed while others should remain intact. In cases where the property names are supplied by user input—making them potentially
unknown
—it’s important to preserve those names.Conversely, when the object is used internally only (for example, accessed directly as
sizes[x]
rather than dynamically via an expression likesizes[x][y]
), the property names are fair game for mangling.Additionally, properties that are not used (such as a property named
ununsed
) could be considered for removal.Babel plugin or link to the feature description
No response
Additional context
Consider the following example:
Here,
A4
andLetter
are provided by the user via thepaper
parameter; hence, these names should not be mangled because the received value is potentiallyunknown
. However, sincesizes
is not exported or used abstractly, its internal properties can be safely mangled.The current output could look like this:
The ideal transformation, according to the proposal, might be:
This approach enhances optimization by renaming internal property names where possible without impacting properties that are exposed or provided by external sources.
The text was updated successfully, but these errors were encountered: