Skip to content

Commit

Permalink
Migrate to bun and wasi-sdk 25 (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
anuraaga authored Feb 7, 2025
1 parent 4b55bc2 commit 3c16253
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 378 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ on:

jobs:
build:
uses: wasilibs/actions/.github/workflows/ci.yaml@4f1fc34b105780b451ecf7f5bf7834c495f6c23c
uses: wasilibs/actions/.github/workflows/ci.yaml@3a74924c1d1fdcf313557c374a13a102a4614a25
secrets: inherit
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ permissions:

jobs:
release:
uses: wasilibs/actions/.github/workflows/release.yaml@4f1fc34b105780b451ecf7f5bf7834c495f6c23c
uses: wasilibs/actions/.github/workflows/release.yaml@3a74924c1d1fdcf313557c374a13a102a4614a25
secrets: inherit
4 changes: 2 additions & 2 deletions .github/workflows/update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ permissions:

jobs:
build:
uses: wasilibs/actions/.github/workflows/update-node.yaml@4f1fc34b105780b451ecf7f5bf7834c495f6c23c
uses: wasilibs/actions/.github/workflows/update-node.yaml@3a74924c1d1fdcf313557c374a13a102a4614a25
with:
packages: "@connectrpc/*"
packages: "@connectrpc/protoc-gen-connect-query"
secrets: inherit
17 changes: 7 additions & 10 deletions buildtools/wasm/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
FROM node:20-bookworm AS buildjs
FROM oven/bun:1-alpine AS buildjs

WORKDIR /app

RUN corepack enable

COPY buildtools/wasm/package.json buildtools/wasm/pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
COPY buildtools/wasm/*.mjs ./
COPY buildtools/wasm/package.json buildtools/wasm/bun.lock ./
RUN bun install --frozen-lockfile --production
COPY buildtools/wasm/*.ts ./
COPY buildtools/wasm/tsconfig.json ./
RUN pnpm run build
RUN bun run build

FROM ghcr.io/webassembly/wasi-sdk:wasi-sdk-21
FROM ghcr.io/webassembly/wasi-sdk:wasi-sdk-25

RUN apt-get update && apt-get install -y binaryen curl patch xz-utils

Expand All @@ -22,14 +19,14 @@ RUN make install
RUN make clean
COPY buildtools/wasm/patch-quickjs.txt ./
RUN patch -p1 < patch-quickjs.txt
ENV CUSTOM_CFLAGS $CFLAGS -DEMSCRIPTEN -D_WASI_EMULATED_SIGNAL
ENV CUSTOM_CFLAGS $CFLAGS -O3 -DEMSCRIPTEN -D_WASI_EMULATED_SIGNAL
RUN make libquickjs.a
RUN $RANLIB libquickjs.a

WORKDIR /app
COPY --from=buildjs /app/dist/protoc-gen-connect-query.js ./
RUN qjsc -e protoc-gen-connect-query.js -o protoc-gen-connect-query.c
RUN $CC $CFLAGS -O2 -o protoc-gen-connect-query-noopt.wasm protoc-gen-connect-query.c -lquickjs -I/usr/local/include/quickjs -L/quickjs -Wl,--global-base=1024
RUN $CC $CFLAGS -O3 -o protoc-gen-connect-query-noopt.wasm protoc-gen-connect-query.c -lquickjs -I/usr/local/include/quickjs -L/quickjs -Wl,--global-base=1024
RUN wasm-opt -o protoc-gen-connect-query.wasm --low-memory-unused --flatten --rereloop --converge -O3 protoc-gen-connect-query-noopt.wasm

CMD [ "cp", "protoc-gen-connect-query.wasm", "/out"]
44 changes: 44 additions & 0 deletions buildtools/wasm/bun.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"lockfileVersion": 1,
"workspaces": {
"": {
"name": "wasm",
"dependencies": {
"@bufbuild/protobuf": "2.2.3",
"@bufbuild/protoplugin": "2.2.3",
"@connectrpc/protoc-gen-connect-query": "2.0.0",
},
"devDependencies": {
"@types/node": "^22.13.1",
"@types/quickjs": "github:Gottox/quickjs-dts",
"prettier": "^3.4.2",
"typescript": "^5.7.2",
},
},
},
"packages": {
"@bufbuild/protobuf": ["@bufbuild/protobuf@2.2.3", "", {}, "sha512-tFQoXHJdkEOSwj5tRIZSPNUuXK3RaR7T1nUrPgbYX1pUbvqqaaZAsfo+NXBPsz5rZMSKVFrgK1WL8Q/MSLvprg=="],

"@bufbuild/protoplugin": ["@bufbuild/protoplugin@2.2.3", "", { "dependencies": { "@bufbuild/protobuf": "2.2.3", "@typescript/vfs": "^1.5.2", "typescript": "5.4.5" } }, "sha512-UsV7mj6NJTZrqIYJK+jNFnnj5tOS7wgNXKyMjebFEpf+OX6pfXE+nx+QPjumOfu4GxdVPfEDnKuwISgqlXSQqw=="],

"@connectrpc/protoc-gen-connect-query": ["@connectrpc/protoc-gen-connect-query@2.0.0", "", { "dependencies": { "@bufbuild/protobuf": "^2.2.1", "@bufbuild/protoplugin": "^2.2.1" }, "peerDependencies": { "@bufbuild/protoc-gen-es": "2.x" }, "optionalPeers": ["@bufbuild/protoc-gen-es"], "bin": { "protoc-gen-connect-query": "bin/protoc-gen-connect-query" } }, "sha512-19L2C+E2JKmt+ZRXj0L2B/htCAJGLPDkg8p9zm0BNgAFaXRmAFiPE1yoozvX6QUVo4JvbEeHWBgoB566/ryN+w=="],

"@types/node": ["@types/node@22.13.1", "", { "dependencies": { "undici-types": "~6.20.0" } }, "sha512-jK8uzQlrvXqEU91UxiK5J7pKHyzgnI1Qnl0QDHIgVGuolJhRb9EEl28Cj9b3rGR8B2lhFCtvIm5os8lFnO/1Ew=="],

"@types/quickjs": ["@types/quickjs@github:Gottox/quickjs-dts#c4bbd81", {}, "Gottox-quickjs-dts-c4bbd81"],

"@typescript/vfs": ["@typescript/vfs@1.6.1", "", { "dependencies": { "debug": "^4.1.1" }, "peerDependencies": { "typescript": "*" } }, "sha512-JwoxboBh7Oz1v38tPbkrZ62ZXNHAk9bJ7c9x0eI5zBfBnBYGhURdbnh7Z4smN/MV48Y5OCcZb58n972UtbazsA=="],

"debug": ["debug@4.4.0", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA=="],

"ms": ["ms@2.1.3", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="],

"prettier": ["prettier@3.4.2", "", { "bin": { "prettier": "bin/prettier.cjs" } }, "sha512-e9MewbtFo+Fevyuxn/4rrcDAaq0IYxPGLvObpQjiZBMAzB9IGmzlnG9RZy3FFas+eBMu2vA0CszMeduow5dIuQ=="],

"typescript": ["typescript@5.7.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw=="],

"undici-types": ["undici-types@6.20.0", "", {}, "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg=="],

"@bufbuild/protoplugin/typescript": ["typescript@5.4.5", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ=="],
}
}
File renamed without changes.
12 changes: 7 additions & 5 deletions buildtools/wasm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
"description": "",
"type": "module",
"scripts": {
"build": "mkdir -p dist && esbuild --external:std --bundle protoc-gen-connect-query.ts --format=esm | node hoist-imports.mjs > dist/protoc-gen-connect-query.js"
"build": "mkdir -p dist && bun build --external std protoc-gen-connect-query.ts | bun run hoist-imports.ts > dist/protoc-gen-connect-query.js"
},
"keywords": [],
"author": "",
"license": "MIT",
"packageManager": "pnpm@8.14.1",
"devDependencies": {
"packageManager": "bun@1.2.2",
"dependencies": {
"@bufbuild/protobuf": "2.2.3",
"@bufbuild/protoplugin": "2.2.3",
"@connectrpc/protoc-gen-connect-query": "2.0.1",
"@connectrpc/protoc-gen-connect-query": "2.0.0"
},
"devDependencies": {
"@types/quickjs": "github:Gottox/quickjs-dts",
"esbuild": "^0.24.0",
"@types/node": "^22.13.1",
"prettier": "^3.4.2",
"typescript": "^5.7.2"
}
Expand Down
Loading

0 comments on commit 3c16253

Please sign in to comment.