Browser APIs together with don’t use that it naming meeting and this along with stops conflicts which have internet browser APIs

Browser APIs together with don’t use that it naming meeting and this along with stops conflicts which have internet browser APIs Just mangling services you to end up in a keen underscore is actually a good heuristic since typical JS code doesn’t typically include identifiers in that way. If you would like end mangling labels […]

Browser APIs together with don’t use that it naming meeting and this along with stops conflicts which have internet browser APIs

Just mangling services you to end up in a keen underscore is actually a good heuristic since typical JS code doesn’t typically include identifiers in that way. If you would like end mangling labels such as for instance __defineGetter__ you could contemplate using an even more state-of-the-art regular term particularly [^_]_$ (i.elizabeth. need trigger a non-underscore with an emphasize).

This is exactly an alternate function in the place of becoming an element of the minify mode because it is an unsafe transformation that does not functions to your arbitrary JavaScript password. They merely work if your considering typical phrase fits every one of new characteristics you want mangled and does not fits any of your own characteristics that you do not require mangled. it merely work if you don’t below any circumstances reference an excellent mangled assets ultimately. Such as, it indicates you cannot fool around with obj[prop] in order to resource property in which prop was a set with which has the newest possessions term. Especially the second sentence structure constructs may be the merely ones entitled to possessions mangling:

While using the this particular feature, just remember that , property names are merely continuously mangled contained in this one esbuild API label although not across esbuild API phone calls. For every single esbuild API label really does another property mangling process thus returns documents from two additional API phone calls parece, which could result in the resulting code to behave improperly.

#Quoted 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_:>.foo_) will be mangled into print(< a:>.a) while print(< 'foo_':>[‘foo_’]) will not be mangled.

If you need to own esbuild so you can and additionally mangle the new content out-of string literals, you might clearly permit one to decisions such as this:

#Preventing renaming

If you need so you can prohibit certain qualities out of mangling, you can reserve them with an additional mode. Eg, that it uses the regular expression ^__.*__$ in order to put aside all features that start and you may prevent having a couple underscores, like __foo__ :

#Persisting renaming choices

State-of-the-art access to the home mangling element involves storage space the mapping regarding new term to help you mangled name within the a long-term cache. Whenever permitted, every mangled assets renamings are filed on the cache inside the initial create. Then produces reuse the newest renamings kept in this new cache and put extra renamings for the recently-added functions. It offers a few outcomes:

Brand new cache serves as a summary of all qualities which were mangled. Possible check they to see if there are people unforeseen assets renamings.

You could disable mangling to own personal features of the form this new renamed really worth to untrue unlike so you can a sequence. This can be just like the put aside props function but on the a beneficial per-possessions base.

You can make sure uniform renaming between yields (e.grams. a central-thread file and an internet personnel, or a collection and a plugin). As opposed to this particular aspect, for each create would do an independent renaming process and mangled assets names almost certainly would not be uniform.

If we want customRenaming_ becoming rebranded in order to cR_ therefore do not want disabledRenaming_ becoming rebranded at all, we could solution another mangle cache JSON so you can esbuild:

#Metafile

That one tells esbuild in order to make some metadata regarding make from inside the JSON style. The next example leaves the newest metadata within the a document titled meta.json :

These records can then be reviewed of the other gadgets. Such, package buddy can be eat esbuild’s metadata style and you will stimulates a great treemap visualization of segments on the bundle and how much room each of them takes up.