rules_js icon indicating copy to clipboard operation
rules_js copied to clipboard

[Bug]: ts-protoc-gen package isn't generating a package_json.bzl even though it looks like it should

Open cfife-btig opened this issue 1 year ago • 3 comments

What happened?

While working on a patch file to get rules_proto_grpc to be compatible with rules_js, I was needing to change the rule for the ts-protoc-gen library (I am using ts-protoc-gen: 0.15.0).

It seems that rules_js registers that it is a binary. For example, the hasBin attribute in my pnpm-lock file is true. Likewise, I can see that the @npm external repository has the package ts-protoc-gen and that @npm//ts-protoc-gen/package_json.bzl does exist. The problem is that the non-syntactic-sugar ts-protoc-gen external repository (AKA @npm__ts-protoc-gen__0.15.0 does not generate it's own package_json file. So I can't get or execute the bin object.

If I try to load("@npm//:ts-protoc-gen/package_json.bzl", ts_bin = "bin"), it will complain with an error like the following

Skipping 'components/ui/proto:proto_grpc_web': error loading package 'components/ui/proto': at /root/.cache/bazel/_bazel_root/cbb1cba52c589b25ddeaba98ec308a80/external/rules_proto_grpc/js/defs.bzl:11:6: at /root/.cache/bazel/_bazel_root/cbb1cba52c589b25ddeaba98ec308a80/external/npm/ts-protoc-gen/package_json.bzl:1:6: cannot load '@npm__ts-protoc-gen__0.15.0//:package_json.bzl': no such file

Version

Development (host) and target OS/architectures:

I am running docker inside of windows. My host and target are the same.

Architecture: x86_64 Host OS: Windows 10 Docker OS: Ubuntu 20

Output of bazel --version:

Bazel 6.3.0

Version of the Aspect rules, or other relevant rules from your WORKSPACE or MODULE.bazel file:

rules_js-1.31.0 rules_proto_grpc-4.4.0 Npm package - ts-protoc-gen: 0.15.0

Language(s) and/or frameworks involved: rules_js rules_proto_grpc (which in turn, needs uses the npm package ts-protoc-gen)

How to reproduce

I think a good starting point would be to include ts-protoc-gen in your package.json file. Run something like `link_all_node_modules`. Then check the external repository `npm__ts-protoc-gen__0.15.0` and the external repository `npm`.

If `npm` has a package_json.bzl file, but `npm__ts-protoc-gen__0.15.0` doesn't. Then you have reproduced my issue.

Any other information?

No response

cfife-btig avatar Aug 31 '23 18:08 cfife-btig

I haven't been able to completely confirm it, because I'm fighting with getting the pnpm patching feature to work through bazel, but it seems more and more likely that the issue is because there is a windows .cmd file in the ts-protoc-gen bin directory

cfife-btig avatar Sep 01 '23 00:09 cfife-btig

it's been hard to confirm this because it's been difficult to make a patch file that removes a .cmd file due to #1132

cfife-btig avatar Sep 05 '23 22:09 cfife-btig

Thanks for the clue about .cmd in the package...

alexeagle avatar Sep 19 '23 00:09 alexeagle