safanaj / svelte-go-only

Experiment with SvelteJS and Golang (with grpc-web)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

svelte-go-only

Experiment with SvelteJS and Golang (with grpc-web)

In this project I just want to learn how to use svelte.js / sveltekit and grpc-web using golang.

In this project I experiment a bit with embed also to make an executable that is self-contained (including html/css/js files).

This is heavily inspired by this demo: https://github.com/agrism/grpc-web-svelte

This project consists in a simple seltejs/sveltekit application (client side) that will communicate with the golang web server (server side) using gRPC, it builds a single self-contained executable.

Requirements

To build this project the below software has to be installed:

  • protoc (3.20.1), this package include:
    • protoc-gen-go (generate go files for types from proto files)
    • protoc-gen-js (generate js files for types from proto files)
  • protoc-gen-go-grpc (generate go files for services from proto files), install it with go install google.golang.org/grpc/cmd/protoc-gen-go-grpc
  • protoc-gen-ts (generate js files for service from proto files), install it with npm -g i @safanaj/ts-protoc-gen
  • sponge, utility used in the Makefile

Notes

The output of protoc-gen-js plugin is not ready for es6, so sveltekit and vitejs are not working to generate client-side JS code, for that reason a simple pythong script is provided to consistently "patch" the js files generated by protoc-gen-js.

Build and run

make build
./svelte-go-only

or

make start

About

Experiment with SvelteJS and Golang (with grpc-web)

License:GNU General Public License v3.0


Languages

Language:Svelte 41.1%Language:Go 30.5%Language:SCSS 8.0%Language:Makefile 7.3%Language:JavaScript 6.4%Language:Python 4.1%Language:HTML 2.6%