Just mangling characteristics you to end in an enthusiastic emphasize are a reasonable heuristic because typical JS code does not generally speaking have identifiers this way. If you would like end mangling names instance __defineGetter__ you might consider utilizing an even more advanced typical term including [^_]_$ (we.elizabeth. have to trigger a low-underscore accompanied by an emphasize).
This can be another means rather than are a portion of the minify setting because it’s a hazardous conversion that doesn’t really works to the haphazard JavaScript code. It just performs if the offered typical phrase matches each of the newest features that you like mangled and will not meets one of your own characteristics you don’t require mangled. It also just work unless you around people things site a beneficial mangled possessions indirectly. Like, this means you simply can’t have fun with obj[prop] to reference a house where prop was a string which has the new possessions title. Especially the second sentence structure constructs may be the just of these eligible for possessions mangling:
While using this particular aspect, understand that possessions names are merely constantly mangled inside a single esbuild API phone call yet not across esbuild API phone calls. For each and every esbuild API phone call do a different property mangling operation so productivity data files generated by two some other API phone calls parece, that may result in the ensuing code to act incorrectly.
#Cited 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_) will be mangled into print(.a) while print([‘foo_’]) will not be mangled.
If you prefer having esbuild to help you and mangle this new content away from sequence literals, you might clearly permit you to choices similar to this:
#Blocking renaming
If you’d like to help you ban certain qualities of mangling, you could put aside all of them with an additional means. Such as, this uses the conventional phrase ^__.*__$ in order to put aside all the attributes you to begin and you will avoid that have one or two underscores, such as __foo__ :
#Persisting renaming decisions
Complex use of the house mangling function relates to storing the newest mapping away from original term so you’re able to mangled identity into the a persistent cache. When let, most of the mangled assets renamings try filed from the cache inside the initial build. Subsequent builds recycle the fresh new renamings kept in the latest cache and incorporate a lot more renamings when it comes to recently-added qualities. It’s a number of consequences:
The fresh cache serves as a list of the characteristics which were mangled. Possible always check they to find out if discover one unexpected possessions renamings.
You might disable mangling to own private functions of the setting new renamed really worth to false rather than so you’re able to a string. This might be much like the put aside props form however, on a great per-possessions foundation.
You can verify consistent renaming between yields (e.grams. a main-bond document and a web staff, or a library and you may a plug-in). In place of this particular feature, each create should do a separate renaming operation additionally the mangled possessions labels likely would not be consistent.
If we require customRenaming_ become rebranded to cR_ and now we don’t want disabledRenaming_ to be renamed whatsoever, we could citation the following mangle cache JSON in order to esbuild:
#Metafile
This 1 says to esbuild to help make some metadata concerning the create for the JSON format. Another analogy puts the metadata from inside the a document entitled meta.json :
This data can then end up being examined by other systems. Instance, plan pal normally eat esbuild’s metadata structure and you will creates a great treemap visualization of the modules on your own package and how far room each one of these takes up.