Skip to content

Commit

Permalink
fix(npm): remove use of pnpm lock dev flag
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedard committed Jan 9, 2025
1 parent e55422e commit 44e3340
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 15 deletions.
8 changes: 0 additions & 8 deletions npm/private/npm_translate_lock_helpers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ def _get_npm_imports(importers, packages, patched_dependencies, only_built_depen
friendly_version = package_info.get("friendly_version")
deps = package_info.get("dependencies")
optional_deps = package_info.get("optional_dependencies")
dev = package_info.get("dev")
optional = package_info.get("optional")
requires_build = package_info.get("requires_build")
transitive_closure = package_info.get("transitive_closure")
Expand All @@ -302,12 +301,6 @@ def _get_npm_imports(importers, packages, patched_dependencies, only_built_depen
msg = "expected package {} resolution to have an integrity or tarball field but found none".format(package_key)
fail(msg)

if attr.prod and dev:
# when prod attribute is set, skip devDependencies
continue
if attr.dev and not dev:
# when dev attribute is set, skip (non-dev) dependencies
continue
if attr.no_optional and optional:
# when no_optional attribute is set, skip optionalDependencies
continue
Expand Down Expand Up @@ -465,7 +458,6 @@ ERROR: can not apply both `pnpm.patchedDependencies` and `npm_translate_lock(pat
version = version,
bins = bins,
package_info = package_info,
dev = dev,
replace_package = replace_package,
)

Expand Down
6 changes: 1 addition & 5 deletions npm/private/pnpm.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@ def _new_import_info(dependencies, dev_dependencies, optional_dependencies):
#
# Metadata may come from different locations depending on the lockfile, this struct should
# have data normalized across lockfiles.
def _new_package_info(id, name, dependencies, optional_dependencies, dev, has_bin, optional, requires_build, version, friendly_version, resolution):
def _new_package_info(id, name, dependencies, optional_dependencies, has_bin, optional, requires_build, version, friendly_version, resolution):
return {
"id": id,
"name": name,
"dependencies": dependencies,
"optional_dependencies": optional_dependencies,
"dev": dev,
"has_bin": has_bin,
"optional": optional,
"requires_build": requires_build,
Expand Down Expand Up @@ -195,7 +194,6 @@ def _convert_v5_packages(packages):
friendly_version = friendly_version,
dependencies = _convert_pnpm_v5_package_dependency_map(package_snapshot.get("dependencies", {})),
optional_dependencies = _convert_pnpm_v5_package_dependency_map(package_snapshot.get("optionalDependencies", {})),
dev = package_snapshot.get("dev", False),
has_bin = package_snapshot.get("hasBin", False),
optional = package_snapshot.get("optional", False),
requires_build = package_snapshot.get("requiresBuild", False),
Expand Down Expand Up @@ -362,7 +360,6 @@ def _convert_v6_packages(packages):
friendly_version = friendly_version,
dependencies = _convert_pnpm_v6_package_dependency_map(package_snapshot.get("dependencies", {})),
optional_dependencies = _convert_pnpm_v6_package_dependency_map(package_snapshot.get("optionalDependencies", {})),
dev = package_snapshot.get("dev", False),
has_bin = package_snapshot.get("hasBin", False),
optional = package_snapshot.get("optional", False),
requires_build = package_snapshot.get("requiresBuild", False),
Expand Down Expand Up @@ -492,7 +489,6 @@ def _convert_v9_packages(packages, snapshots):
friendly_version = friendly_version,
dependencies = _convert_pnpm_v9_package_dependency_map(snapshots, package_snapshot.get("dependencies", {})),
optional_dependencies = _convert_pnpm_v9_package_dependency_map(snapshots, package_snapshot.get("optionalDependencies", {})),
dev = None, # TODO(pnpm9): must inspect importers.*.devDependencies?
has_bin = package_data.get("hasBin", False),
optional = package_snapshot.get("optional", False),
requires_build = None, # Unknown from lockfile in v9
Expand Down
2 changes: 0 additions & 2 deletions npm/private/test/parse_pnpm_lock_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ expected_packages = {
"@aspect-test/d": "2.0.0_at_aspect-test_c_1.0.0",
},
"optional_dependencies": {},
"dev": False,
"has_bin": True,
"optional": False,
"requires_build": False,
Expand Down Expand Up @@ -171,7 +170,6 @@ def _parse_lockfile_v9_test_impl(ctx):
# NOTE: unknown properties in >=v9
v9_expected_packages = dict(expected_packages)
v9_expected_packages["@aspect-test/a@5.0.0"] = dict(v9_expected_packages["@aspect-test/a@5.0.0"])
v9_expected_packages["@aspect-test/a@5.0.0"]["dev"] = None
v9_expected_packages["@aspect-test/a@5.0.0"]["requires_build"] = None

expected = (
Expand Down

0 comments on commit 44e3340

Please sign in to comment.