Skip to content

Commit

Permalink
fix ts_proto_library
Browse files Browse the repository at this point in the history
  • Loading branch information
thesayyn committed Jun 16, 2022
1 parent c8bc675 commit fb74474
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 28 deletions.
20 changes: 19 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"recharts": "^2.1.9",
"rollup-plugin-replace": "^2.2.0",
"rxjs": "^6.6.3",
"semver": "^7.1.2",

"tmp": "^0.2.0",
"tslib": "^2.1.0",
"typescript": "4.7.3",
Expand All @@ -71,5 +71,23 @@
},
"resolutions": {
"@types/react": "^16.8.17"
},
"pnpm": {
"packageExtensions": {
"protobufjs": {
"dependencies": {
"semver": "^7.1.2",
"chalk": "^4.0.0",
"glob": "^7.1.6",
"jsdoc": "^3.6.3",
"minimist":"^1.2.0",
"tmp":"^0.2.0",
"uglify-js":"^3.7.7",
"espree":"^7.0.0",
"escodegen":"^1.13.0",
"estraverse":"^5.1.0"
}
}
}
}
}
77 changes: 53 additions & 24 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions proto/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ load("@rules_proto//proto:defs.bzl", "ProtoInfo")
# Per Bazel semantics, all dependencies should be pre-declared.
# Note, you'll also need to install all of these in your package.json!
# (This should be fixed when we switch to protobufjs-cli)
# NOTE: this is unused since pnpm.packageExtensions in package.json fixes this right within build graph.
_PROTOBUFJS_CLI_DEPS = ["//:node_modules/%s" % s for s in [
"chalk",
"escodegen",
Expand Down Expand Up @@ -66,7 +67,9 @@ def ts_proto_library(name, proto, **kwargs):
# Transform .proto files to a single _pb.js file named after the macro
bin.pbjs(
name = js_target,
srcs = [":" + proto_target] + _PROTOBUFJS_CLI_DEPS,
srcs = [":" + proto_target],
copy_srcs_to_bin = False,
chdir = "../../../",
# Arguments documented at
# https://github.com/protobufjs/protobuf.js/tree/6.8.8#pbjs-for-javascript
args = [
Expand All @@ -75,15 +78,17 @@ def ts_proto_library(name, proto, **kwargs):
"--root=%s" % name,
"--strict-long", # Force usage of Long type with int64 fields
"--out=$@",
"$(execpaths %s)" % proto_target,
"$(locations %s)" % proto_target,
],
outs = [js_out],
)

# Transform the _pb.js file to a .d.ts file with TypeScript types
bin.pbts(
name = ts_target,
srcs = [js_target] + _PROTOBUFJS_CLI_DEPS,
srcs = [js_target],
copy_srcs_to_bin = False,
chdir = "../../../",
# Arguments documented at
# https://github.com/protobufjs/protobuf.js/tree/6.8.8#pbts-for-typescript
args = [
Expand Down

0 comments on commit fb74474

Please sign in to comment.