Internet browser APIs also don’t use so it naming discussion which means this together with hinders conflicts that have browser APIs

Simply mangling functions that produce a keen emphasize is actually a good heuristic just like the typical JS code will not generally incorporate identifiers like that. When you need to stop mangling labels instance __defineGetter__ you can contemplate using a very advanced regular phrase particularly [^_]_$ (we.age. need certainly to produce a non-emphasize accompanied by an enthusiastic emphasize).

This is another setting instead of being a portion of the minify means because it is a harmful sales that doesn’t really works to the arbitrary JavaScript code. It only performs in the event the provided typical phrase matches each one of the features that you want mangled and does not fits any of one’s functions you never require mangled. What’s more, it only functions if you do not below any affairs source an excellent mangled possessions ultimately. Particularly, it indicates you can’t have fun with obj[prop] to help you reference property in which prop is a string that contains brand new possessions label. Specifically the following syntax constructs will be the just ones eligible for property mangling:

While using the this feature, just remember that , possessions names are only constantly mangled inside just one esbuild API label although not across esbuild API calls. For every esbuild API phone call do a different possessions mangling procedure very efficiency data files made by several various other API calls es, that may result in the ensuing 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_) will be mangled into print(.a) while print([‘foo_’]) will not be mangled.

If you want to possess esbuild to help you as well as mangle brand new articles of sequence literals, you could clearly permit you to definitely conclusion along these lines:

#Blocking renaming

If you’d like to ban particular services off mangling, you could potentially set-aside them with an extra setting. Such as, this spends the conventional term ^__.*__$ so you can put aside all the functions you to definitely initiate and end which have one or two underscores, such as for instance __foo__ :

#Persisting renaming choices

State-of-the-art usage of the house or property mangling element comes to storing the fresh mapping out-of new name in order to mangled label inside a persistent cache. When enabled, all of the mangled assets renamings are recorded regarding the cache in first build. After that yields recycle the newest renamings stored in new cache and you can include most renamings for recently-extra characteristics. It has got a few consequences:

The cache functions as a listing of all the attributes which were mangled. Possible search they to see if there are people unanticipated possessions renamings.

You might eliminate mangling for private features from the setting the brand new renamed value so you’re able to not true in place of so you’re able to a string. This really is similar to the put aside props function but towards the good per-possessions foundation.

You can ensure consistent renaming anywhere between creates (elizabeth.grams. a central-bond document and you will a web personnel, otherwise a collection and you will a plug-in). Versus this feature, for each and every create should do an independent renaming process in addition to mangled property labels almost certainly wouldn’t be uniform.

If we need customRenaming_ are renamed to help you cR_ and in addition we wouldn’t like disabledRenaming_ becoming rebranded at all, we could citation another mangle cache JSON in order to esbuild:

#Metafile

This package says to esbuild in order to make specific metadata concerning create from inside the JSON format. Another analogy throws new metadata during the a document called meta.json :

This data may then feel reviewed by the almost every other systems. Including, bundle friend is also consume esbuild’s metadata structure and you can generates good treemap visualization of the modules on your bundle and how much room each one occupies.

error: Content is protected !!