-
-
Notifications
You must be signed in to change notification settings - Fork 108
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
[FR]: npm_link_all_packages
should provide shorthands for "all non-devDependencies" and "all devDependencies"
#1879
Comments
This would be awesome in combination with Ideally this would just work: npm_link_all_packages()
ts_project(
name = "srcs_transpiled",
srcs = glob(["*.ts"]),
deps = [":node_modules"],
)
# Exclude development dependencies here?
js_binary(
name = "bin",
data = [":srcs_transpiled"],
entry_point = "index.js",
)
# Or here?
js_image_layer(
name = "layers",
binary = ":bin",
root = "/app",
) But I'm also okay with: npm_link_all_packages()
ts_project(
name = "srcs_transpiled",
srcs = glob(["*.ts"]),
deps = [":node_modules"],
)
# Strip node dependencies for re-linking
js_info_files(
name = "srcs_stripped_deps",
srcs = [":srcs_transpiled"],
include_npm_sources = False,
)
# Re-link here
js_binary(
name = "bin",
# Auto-generated target containing only dependencies and not devDependencies
data = [":srcs_stripped_deps", ":node_modules_nodev"],
entry_point = "index.js",
)
js_image_layer(
name = "layers",
binary = ":bin",
root = "/app",
) |
I just noticed that the documentation for
However, this is followed by:
The problem with this definition of "dev" dependencies is that a 3rd party dep can be in A better definition would be whether the direct dependency appears in the |
Yes, this is the exact issue I had in #2013 but unfortunately the Aspect devs seem unresponsive. |
I recently started working on this task and noticed exactly what you're describing. The lockfile I think |
Mostly, yeah. To make the problem explicit: In certain configurations the node_modules graph can look something like this: flowchart
pj[package.json] -->|devDependencies| dep1
pj -->|dependencies| dep2
dep2 -->|dependencies| dep1
What I've observed is that |
I've been working on this as well. My progress is in #2051, which adds Even if the forwarding behavior of dev dependencies for
to avoid |
What is the current behavior?
npm_link_all_packages
provides you with a:node_modules
target that represents all dependencies in package.json.Describe the feature
There should also be some sort of automatically generated shorthand target for ":node_modules excluding dev deps" and "only dev deps". It's common to not want to micro-manage package dependencies in both package.json and BUILD.bazel, but still have targets to which dev deps are not accessible (most non-test targets), to avoid accidental inclusion of dev libraries in production code.
See https://bazelbuild.github.io/rules_rust/crate_universe.html#all_crate_deps for one potential API approach.
The text was updated successfully, but these errors were encountered: