I took quite some substancial inspiration from this REPO.
npm install arrow-js-ffiCompiling from source
Unfortunately we cannot compile .protoc files to js with the original
protoc command from google. Thats why we use the official protobuf-javascript
library.
Prerequisites
- npm
- (bazel) -> If you want to play around with yourself compiling
Installation
npm install -g grpc-tools
npm install -g protoc-gen-grpc-webCompile the Protobuf file
Run this from the /proto directory of the Project
grpc_tools_node_protoc \
--js_out=import_style=commonjs:. \
--grpc-web_out=import_style=commonjs,mode=grpcwebtext:. \
Flight.protoOptional: If you hate yourself then use the flag closure instead of commonjs
If you want modern and with TS
grpc_tools_node_protoc \
--js_out=import_style=es6:. \
--grpc-web_out=import_style=es6,mode=grpcwebtext:. \
Flight.protoThis generates the Flight_grpc_web client file and the regular protobuf to js compilation.
Done.
# Compile the wasm code
cd wasm/go
GOOS=js GOARCH=wasm go build -o main.wasm
rm ../../public/main.wasm
mv main.wasm ../../publicThen serve....
Not in use in this project
# macos
brew tap tinygo-org/tools
brew install tinygocompile our wasm code:
GOOS=js GOARCH=wasm tinygo build -o wasm.wasm ./main.go
# Or like so:
tinygo build -o public/main.wasm -target wasm -opt z .npm build
npm start