diff --git a/.gitignore b/.gitignore index 165a7f9ae6..9a5e8f7271 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ dist/ deno assets.go msg.pb.go +msg.pb.js +msg.pb.d.ts diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..5cd8b9c150 --- /dev/null +++ b/Makefile @@ -0,0 +1,29 @@ +deno: assets.go msg.pb.go main.go + go build -o deno + +assets.go: dist/main.js + go-bindata -pkg main -o assets.go dist/ + +msg.pb.go: msg.proto + protoc --go_out=. msg.proto + +msg.pb.js: msg.proto node_modules + ./node_modules/.bin/pbjs -t static-module -w commonjs -o msg.pb.js msg.proto + +msg.pb.d.ts: msg.pb.js node_modules + ./node_modules/.bin/pbts -o msg.pb.d.ts msg.pb.js + +dist/main.js: main.ts msg.pb.js msg.pb.d.ts node_modules + ./node_modules/.bin/parcel build --out-dir=dist/ --no-minify main.ts + +node_modules: + yarn + +clean: + -rm -f deno assets.go msg.pb.go msg.pb.js msg.pb.d.ts + -rm -rf dist/ + +distclean: clean + -rm -rf node_modules/ + +.PHONY: clean distclean diff --git a/main.go b/main.go index fc69fee599..3ee79fb6bd 100644 --- a/main.go +++ b/main.go @@ -1,9 +1,5 @@ package main -//go:generate protoc --go_out=. msg.proto -//go:generate ./node_modules/.bin/parcel build --out-dir=dist/ --no-minify main.ts -//go:generate go-bindata -pkg $GOPACKAGE -o assets.go dist/ - import ( "github.com/golang/protobuf/proto" "github.com/ry/v8worker2" diff --git a/main.ts b/main.ts index 38044b3d82..9071c2fcd7 100644 --- a/main.ts +++ b/main.ts @@ -1,7 +1,10 @@ import * as ts from "typescript"; +import { main as pb } from "./msg.pb" V8Worker2.recv((ab: ArrayBuffer) { + let msg = pb.Msg.decode(new Uint8Array(ab)); V8Worker2.print("Got array buffer", ab.byteLength); + V8Worker2.print("msg.argv", msg.argv); }); V8Worker2.print("Hello");