chore: rework internal protocol typing #348
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #321
We're using
@grpc/proto-loader
to dynamically load the gRPC services and messages for the proxy protocol. In the TypeScript conversion, the protocols were typed using the generatedprotobufjs
types (which proto-loader builds on). But proto-loader can now also generate types, aligned with what will be loaded. Switch the protocol typing over to usingproto-loader-gen-types
.Just the discovery protocol was using a different approach, with statically generated services using
grpc-tools
. Revert this back to proto-loader, with all the typing provided now.Also update the build to use TypeScript sub-projects and project references.
proto-loader-gen-types
generates.ts
files, rather than just.d.ts
type declarations, so create a separatetypes
project for these so they can be just for development, only used in type positions — otherwise they can be pulled into the generated dist as well. This also tightens up which files can be referenced from sources — there's a sub-project just for accessingpackage.json
andconfig.json
, and tests are a separate sub-project as well.This also tidies up the dist and package building. The published package has been duplicating files (under root dir and
dist
dir), and including files that aren't needed, such as tests. TypeScript build now mapssrc
todist
directly. Package still includes source maps and sources — which will allow for stack traces withts
sources and easier debugging. Although it looks like many projects don't include these. Could also look at inlined source maps and sources.Package for the last release was:
After these changes: