Skip to content

Conversation

@jbedard
Copy link
Member

@jbedard jbedard commented Nov 6, 2025

Generate factory methods instead of inline code within npm_link_all_packages to better align first-party package linking with third-party.

Changes are visible to end-users: no

Test plan

  • Covered by existing test cases

@jbedard jbedard requested review from Mivr and dzbarsky November 6, 2025 08:17
@aspect-workflows
Copy link

aspect-workflows bot commented Nov 6, 2025

Test

3 test targets passed

Targets
//npm/private/test:write_npm_translate_lock_0_test [k8-fastbuild] 174ms
//npm/private:_test_gendocs_0_0 [k8-fastbuild]                    105ms
//npm/private:_test_gendocs_0_1 [k8-fastbuild]                    44ms

Total test execution time was 323ms. 291 tests (99.0%) were fully cached saving 48s.


Test

e2e/bzlmod

All tests were cache hits

5 tests (100.0%) were fully cached saving 562ms.


Test

e2e/git_dep_metadata

All tests were cache hits

1 test (100.0%) was fully cached saving 31ms.


Test

e2e/gyp_no_install_script

All tests were cache hits

2 tests (100.0%) were fully cached saving 184ms.


Test

e2e/js_image_oci

All tests were cache hits

1 test (100.0%) was fully cached saving 7s.


Test

e2e/npm_link_package

All tests were cache hits

3 tests (100.0%) were fully cached saving 664ms.


Test

e2e/npm_link_package-esm

All tests were cache hits

3 tests (100.0%) were fully cached saving 596ms.


Test

e2e/npm_link_package-rerooted

All tests were cache hits

3 tests (100.0%) were fully cached saving 564ms.


Test

e2e/npm_translate_lock

All tests were cache hits

3 tests (100.0%) were fully cached saving 582ms.


Test

e2e/npm_translate_lock_disable_hooks

All tests were cache hits

3 tests (100.0%) were fully cached saving 241ms.


Test

e2e/npm_translate_lock_empty

All tests were cache hits

2 tests (100.0%) were fully cached saving 105ms.


Test

e2e/npm_translate_lock_exclude_package_contents

All tests were cache hits

1 test (100.0%) was fully cached saving 34ms.


Test

e2e/npm_translate_lock_multi

All tests were cache hits

2 tests (100.0%) were fully cached saving 164ms.


Test

e2e/npm_translate_lock_partial_clone

All tests were cache hits

1 test (100.0%) was fully cached saving 61ms.


Test

e2e/npm_translate_lock_replace_packages

All tests were cache hits

4 tests (100.0%) were fully cached saving 413ms.


Test

e2e/npm_translate_lock_subdir_patch

All tests were cache hits

1 test (100.0%) was fully cached saving 105ms.


Test

e2e/npm_translate_package_lock

Buildkite build #10009 is running...


Test

e2e/npm_translate_yarn_lock

All tests were cache hits

1 test (100.0%) was fully cached saving 31ms.


Test

e2e/package_json_module

All tests were cache hits

1 test (100.0%) was fully cached saving 313ms.


Test

e2e/patch_from_repo

All tests were cache hits

1 test (100.0%) was fully cached saving 31ms.


Test

e2e/pnpm_lockfiles

5 test targets passed

Targets
//v101:repos_0_test [k8-fastbuild]                                89ms
//v54:repos_0_test [k8-fastbuild]                                 112ms
//v60:repos_0_test [k8-fastbuild]                                 136ms
//v61:repos_0_test [k8-fastbuild]                                 152ms
//v90:repos_0_test [k8-fastbuild]                                 151ms

Total test execution time was 640ms. 62 tests (92.5%) were fully cached saving 7s.


Test

e2e/pnpm_repo_install

All tests were cache hits

1 test (100.0%) was fully cached saving 950ms.


Test

e2e/pnpm_workspace

1 test target passed

Targets
//:repos_test [k8-fastbuild]                                      137ms

Total test execution time was 137ms. 14 tests (93.3%) were fully cached saving 2s.


Test

e2e/pnpm_workspace_deps

All tests were cache hits

3 tests (100.0%) were fully cached saving 703ms.


Test

e2e/pnpm_workspace_rerooted

1 test target passed

Targets
//:repos_test [k8-fastbuild]                                      158ms

Total test execution time was 158ms. 14 tests (93.3%) were fully cached saving 4s.


Test

e2e/repo_mapping

All tests were cache hits

3 tests (100.0%) were fully cached saving 454ms.


Test

e2e/rules_foo

All tests were cache hits

2 tests (100.0%) were fully cached saving 189ms.


Test

e2e/runfiles

All tests were cache hits

1 test (100.0%) was fully cached saving 118ms.


Test

e2e/stamped_package_json

All tests were cache hits

1 test (100.0%) was fully cached saving 44ms.


Test

e2e/vendored_node

All tests were cache hits

1 test (100.0%) was fully cached saving 78ms.


Test

e2e/vendored_tarfile

All tests were cache hits

1 test (100.0%) was fully cached saving 31ms.


Test

e2e/verify_patches

All tests were cache hits

2 tests (100.0%) were fully cached saving 109ms.


Test

e2e/worker

All tests were cache hits

1 test (100.0%) was fully cached saving 35ms.


Test

e2e/workspace

All tests were cache hits

1 test (100.0%) was fully cached saving 35ms.


Buildifier      Format

link_68("{}/uvu".format(name), False, name, "uvu")
link_targets.append(":{}/uvu".format(name))
_fp_link_0(name)
link_targets.append(":{}/@scoped/c".format(name))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally we'd generate a bit tighter code here and didn't keep checking for @scoped not in scope_targets

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That code has simply moved and is not new. But now it is alongside the third-party code (which does the exact same thing) so I hope we can cleanup both together now, coming soon...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #2428

# Generated npm_link_package_store for linking of first-party "@scoped/c" package
# buildifier: disable=function-docstring
def _fp_link_0(name):
_npm_link_package_store(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably want to package these up into a macro in the rules_js repo and invoke that with the extra args it needs, to generate less code?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean similar to what _LINK_JS_PACKAGE_LINK_IMPORTED_STORE_TMPL in npm_import.bzl is doing?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #2429

for link_package in all_fp_link_packages.keys():
if link_package not in links_pkg_bzl:
links_pkg_bzl[link_package] = []
links_pkg_bzl[link_package].append(""" _fp_link_{i}(name)""".format(i = i))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we arrange to do this first so link_targets is empty before this, and then the below will essentially reduce to scope_targets["{package_scope}"] = list(link_targets)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... now that this PR is moving all first+third-party into a single if bazel_package == "x" block I think you're right... it can probably change to a single assignment (per scope) instead of all this appending.

That will probably be in a followup...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #2428

Copy link
Collaborator

@dzbarsky dzbarsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feel free to do the codegen cleanups in a followup

@jbedard jbedard merged commit 7378e38 into aspect-build:main Nov 6, 2025
102 checks passed
@jbedard jbedard deleted the locals-reorder2 branch November 6, 2025 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants