Skip to content

Conversation

@makiuchi-d
Copy link
Member

Goのprotobufを更新したらgopherjs(go v1.19)ではビルドできなくなってしまいました。
gopherjsの更新が遅いことと、Go本体がwasmをサポートし始めたことから、gopherjsの部分をwasmに置き換えてみました。

wasmを利用するにはcommonjsではなくesmoduleにする必要があり、
dashboardのbackendを結構書き換えることになりました……

serverの変更内容

  • go、ライブラリ、ツール類の更新
  • 非推奨になった関数の置き換え

dashboardのbackendの変更内容

  • gopherjs利用部分をwasmに置き換え
    • go-binary/main.go を wasm 用に修正
    • src/plugins/binary.js, binary.d.ts をwasm呼び出し用に手書き
      • wasmが扱える型の制限のため、json文字列として返す
    • GitHub Actions修正
  • tscの設定をcommonjsからesmoduleに変更
    • import文をesmの形式に(拡張子必須、ディレクトリ指定不可、など)
    • protoc-gen-ts から protoc-gen-es に変更
    • 生成される型の相違点を修正
    • gRPCクライアントライブラリをgrpc-jsからconnectrpcに変更
    • apolloサーバを更新
  • prismaも更新
    • openssl絡みで動かなくなったので

cjsとesmの違いをきちんとは理解できていないので、なにか変なことしていたら指摘おねがいします


func (s *grpcServer) Dial() (*grpc.ClientConn, error) {
return grpc.Dial(fmt.Sprintf("%s:%d", s.Host, s.Port),
return grpc.NewClient(fmt.Sprintf("%s:%d", s.Host, s.Port),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@makiuchi-d makiuchi-d requested a review from methane December 24, 2024 05:59
publicProps: binary.Unmarshaled;
privateProps: binary.Unmarshaled;
created: Timestamp.AsObject | undefined;
created: string | undefined;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Timestamp型が内部でunixtimeをBigInt型で持っているために
そのままではJSONエンコードできないので文字列として返すようにしました。
この値はfrontendでは使っていないです。

Copy link
Member

@methane methane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JS部分はよくわからないけれどGo部分はOKです。

Copy link
Collaborator

@superkerokero superkerokero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wasmとjavascript部分のコードを確認済み。
wasmの方がメンテナンスとパフォーマンス観点で優れているのでありがたいです👍
ご対応ありがとうございます🙇

@KLab KLab deleted a comment from ourenji Dec 25, 2024
@makiuchi-d
Copy link
Member Author

toplevel awaitを使っているのにtsconfigのtargetがes2020だったのでes2022に直しました。
ほかは変えていないのでマージしてしまいます。

@makiuchi-d makiuchi-d merged commit c292844 into main Dec 25, 2024
4 checks passed
@makiuchi-d makiuchi-d deleted the update-go-and-libs branch December 25, 2024 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants