Skip to content

Commit

Permalink
fix #3300, fix #3779: add @esbuild/wasi-preview1
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Jun 30, 2024
1 parent 6679ec8 commit b722000
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
/npm/@esbuild/android-x64/esbuild.wasm
/npm/@esbuild/android-x64/wasm_exec_node.js
/npm/@esbuild/android-x64/wasm_exec.js
/npm/@esbuild/wasi-preview1/esbuild.wasm
/npm/esbuild-wasm/browser.js
/npm/esbuild-wasm/esbuild.wasm
/npm/esbuild-wasm/esm/
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
The ECMAScript 2024 specification was just approved, so it has been added to esbuild as a possible compilation target. You can read more about the features that it adds here: [https://2ality.com/2024/06/ecmascript-2024.html](https://2ality.com/2024/06/ecmascript-2024.html). The only addition that's relevant for esbuild is the regular expression `/v` flag. With `--target=es2024`, regular expressions that use the `/v` flag will now be passed through untransformed instead of being transformed into a call to `new RegExp`.
* Publish binaries for WASI (WebAssembly System Interface) preview 1 ([#3300](https://github.com/evanw/esbuild/issues/3300), [#3779](https://github.com/evanw/esbuild/pull/3779))
The upcoming WASI (WebAssembly System Interface) standard is going to be a way to run WebAssembly outside of a JavaScript host environment. In this scenario you only need a `.wasm` file without any supporting JavaScript code. Instead of JavaScript providing the APIs for the host environment, the WASI standard specifies a "system interface" that WebAssembly code can access directly (e.g. for file system access).
Development versions of the WASI specification are being released using preview numbers. The people behind WASI are currently working on preview 2 but the Go compiler has [released support for preview 1](https://go.dev/blog/wasi), which from what I understand is now considered an unsupported legacy release. However, some people have requested that esbuild publish binary executables that support WASI preview 1 so they can experiment with them.
This release publishes esbuild precompiled for WASI preview 1 to the `@esbuild/wasi-preview1` package on npm (specifically the file `@esbuild/wasi-preview1/esbuild.wasm`). This binary executable has not been tested and won't be officially supported, as it's for an old preview release of a specification that has since moved in another direction. If it works for you, great! If not, then you'll likely have to wait for the ecosystem to evolve before using esbuild with WASI. For example, it sounds like perhaps WASI preview 1 doesn't include support for opening network sockets so esbuild's local development server is unlikely to work with WASI preview 1.
* Warn about `onResolve` plugins not setting a path ([#3790](https://github.com/evanw/esbuild/issues/3790))
Plugins that return values from `onResolve` without resolving the path (i.e. without setting either `path` or `external: true`) will now cause a warning. This is because esbuild only uses return values from `onResolve` if it successfully resolves the path, and it's not good for invalid input to be silently ignored.
Expand Down
15 changes: 13 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ platform-all:
platform-neutral \
platform-openbsd-x64 \
platform-sunos-x64 \
platform-wasi-preview1 \
platform-wasm \
platform-win32-arm64 \
platform-win32-ia32 \
Expand All @@ -323,6 +324,10 @@ platform-win32-arm64: version-go
node scripts/esbuild.js npm/@esbuild/win32-arm64/package.json --version
CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build $(GO_FLAGS) -o npm/@esbuild/win32-arm64/esbuild.exe ./cmd/esbuild

platform-wasi-preview1: version-go
node scripts/esbuild.js npm/@esbuild/wasi-preview1/package.json --version
CGO_ENABLED=0 GOOS=wasip1 GOARCH=wasm go build $(GO_FLAGS) -o npm/@esbuild/wasi-preview1/esbuild.wasm ./cmd/esbuild

platform-unixlike: version-go
@test -n "$(GOOS)" || (echo "The environment variable GOOS must be provided" && false)
@test -n "$(GOARCH)" || (echo "The environment variable GOARCH must be provided" && false)
Expand Down Expand Up @@ -428,7 +433,7 @@ publish-all: check-go-version
publish-win32-x64 \
publish-win32-ia32 \
publish-win32-arm64 \
publish-sunos-x64
publish-wasi-preview1

@echo Enter one-time password:
@read OTP && OTP="$$OTP" $(MAKE) --no-print-directory -j4 \
Expand Down Expand Up @@ -462,7 +467,8 @@ publish-all: check-go-version
@read OTP && OTP="$$OTP" $(MAKE) --no-print-directory -j4 \
publish-aix-ppc64 \
publish-linux-ppc64 \
publish-linux-s390x
publish-linux-s390x \
publish-sunos-x64

# Do these last to avoid race conditions
@echo Enter one-time password:
Expand All @@ -483,6 +489,9 @@ publish-win32-ia32: platform-win32-ia32
publish-win32-arm64: platform-win32-arm64
test -n "$(OTP)" && cd npm/@esbuild/win32-arm64 && npm publish --otp="$(OTP)"

publish-wasi-preview1: platform-wasi-preview1
test -n "$(OTP)" && cd npm/@esbuild/wasi-preview1 && npm publish --otp="$(OTP)"

publish-aix-ppc64: platform-aix-ppc64
test -n "$(OTP)" && cd npm/@esbuild/aix-ppc64 && npm publish --otp="$(OTP)"

Expand Down Expand Up @@ -604,6 +613,7 @@ validate-builds:
@$(MAKE) --no-print-directory TARGET=platform-netbsd-x64 SCOPE=@esbuild/ PACKAGE=netbsd-x64 SUBPATH=bin/esbuild validate-build
@$(MAKE) --no-print-directory TARGET=platform-openbsd-x64 SCOPE=@esbuild/ PACKAGE=openbsd-x64 SUBPATH=bin/esbuild validate-build
@$(MAKE) --no-print-directory TARGET=platform-sunos-x64 SCOPE=@esbuild/ PACKAGE=sunos-x64 SUBPATH=bin/esbuild validate-build
@$(MAKE) --no-print-directory TARGET=platform-wasi-preview1 SCOPE=@esbuild/ PACKAGE=wasi-preview1 SUBPATH=esbuild.wasm validate-build
@$(MAKE) --no-print-directory TARGET=platform-wasm PACKAGE=esbuild-wasm SUBPATH=esbuild.wasm validate-build
@$(MAKE) --no-print-directory TARGET=platform-win32-arm64 SCOPE=@esbuild/ PACKAGE=win32-arm64 SUBPATH=esbuild.exe validate-build
@$(MAKE) --no-print-directory TARGET=platform-win32-ia32 SCOPE=@esbuild/ PACKAGE=win32-ia32 SUBPATH=esbuild.exe validate-build
Expand All @@ -613,6 +623,7 @@ clean:
go clean -cache
go clean -testcache
rm -f esbuild
rm -f npm/@esbuild/wasi-preview1/esbuild.wasm
rm -f npm/@esbuild/win32-arm64/esbuild.exe
rm -f npm/@esbuild/win32-ia32/esbuild.exe
rm -f npm/@esbuild/win32-x64/esbuild.exe
Expand Down
3 changes: 3 additions & 0 deletions npm/@esbuild/wasi-preview1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# esbuild

This is the WASI (WebAssembly System Interface) preview 1 binary for esbuild, a JavaScript bundler and minifier. See https://github.com/evanw/esbuild for details.
10 changes: 10 additions & 0 deletions npm/@esbuild/wasi-preview1/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "@esbuild/wasi-preview1",
"version": "0.21.5",
"description": "The WASI (WebAssembly System Interface) preview 1 binary for esbuild, a JavaScript bundler.",
"repository": {
"type": "git",
"url": "git+https://github.com/evanw/esbuild.git"
},
"license": "MIT"
}

0 comments on commit b722000

Please sign in to comment.