Which API choice enables you to identify the functional directory to utilize to your build

They generally speaking defaults to the current working set of the process you are using to call esbuild’s API. The working index is utilized from the esbuild for some other something together with fixing relative paths considering since the API options to absolute pathways and you may quite-print natural routes as the cousin routes during the log texts. Here is how to override they:

#JS-particular info

This new node-mainly based JS API is available in each other parallel and you will asynchronous types, for every single with assorted tradeoffs. You should be aware of the variations to pick the fresh new right one to suit your problem:

#Connect API

  • To stop pledges can result in machine password
  • Performs during the things that must definitely be synchronous for example in this need .extensions
  • You simply can’t explore plugins towards the synchronous API while the plugins try asynchronous
  • It reduces the present day bond so that you are unable to carry out almost every other work meanwhile
  • With the parallel API inhibits esbuild off parallelizing esbuild API calls

#Async API

  • You need plugins towards asynchronous API
  • The present day bond is not prohibited so you’re able to would almost every other operate in the latest interim
  • You could manage many simultaneous esbuild API phone calls at exactly the same time which are up coming pass on across all of the readily available CPUs for maximum results
  • Using promises can cause messier password, particularly in CommonJS in which ideal-level wait a little for isn’t offered
  • Can not work in things that must definitely be synchronous particularly in this need .extensions

#Powering on internet browser

The fresh esbuild API may also run in the newest internet browser playing with WebAssembly inside the a web Worker. When planning on taking advantageous asset of that it make an effort to created the fresh esbuild-wasm plan as opposed to the esbuild bundle:

This new API on the internet browser is similar to the fresh new API to have node besides you should phone call initialize() earliest, and you should solution the latest Hyperlink of WebAssembly digital. The parallel designs of the API are not available. Whenever you are using a beneficial bundler, that would research something similar to which:

If you are currently powering so it code of an employee plus don’t need initialize to produce several other staff member, you might violation staff member: not true so you can it. Then it can establish an effective WebAssembly module in the same thread due to the fact thread one phone calls initialize .

New API are going to be accessed in another of three ways: towards demand line, within the JavaScript, plus in Go. The fresh axioms and you can parameters is actually mostly identical involving the three languages so they really will be provided along with her here as opposed to having independent records per language.

There are two main API dating in Portland contacts esbuild’s API: change and create. It is essential to understand which one just be having fun with since the they work in another way.

If you use JavaScript make sure to look at the JS-particular facts section below. It’s also possible to get the TypeScript variety of definitions having esbuild of good use given that a research. If you use Go make sure you investigate immediately produced Go records.

If you utilize this new command-range API, it could be useful to know that the brand new flags have certainly about three forms: –foo , –foo=bar , otherwise –foo:club . The shape –foo is employed to own providing boolean flags instance –minify , the proper execution –foo=pub can be used for flags having an individual worth and you may are merely given just after for example –platform= , as well as the mode –foo:bar is employed to possess flags which have numerous opinions and can getting re-given many times such –external: .

#Transform API

The latest change API call works on a single sequence as opposed to availableness in order to a file program. This will make it perfect for include in surroundings as opposed to a document system (such as for example a browser) otherwise included in other product strings. This is what a straightforward alter turns out: