Simply mangling features one to bring about an enthusiastic emphasize is a reasonable heuristic since regular JS password will not generally include identifiers like that. When you need to prevent mangling brands such __defineGetter__ you could consider using a more complex typical term such as [^_]_$ (i.e. need to cause a low-emphasize followed closely by a keen emphasize).
It is a different sort of setting in place of being a portion of the minify form because it’s a hazardous conversion process that doesn’t performs on haphazard JavaScript password. They merely works in the event your offered regular expression fits each of the fresh characteristics you want mangled and will not fits people of the qualities that you do not wanted mangled. Additionally, it merely work unless you significantly less than one factors resource a mangled property indirectly. Like, this means you can’t play with obj[prop] to help you site property where prop are a set that has had the new property term. Especially the next sentence structure constructs are definitely the merely of them qualified to receive possessions mangling:
While using this feature, understand that property brands are only continuously mangled in this one esbuild API call but not round the esbuild API phone calls. For each esbuild API name does a different assets mangling procedure therefore productivity data generated by a few various other API calls es, that may result in the resulting password to act wrongly.
#Cited services
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 want to possess esbuild so you can also mangle the latest material off string literals, you might clearly permit one to conclusion similar to this:
#Preventing renaming
If you want so you can prohibit specific qualities regarding mangling, you can put aside these with an extra mode. For example, that it uses the standard term ^__.*__$ so you can set aside most of the characteristics one start and you will stop which have a few underscores, such as __foo__ :
#Persisting renaming behavior
Complex entry to the house or property mangling function concerns storing the newest mapping out-of brand spanking new name so you’re able to mangled label into the a chronic cache. When let, the mangled possessions renamings is actually submitted throughout the cache when you look at the initially make. Next generates reuse the latest renamings kept in the latest cache and create even more renamings the freshly-added functions. It offers a number of effects:
This new cache serves xpress Kortingscode as a list of every services that were mangled. You can easily inspect it to find out if you can find people unexpected possessions renamings.
You could eliminate mangling to own individual characteristics from the means this new renamed worth to incorrect in lieu of to help you a set. This will be similar to the set-aside props mode but into an effective per-property foundation.
You might guarantee uniform renaming anywhere between generates (e.grams. a central-thread document and you can a web personnel, otherwise a library and you can a plug-in). In the place of this particular aspect, for every generate should do another renaming operation as well as the mangled property names almost certainly wouldn’t be uniform.
If we want customRenaming_ to-be rebranded in order to cR_ and in addition we don’t want disabledRenaming_ are rebranded anyway, we can solution the following mangle cache JSON in order to esbuild:
#Metafile
That one tells esbuild to make some metadata concerning create within the JSON style. The second analogy places the new metadata inside a file named meta.json :
These details can then end up being examined by the almost every other units. Including, package pal can be consume esbuild’s metadata style and you will stimulates a good treemap visualization of the segments on your own plan and how much room each of them occupies.