npm_package doesn't handle siblings ts_library targets
It's a bit tricky to describe but a minimal example is given here: https://github.com/Springworks/rules_nodejs_min_pub/tree/adbe6b964d60c7ccaa4704ed3f2d2df40f680c1e
In short if there are dependencies which are not children in the filesystem tree they seem to not get bundled.
Given the super_package/BUILD.bazel
ts_library(
name = "super_library",
srcs = ["index.ts"],
deps = ["//another_library", "//some_library"],
tsconfig = "//:tsconfig.json",
)
npm_package(
name = "super_package",
srcs = ["package.json"],
deps = [":super_library"],
replacements = { "demo/": "" },
)
I would have expected "another_library" and "some_library" to get pulled into the NPM package, but the resulting package tree looks like:
bazel-bin/super_package/super_package
├── index.d.ts
├── index.js
└── package.json
We have to know what path these should have inside the resulting bundle, and we use the input filesystem to figure this out.
a/
npm_package
file1
b/
file2
it's clear the resulting package ought to contain
file1
b/file2
But if you bring in dependencies that are not in the same package with the npm_package rule, where should they be laid out in the output tree? Would they always be flattened into the root? It's hard to specify this.
Probably the right solution here is to use the additional_root_dirs attribute from ts_devserver for consistency.
Then we'd consult that list when copying files, and if an input is not in a subdirectory of the target, we'd normalize its path to the longest of the additional_root_dirs that it's a child of.
@gregmagolan can I assign this one to you since you're looking at the root dirs loading for ts_devserver and ts_web_test_suite?
@alexeagle Sounds good
@alexeagle I don't agree with this approach
What is being described is a peer dependency and should be expressed as one in the package.json just as angular/angular does when it publishes.
This issue has been automatically marked as stale because it has not had any activity for 90 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!
This issue was automatically closed because it went two weeks without a reply since it was labeled "Can Close?"