-
Notifications
You must be signed in to change notification settings - Fork 522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support pkg_npm() targets as dependencies for ts_library() #1967
Comments
I tried to do this in https://github.com/bazelbuild/rules_nodejs/pull/1898/files |
This issue has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs in two weeks. Collaborators can add a "cleanup" or "need: discussion" label to keep it open indefinitely. Thanks for your contributions to rules_nodejs! |
Decided that js_library is the right rule for this |
See #2187 |
🚀 feature request
Relevant Rules
ts_library() and pkg_npm()
Description
Currently, attempting to use a pkg_npm() target as a ts_library dependency results in an error of the form "<merged target //Foo/src:pkg> doesn't contain declared provider 'DeclarationInfo', even if the pkg_npm was originally itself generated in part from another ts_library() target. For example,
... foo/BUILD:
ts_library(
name = "foo_lib",
module_name = "@foo"
srcs = glob(["**/*.ts"])
)
filegroup(
name = "foo_static",
srcs = glob(["/*.json","/*.css"])
)
pkg_npm(
name = "foo",
package_name = "@foo",
srcs = [":foo_static"],
deps = [":foo_lib"]
)
... bar/BUILD:
ts_library(
name = "bar",
srcs = glob(["**/*.ts")
deps = ["//Foo:foo"]
)
Describe the solution you'd like
Ideally, pkg_npm() targets could be accepted as ts_library dependencies and treated the same as any imported node module. Our main use case for this is in libraries that bundle separate files (e.g. JSON, CSS, etc) along with TS code, where those files are resolved at runtime relative to the source files. Currently (pre-bazel) this is implemented by just copying all the additional files into the tsc build directory
Describe alternatives you've considered
I've tried to work around this by putting a direct dependency between the ts_library() targets, which is sufficient for compilation, but then there doesn't seem to be an obvious way to get the correct, merged pkg_npm dependency at runtime - having both as dependencies leads to mapping errors ala:
attribute deps: conflicting mapping at '//Foo/src:pkg': '@foo' maps to both ["execroot", "bazel-out/darwin-fastbuild/bin/lib/Foo/src".
The text was updated successfully, but these errors were encountered: