Browser APIs also avoid this naming meeting so this and hinders conflicts with browser APIs 30 septiembre, 2022 – Posted in: muzmatch-inceleme kayД±t olmak

Just mangling services you to definitely lead to an emphasize was a good heuristic as normal JS password does not usually have identifiers that way. If you would like avoid mangling labels particularly __defineGetter__ you can consider utilizing a more state-of-the-art typical term eg [^_]_$ (i.e. need to result in a non-underscore with an enthusiastic underscore).

This might be another means instead of being an element of muzmatch giriЕџ the minify mode because it is a dangerous sales that will not functions to your haphazard JavaScript code. They only functions in case your considering normal phrase fits every one of brand new services you want mangled and will not matches people of your services that you don’t need mangled. What’s more, it just performs if you do not under people factors source an effective mangled possessions indirectly. Particularly, it indicates you cannot fool around with obj[prop] to help you reference a property where prop try a set which has had this new possessions term. Especially the second syntax constructs will be simply of those entitled to property mangling:

While using this particular aspect, understand that possessions brands are only continuously mangled within one esbuild API phone call however around the esbuild API calls. For each and every esbuild API label do a separate property mangling procedure thus efficiency records made by a couple of more API calls parece, that’ll result in the resulting password to act wrongly.

#Cited qualities

By default, esbuild doesn’t modify the contents of string literals. This means you can avoid property mangling for an individual property by quoting it as a string. However, you must consistently use quotes or no quotes for a given property everywhere for this to work. For example, print(< foo_:>.foo_) will be mangled into print(< a:>.a) while print(< 'foo_':>[‘foo_’]) will not be mangled.

If you’d like to have esbuild to help you as well as mangle the fresh material from string literals, you can clearly allow that decisions like this:

#Stopping renaming

If you would like to ban certain services from mangling, you could set-aside these with an extra function. Particularly, which spends the standard expression ^__.*__$ in order to put aside all functions one begin and you will end having a couple underscores, such as for example __foo__ :

#Persisting renaming decisions

Complex usage of the home mangling function pertains to space brand new mapping regarding original identity to help you mangled label inside the a chronic cache. Whenever enabled, every mangled property renamings try recorded in the cache inside the initially generate. After that builds recycle the latest renamings stored in the cache and create a lot more renamings for the newly-additional properties. It has got a few outcomes:

The brand new cache serves as a summary of all the qualities that were mangled. You can search it to see if you will find any unforeseen possessions renamings.

You might disable mangling to possess private properties by the form the fresh rebranded worth so you’re able to not the case rather than so you can a string. This will be just like the set aside props form however, toward good per-property base.

You could potentially make certain consistent renaming between creates (age.grams. a central-bond file and you can a web site employee, or a library and you may a plugin). Without this particular aspect, for each and every create should do an independent renaming process in addition to mangled property brands most likely wouldn’t be uniform.

If we need customRenaming_ are rebranded so you’re able to cR_ so we don’t want disabledRenaming_ as renamed anyway, we are able to violation next mangle cache JSON in order to esbuild:

#Metafile

This 1 tells esbuild in order to make some metadata about the create within the JSON format. The second analogy sets the brand new metadata in a document entitled meta.json :

This data may then end up being examined from the other tools. Such as, bundle friend can eat esbuild’s metadata format and builds a beneficial treemap visualization of the segments on your plan and exactly how much space each one uses up.