BLOG

Web browser APIs and additionally avoid using this naming summit so this also stops disputes which have web browser APIs

Web browser APIs and additionally avoid using this naming summit so this also stops disputes which have web browser APIs

Only mangling functions you to definitely end in an emphasize is actually a good heuristic as the normal JS password cannot typically have identifiers this way. When you need to stop mangling brands for example __defineGetter__ you could potentially consider using an even more complex normal expression such as for instance [^_]_$ (i.elizabeth. need to result in a non-emphasize with a keen emphasize).

This can be a special form rather than are a portion of the minify setting because it is an unsafe transformation that will not works into the arbitrary JavaScript password. They simply work if for example the offered regular expression matches all of the new characteristics that you want mangled and won’t fits people of the services you never need mangled. It also just functions if you do not below any facts reference an effective mangled possessions indirectly. Instance, it means you can’t explore obj[prop] so you can site a house in which prop try a series which has had this new property name. Specifically another sentence structure constructs is the just ones entitled to property mangling:

While using the this particular feature, remember that property brands are merely constantly mangled in this a single esbuild API telephone call but not all over esbuild API calls. Per esbuild API phone call do an independent assets mangling operation very productivity records from a couple of additional API calls es, that will cause the resulting code to act improperly.

#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 like to own esbuild so you’re able to along with mangle the fresh new information away from string literals, you might explicitly allow that conclusion like this:

#Blocking renaming

If you’d like so you can prohibit specific services of mangling, you could reserve them with an extra form. Eg, which uses the standard phrase ^__.*__$ so you can set aside every services you to definitely initiate and you may prevent having one or two underscores, such as for example __foo__ :

#Persisting renaming choices

Advanced the means to access the home mangling function comes to storage new mapping regarding totally new identity so you’re able to mangled name from inside the a long-term cache. Whenever allowed, every mangled property renamings are filed throughout the cache inside 1st generate. Further yields reuse the fresh renamings stored in this new cache and you can put extra renamings your recently-additional qualities. It has a few effects:

The newest cache serves as a summary of the services that have been mangled. You’ll see it to find out if discover one unanticipated possessions renamings.

You could https://datingmentor.org/escort/new-orleans/ potentially eliminate mangling to possess private attributes from the function the fresh new renamed worthy of to help you not true unlike so you can a sequence. That is similar to the reserve props means however, on a per-possessions base.

You can make sure uniform renaming between stimulates (age.grams. a central-bond document and you will an internet employee, or a collection and you will a plugin). Without this particular aspect, for each and every create would do a separate renaming procedure additionally the mangled assets names probably would not be consistent.

When we need customRenaming_ to-be renamed to cR_ therefore we do not want disabledRenaming_ is rebranded after all, we can admission the following mangle cache JSON in order to esbuild:

#Metafile

This option says to esbuild to make particular metadata concerning the generate within the JSON format. Another analogy throws the newest metadata from inside the a document named meta.json :

This info may then become reviewed because of the almost every other systems. Instance, plan pal normally consume esbuild’s metadata structure and you can produces a great treemap visualization of your own segments on your own plan and exactly how far place each one uses up.