-
Enable faster synchronous transforms with the JS API by default (#1000)
Currently the synchronous JavaScript API calls
transformSync
andbuildSync
spawn a new child process on every call. This is due to limitations with node'schild_process
API. Doing this meanstransformSync
andbuildSync
are much slower thantransform
andbuild
, which share the same child process across calls.This release improves the performance of
transformSync
andbuildSync
by up to 20x. It enables a hack where node'sworker_threads
API and atomics are used to block the main thread while asynchronous communication with a single long-lived child process happens in a worker. Previously this was only enabled when theESBUILD_WORKER_THREADS
environment variable was set to1
. But this experiment has been available for a while (since version 0.9.6) without any reported issues. Now this hack will be enabled by default. It can be disabled by settingESBUILD_WORKER_THREADS
to0
before running node. -
Fix nested output directories with WebAssembly on Windows (#1399)
Many functions in Go's standard library have a bug where they do not work on Windows when using Go with WebAssembly. This is a long-standing bug and is a fault with the design of the standard library, so it's unlikely to be fixed. Basically Go's standard library is designed to bake "Windows or not" decision into the compiled executable, but WebAssembly is platform-independent which makes "Windows or not" is a run-time decision instead of a compile-time decision. Oops.
I have been working around this by trying to avoid using path-related functions in the Go standard library and doing all path manipulation by myself instead. This involved completely replacing Go's
path/filepath
library. However, I missed theos.MkdirAll
function which is also does path manipulation but is outside of thepath/filepath
package. This meant that nested output directories failed to be created on Windows, which caused a build error. This problem only affected theesbuild-wasm
package.This release manually reimplements nested output directory creation to work around this bug in the Go standard library. So nested output directories should now work on Windows with the
esbuild-wasm
package.