Only mangling features you to definitely result in an emphasize is a fair heuristic because the regular JS password cannot generally speaking have identifiers in that way. If you would like prevent mangling names instance __defineGetter__ you could consider using a far more complex regular expression including [^_]_$ (i.elizabeth. need certainly to result in a non-emphasize accompanied by an enthusiastic underscore).
While using this particular feature, remember that property labels are merely continuously mangled inside one esbuild API name although not across the esbuild API phone calls. For each and every esbuild API call does a different property mangling operation therefore efficiency data generated by a couple other API calls es, that will result in the resulting password to do something incorrectly.
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 like getting esbuild so you’re able to also mangle the fresh new contents away from sequence literals, you could explicitly enable you to conclusion similar to this:
If you would like so you can prohibit certain functions out-of mangling, you could potentially set-aside all of them with an additional means. For example, this uses the standard term ^__.*__$ to set-aside all functions you to definitely begin and you will avoid with several underscores, instance __foo__ :
#Persisting renaming behavior
Complex access to the home mangling function relates to storage space the new mapping away from brand new term so you’re able to mangled title inside a long-term cache. When permitted, all mangled property renamings try registered about cache in very first make. Subsequent produces recycle the latest renamings kept in the cache and you can create additional renamings when it comes to recently-additional functions. This has a number of effects:
Brand new cache functions as a listing of every properties which were mangled. You can easily test it to see if there are one unforeseen possessions renamings.
You might eliminate mangling to possess private features from the mode the fresh new rebranded worth to untrue in lieu of to help you a sequence. This might be similar to the set-aside props means but toward a good http://datingmentor.org/escort/yonkers per-possessions base.
You can be certain that uniform renaming ranging from produces (elizabeth.grams. a main-bond file and an internet staff member, or a collection and a plugin). Instead this feature, per generate would do an independent renaming operation in addition to mangled property labels probably would not be uniform.
If we wanted customRenaming_ to-be rebranded to help you cR_ so we don’t want disabledRenaming_ becoming renamed at all, we are able to solution next mangle cache JSON to help you esbuild:
This option tells esbuild to make certain metadata concerning the create during the JSON format. The second analogy throws the brand new metadata when you look at the a file named meta.json :
This data are able to become reviewed from the most other tools. Like, package buddy is consume esbuild’s metadata format and you will generates a good treemap visualization of the segments in your bundle as well as how far space each one takes up.