Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NetBSD amd64 binary #1624

Merged
merged 6 commits into from
Oct 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## Unreleased

* Experimental support for esbuild on NetBSD ([#1624](https://github.com/evanw/esbuild/pull/1624))

With this release, esbuild now has a published binary executable for [NetBSD](https://www.netbsd.org/) in the [`esbuild-netbsd-64`](http://npmjs.com/package/esbuild-netbsd-64) npm package, and esbuild's installer has been modified to attempt to use it when on NetBSD. Hopefully this makes installing esbuild via npm work on NetBSD. This change was contributed by [@gdt](https://github.com/gdt).

⚠️ Note: NetBSD is not one of [Node's supported platforms](https://nodejs.org/api/process.html#process_process_platform), so installing esbuild may or may not work on NetBSD depending on how Node has been patched. This is not a problem with esbuild. ⚠️

## 0.13.5

* Improve watch mode accuracy ([#1113](https://github.com/evanw/esbuild/issues/1113))
Expand Down
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ platform-all: cmd/esbuild/version.go test-all
platform-darwin-arm64 \
platform-freebsd \
platform-freebsd-arm64 \
platform-netbsd \
platform-openbsd \
platform-linux \
platform-linux-32 \
Expand Down Expand Up @@ -162,6 +163,9 @@ platform-freebsd:
platform-freebsd-arm64:
make GOOS=freebsd GOARCH=arm64 NPMDIR=npm/esbuild-freebsd-arm64 platform-unixlike

platform-netbsd:
make GOOS=netbsd GOARCH=amd64 NPMDIR=npm/esbuild-netbsd-64 platform-unixlike

platform-openbsd:
make GOOS=openbsd GOARCH=amd64 NPMDIR=npm/esbuild-openbsd-64 platform-unixlike

Expand Down Expand Up @@ -234,6 +238,10 @@ publish-all: cmd/esbuild/version.go test-prepublish
publish-linux-ppc64le \
publish-sunos

@echo Enter one-time password:
@read OTP && OTP="$$OTP" $(MAKE) -j1 \
publish-netbsd

# Do these last to avoid race conditions
@echo Enter one-time password:
@read OTP && OTP="$$OTP" make -j2 \
Expand Down Expand Up @@ -269,6 +277,9 @@ publish-freebsd: platform-freebsd
publish-freebsd-arm64: platform-freebsd-arm64
test -n "$(OTP)" && cd npm/esbuild-freebsd-arm64 && npm publish --otp="$(OTP)"

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

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

Expand Down Expand Up @@ -317,6 +328,7 @@ clean:
rm -rf npm/esbuild-darwin-arm64/bin
rm -rf npm/esbuild-freebsd-64/bin
rm -rf npm/esbuild-freebsd-amd64/bin
rm -rf npm/esbuild-netbsd-64/bin
rm -rf npm/esbuild-openbsd-64/bin
rm -rf npm/esbuild-linux-32/bin
rm -rf npm/esbuild-linux-64/bin
Expand Down
3 changes: 2 additions & 1 deletion lib/npm/node-platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ export const knownUnixlikePackages: Record<string, string> = {
'darwin x64 LE': 'esbuild-darwin-64',
'freebsd arm64 LE': 'esbuild-freebsd-arm64',
'freebsd x64 LE': 'esbuild-freebsd-64',
'openbsd x64 LE': 'esbuild-openbsd-64',
'linux arm LE': 'esbuild-linux-arm',
'linux arm64 LE': 'esbuild-linux-arm64',
'linux ia32 LE': 'esbuild-linux-32',
'linux mips64el LE': 'esbuild-linux-mips64le',
'linux ppc64 LE': 'esbuild-linux-ppc64le',
'linux x64 LE': 'esbuild-linux-64',
'netbsd x64 LE': 'esbuild-netbsd-64',
'openbsd x64 LE': 'esbuild-openbsd-64',
'sunos x64 LE': 'esbuild-sunos-64',
};

Expand Down
5 changes: 5 additions & 0 deletions npm/esbuild-netbsd-64/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# esbuild

This is the NetBSD AMD64 binary for esbuild, a JavaScript bundler and minifier. See https://github.com/evanw/esbuild for details.

⚠️ Note: NetBSD is not one of [Node's supported platforms](https://nodejs.org/api/process.html#process_process_platform), so installing esbuild may or may not work on NetBSD depending on how Node has been patched. This is not a problem with esbuild. ⚠️
13 changes: 13 additions & 0 deletions npm/esbuild-netbsd-64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "esbuild-netbsd-64",
"version": "0.13.0",
"description": "The NetBSD AMD64 binary for esbuild, a JavaScript bundler.",
"repository": "https://github.com/evanw/esbuild",
"license": "MIT",
"os": [
"netbsd"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this will work because netbsd is not currently listed as a platform that node can return. From https://nodejs.org/api/process.html#process_process_platform:

The process.platform property returns a string identifying the operating system platform on which the Node.js process is running.

Currently possible values are:

  • 'aix'
  • 'darwin'
  • 'freebsd'
  • 'linux'
  • 'openbsd'
  • 'sunos'
  • 'win32'

The value 'android' may also be returned if the Node.js is built on the Android operating system. However, Android support in Node.js is experimental.

This matters because esbuild's API uses process.platform to determine which package to take the binary executable from:

let platformKey = `${process.platform} ${os.arch()} ${os.endianness()}`;

This key is used to look up into the map of known packages here:

export const knownWindowsPackages: Record<string, string> = {
'win32 arm64 LE': 'esbuild-windows-arm64',
'win32 ia32 LE': 'esbuild-windows-32',
'win32 x64 LE': 'esbuild-windows-64',
};
export const knownUnixlikePackages: Record<string, string> = {
'android arm64 LE': 'esbuild-android-arm64',
'darwin arm64 LE': 'esbuild-darwin-arm64',
'darwin x64 LE': 'esbuild-darwin-64',
'freebsd arm64 LE': 'esbuild-freebsd-arm64',
'freebsd x64 LE': 'esbuild-freebsd-64',
'openbsd x64 LE': 'esbuild-openbsd-64',
'linux arm LE': 'esbuild-linux-arm',
'linux arm64 LE': 'esbuild-linux-arm64',
'linux ia32 LE': 'esbuild-linux-32',
'linux mips64el LE': 'esbuild-linux-mips64le',
'linux ppc64 LE': 'esbuild-linux-ppc64le',
'linux x64 LE': 'esbuild-linux-64',
'sunos x64 LE': 'esbuild-sunos-64',
};

If process.platform can't return netbsd then running esbuild's JavaScript API on NetBSD won't work. You are welcome to build esbuild from source from NetBSD because Go supports NetBSD, but I don't think it makes sense to publish a NetBSD binary executable to npm if node doesn't support NetBSD.

],
"cpu": [
"x64"
]
}
1 change: 1 addition & 0 deletions npm/esbuild/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"esbuild-linux-arm64": "0.13.5",
"esbuild-linux-mips64le": "0.13.5",
"esbuild-linux-ppc64le": "0.13.5",
"esbuild-netbsd-64": "0.13.5",
"esbuild-openbsd-64": "0.13.5",
"esbuild-sunos-64": "0.13.5",
"esbuild-windows-32": "0.13.5",
Expand Down