Skip to content

Latest commit

 

History

History
241 lines (168 loc) · 9.11 KB

File metadata and controls

241 lines (168 loc) · 9.11 KB

TS Proto

Guide

Reference

Starlark reference

Install

WORKSPACE.bazel

Add ts-proto as an external dependency.

Configure

BUILD.bazel

load("@better_rules_javascript//protobuf:rules.bzl", "js_protoc")

package(default_visibility = ["//visibility:public"])

cjs_root(
    descriptor = "proto.package.json",
    name = "proto_root",
    package_name = "@better_rules_javascript_test/proto"
)

js_protoc(
    name = "js_protoc",
    root = ":proto_root",
    runtime = "@npm//google-protobuf:lib",
)

package.json

{}

rules.bzl

load("@better_rules_javascript//ts-proto:aspects.bzl", "js_proto_aspect")
load("@better_rules_javascript//ts-proto:rules.bzl", "js_proto_library_rule")

js_proto = js_proto_aspect("@better_rules_javascript_test//:lib_protoc")

js_proto_library = js_proto_library_rule(js_proto)

Use

load("@rules_proto//proto:defs.bzl", "proto_library")
load("//:rules.bzl", "js_proto_library")

proto_library(
    name = "proto",
    srcs = glob(["**/*.proto"]),
)

js_proto_library(
    name = "js",
    dep = ":proto",
)

//ts-proto:providers.bzl

TsProtoInfo

TsProtoInfo(transitive_libs)

TS proto info

FIELDS

Name Description
transitive_libs Transitive libraries

TsProtobuf

TsProtobuf(bin, tsc, deps_cjs, deps_js, deps_ts, options)

TypeScript Protobuf compiler

FIELDS

Name Description
bin Plugin
tsc TypeScript compiler
deps_cjs List of CjsInfo
deps_js List of JsInfo
deps_ts List of TsInfo
options Options

TsProtosInfo

TsProtosInfo(cjs, js, ts, default)

FIELDS

Name Description
cjs Dict of CjsInfo by label
js Dict of JsInfo by label
ts Dict of TsInfo by label
default Dict of DefaultInfo by label

create_lib

create_lib(label, path, files, deps)
Create library struct

PARAMETERS

Name Description Default Value
label Label none
path Directory path none
files List of TypeScript files none
deps Labels of dependencies none

//ts-proto:rules.bzl

ts_proto_export

ts_proto_export(name, dep, lib)

TypeScript protobuf library

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required
dep - Label optional None
lib - Label optional None

ts_protoc

ts_protoc(name, bin, deps, options, tsc)

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required
bin Protoc plugin Label required
deps Dependencies List of labels required
options - List of strings optional []
tsc TypeScript compiler Label required

configure_ts_protoc

configure_ts_protoc(name, tsc, ts_proto, deps, options, visibility)

PARAMETERS

Name Description Default Value
name

-

none
tsc

-

none
ts_proto

-

none
deps

-

none
options

-

[]
visibility

-

None

ts_proto_libraries_rule

ts_proto_libraries_rule(aspect, compiler)

PARAMETERS

Name Description Default Value
aspect

-

none
compiler

-

none