Skip to content

Commit

Permalink
refactor(pnpm): reduce assumptions on numeric version specifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedard committed May 31, 2024
1 parent d55c9de commit 57e9e69
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion npm/private/npm_translate_lock_helpers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def _get_npm_imports(importers, packages, patched_dependencies, only_built_depen
if dep_version.startswith("npm:"):
# special case for alias dependencies such as npm:alias-to@version
maybe_package = dep_version[4:]
elif dep_version[0].isdigit():
elif dep_version not in packages:
maybe_package = utils.pnpm_name(dep_package, dep_version)
else:
maybe_package = dep_version
Expand Down
4 changes: 2 additions & 2 deletions npm/private/transitive_closure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ def gather_transitive_closure(packages, package, no_optional, cache = {}):
# an aliased dependency
package_key = version[4:]
name, version = utils.parse_pnpm_package_key(name, version)
elif version[0].isdigit():
elif version not in packages:
package_key = utils.pnpm_name(name, version)
else:
package_key = version
transitive_closure[name] = transitive_closure.get(name, [])
if version in transitive_closure[name]:
continue
transitive_closure[name].append(version)
if package_key.startswith("link:"):
if version.startswith("link:"):
# we don't need to drill down through first-party links for the transitive closure since there are no cycles
# allowed in first-party links
continue
Expand Down

0 comments on commit 57e9e69

Please sign in to comment.