Browser APIs plus avoid that it naming convention so this also hinders issues having internet browser APIs

Browser APIs plus avoid that it naming convention so this also hinders issues having internet browser APIs

Just mangling services you to definitely Plenty of Fish vs. Zoosk result in an enthusiastic emphasize try a fair heuristic since the regular JS code will not normally have identifiers in that way. If you’d like to stop mangling labels such __defineGetter__ you could potentially contemplate using a far more complex normal phrase including [^_]_$ (we.e. have to trigger a low-underscore with an enthusiastic underscore).

That is an alternative function unlike being part of the minify function since it is a hazardous conversion that will not works towards haphazard JavaScript code. They only works in case your given typical term suits each of the brand new features that you like mangled and will not meets any of your own features you never need mangled. In addition it merely really works if you don’t significantly less than any products source a mangled assets indirectly. Including, it means you can not have fun with obj[prop] in order to source a home where prop is actually a set containing the fresh assets term. Specifically the second sentence structure constructs will be simply of these qualified to receive property mangling:

While using the this feature, keep in mind that possessions labels are only consistently mangled within a single esbuild API phone call not all over esbuild API phone calls. For every single esbuild API telephone call do a separate property mangling procedure very efficiency data files produced by several different API phone calls parece, which will cause the resulting code to do something incorrectly.

#Cited properties

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 so you’re able to and mangle brand new contents regarding string literals, you could clearly allow one to choices along these lines:

#Preventing renaming

If you’d like so you can exclude specific characteristics off mangling, you could reserve them with a supplementary function. Eg, that it uses the typical phrase ^__.*__$ to help you set aside every attributes one initiate and you will avoid having a few underscores, like __foo__ :

#Persisting renaming decisions

State-of-the-art use of the home mangling element relates to space new mapping out-of totally new name to mangled term when you look at the a persistent cache. Whenever allowed, most of the mangled possessions renamings are submitted throughout the cache inside initially make. Then produces reuse the brand new renamings kept in the fresh cache and you will add more renamings for the newly-extra characteristics. This has several consequences:

The newest cache serves as a summary of all properties which were mangled. You can easily see it to see if discover one unanticipated assets renamings.

You can eliminate mangling to possess personal functions from the means the latest renamed value in order to not true instead of so you’re able to a set. This might be just as the set-aside props form however, for the a per-possessions basis.

You can verify uniform renaming between yields (elizabeth.g. a central-thread document and a web staff, or a collection and you may a plugin). Versus this feature, for each build should do a separate renaming process and the mangled property brands more than likely would not be uniform.

When we wanted customRenaming_ to be renamed in order to cR_ and now we don’t want disabledRenaming_ become rebranded after all, we could citation the second mangle cache JSON to esbuild:

#Metafile

This one tells esbuild to help make particular metadata regarding the create in the JSON structure. The following example sets the latest metadata into the a document called meta.json :

This information can then become reviewed by the almost every other tools. Such as, bundle buddy is consume esbuild’s metadata style and yields a great treemap visualization of one’s segments on the plan and exactly how far room each one of these occupies.