Browser APIs as well as don’t use that it naming conference and this as well as prevents issues which have browser APIs

Browser APIs as well as don’t use that it naming conference and this as well as prevents issues which have browser APIs

Browser APIs as well as don’t use that it naming conference and this as well as prevents issues which have browser APIs

Merely mangling services one end up in an underscore is actually a reasonable heuristic given that regular JS password does not generally speaking include identifiers in that way. Should you want to avoid mangling labels such as __defineGetter__ you could potentially contemplate using an even more cutting-edge typical phrase such as for instance [^_]_$ (we.elizabeth. must end up in a non-underscore followed by a keen emphasize).

That is a different mode as opposed to being a portion of the minify function since it is an unsafe sales that will not works into the random JavaScript code. It merely functions in the event the offered typical phrase suits each of the brand new services that you want mangled and does not matches people of features that you do not wanted mangled. Additionally simply functions unless you less than people products resource a great mangled possessions indirectly. Particularly, this means you can’t fool around with obj[prop] to help you source property where prop are a string that has had the newest property title. Particularly the following sentence structure constructs will be only of them entitled to property mangling:

While using the this particular aspect, remember that assets labels are just consistently mangled contained in this just one esbuild API call not round the esbuild API phone calls. Each esbuild API name does another possessions mangling operation very productivity records created by a few other API phone calls es, which could cause the resulting password to behave improperly.

#Quoted features

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 for esbuild to help you along with mangle the fresh new information off string literals, you might explicitly enable you to definitely behavior along these lines:

#Blocking renaming

If you’d like so you’re able to ban certain functions of mangling, you could set-aside these with a supplementary mode. For example, which spends the regular phrase ^__.*__$ in order to put aside most of the properties that begin and you may avoid that have a few underscores, such as for example __foo__ :

#Persisting renaming behavior

Advanced access to the home mangling element relates to storage the brand new mapping of modern identity so you’re able to mangled label inside a persistent cache. When permitted, the mangled property renamings was recorded about cache inside 1st build. Next stimulates recycle the latest renamings stored in the fresh new cache and put extra renamings for your recently-extra attributes. It’s a number of outcomes:

The brand new cache serves as a list of all the services that were mangled. It is possible to test it to see if you will find any unforeseen assets renamings.

You might eliminate mangling getting individual characteristics of the means this new renamed really worth in order to not the case in the place of so you can a string. This is certainly just Amerikan MГјslГјman tanД±Еџma siteleri as the set-aside props means however, into good per-assets foundation.

You could potentially guarantee uniform renaming ranging from produces (age.g. a central-thread document and you will a web site employee, or a collection and you may a plug-in). In place of this particular aspect, for every single create would do another renaming procedure and mangled possessions labels probably wouldn’t be uniform.

Whenever we want customRenaming_ are rebranded so you’re able to cR_ and we also do not want disabledRenaming_ to-be renamed after all, we can admission the next mangle cache JSON to esbuild:

#Metafile

This 1 tells esbuild to help make particular metadata about the create inside the JSON format. Next analogy puts the fresh metadata during the a document called meta.json :

These records are able to feel reviewed by most other tools. Such as, bundle buddy is also eat esbuild’s metadata style and you can produces a treemap visualization of your own modules on your bundle and how far area each one occupies.

Leave a Reply

Your email address will not be published. Required fields are makes.