Specifically, the following password optimizations was simple for JavaScript code but they are not accomplished by esbuild (not an exhaustive list):
- Dead-password removal contained in this setting regulators
- Setting inlining
- Cross-statement constant propagation
- Object profile acting
- Allowance sinking
- Approach devirtualization
- Symbolic execution
- JSX phrase hoisting
- TypeScript enum detection and you can inlining
In the event your code utilizes activities which need some of such types of password optimization is compact, or you seek the perfect JavaScript minification algorithm available circumstances, you have to know playing with most other gadgets. Some examples of products you to incorporate some of these complex password optimizations are Terser and you can Yahoo Closure Compiler.
#Outdir
This kits new productivity index toward make procedure. Including, which command will generate a list named out :
Brand new efficiency list was produced in the event it cannot currently exists, nonetheless it may not be cleared if it currently include particular data. Any generated data will silently overwrite present data files with the exact same title. You will want to clear the fresh new efficiency list oneself prior to running esbuild when the need this new yields index to only have records throughout the newest focus on of esbuild.
In case your create contains multiple admission factors during the independent listing, this new directory design could be duplicated into the production index undertaking on the low popular ancestor index certainly most of the type in entry point routes. Such as for instance, in the event that there are two main admission items src/ home/ index.ts and you may src/ about/ list.ts , brand new efficiency list tend to incorporate house/ index.js and in the/ directory.js . If you wish to personalize which decisions, you really need to change the outbase list.
#Outfile
That one kits new returns file term into the create process. This is exactly merely applicable if there’s one entry point. In the event the discover several admission items, you must utilize the outdir alternative alternatively so you can establish a returns index. Using outfile turns out which:
#Platform
By default, esbuild’s bundler is actually configured generate code intended for the fresh new internet browser. If your included code is meant to run-in node rather, you should put the working platform to node :
Whenever bundling try allowed the new standard output format is decided in order to iife , and therefore wraps the fresh new made JavaScript code into the an instantaneously-invoked setting term to end variables of dripping to your global extent.
If the a deal specifies a map with the web browser industry for the their bundle.json file, esbuild will use that map to displace particular documents or segments the help of its web browser-friendly versions. Such as for example, a package you will consist of a replacement out-of path having street-browserify .
The main sphere means is decided so you can internet browser, component, main however with some extra special conclusion. If a great deal helps component and chief not web browser following main is used in place of module if that package try ever brought in playing with want() . Which behavior enhances compatibility which have CommonJS segments one export a work from the assigning they to help you module.exports .
The fresh criteria form automatically is sold with the new browser updates. This change how the exports field into the bundle.json data are translated so you’re able to like web browser-particular code.
With wing pГјf noktalarД± all the create API, all of the process. env. NODE_ENV words is actually instantly outlined to “production” in the event that most of the minification options are allowed and you will “development” or even. It just happens in the event that procedure , techniques.env , and procedure.env.NODE_ENV aren’t currently laid out. So it replacing is necessary to stop Behave-created code crashing immediately (since the techniques is good node API, maybe not a web API).
Whenever bundling was let the brand new default efficiency structure is determined to cjs , and this represents CommonJS (new component format used by node). ES6-concept exports using export comments is converted into getters on the latest CommonJS exports object.