Only mangling functions one cause an emphasize is a reasonable heuristic since the normal JS password cannot normally incorporate identifiers like that. If you wish to prevent mangling brands such __defineGetter__ you could contemplate using a very advanced regular term such [^_]_$ (i.e. need to cause a low-underscore with an emphasize).
This is yet another mode rather than getting area of the minify form since it is a dangerous transformation that will not really works to the arbitrary JavaScript password. They merely performs if the offered normal phrase matches all of the services you want mangled and will not meets any of your own characteristics that you don’t want mangled. In addition, it merely really works if you don’t below any factors reference an effective mangled assets indirectly. For example, it means you can not use obj[prop] so you’re able to reference property where prop is a sequence that has had this new possessions term. Specifically next sentence structure constructs could be the only ones eligible for possessions mangling:
While using the this particular feature, remember that possessions names are only continuously mangled within this just one esbuild API phone call although not around the esbuild API phone calls. For each esbuild API phone call does a separate possessions mangling process so yields records from a couple of other API phone calls es, which will result in the ensuing code to do something incorrectly.
#Quoted attributes
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 would like getting esbuild so you can together with mangle this new contents regarding sequence literals, you could potentially explicitly allow one decisions such as this:
#Preventing renaming
If you’d like so you can exclude specific features regarding mangling, you could reserve all of them with an extra form. Such as for example, so it uses the conventional term ^__.*__$ so you can set aside the functions you to definitely initiate and you may stop which have a couple underscores, such as __foo__ :
#Persisting renaming conclusion
Advanced entry to the property mangling feature concerns storing the fresh mapping regarding brand spanking new title to mangled title when you look at the a persistent cache. When permitted, every mangled possessions renamings is actually recorded on the cache in 1st generate. After that produces recycle the fresh new renamings stored in this new cache and add even more renamings for all the recently-added qualities. It offers a number of outcomes:
This new cache functions as a list of all of the features which were mangled. You are able to check always they to see if you will find any unanticipated assets renamings.
You could potentially disable mangling for individual characteristics because of the function brand new renamed worthy of so you can not true rather than to a string. This can be just as the put aside props setting however, on the a great per-property foundation.
You could potentially be sure consistent renaming anywhere between builds (elizabeth.g. a central-thread document and you can a web staff member, or a library and you can a plug-in). Versus this particular feature, for each and every create should do a separate renaming process and the mangled assets brands more than likely wouldn’t be consistent.
When we want customRenaming_ to be renamed so you can cR_ and now we don’t want disabledRenaming_ as renamed anyway, we are able to violation the next mangle cache JSON in order to esbuild:
#Metafile
That one says to esbuild to help make particular metadata concerning the make in JSON structure. Another analogy throws this new metadata in the a file titled meta.json :
This info are able to end up being examined from the other gadgets. Eg, plan friend normally consume esbuild’s metadata structure and you may builds an effective treemap visualization of the segments on your own bundle and how much room https://datingmentor.org/cs/zelena-seznamka every one occupies.
Αφήστε μια απάντηση