@@ -140,15 +140,19 @@ def npm_package(
140140 include_runfiles = False ,
141141 hardlink = "auto" ,
142142 publishable = False ,
143+ pnpm_binary = "@pnpm//:pnpm" ,
143144 verbose = False ,
144145 ** kwargs ):
145146 """A macro that packages sources into a directory (a tree artifact) and provides an `NpmPackageInfo`.
146147
147148 This target can be used as the `src` attribute to `npm_link_package`.
148149
149150 With `publishable = True` the macro also produces a target `[name].publish`, that can be run to publish to an npm registry.
150- Under the hood, this target runs `npm publish`. You can pass arguments to npm by escaping them from Bazel using a double-hyphen,
151- for example: `bazel run //path/to:my_package.publish -- --tag=next`
151+ Under the hood, this target runs `pnpm publish`. You can pass arguments to pnpm by escaping them from Bazel using a double-hyphen,
152+ for example: `bazel run //path/to:my_package.publish -- --tag=next`.
153+
154+ pnpm publishing uses the configured `pnpm_binary` and can resolve pnpm workspace settings such as `catalog` entries from
155+ `pnpm-workspace.yaml`. Workspace protocol dependencies follow pnpm's own resolution requirements.
152156
153157 Files and directories can be arranged as needed in the output directory using
154158 the `root_paths`, `include_srcs_patterns`, `exclude_srcs_patterns` and `replace_prefixes` attributes.
@@ -210,7 +214,7 @@ def npm_package(
210214
211215 srcs: Files and/or directories or targets that provide `DirectoryPathInfo` to copy into the output directory.
212216
213- args: Arguments that are passed down to `<name>.publish` target and `npm publish` command.
217+ args: Arguments that are passed down to `<name>.publish` target and the publish command.
214218
215219 data: Runtime / linktime npm dependencies of this npm package.
216220
@@ -409,6 +413,9 @@ def npm_package(
409413
410414 publishable: When True, enable generation of `{name}.publish` target
411415
416+ pnpm_binary: Label of the pnpm binary used for publishing. This is typically `@pnpm//:pnpm`
417+ from the `pnpm` extension in `@aspect_rules_js//npm:extensions.bzl`.
418+
412419 verbose: If true, prints out verbose logs to stdout
413420
414421 **kwargs: Additional attributes such as `tags` and `visibility`
@@ -437,10 +444,11 @@ def npm_package(
437444 name = "{}.publish" .format (name ),
438445 entry_point = Label ("@aspect_rules_js//npm/private:npm_publish_mjs" ),
439446 fixed_args = [
447+ "$(rootpath {})" .format (pnpm_binary ),
440448 "./$(rootpath :{})" .format (name ),
441449 ],
442- data = [name ],
443- # required to make npm to be available in PATH
450+ data = [name , pnpm_binary ],
451+ # pnpm <11 may delegate registry operations to npm. This can be removed when rules_js drops pnpm <=10.
444452 include_npm = True ,
445453 args = args ,
446454 tags = kwargs .get ("tags" , []) + ["manual" ],
0 commit comments