Skip to content

Commit

Permalink
feat: code generation (#40)
Browse files Browse the repository at this point in the history
* add codegen and benchmark

* custom serialization

* pbjs is faster than vanilla serialization

* before ts-proto

* ts-proto

* remove logs

* remove generated code

* remove unused code generator

* remove commented code

* npm dedup

* remove dp
  • Loading branch information
menduz authored May 11, 2022
1 parent f898f02 commit 96cc733
Show file tree
Hide file tree
Showing 23 changed files with 1,135 additions and 585 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@ coverage
protoc3
src/protocol/*_pb.*
test/codegen/*_pb.*
test/codegen/*_pb.*
test/codegen/*_pb.*

**/*.log

src/protocol/index.ts
test/codegen/client.ts
23 changes: 13 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,15 @@ install_compiler:

install: install_compiler
npm install
npm i -D ts-protoc-gen
npm i -S google-protobuf@$(PROTOBUF_VERSION)
npm i -S @types/google-protobuf@latest

test:
${PROTOC} "--js_out=binary,import_style=commonjs_strict:$(PWD)/test/codegen" \
--ts_out="$(PWD)/test/codegen" \
${PROTOC} \
--plugin=./node_modules/.bin/protoc-gen-ts_proto \
--ts_proto_opt=esModuleInterop=true \
--ts_proto_out="$(PWD)/test/codegen" \
-I="$(PWD)/test/codegen" \
"$(PWD)/test/codegen/client.proto"
node_modules/.bin/jest --detectOpenHandles --colors --runInBand $(TESTARGS) --coverage
node_modules/.bin/jest --detectOpenHandles --colors --runInBand $(TESTARGS) --coverage $(TEST_FILE)

test-watch:
node_modules/.bin/jest --detectOpenHandles --colors --runInBand --watch $(TESTARGS) --coverage
Expand All @@ -49,14 +48,18 @@ build:
node_modules/.bin/ts-node scripts/generate-proto-file.ts
@rm -rf dist || true
@mkdir -p dist
${PROTOC} "--js_out=binary,import_style=commonjs_strict:$(PWD)/src/protocol" \
--ts_out="$(PWD)/src/protocol" \
${PROTOC} \
--plugin=./node_modules/.bin/protoc-gen-ts_proto \
--ts_proto_opt=esModuleInterop=true \
--ts_proto_out="$(PWD)/src/protocol" \
-I="$(PWD)/src/protocol" \
"$(PWD)/src/protocol/index.proto"
@echo 'exports.default = proto;' >> ./src/protocol/index_pb.js
@cp -r src/protocol dist/protocol
./node_modules/.bin/tsc -p tsconfig.json
rm -rf node_modules/@microsoft/api-extractor/node_modules/typescript || true
./node_modules/.bin/api-extractor run $(LOCAL_ARG) --typescript-compiler-folder ./node_modules/typescript

.PHONY: build test
cheap-perf:
@time node_modules/.bin/ts-node test/bench.ts

.PHONY: build test cheap-perf
Loading

0 comments on commit 96cc733

Please sign in to comment.