Only mangling services one to lead to an emphasize was a good heuristic as the typical JS code cannot usually contain identifiers by doing this. If you wish to stop mangling brands such as for example __defineGetter__ you can contemplate using a very complex typical phrase eg [^_]_$ (i.e. must end in a low-emphasize followed closely by an emphasize).
This is certainly an alternative function rather than getting an element of the minify means since it is an unsafe conversion process that will not works on the arbitrary JavaScript code. It simply really works if for example the offered normal term suits every one of the services you want mangled and won’t match people of properties you never need mangled. What’s more, it only really works if you do not lower than any situations resource good mangled assets indirectly. Such as for example, it means you simply can’t play with obj[prop] to resource a home in which prop is a string that has had this new assets term. Specifically the second syntax constructs are the just ones qualified to receive property mangling:
While using this feature, understand that property brands are just constantly mangled contained in this a single esbuild API call yet not across esbuild API phone calls. For every esbuild API phone call really does an independent property mangling process thus efficiency documents from two various other API calls es, which will cause the ensuing password to do something wrongly.
#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 need to possess esbuild so you’re able to and additionally mangle the fresh new contents from sequence literals, you might explicitly allow you to definitely decisions in this way:
#Blocking renaming
If you’d like to help you prohibit certain functions off mangling, you might put aside these with an extra setting. Like, this spends the conventional term ^__.*__$ so you can reserve all the qualities that initiate and end that have a couple underscores, instance __foo__ :
#Persisting renaming conclusion
Advanced use of the house or property mangling ability comes to space the fresh new mapping out-of original identity so you can mangled label into the a long-term cache. Whenever let, every mangled assets renamings try registered in the cache inside 1st generate. Further stimulates recycle the brand new renamings kept in the brand new cache and you may create most renamings the newly-extra characteristics. It offers a number of outcomes:
This new cache functions as a listing of the attributes which were mangled Omaha dating. You can check it to see if you can find one unforeseen assets renamings.
You can eliminate mangling getting personal properties because of the form the fresh renamed worthy of so you can untrue unlike to help you a sequence. That is just like the put aside props means however, on an excellent per-property base.
You could be sure consistent renaming anywhere between stimulates (elizabeth.grams. a main-bond document and an internet personnel, or a collection and you can a plugin). As opposed to this particular feature, each create should do a separate renaming procedure plus the mangled assets names most likely would not be uniform.
If we need customRenaming_ as renamed so you can cR_ therefore we do not want disabledRenaming_ getting renamed anyway, we can citation the next mangle cache JSON in order to esbuild:
#Metafile
This package tells esbuild to help make specific metadata regarding build within the JSON structure. Next example leaves the newest metadata inside a file named meta.json :
This info can then become examined from the almost every other units. Particularly, bundle friend normally consume esbuild’s metadata style and builds good treemap visualization of the segments in your plan and just how much space each one of these takes up.