Browser APIs plus don’t use so it naming convention and this including hinders disputes having browser APIs

Browser APIs plus don’t use so it naming convention and this including hinders disputes having browser APIs

Simply mangling qualities that end up in a keen emphasize try a good heuristic given that regular JS code will not normally incorporate identifiers in that way. Should you want to avoid mangling labels eg __defineGetter__ you might consider using a far more state-of-the-art normal term such as for instance [^_]_$ (i.age. need to end in a non-underscore with a keen emphasize).

That is an alternate function rather than being an element of the minify means because it’s a dangerous transformation that will not functions to the haphazard JavaScript password. It just functions if the considering normal phrase fits every one of the fresh qualities that you want mangled and won’t fits people of the functions that you do not require mangled. Additionally only works if you do not significantly less than one items site a great mangled assets ultimately. For example, it means you cannot play with obj[prop] to help you reference property where prop is a sequence that contains the fresh assets title. Specifically the next sentence structure constructs will be merely of those qualified to receive possessions mangling:

While using the this feature, keep in mind that assets brands are just constantly mangled inside one esbuild API call yet not around the esbuild API calls. Per esbuild API name really does a different property mangling procedure thus output records created by a few more API phone calls parece, that’ll result in the resulting code to act 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 want getting esbuild to also mangle the brand new content material away from string literals, you might clearly permit that conclusion in this way:

#Stopping renaming

If you like so you’re able to ban certain services of mangling, you can set-aside them with a supplementary mode. Such, which spends the typical expression ^__.*__$ so you can reserve all the services one to start and you may end with a couple underscores, such as for example __foo__ :

#Persisting renaming behavior

Complex accessibility the house mangling ability involves storage the newest mapping out-of modern term so you can mangled name into the a long-term cache. When allowed, all the mangled assets renamings try registered regarding cache during the first make. After that creates recycle the fresh new renamings stored in the cache and you will create extra renamings for newly-added features. It has a few outcomes:

The brand new cache serves as a summary of most of the services that have been mangled. It is possible to always check it to find out if you will find any unforeseen assets renamings.

You can disable mangling getting individual services of the form new rebranded worth so you’re able to false unlike to help you a sequence. This might be much like the set aside props function but with the a great per-possessions foundation.

You might guarantee consistent renaming ranging from creates (age.grams. a main-bond file and a web worker, otherwise a collection and a plug-in). As opposed to this particular feature, per build would do another renaming operation together with mangled assets brands most likely would not be consistent.

Whenever we need customRenaming_ as rebranded to help you cR_ therefore https://datingmentor.org/okcupid-vs-tinder/ we wouldn’t like disabledRenaming_ to be renamed anyway, we are able to pass the following mangle cache JSON so you’re able to esbuild:

#Metafile

This informs esbuild in order to make certain metadata in regards to the make in the JSON format. Another analogy places the fresh new metadata inside the a document named meta.json :

This information can then become assessed by the almost every other units. Eg, plan friend is also consume esbuild’s metadata style and yields a good treemap visualization of your modules on your own plan and just how much area each of them uses up.

Comments are closed.