From 055f9e38ee16de75b12ef0ad9dd8bf4ddec14fd6 Mon Sep 17 00:00:00 2001 From: Evan Wallace Date: Mon, 5 Dec 2022 21:35:51 -0500 Subject: [PATCH] add a shell script that downloads esbuild directly --- .gitignore | 1 + CHANGELOG.md | 16 ++++++++++++++++ Makefile | 12 +++++++++++- dl.sh | 21 +++++++++++++++++++++ 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100755 dl.sh diff --git a/.gitignore b/.gitignore index af87b3202a4..34ede119e9d 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ /require/*/demo/ /scripts/.*/ /validate/ +/www bin esbuild.exe node_modules/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 4303f60b586..86a30643f45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,22 @@ This change was not made with performance in mind. But as a bonus, installing esbuild with npm may potentially happen faster now. This is because npm's package installation protocol is inefficient: it always downloads metadata for all past versions of each package even when it only needs metadata about a single version. This makes npm package downloads O(n) in the number of published versions, which penalizes packages like esbuild that are updated regularly. Since most of esbuild's package names have now changed, npm will now need to download much less data when installing esbuild (8.72mb of package manifests before this change → 0.06mb of package manifests after this change). However, this is only a temporary improvement. Installing esbuild will gradually get slower again as further versions of esbuild are published. +* Publish a shell script that downloads esbuild directly + + In addition to all of the existing ways to install esbuild, you can now also download esbuild directly like this: + + ```sh + curl -fsSL https://esbuild.github.io/dl/latest | sh + ``` + + This runs a small shell script that downloads the latest `esbuild` binary executable to the current directory. This can be convenient on systems that don't have `npm` installed or when you just want to get a copy of esbuild quickly without any extra steps. If you want a specific version of esbuild (starting with this version onward), you can provide that version in the URL instead of `latest`: + + ```sh + curl -fsSL https://esbuild.github.io/dl/v0.16.0 | sh + ``` + + Note that the download script needs to be able to access registry.npmjs.org to be able to complete the download. This download script doesn't yet support all of the platforms that esbuild supports because I lack the necessary testing environments. If the download script doesn't work for you because you're on an unsupported platform, please file an issue on the esbuild repo so we can add support for it. + * Fix some parameter names for the Go API This release changes some parameter names for the Go API to be consistent with the JavaScript and CLI APIs: diff --git a/Makefile b/Makefile index bd991af7f9a..c19cd30d943 100644 --- a/Makefile +++ b/Makefile @@ -434,7 +434,8 @@ publish-all: check-go-version @read OTP && OTP="$$OTP" $(MAKE) --no-print-directory -j4 \ publish-neutral \ publish-deno \ - publish-wasm + publish-wasm \ + publish-dl git push origin main "v$(ESBUILD_VERSION)" @@ -519,6 +520,15 @@ publish-deno: cd deno && git tag "v$(ESBUILD_VERSION)" cd deno && git push origin main "v$(ESBUILD_VERSION)" +publish-dl: + test -d www/.git || (rm -fr www && git clone git@github.com:esbuild/esbuild.github.io.git www) + cd www && git fetch && git checkout gh-pages && git reset --hard origin/gh-pages + cd www && cat ../dl.sh | sed 's/$$ESBUILD_VERSION/$(ESBUILD_VERSION)/' > dl/latest + cd www && cat ../dl.sh | sed 's/$$ESBUILD_VERSION/$(ESBUILD_VERSION)/' > "dl/v$(ESBUILD_VERSION)" + cd www && git add dl/latest "dl/v$(ESBUILD_VERSION)" + cd www && git commit -m "publish download script for $(ESBUILD_VERSION)" + cd www && git push origin gh-pages + validate-build: @test -n "$(TARGET)" || (echo "The environment variable TARGET must be provided" && false) @test -n "$(PACKAGE)" || (echo "The environment variable PACKAGE must be provided" && false) diff --git a/dl.sh b/dl.sh new file mode 100755 index 00000000000..3d52c63eef5 --- /dev/null +++ b/dl.sh @@ -0,0 +1,21 @@ +#!/bin/sh +set -eu +dir=$(mktemp -d) +platform=$(uname -ms) +tgz="$dir/esbuild-$ESBUILD_VERSION.tgz" + +# Download the binary executable for the current platform +case $platform in + 'Darwin arm64') curl -fo "$tgz" "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-$ESBUILD_VERSION.tgz";; + 'Darwin x86_64') curl -fo "$tgz" "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-$ESBUILD_VERSION.tgz";; + 'Linux arm64' | 'Linux aarch64') curl -fo "$tgz" "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-$ESBUILD_VERSION.tgz";; + 'Linux x86_64') curl -fo "$tgz" "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-$ESBUILD_VERSION.tgz";; + 'NetBSD amd64') curl -fo "$tgz" "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-$ESBUILD_VERSION.tgz";; + 'OpenBSD amd64') curl -fo "$tgz" "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-$ESBUILD_VERSION.tgz";; + *) echo "error: Unsupported platform: $platform"; exit 1 +esac + +# Extract the binary executable to the current directory +tar -xzf "$tgz" -C "$dir" package/bin/esbuild +mv "$dir/package/bin/esbuild" . +rm "$tgz"