Skip to content

Commit 431c2f9

Browse files
authored
Simplify NodeJS proto compilation (#93)
## What is the goal of this PR? Simplify the `genrule` that builds our protocol for Typescript ## What are the changes implemented in this PR? * Move `//protobuf:proto-raw-buffers` into `srcs` since this is what they are * Remove symlinking `node_modules` - not needed * `dirname $(execpath //:WORKSPACE)` always evaluates to `.` (since `WORKSPACE` is a top-level file)
1 parent 17dfece commit 431c2f9

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

grpc/nodejs/BUILD

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,32 +63,29 @@ genrule(
6363
"protobuf/transaction_pb.js",
6464
],
6565
# The below command performs a protoc compilation of our proto files into typescript and javascript. Line by line:
66-
# Symlink the node modules required by the typescript plugin into the directory the command will be run from
6766
# Run the node.js protoc (protocol compiler) with the following flags:
6867
# Use the gen-ts plugin to generate typescript declaration files in addition to javascript
6968
# Output javascript with commonjs style exports, to the genrule output directory.
7069
# Output services to the genrule output directory (without this line, grakn_grpc_pb is omitted)
7170
# Output typescript to (you guessed it) the genrule output directory
72-
# Set the .proto file relative path to the WORKSPACE this command is being run from
71+
# Set the .proto file relative path to root folder (same as where WORKSPACE resides)
7372
# Use the .proto files found in the :proto-raw-buffers filegroup as inputs.
74-
cmd = "ln -s $(execpath //grpc/nodejs:protoc-gen-ts).runfiles/npm/node_modules ./node_modules ;\
75-
$(execpath //grpc/nodejs:grpc_tools_node_protoc) \
73+
cmd = "$(execpath //grpc/nodejs:grpc_tools_node_protoc) \
7674
--plugin='protoc-gen-ts=$(rootpath @npm//:node_modules/grpc_tools_node_protoc_ts/bin/protoc-gen-ts)' \
7775
--js_out='import_style=commonjs,binary:./$(@D)/' \
7876
--grpc_out='grpc_js:./$(@D)/' \
7977
--ts_out='grpc_js:./$(@D)/' \
80-
--proto_path=`dirname $(execpath //:WORKSPACE)` \
78+
--proto_path=. \
8179
$(execpaths //protobuf:proto-raw-buffers);",
82-
# Dependencies for the above command. the //:WORKSPACE label is required to locate the relative path for the .proto files so they can import each other.
8380
tools = [
8481
"//grpc/nodejs:grpc_tools_node_protoc",
85-
"//grpc/nodejs:protoc-gen-ts",
8682
"@npm//:node_modules/grpc_tools_node_protoc_ts/bin/protoc-gen-ts",
8783
"@npm//grpc_tools_node_protoc_ts",
8884
"@npm//google-protobuf",
89-
"//protobuf:proto-raw-buffers",
90-
"//:WORKSPACE"
9185
],
86+
srcs = [
87+
"//protobuf:proto-raw-buffers",
88+
]
9289
)
9390

9491
pkg_npm(

0 commit comments

Comments
 (0)