@@ -5,7 +5,7 @@ load(":utils.bzl", "DEFAULT_REGISTRY_DOMAIN_SLASH", "utils")
5
5
6
6
def _is_vendored_tarfile (package_snapshot ):
7
7
if "resolution" in package_snapshot :
8
- return "tarball" in package_snapshot ["resolution" ]
8
+ return "tarball" in package_snapshot ["resolution" ] and package_snapshot [ "resolution" ][ "tarball" ]. startswith ( "file:" )
9
9
return False
10
10
11
11
def _to_package_key (name , version ):
@@ -461,9 +461,9 @@ def _convert_v9_packages(packages, snapshots):
461
461
result = {}
462
462
463
463
# Snapshots contains the packages with the keys (which include peers) to return
464
- for package_key , package_snapshot in snapshots .items ():
465
- peer_meta_index = package_key .find ("(" )
466
- static_key = package_key [:peer_meta_index ] if peer_meta_index > 0 else package_key
464
+ for package_path , package_snapshot in snapshots .items ():
465
+ peer_meta_index = package_path .find ("(" )
466
+ static_key = package_path [:peer_meta_index ] if peer_meta_index > 0 else package_path
467
467
if not static_key in packages :
468
468
msg = "package {} not found in pnpm 'packages'" .format (static_key )
469
469
fail (msg )
@@ -474,17 +474,23 @@ def _convert_v9_packages(packages, snapshots):
474
474
msg = "package {} has no resolution field" .format (static_key )
475
475
fail (msg )
476
476
477
- # the raw name + version are the key, not including peerDeps+patch
477
+ package_key = _convert_pnpm_v6_v9_version_peer_dep (package_path )
478
+
479
+ # the raw name + version are the static_key, not including peerDeps+patch
478
480
version_index = static_key .index ("@" , 1 )
479
481
name = static_key [:version_index ]
480
- package_key = _convert_pnpm_v6_v9_version_peer_dep (package_key )
481
482
482
- # Extract the version including peerDeps+patch from the key
483
+ # Extract the version including peerDeps+patch from the package_key
483
484
version = package_key [package_key .index ("@" , 1 ) + 1 :]
484
485
485
486
# package_data can have the resolved "version" for things like https:// deps
486
487
friendly_version = package_data ["version" ] if "version" in package_data else static_key [version_index + 1 :]
487
488
489
+ # direct reference to tarball files: use the friendly_version to align with pnpm <v9 which
490
+ # uses the resolved version in the package store.
491
+ if _is_vendored_tarfile (package_data ):
492
+ version = friendly_version
493
+
488
494
package_info = _new_package_info (
489
495
id = package_data .get ("id" , None ), # TODO: does v9 have "id"?
490
496
name = name ,
0 commit comments