Skip to content
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

docs: include pnpm in bzlmod install snippet #1740

Merged
merged 4 commits into from
May 16, 2024
Merged

Conversation

alexeagle
Copy link
Member

Fixes #1737


Changes are visible to end-users: no

Test plan

None

@alexeagle alexeagle requested review from jbedard and gregmagolan May 16, 2024 14:06
@alexeagle alexeagle enabled auto-merge (squash) May 16, 2024 14:07
Copy link

aspect-workflows bot commented May 16, 2024

Test

All tests were cache hits

211 tests (100.0%) were fully cached saving 42s.


Test

e2e/bzlmod

All tests were cache hits

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


Test

e2e/gyp_no_install_script

All tests were cache hits

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


Test

e2e/js_image_oci

All tests were cache hits

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


Test

e2e/npm_link_package

All tests were cache hits

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


Test

e2e/npm_link_package-esm

All tests were cache hits

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


Test

e2e/npm_translate_lock

All tests were cache hits

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


Test

e2e/npm_translate_lock_empty

All tests were cache hits

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


Test

e2e/npm_translate_lock_multi

All tests were cache hits

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


Test

e2e/npm_translate_lock_partial_clone

All tests were cache hits

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


Test

e2e/npm_translate_lock_subdir_patch

All tests were cache hits

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


Test

e2e/npm_translate_package_lock

All tests were cache hits

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


Test

e2e/npm_translate_yarn_lock

All tests were cache hits

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


Test

e2e/package_json_module

All tests were cache hits

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


Test

e2e/pnpm_lockfiles

All tests were cache hits

7 tests (100.0%) were fully cached saving 2s.


Test

e2e/pnpm_workspace

All tests were cache hits

8 tests (100.0%) were fully cached saving 5s.


Test

e2e/pnpm_workspace_rerooted

All tests were cache hits

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


Test

e2e/repo_mapping

All tests were cache hits

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


Test

e2e/rules_foo

All tests were cache hits

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


Test

e2e/vendored_node

All tests were cache hits

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


Buildifier      Format

Copy link
Member

@gregmagolan gregmagolan left a comment

Choose a reason for hiding this comment

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

This won't work actually since there is a collision on the pnpm name. We need to change the name that rules_js in its MODULE.bazel so it is something different. Probably need to change the WORKSPACE one as well and any references to the pnpm name in the repository rules.

@alexeagle
Copy link
Member Author

I'm confused, I copied this from a currently-working example. rules_js should allow the root module to specify the pnpm version.

@alexeagle alexeagle force-pushed the alexeagle-patch-4 branch from 36994e8 to 43d60d3 Compare May 16, 2024 15:49
@gregmagolan
Copy link
Member

gregmagolan commented May 16, 2024

I'm confused, I copied this from a currently-working example. rules_js should allow the root module to specify the pnpm version.

Ahh. I see the difference in the issue I hit the other day. I had

pnpm = use_extension("@aspect_rules_js//npm:extensions.bzl", "pnpm")
pnpm.pnpm(
    name = "pnpm",
    pnpm_version = "x.x.x",
)
use_repo(pnpm, "pnpm")

to be able to specify the pnpm version used. That fails with,

Error in repository_rule: A repo named pnpm is already generated by this module extension at /private/var/tmp/_bazel_greg/57ee58d6d02323ceb00ee1ecdb8330c9/external/aspect_rules_js~/npm/private/npm_import.bzl:1205:20

The snipped in this PR doesn't do that and it just uses the pnpm version registered by rules_js.

The current shape is probably not what users want since they'll want to specify the version used. To do that the user currently has to use something other the @pnpm with bzlmod:

pnpm = use_extension("@aspect_rules_js//npm:extensions.bzl", "pnpm")
pnpm.pnpm(
    name = "pnpm-local",
    pnpm_version = "8.6.6",
)
# Allows developers to get a local node_modules tree, using
# bazel run -- @pnpm-local//:pnpm --dir $PWD install
use_repo(pnpm, "pnpm-local")

@alexeagle
Copy link
Member Author

Lemme see about fixing that bug while I'm here, was just doing that in another ruleset extensions.bzl

@alexeagle
Copy link
Member Author

Yeah #1491 got this wrong, correct pattern is in rules-template

@alexeagle
Copy link
Member Author

@jbedard https://github.com/bazel-contrib/rules-template/blob/main/mylang/extensions.bzl#L26-L51 shows the way it's meant to select a resolved version rather than just prevent usage. I'll send a separate PR with the fix.

@alexeagle alexeagle merged commit 5d41461 into main May 16, 2024
104 checks passed
@alexeagle alexeagle deleted the alexeagle-patch-4 branch May 16, 2024 16:12
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.

[Bug]: bazel run -- @pnpm//:pnpm does not work
3 participants