Skip to content

Commit

Permalink
fix #995: windows arm64 support
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Aug 17, 2021
1 parent bff9917 commit decfb7a
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 2 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

* Add support for native esbuild on Windows 64-bit ARM ([#995](https://github.com/evanw/esbuild/issues/995))

The newly-released Go version 1.17.0 [adds support for Windows 64-bit ARM CPUs](https://golang.org/doc/go1.17#windows), so esbuild can now support these CPUs as well. This release introduces support for `npm install esbuild` on Windows 64-bit ARM.

## 0.12.20

* Avoid the sequence `</style` in CSS output ([#1509](https://github.com/evanw/esbuild/issues/1509))
Expand Down
24 changes: 22 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ platform-all: cmd/esbuild/version.go test-all
make -j8 \
platform-windows \
platform-windows-32 \
platform-windows-arm64 \
platform-android-arm64 \
platform-darwin \
platform-darwin-arm64 \
Expand All @@ -135,6 +136,10 @@ platform-windows-32:
cd npm/esbuild-windows-32 && npm version "$(ESBUILD_VERSION)" --allow-same-version
CGO_ENABLED=0 GOOS=windows GOARCH=386 go build $(GO_FLAGS) -o npm/esbuild-windows-32/esbuild.exe ./cmd/esbuild

platform-windows-arm64:
cd npm/esbuild-windows-arm64 && npm version "$(ESBUILD_VERSION)" --allow-same-version
CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build $(GO_FLAGS) -o npm/esbuild-windows-arm64/esbuild.exe ./cmd/esbuild

platform-unixlike:
test -n "$(GOOS)" && test -n "$(GOARCH)" && test -n "$(NPMDIR)"
mkdir -p "$(NPMDIR)/bin"
Expand Down Expand Up @@ -196,30 +201,41 @@ publish-all: cmd/esbuild/version.go test-prepublish
@echo "Checking for unpushed commits..." && git fetch
@test "" = "`git cherry`" || (echo "Refusing to publish with unpushed commits" && false)
rm -fr npm && git checkout npm

@echo Enter one-time password:
@read OTP && OTP="$$OTP" make -j4 \
publish-windows \
publish-windows-32 \
publish-windows-arm64 \
publish-openbsd

@echo Enter one-time password:
@read OTP && OTP="$$OTP" make -j4 \
publish-freebsd \
publish-freebsd-arm64 \
publish-openbsd \
publish-darwin \
publish-darwin-arm64

@echo Enter one-time password:
@read OTP && OTP="$$OTP" make -j4 \
publish-android-arm64 \
publish-linux \
publish-linux-32 \
publish-linux-arm \
publish-linux-arm

@echo Enter one-time password:
@read OTP && OTP="$$OTP" make -j4 \
publish-linux-arm64 \
publish-linux-mips64le \
publish-linux-ppc64le

# Do these last to avoid race conditions
@echo Enter one-time password:
@read OTP && OTP="$$OTP" make -j2 \
publish-neutral \
publish-deno \
publish-wasm

git commit -am "publish $(ESBUILD_VERSION) to npm"
git tag "v$(ESBUILD_VERSION)"
git push origin master "v$(ESBUILD_VERSION)"
Expand All @@ -230,6 +246,9 @@ publish-windows: platform-windows
publish-windows-32: platform-windows-32
test -n "$(OTP)" && cd npm/esbuild-windows-32 && npm publish --otp="$(OTP)"

publish-windows-arm64: platform-windows-arm64
test -n "$(OTP)" && cd npm/esbuild-windows-arm64 && npm publish --otp="$(OTP)"

publish-android-arm64: platform-android-arm64
test -n "$(OTP)" && cd npm/esbuild-android-arm64 && npm publish --otp="$(OTP)"

Expand Down Expand Up @@ -284,6 +303,7 @@ clean:
rm -f esbuild
rm -f npm/esbuild-windows-32/esbuild.exe
rm -f npm/esbuild-windows-64/esbuild.exe
rm -f npm/esbuild-windows-arm64/esbuild.exe
rm -rf npm/esbuild-android-arm64/bin
rm -rf npm/esbuild-darwin-64/bin
rm -rf npm/esbuild-darwin-arm64/bin
Expand Down
3 changes: 3 additions & 0 deletions npm/esbuild-windows-arm64/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# esbuild

This is the Windows ARM 64-bit binary for esbuild, a JavaScript bundler and minifier. See https://github.com/evanw/esbuild for details.
14 changes: 14 additions & 0 deletions npm/esbuild-windows-arm64/bin/esbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env node

// Unfortunately even though npm shims "bin" commands on Windows with auto-
// generated forwarding scripts, it doesn't strip the ".exe" from the file name
// first. So it's possible to publish executables via npm on all platforms
// except Windows. I consider this a npm bug.
//
// My workaround is to add this script as another layer of indirection. It'll
// be slower because node has to boot up just to shell out to the actual exe,
// but Windows is somewhat of a second-class platform to npm so it's the best
// I can do I think.
const esbuild_exe = require.resolve('esbuild-windows-arm64/esbuild.exe');
const child_process = require('child_process');
child_process.spawnSync(esbuild_exe, process.argv.slice(2), { stdio: 'inherit' });
16 changes: 16 additions & 0 deletions npm/esbuild-windows-arm64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "esbuild-windows-arm64",
"version": "0.12.20",
"description": "The Windows ARM 64-bit binary for esbuild, a JavaScript bundler.",
"repository": "https://github.com/evanw/esbuild",
"license": "MIT",
"os": [
"win32"
],
"cpu": [
"arm64"
],
"directories": {
"bin": "bin"
}
}

0 comments on commit decfb7a

Please sign in to comment.