Created
February 15, 2023 17:23
Revisions
-
lewish created this gist
Feb 15, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ load("@rules_proto_grpc//:defs.bzl", "proto_plugin") load("@npm//:@protobuf-ts/plugin/package_json.bzl", protobuf_ts_plugin = "bin") package(default_visibility = ["//visibility:public"]) protobuf_ts_plugin.protoc_gen_ts_binary( name = "protoc_gen_ts", ) proto_plugin( name = "protobuf-ts-plugin", outputs = [ "{protopath}.ts", ], tool = ":protoc_gen_ts", use_built_in_shell_environment = False, ) proto_plugin( name = "protobuf-ts-plugin-grpc", outputs = [ "{protopath}.client.ts", ], tool = ":protoc_gen_ts", use_built_in_shell_environment = False, ) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ typescript_proto_library( name = "protos_typescript_protos_ts", output_mode = "NO_PREFIX_FLAT", protos = [ ":protos_proto", ], ) ts_library( name = "protos_typescript_protos", srcs = [ ":protos_typescript_protos_ts", ], deps = [ "//:node_modules/@protobuf-ts/runtime", "//:node_modules/@protobuf-ts/runtime-rpc", "//google/protobuf:protobuf_typescript_protos", ], ) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ load( "@rules_proto_grpc//:defs.bzl", "ProtoPluginInfo", "proto_compile_attrs", "proto_compile_impl", ) def _ts_proto_compile_impl(ctx): base_env = { # Make up for https://github.com/bazelbuild/bazel/issues/15470. "BAZEL_BINDIR": ctx.bin_dir.path, } return proto_compile_impl(ctx, base_env = base_env) # Create compile rule typescript_proto_library = rule( implementation = _ts_proto_compile_impl, attrs = dict( proto_compile_attrs, _plugins = attr.label_list( providers = [ProtoPluginInfo], default = [ Label("//tools/protobuf-ts:protobuf-ts-plugin"), ], doc = "List of protoc plugins to apply", ), ), toolchains = [str(Label("@rules_proto_grpc//protobuf:toolchain_type"))], ) typescript_grpc_library = rule( implementation = _ts_proto_compile_impl, attrs = dict( proto_compile_attrs, _plugins = attr.label_list( providers = [ProtoPluginInfo], default = [ Label("//tools/protobuf-ts:protobuf-ts-plugin-grpc"), ], doc = "List of protoc plugins to apply", ), ), toolchains = [str(Label("@rules_proto_grpc//protobuf:toolchain_type"))], )