Skip to content

Commit

Permalink
follow-up to #2457
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Aug 29, 2022
1 parent 4eb1713 commit 6414eeb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Unreleased

* Lower `for await` loops
* Lower `for await` loops ([#1930](https://github.com/evanw/esbuild/issues/1930))

This release lowers `for await` loops to the equivalent `for` loop containing `await` when esbuild is configured such that `for await` loops are unsupported. This transform still requires at least generator functions to be supported since esbuild's lowering of `await` currently relies on generators. This new transformation is modeled after what the TypeScript compiler does. Here's an example:

Expand Down Expand Up @@ -75,6 +75,12 @@

Some people write code that contains a label with an immediate break such as `x: break x`. Previously this code was not removed during minification but it will now be removed during minification starting with this release.

* Fix installing esbuild via Yarn with `enableScripts: false` configured ([#2457](https://github.com/evanw/esbuild/pull/2457))

If esbuild is installed with Yarn with the `enableScripts: false` setting configured, then Yarn will not "unplug" the `esbuild` package (i.e. it will keep the entire package inside a `.zip` file). This messes with esbuild's library code that extracts the platform-specific binary executable because that code copies the binary executable into the esbuild package directory, and Yarn's `.zip` file system shim doesn't let you write to a directory inside of a `.zip` file. This release fixes this problem by writing to the `node_modules/.cache/esbuild` directory instead in this case. So you should now be able to use esbuild with Yarn when `enableScripts: false` is configured.

This fix was contributed by [@jonaskuske](https://github.com/jonaskuske).

## 0.15.5

* Fix issues with Yarn PnP and Yarn's workspaces feature ([#2476](https://github.com/evanw/esbuild/issues/2476))
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ test-e2e-yarn-berry:
cd e2e-yb && echo "1+2" | yarn esbuild && yarn node -p "require('esbuild').transformSync('1+2').code"

# Test install without scripts
rm -fr e2e-yb && mkdir e2e-yb && cd e2e-yb && echo {} > package.json && echo 'enableScripts: false' > yarn.lock && yarn set version berry && yarn add esbuild
rm -fr e2e-yb && mkdir e2e-yb && cd e2e-yb && echo {} > package.json && touch yarn.lock && echo 'enableScripts: false' > .yarnrc.yml && yarn set version berry && yarn add esbuild
cd e2e-yb && echo "1+2" | yarn esbuild && yarn node -p "require('esbuild').transformSync('1+2').code"
# Test CI reinstall
cd e2e-yb && yarn install --immutable
Expand Down
18 changes: 18 additions & 0 deletions lib/npm/node-platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,24 @@ by esbuild to install the correct binary executable for your current platform.`)
// it's inside a virtual file system and the OS needs it in the real file
// system. So we need to copy the file out of the virtual file system into
// the real file system.
//
// You might think that we could use "preferUnplugged: true" in each of the
// platform-specific packages for this instead, since that tells Yarn to not
// use the virtual file system for those packages. This is not done because:
//
// * Really early versions of Yarn don't support "preferUnplugged", so package
// installation would break on those Yarn versions if we did this.
//
// * Earlier Yarn versions always installed all optional dependencies for all
// platforms even though most of them are incompatible. To minimize file
// system space, we want these useless packages to take up as little space
// as possible so they should remain unzipped inside their ".zip" files.
//
// We have to explicitly pass "preferUnplugged: false" instead of leaving
// it up to Yarn's default behavior because Yarn's heuristics otherwise
// automatically unzip packages containing ".exe" files, and we don't want
// our Windows-specific packages to be unzipped either.
//
let pnpapi: any;
try {
pnpapi = require('pnpapi');
Expand Down

0 comments on commit 6414eeb

Please sign in to comment.