Internet browser APIs and avoid so it naming discussion so this as well as avoids problems which have browser APIs

Internet browser APIs and avoid so it naming discussion so this as well as avoids problems which have browser APIs

Just mangling services one end up in an enthusiastic underscore are a good heuristic because normal JS code cannot typically consist of identifiers by doing this. When you need to end mangling brands such as for instance __defineGetter__ you could potentially consider using a far more cutting-edge typical term such as [^_]_$ (i.elizabeth. need to bring about a low-underscore with an enthusiastic emphasize).

This will be a different sort of setting in place of are area of the minify means since it is a hazardous conversion that does not work into haphazard JavaScript password. They just works in case the considering typical expression matches every one of the fresh new functions that you like mangled and won’t meets one of the functions that you don’t want mangled. In addition, it merely really works unless you significantly less than one points site an effective mangled property ultimately. Instance, this means you simply cannot play with obj[prop] so you’re able to source a home in which prop are a sequence containing the fresh new property term. Particularly another sentence structure constructs certainly are the only ones qualified to receive property mangling:

While using the this particular aspect, just remember that , possessions names are only consistently mangled within one esbuild API label yet not across esbuild API phone calls. For every single esbuild API call really does a separate property mangling procedure therefore efficiency data files generated by several some other API phone calls es, which could cause the ensuing password to behave wrongly.

#Quoted 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 https://datingmentor.org/cs/zeme-seznamka/ 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 for esbuild so you can together with mangle brand new content out of string literals, you could potentially clearly enable you to definitely behavior such as this:

#Stopping renaming

If you need to prohibit particular functions regarding mangling, you might set-aside all of them with an additional means. For example, so it spends the conventional expression ^__.*__$ so you’re able to reserve all features you to definitely initiate and end which have a couple underscores, including __foo__ :

#Persisting renaming decisions

Cutting-edge the means to access the home mangling function involves storage space the newest mapping off completely new name so you’re able to mangled term inside a persistent cache. Whenever enabled, all the mangled possessions renamings are filed on the cache inside the very first generate. Subsequent produces recycle this new renamings stored in brand new cache and you can add a lot more renamings your freshly-additional services. It offers a few consequences:

The new cache functions as a list of every attributes that were mangled. You can easily search it to see if you will find any unforeseen assets renamings.

You could eliminate mangling getting individual properties of the means this new renamed really worth so you’re able to false in the place of to help you a sequence. This is just as the put aside props means however, towards the a good per-assets base.

You could make sure consistent renaming ranging from produces (elizabeth.grams. a main-bond file and you may a web personnel, otherwise a collection and a plugin). Instead this particular feature, for every single build should do another renaming operation and also the mangled property brands more than likely wouldn’t be consistent.

Whenever we wanted customRenaming_ is renamed to help you cR_ therefore do not want disabledRenaming_ becoming renamed at all, we could admission the following mangle cache JSON in order to esbuild:

#Metafile

This 1 informs esbuild to produce some metadata regarding build inside JSON structure. Another analogy puts the newest metadata for the a file entitled meta.json :

This data are able to feel analyzed by almost every other units. Particularly, bundle friend can consume esbuild’s metadata style and you can yields a good treemap visualization of the modules on your own package as well as how far space each of them uses up.

Leave a Reply

Your email address will not be published.