Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javascript backend - run node package install once per workspace #20826

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 1 addition & 12 deletions src/python/pants/backend/javascript/install_node_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,7 @@
from pants.engine.internals.selectors import Get
from pants.engine.process import ProcessResult
from pants.engine.rules import Rule, collect_rules, rule
from pants.engine.target import (
SourcesField,
Target,
TransitiveTargets,
TransitiveTargetsRequest,
targets_with_sources_types,
)
from pants.engine.target import SourcesField, Target, TransitiveTargets, TransitiveTargetsRequest
from pants.engine.unions import UnionMembership, UnionRule


Expand Down Expand Up @@ -86,11 +80,6 @@ async def install_node_packages_for_address(
target = project_env.ensure_target()
transitive_tgts = await Get(TransitiveTargets, TransitiveTargetsRequest([target.address]))

pkg_tgts = targets_with_sources_types(
[PackageJsonSourceField], transitive_tgts.dependencies, union_membership
)
assert target not in pkg_tgts

source_files = await _get_relevant_source_files(
(tgt[SourcesField] for tgt in transitive_tgts.closure if tgt.has_field(SourcesField)),
with_js=False,
Expand Down
8 changes: 3 additions & 5 deletions src/python/pants/backend/javascript/nodejs_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,9 @@ async def find_node_js_projects(
# Note: If pnpm_workspace.yaml is present for an npm-managed project, it will override the package.json["workspaces"] setting, which is not intuitive
# Probably pnpm_workspace.yaml should only be used for pnpm projects.
project_paths = (
(
ProjectPaths(pkg.root_dir, ["", *pkg.workspaces])
if pkg not in pnpm_workspaces
else ProjectPaths(pkg.root_dir, ["", *pnpm_workspaces[pkg].packages])
)
ProjectPaths(pkg.root_dir, ["", *pkg.workspaces])
if pkg not in pnpm_workspaces
else ProjectPaths(pkg.root_dir, ["", *pnpm_workspaces[pkg].packages])
for pkg in package_workspaces
)

Expand Down
5 changes: 1 addition & 4 deletions src/python/pants/backend/javascript/nodejs_project_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,7 @@ def test_parses_projects(rule_runner: RuleRunner) -> None:
@pytest.mark.parametrize(
("package_manager", "expected_immutable_install_args"),
[
(
None,
("clean-install",),
),
(None, ("clean-install",)),
("npm@10.2.4", ("clean-install",)),
("pnpm@7.5.0", ("install", "--frozen-lockfile")),
("yarn@1.22.19", ("install", "--frozen-lockfile")),
Expand Down