Skip to content

Commit b722000

Browse files
committed
fix #3300, fix #3779: add @esbuild/wasi-preview1
1 parent 6679ec8 commit b722000

File tree

5 files changed

+35
-2
lines changed

5 files changed

+35
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
/npm/@esbuild/android-x64/esbuild.wasm
1414
/npm/@esbuild/android-x64/wasm_exec_node.js
1515
/npm/@esbuild/android-x64/wasm_exec.js
16+
/npm/@esbuild/wasi-preview1/esbuild.wasm
1617
/npm/esbuild-wasm/browser.js
1718
/npm/esbuild-wasm/esbuild.wasm
1819
/npm/esbuild-wasm/esm/

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@
3232
3333
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`.
3434
35+
* 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))
36+
37+
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).
38+
39+
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.
40+
41+
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.
42+
3543
* Warn about `onResolve` plugins not setting a path ([#3790](https://github.com/evanw/esbuild/issues/3790))
3644
3745
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.

Makefile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ platform-all:
306306
platform-neutral \
307307
platform-openbsd-x64 \
308308
platform-sunos-x64 \
309+
platform-wasi-preview1 \
309310
platform-wasm \
310311
platform-win32-arm64 \
311312
platform-win32-ia32 \
@@ -323,6 +324,10 @@ platform-win32-arm64: version-go
323324
node scripts/esbuild.js npm/@esbuild/win32-arm64/package.json --version
324325
CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build $(GO_FLAGS) -o npm/@esbuild/win32-arm64/esbuild.exe ./cmd/esbuild
325326

327+
platform-wasi-preview1: version-go
328+
node scripts/esbuild.js npm/@esbuild/wasi-preview1/package.json --version
329+
CGO_ENABLED=0 GOOS=wasip1 GOARCH=wasm go build $(GO_FLAGS) -o npm/@esbuild/wasi-preview1/esbuild.wasm ./cmd/esbuild
330+
326331
platform-unixlike: version-go
327332
@test -n "$(GOOS)" || (echo "The environment variable GOOS must be provided" && false)
328333
@test -n "$(GOARCH)" || (echo "The environment variable GOARCH must be provided" && false)
@@ -428,7 +433,7 @@ publish-all: check-go-version
428433
publish-win32-x64 \
429434
publish-win32-ia32 \
430435
publish-win32-arm64 \
431-
publish-sunos-x64
436+
publish-wasi-preview1
432437

433438
@echo Enter one-time password:
434439
@read OTP && OTP="$$OTP" $(MAKE) --no-print-directory -j4 \
@@ -462,7 +467,8 @@ publish-all: check-go-version
462467
@read OTP && OTP="$$OTP" $(MAKE) --no-print-directory -j4 \
463468
publish-aix-ppc64 \
464469
publish-linux-ppc64 \
465-
publish-linux-s390x
470+
publish-linux-s390x \
471+
publish-sunos-x64
466472

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

492+
publish-wasi-preview1: platform-wasi-preview1
493+
test -n "$(OTP)" && cd npm/@esbuild/wasi-preview1 && npm publish --otp="$(OTP)"
494+
486495
publish-aix-ppc64: platform-aix-ppc64
487496
test -n "$(OTP)" && cd npm/@esbuild/aix-ppc64 && npm publish --otp="$(OTP)"
488497

@@ -604,6 +613,7 @@ validate-builds:
604613
@$(MAKE) --no-print-directory TARGET=platform-netbsd-x64 SCOPE=@esbuild/ PACKAGE=netbsd-x64 SUBPATH=bin/esbuild validate-build
605614
@$(MAKE) --no-print-directory TARGET=platform-openbsd-x64 SCOPE=@esbuild/ PACKAGE=openbsd-x64 SUBPATH=bin/esbuild validate-build
606615
@$(MAKE) --no-print-directory TARGET=platform-sunos-x64 SCOPE=@esbuild/ PACKAGE=sunos-x64 SUBPATH=bin/esbuild validate-build
616+
@$(MAKE) --no-print-directory TARGET=platform-wasi-preview1 SCOPE=@esbuild/ PACKAGE=wasi-preview1 SUBPATH=esbuild.wasm validate-build
607617
@$(MAKE) --no-print-directory TARGET=platform-wasm PACKAGE=esbuild-wasm SUBPATH=esbuild.wasm validate-build
608618
@$(MAKE) --no-print-directory TARGET=platform-win32-arm64 SCOPE=@esbuild/ PACKAGE=win32-arm64 SUBPATH=esbuild.exe validate-build
609619
@$(MAKE) --no-print-directory TARGET=platform-win32-ia32 SCOPE=@esbuild/ PACKAGE=win32-ia32 SUBPATH=esbuild.exe validate-build
@@ -613,6 +623,7 @@ clean:
613623
go clean -cache
614624
go clean -testcache
615625
rm -f esbuild
626+
rm -f npm/@esbuild/wasi-preview1/esbuild.wasm
616627
rm -f npm/@esbuild/win32-arm64/esbuild.exe
617628
rm -f npm/@esbuild/win32-ia32/esbuild.exe
618629
rm -f npm/@esbuild/win32-x64/esbuild.exe

npm/@esbuild/wasi-preview1/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# esbuild
2+
3+
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.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "@esbuild/wasi-preview1",
3+
"version": "0.21.5",
4+
"description": "The WASI (WebAssembly System Interface) preview 1 binary for esbuild, a JavaScript bundler.",
5+
"repository": {
6+
"type": "git",
7+
"url": "git+https://github.com/evanw/esbuild.git"
8+
},
9+
"license": "MIT"
10+
}

0 commit comments

Comments
 (0)