Skip to content

feat: add pnpm_version_from#2349

Merged
alexeagle merged 2 commits into
mainfrom
pnpm_version_from
Sep 15, 2025
Merged

feat: add pnpm_version_from#2349
alexeagle merged 2 commits into
mainfrom
pnpm_version_from

Conversation

@alexeagle

@alexeagle alexeagle commented Sep 15, 2025

Copy link
Copy Markdown
Contributor

Ideally pnpm version should be kept in-sync with non-Bazel codepaths, and the easiest way to do this is the packageManager field in package.json

See https://github.com/nodejs/corepack#when-authoring-packages

@alexeagle alexeagle requested a review from jbedard September 15, 2025 02:34
@alexeagle alexeagle changed the title feat: add pnpm_version_frem feat: add pnpm_version_from Sep 15, 2025
@aspect-workflows

aspect-workflows Bot commented Sep 15, 2025

Copy link
Copy Markdown

Test

1 test target passed

Targets
//npm/private/test:test_pnpm_test_5 [k8-fastbuild] 79ms

Total test execution time was 79ms. 222 tests (99.6%) were fully cached saving 30s.


Test

e2e/bzlmod

All tests were cache hits

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


Test

e2e/gyp_no_install_script

All tests were cache hits

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


Test

e2e/js_image_oci

All tests were cache hits

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


Test

e2e/npm_link_package

All tests were cache hits

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


Test

e2e/npm_link_package-esm

All tests were cache hits

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


Test

e2e/npm_translate_lock

All tests were cache hits

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


Test

e2e/npm_translate_lock_empty

All tests were cache hits

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


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

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


Test

e2e/npm_translate_lock_subdir_patch

All tests were cache hits

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


Test

e2e/npm_translate_package_lock

All tests were cache hits

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


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 496ms.


Test

e2e/pnpm_lockfiles

All tests were cache hits

67 tests (100.0%) were fully cached saving 10s.


Test

e2e/pnpm_workspace

All tests were cache hits

15 tests (100.0%) were fully cached saving 3s.


Test

e2e/pnpm_workspace_rerooted

All tests were cache hits

15 tests (100.0%) were fully cached saving 4s.


Test

e2e/repo_mapping

All tests were cache hits

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


Test

e2e/rules_foo

All tests were cache hits

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


Test

e2e/runfiles

All tests were cache hits

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


Test

e2e/vendored_node

All tests were cache hits

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


Buildifier      Format

Ideally pnpm version should be kept in-sync with non-Bazel codepaths, and the easiest way to do this is the packageManager field in package.json
@alexeagle alexeagle merged commit aa7fc5d into main Sep 15, 2025
108 checks passed
@alexeagle alexeagle deleted the pnpm_version_from branch September 15, 2025 23:14
Comment on lines +66 to +69
# Avoid inserting the default version from a non-root module
# (likely rules_js itself) if the root module already has a version.
if mod.is_root or len(registrations[attr.name]) == 0:
registrations[attr.name].append(v)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@alexeagle it seems to me that this code block essentially breaks all non-root module registrations. Note that:

  • There is always a registration for attr.name == "pnpm" (the one from rules_js itself)
  • It is not allowed to register a different name (see above).

Do you recall why you added this (it is not clear to me how it relates to the PR).

Sorry for the comment on the old PR, I'll file a bug report once I get a chance, but wanted to share the finding anyways.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think you are correct, and I have a fix WIP: #2883

jbedard added a commit that referenced this pull request Jun 11, 2026
The default `pnpm` repo was always taking priority and could not be
overridden. See #2349 (comment)

### Changes are visible to end-users: no

### Test plan

- Covered by existing test cases
- New test cases added
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.

4 participants