-
-
Notifications
You must be signed in to change notification settings - Fork 150
Optimize package store symlink creation #2401
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
base: main
Are you sure you want to change the base?
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
npm/private/npm_package_store.bzl
Outdated
target = dep_ref_def_package_store_directory.short_path[_PACKAGE_STORE_PREFIX_LEN:] | ||
for dep_ref_dep_alias in dep_ref_dep_aliases: | ||
# "node_modules/{package_store_root}/{package_store_name}/node_modules/{package}" | ||
dep_ref_dep_symlink_path = "node_modules/{}/{}/node_modules/{}".format(utils.package_store_root, dep_package_store_name, dep_ref_dep_alias) | ||
files.append(utils.make_symlink(ctx, dep_ref_dep_symlink_path, dep_ref_def_package_store_directory.path)) | ||
symlink = ctx.actions.declare_symlink(dep_ref_dep_symlink_path) | ||
ctx.actions.symlink( | ||
output = symlink, | ||
target_path = ("../../.." if "/" in dep_ref_dep_alias else "../..") + target, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Construct relative target path from wrong substring
The new symlink code slices dep_ref_def_package_store_directory.short_path
using a fixed _PACKAGE_STORE_PREFIX_LEN
that only accounts for node_modules/.aspect_rules_js
. A package store directory’s short_path
is actually prefixed by the rule’s package path (e.g. npm/private/node_modules/.aspect_rules_js/...
), so slicing by a fixed offset removes part of the .aspect_rules_js
prefix and often the leading slash. The resulting target_path
becomes ../../..rules_js/...
instead of ../../../.aspect_rules_js/...
, producing broken symlinks for any npm package store defined in a subpackage rather than the workspace root. This will cause transitive dependencies to be unresolved. Consider computing the relative path with paths.relative_file
or by trimming the substring starting after the first occurrence of node_modules/{package_store_root}
.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good bot
916a3d6
to
33b0187
Compare
33b0187
to
9d073e3
Compare
We waste a fair bit of analysis time computing what these symlink targets should be, but we can do this much more directly.
Before:

After:

Changes are visible to end-users: no
Test plan
existing tests