Some examples of gadgets you to definitely implement these complex password optimizations include Terser and you may Yahoo Closing Compiler

Some examples of gadgets you to definitely implement these complex password optimizations include Terser and you may Yahoo Closing Compiler

  • TypeScript enum recognition and you can inlining

In case your code utilizes activities which need the these types of code optimization is compact, or if you are searching for the suitable JavaScript minification formula available case, you have to know using most other systems.

#Outdir

This 1 establishes this new efficiency directory towards the create operation. Like, so it command will create an index entitled out :

The fresh new yields list was made if this cannot currently occur, however it won’t be removed in the event it already include particular documents. People made documents tend to quietly overwrite current files with similar name. You ought to clear the new yields directory oneself before powering esbuild in the event that you need new output index to simply contain data files about current work at of esbuild.

If your build consists of multiple admission points for the independent lists, the brand new index framework would be replicated on output list starting regarding reduced popular predecessor index among all input entry way pathways. Like, in the event the there are 2 entryway affairs src/ home/ directory.ts and src/ about/ index.ts , the yields directory have a tendency to contain family/ directory.js and in the/ index.js . If you would like tailor which behavior, you should replace the outbase list.

#Outfile

This package kits the fresh new output file identity on make process. This is certainly just appropriate if you have just one entry point. In the event the discover several admission things, you must make use of the outdir choice as an alternative to help you indicate an efficiency list. Playing with outfile looks like which:

#Platform

Automatically, esbuild’s bundler is configured to generate password intended for new internet browser. If your bundled password is meant to run-in node as an alternative, you ought to put the platform in order to node :

Whenever bundling is actually allowed new default returns style is decided so you’re able to iife , and therefore wraps the fresh new made JavaScript password when you look at the an immediately-invoked means phrase to avoid variables out-of leaking to your internationally extent.

If the a package specifies a chart to your web browser industry from inside the their bundle.json file, esbuild uses you to chart to restore specific documents yubo cena otherwise segments with their web browser-friendly items. Including, a package you are going to include a substitution regarding path having street-browserify .

Area of the fields form is set to help you internet browser, module, main but with specific most special conclusion. If a package helps component and you will main not web browser upcoming main is used in the place of module if that bundle was ever before brought in playing with want() . Which behavior advances being compatible having CommonJS segments one to export a work because of the assigning they so you’re able to component.exports .

This new criteria means automatically includes the latest internet browser updates. This changes how exports industry into the bundle.json data files are interpreted in order to choose internet browser-particular password.

With all the generate API, all techniques. env. NODE_ENV terms was instantly defined so you’re able to «production» when the the minification options are permitted and you can «development» otherwise. Which simply goes if the procedure , processes.env , and you can process.env.NODE_ENV aren’t already outlined. This replacing is necessary to stop Behave-created password crashing instantaneously (since the process try a beneficial node API, maybe not a web API).

Whenever bundling are allowed the fresh default production format is decided so you can cjs , and therefore stands for CommonJS (the brand new component format used by node). ES6-build exports having fun with export statements is converted into getters towards the this new CommonJS exports object.

Most of the dependent-during the node segments such as for example fs are instantly marked as exterior so they cannot lead to errors in the event that bundler tries to bundle them.

The main areas mode is set so you can chief, module . It means forest trembling won’t occurs to possess bundles that render each other module and head while the forest moving works closely with ECMAScript modules however with CommonJS modules.

Deja una respuesta