Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: rework internal protocol typing #348

Merged
merged 1 commit into from
May 31, 2022

Conversation

pvlugter
Copy link
Member

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 generated protobufjs 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 using proto-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 separate types 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 accessing package.json and config.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 maps src to dist directly. Package still includes source maps and sources — which will allow for stack traces with ts 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:

=== Tarball Details ===
name:          @kalix-io/kalix-javascript-sdk
version:       1.0.0-M8
package size:  996.0 kB
unpacked size: 14.4 MB
total files:   471

After these changes:

=== Tarball Details ===
name:          @kalix-io/kalix-javascript-sdk
version:       0.0.0
package size:  160.4 kB
unpacked size: 841.6 kB
total files:   181

Copy link
Contributor

@johanandren johanandren left a comment

Choose a reason for hiding this comment

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

LGTM!

@johanandren johanandren merged commit 2efb8c3 into lightbend:main May 31, 2022
@pvlugter pvlugter deleted the protocol branch May 31, 2022 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kalix-runtime Runtime and SDKs sub-team typescript-sdk
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Internal static SDK protocol
2 participants