aspect-build / aspect-build/rules_js

[Question]: How to use js_grpc_node_library with custom npm repo name

Open
#1,004 3 comments 1 reaction 0 assignees View on GitHub
enhancement need: more info
Dominant language
Starlark
Stars
378
Forks
183
Avg merge
1d 9h
Merged PRs (30d)
32

Description

I'm using rules_js, my `WORKSPACE` declares a custom name for the npm repo:

```
npm_translate_lock(
name = "custom_npm",
)
```

I'm also using https://github.com/rules-proto-grpc/rules_proto_grpc , my `BUILD` file looks like this:

```
proto_library(
name = "api_proto",
srcs = ["api.proto"],
)

js_grpc_node_library(
name = "protos_js",
protos = [":api_proto"],
)
```

Adding `deps_repo="@custom_npm"` doesn't work because the dep is looked up at `@custom_npm//@grpc/grpc-js` which I believe is correct when using the old and now unmaintained `rules_nodejs`, but when using the newer `rules_js` the dep is placed instead at `@custom_npm//:node_modules/@grpc/grpc-js` (per docs https://docs-legacy.aspect.build/aspect-build/rules_js/v1.6.4/docs/npm_import-docgen.html#npm_translate_lock-link_workspace).

In `rules_proto_grpc` there's a string replacement taking place https://github.com/rules-proto-grpc/rules_proto_grpc/blob/bbb81931a510290127471b25d31b97e8211fa401/js/js_grpc_node_library.bzl#L22 that doesn't seem ameanable to working with the way `rules_js` declares the npm dependencies when using a custom repo name, unless there is some other trick I am missing, is there a way to make this work?

Contributor guide

Open the contributing guide

Research direction

Start with the WORKSPACE and BUILD examples, then inspect js/js_grpc_node_library.bzl at the linked string replacement and compare it with the rules_js npm_translate_lock documentation. Verify how @custom_npm labels are resolved for @grpc/grpc-js; done means determining whether the documented custom repository setup can work or identifying the required compatibility change.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.