Skip to content

Commit 739dbdc

Browse files
authored
feat: support pnpm 11 binary (#2820)
### Changes are visible to end-users: yes - Searched for relevant documentation and updated as needed: yes - Breaking change (forces users to change their own code or config): no - Suggested release notes appear below: no ### Test plan - Covered by existing test cases - New test cases added
1 parent f10e4fa commit 739dbdc

5 files changed

Lines changed: 36 additions & 6 deletions

File tree

e2e/pnpm_lockfiles/setup.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ pushd v90 && npx -y pnpm@~9 install --lockfile-only && popd
1010
# pnpm v10
1111
pushd v101 && npx -y pnpm@~10 install --lockfile-only && popd
1212

13-
# pnpm v11 rc
14-
pushd v110 && npx -y pnpm@next-11 install --lockfile-only && popd
13+
# pnpm v11
14+
pushd v110 && npx -y pnpm@~11 install --lockfile-only && popd

e2e/pnpm_lockfiles/v110/pnpm-lock.yaml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

e2e/pnpm_repo_install/BUILD.bazel

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,17 @@ sh_test(
66
args = ["$(location @pnpm)"],
77
data = ["@pnpm"],
88
)
9+
10+
sh_test(
11+
name = "pnpm_install_test_v10",
12+
srcs = ["pnpm_install_test.sh"],
13+
args = ["$(location @pnpm_v10//:pnpm)"],
14+
data = ["@pnpm_v10//:pnpm"],
15+
)
16+
17+
sh_test(
18+
name = "pnpm_install_test_v11",
19+
srcs = ["pnpm_install_test.sh"],
20+
args = ["$(location @pnpm_v11//:pnpm)"],
21+
data = ["@pnpm_v11//:pnpm"],
22+
)

e2e/pnpm_repo_install/MODULE.bazel

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ node = use_extension(
1212
"node",
1313
dev_dependency = True,
1414
)
15+
16+
# pnpm 11 requires Node >= 22.13.
17+
node.toolchain(node_version = "22.19.0")
1518
use_repo(node, "nodejs_toolchains")
1619
use_repo(node, "nodejs_darwin_amd64")
1720
use_repo(node, "nodejs_darwin_arm64")
@@ -41,4 +44,13 @@ pnpm.pnpm(
4144
pnpm_version = "9.15.9",
4245
pnpm_version_integrity = "sha512-aARhQYk8ZvrQHAeSMRKOmvuJ74fiaR1p5NQO7iKJiClf1GghgbrlW1hBjDolO95lpQXsfF+UA+zlzDzTfc8lMQ==",
4346
)
44-
use_repo(pnpm, "pnpm")
47+
pnpm.pnpm(
48+
name = "pnpm_v10",
49+
pnpm_version = "10.33.2",
50+
)
51+
pnpm.pnpm(
52+
name = "pnpm_v11",
53+
pnpm_version = "11.0.4",
54+
pnpm_version_integrity = "sha512-CjlxZQB6AU7VKRmmHl9GxIubyohATDA+yuzGP2Le9WOJjTxril1epYEes5jP4DqwXaGlzpY/Em1erUwC+TuDww==",
55+
)
56+
use_repo(pnpm, "pnpm", "pnpm_v10", "pnpm_v11")

npm/private/pnpm_repository.bzl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ def pnpm_repository(name, pnpm_version, include_npm, integrity):
3131

3232
key = "{}@{}".format("pnpm", pnpm_version)
3333

34+
# pnpm 11 switched the bundled entry from CJS to ESM.
35+
major = pnpm_version.split(".")[0]
36+
ext = "mjs" if major.isdigit() and int(major) >= 11 else "cjs"
37+
3438
_npm_import_rule(
3539
name = name,
3640
key = key,
@@ -43,10 +47,10 @@ def pnpm_repository(name, pnpm_version, include_npm, integrity):
4347
"""js_binary(
4448
name = "pnpm",
4549
data = glob(["package/**"]),
46-
entry_point = "package/dist/pnpm.cjs",
50+
entry_point = "package/dist/pnpm.{ext}",
4751
include_npm = {include_npm},
4852
visibility = ["//visibility:public"],
49-
)""".format(include_npm = include_npm),
53+
)""".format(ext = ext, include_npm = include_npm),
5054
]),
5155
extract_full_archive = True,
5256
)

0 commit comments

Comments
 (0)