Skip to content

Commit

Permalink
fix yarn-specific perf regression (#590)
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Dec 20, 2020
1 parent 8bfe7ca commit 6589c0b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

* Fix a performance regression from version 0.8.4 specific to Yarn 2

Code using esbuild's `transformSync` function via Yarn 2 experienced a dramatic slowdown in esbuild version 0.8.4 and above. This version added a wrapper script to fix Yarn 2's incompatibility with binary packages. Some code that tries to avoid unnecessarily calling into the wrapper script contained a bug that caused it to fail, which meant that using `transformSync` with Yarn 2 called into the wrapper script unnecessarily. This launched an extra node process every time the esbuild executable was invoked which can be over 6x slower than just invoking the esbuild executable directly. This release should now invoke the esbuild executable directly without going through the wrapper script, which fixes the performance regression.

## 0.8.24

* Share reference-counted service instances internally ([#600](https://github.com/evanw/esbuild/issues/600))
Expand Down
6 changes: 3 additions & 3 deletions lib/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ let esbuildCommandAndArgs = (): [string, string[]] => {
// to if the original location is replaced by our Yarn 2 compatibility hack.
// If it exists, we can infer that we are running within Yarn 2 and the
// JavaScript API should invoke the binary here instead to avoid a slowdown.
// This is a performance improvement of about 0.1 seconds for Yarn 2 on my
// machine.
let pathForYarn2 = path.join(__dirname, 'esbuild');
// Calling the binary directly can be over 6x faster than calling the wrapper
// script instead.
let pathForYarn2 = path.join(__dirname, '..', 'esbuild');
if (fs.existsSync(pathForYarn2)) {
return [pathForYarn2, []];
}
Expand Down

0 comments on commit 6589c0b

Please sign in to comment.