diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e52234657f..52ca4023539 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,10 @@ The [`@viewport`](https://www.w3.org/TR/css-device-adapt-1/#atviewport-rule) rule has been deprecated and removed from the web. Modern browsers now completely ignore this rule. However, in theory it sounds like would still work for mobile versions of Internet Explorer, if those still exist. The https://ant.design/ library contains an instance of the `@-ms-viewport` rule and it currently causes a warning with esbuild, so this release adds support for parsing this rule to disable the warning. +* Avoid mutating the binary executable file in place ([#963](https://github.com/evanw/esbuild/issues/963)) + + This release changes the install script for the `esbuild` npm package to use the "rename a temporary file" approach instead of the "write the file directly" approach to replace the `esbuild` command stub file with the real binary executable. This should hopefully work around a problem with the [pnpm](https://pnpm.js.org/) package manager and its use of hard links. + ## 0.9.3 * Fix path resolution with the `exports` field for scoped packages diff --git a/lib/install.ts b/lib/install.ts index e075cf1fb3d..48bd79581fd 100644 --- a/lib/install.ts +++ b/lib/install.ts @@ -222,7 +222,13 @@ function installDirectly(name: string) { fs.copyFileSync(process.env.ESBUILD_BINARY_PATH, binPath); validateBinaryVersion(binPath); } else { - installBinaryFromPackage(name, 'bin/esbuild', binPath) + // Write to a temporary file, then move the file into place. This is an + // attempt to avoid problems with package managers like pnpm which will + // usually turn each file into a hard link. We don't want to mutate the + // hard-linked file which may be shared with other files. + const tempBinPath = binPath + '__'; + installBinaryFromPackage(name, 'bin/esbuild', tempBinPath) + .then(() => fs.renameSync(tempBinPath, binPath)) .catch(e => setImmediate(() => { throw e; })); } }