66.4. esbuild-0.28.2
JavaScript and TypeScript bundler and minifier
| Version | 0.28.2, release 1 |
| Shelf | lang — Language implementations, plus the modules of any language that has no module shelf of its own |
| Phase | 40_lang (Languages), 47 of 186 in build order |
| Licence | MIT |
| Homepage | https://esbuild.github.io/ |
| Build time | 0.3 SBU |
| Installed size | 12.2 MiB in 2 files |
| Recipe | ports/core/lang/esbuild/kpkgbuild |
About
esbuild bundles and minifies JavaScript and TypeScript. It is one Go program, built here with cgo off from its vendor bundle. chromium is the reason for the port: its build deletes every ELF file in its source tree and links /usr/bin/esbuild into the DevTools front end’s third_party/esbuild in its place.
Sources
esbuild-0.28.2.tar.gz(1.9 MiB)
sha256300162f899361d9f0263065f8728ef9086dcfc1a3d36bcbc4e0abe5de9c58bf8
upstream: https://github.com/evanw/esbuild/archive/v0.28.2/esbuild-0.28.2.tar.gz
archive copy: sources-3/lang--esbuild-0.28.2.tar.gzesbuild-vendor-0.28.2.tar.xz(278.8 KiB)
sha256092b1e71b92060854cc0f2d9b0b02a52018228026c4b87058de8bb47e122304c
a vendor bundle: the dependencies upstream’s own tool would download, packed once
archive copy: sources-3/lang--esbuild-vendor-0.25.1.tar.xz
Dependencies
Depends on: go.
Required by (1): chromium.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/40_lang/phase.env && kpkg install esbuild'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/lang/esbuild.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/lang/esbuild
echo '300162f899361d9f0263065f8728ef9086dcfc1a3d36bcbc4e0abe5de9c58bf8 esbuild-0.28.2.tar.gz' | sha256sum -c -
echo '092b1e71b92060854cc0f2d9b0b02a52018228026c4b87058de8bb47e122304c esbuild-vendor-0.28.2.tar.xz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/esbuild
SRC=$SRC_ROOT/esbuild-0.28.2
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf esbuild-0.28.2.tar.gz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the recipe’s helpers series and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
tar xf $PORT_SRC/${name}-vendor-${version}.tar.xz
export CGO_ENABLED=0
go build -mod=vendor -trimpath -ldflags "-s -w" -o esbuild-bin ./cmd/esbuild
install -Dm755 esbuild-bin "$PKG/usr/bin/esbuild"
install -Dm644 LICENSE.md "$PKG/usr/share/licenses/$name/LICENSE.md"
The switches, and why each is set:
-mod=vendor— Build from thevendor/directory the vendor bundle unpacks into the source, never from the module cache or the network.-trimpath— Leave the build directory’s paths out of the binary. The tree’s exportedGOFLAGScarries it already; see go.-ldflags "-s -w"— Leave the symbol table and the DWARF debugging information out of the binary. The Go linker writes both by default, andkpkgdoes not strip them.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/esbuild, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf esbuild-0.28.2-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/esbuild, and runs the triggers its paths call for.
Contents
Installed programs: esbuild.
Installed directories: /usr/share/licenses/esbuild.
Notes
series holds the port at one exact release, the one the DevTools front end’s DEPS in the Chromium source pins its esbuild to (the infra/3pp/tools/esbuild package). The version checker offers no other release while series names it (see Filtering), and a Chromium release that moves the pin needs version and series moved to match.