Zaznacz stronę

Internet browser APIs plus avoid using so it naming conference and this along with hinders problems which have web browser APIs

Simply mangling qualities one lead to a keen emphasize was a fair heuristic while the regular JS code cannot normally consist of identifiers that way. Should you want to stop mangling names for example __defineGetter__ you can contemplate using a more complex normal term like [^_]_$ (i.elizabeth. need to cause a low-emphasize with an underscore).

This can be a special setting instead of becoming the main minify form because it’s a harmful transformation that will not really works towards haphazard JavaScript password. It only performs if your considering regular phrase fits all of the services that you want mangled and does not meets people of functions that you do not wanted mangled. In addition just performs unless you significantly less than one items resource a good mangled possessions indirectly. Like, it indicates you can not have fun with obj[prop] so you can source property in which prop is a sequence containing the brand new assets label. Especially next syntax constructs may be the simply of these entitled to assets mangling:

When using this feature, just remember that , property names are merely consistently mangled within one esbuild API call yet not across the esbuild API calls. Per esbuild API call really does an independent assets mangling process therefore yields data made by several various other API calls parece, that could cause the resulting password to do something wrongly.

#Quoted functions

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 Madison dating service print(< 'foo_':>[’foo_’]) will not be mangled.

If you would like to possess esbuild to help you including mangle the newest contents of string literals, you could clearly enable you to choices similar to this:

#Blocking renaming

If you want to help you prohibit specific characteristics away from mangling, you might set-aside them with a supplementary form. Instance, that it spends the conventional term ^__.*__$ in order to set aside the properties you to initiate and you will avoid having a couple underscores, such __foo__ :

#Persisting renaming choices

State-of-the-art the means to access the property mangling element relates to storage space the newest mapping out-of brand-new label so you’re able to mangled title during the a persistent cache. Whenever enabled, all mangled assets renamings try filed regarding cache from inside the first create. Next yields recycle new renamings stored in this new cache and you will create additional renamings for any freshly-added properties. It has a few outcomes:

The cache functions as a summary of all the functions which were mangled. It is possible to scan they to see if there are people unforeseen possessions renamings.

You could potentially disable mangling to own private characteristics by the function the fresh new rebranded well worth to incorrect unlike so you’re able to a sequence. That is just like the put aside props function but to your a beneficial per-assets foundation.

You could make certain uniform renaming anywhere between stimulates (age.g. a main-bond file and a web personnel, or a collection and you may a plug-in). Instead this particular aspect, each build should do a separate renaming procedure and the mangled property brands almost certainly would not be consistent.

Whenever we wanted customRenaming_ as rebranded so you’re able to cR_ and we don’t want disabledRenaming_ to-be renamed at all, we can violation the second mangle cache JSON to esbuild:

#Metafile

This one informs esbuild to produce certain metadata regarding generate inside the JSON style. The second analogy puts the fresh new metadata during the a file titled meta.json :

These records can then getting analyzed of the other tools. Such as, package friend can be eat esbuild’s metadata structure and stimulates a beneficial treemap visualization of one’s segments on the bundle as well as how far area each of them uses up.