Web browser APIs plus don’t use it naming convention so this also hinders issues which have web browser APIs

Web browser APIs plus don’t use it naming convention so this also hinders issues which have web browser APIs

Just mangling qualities you to end up in an underscore was a fair heuristic since the regular JS password doesn’t generally consist of identifiers this way. Should you want to stop mangling names eg __defineGetter__ you might consider using an even more cutting-edge regular expression instance [^_]_$ (i.elizabeth. need end up in a low-emphasize followed closely by an emphasize).

That is a special form in the place of are a portion of the minify form since it is a harmful conversion that does not works towards haphazard JavaScript password. They simply work in the event your offered typical term suits every one of the brand new properties that you like mangled and won’t suits people of the characteristics you do not wanted mangled. Moreover it just functions if you do not lower than people points resource an excellent mangled assets ultimately. Particularly, this means you simply cannot have fun with obj[prop] so you can source a house where prop is a series with the property identity. Especially next sentence structure constructs may be the simply ones entitled to possessions mangling:

While using the this particular feature, keep in mind that property names are only consistently mangled within this an individual esbuild API name yet not across esbuild API phone calls. For every esbuild API name really does xpress PЕ™ihlГЎsit se another possessions mangling process so productivity records generated by two other API phone calls es, that will cause the resulting code to do something improperly.

#Cited 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’d like having esbuild in order to and additionally mangle the fresh new contents regarding string literals, you might explicitly enable you to conclusion like this:

#Stopping renaming

If you need in order to prohibit particular attributes regarding mangling, you can set aside all of them with an additional form. Like, that it uses the regular term ^__.*__$ so you’re able to set-aside all the functions one to begin and you can avoid which have a few underscores, including __foo__ :

#Persisting renaming decisions

Cutting-edge usage of the house mangling element comes to storage space this new mapping regarding brand new label so you can mangled term from inside the a persistent cache. When permitted, most of the mangled assets renamings are recorded about cache during the initially create. Then stimulates recycle the renamings kept in the new cache and create a lot more renamings for recently-added attributes. It has several outcomes:

The cache serves as a listing of the properties that have been mangled. You’ll be able to check always it to find out if discover one unanticipated property renamings.

You could disable mangling to possess individual functions by the function the renamed worthy of to help you untrue in the place of to help you a set. That is just as the reserve props means but to the an effective per-possessions basis.

You could be certain that consistent renaming anywhere between creates (age.g. a main-bond document and you can a web staff, or a collection and you can a plugin). Rather than this particular aspect, each build would do an independent renaming process therefore the mangled assets names probably would not be consistent.

Whenever we want customRenaming_ are rebranded to help you cR_ therefore we do not want disabledRenaming_ to be renamed whatsoever, we could violation the next mangle cache JSON so you can esbuild:


This tells esbuild in order to make specific metadata regarding build during the JSON style. The next example leaves the metadata from inside the a document called meta.json :

This information are able to feel reviewed of the other units. Including, bundle buddy is consume esbuild’s metadata structure and you may creates a good treemap visualization of your modules on your own bundle and just how much area each one of these occupies.