Skip to content

fix(pm): keep npm workspace root edits out of the current member - #3535

Closed
SaKaNa-Y wants to merge 4 commits into
voidzero-dev:mainfrom
SaKaNa-Y:fix/npm-workspace-root-dependency-edits
Closed

SaKaNa-Y wants to merge 4 commits into
voidzero-dev:mainfrom
SaKaNa-Y:fix/npm-workspace-root-dependency-edits

Conversation

@SaKaNa-Y

@SaKaNa-Y SaKaNa-Y commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

From packages/app, vp remove -w testnpm2 can remove the dependency from both the root and app. The command succeeds even if app still imports the package. A root-only add can also write an extra declaration to app.

Command from app Manifests to edit
vp remove -w testnpm2 Root only
vp add -w --filter docs testnpm2 Root and docs

For npm dependency edits, select the owning project when npm loads its configuration. Keep the original launcher and working directory so relative paths, configuration files and install scripts retain their meaning. Package-bearing vp install and the removal aliases use the same path.

If npm would save a local dependency path that does not resolve from a member, stop before writing. For a combined root and member add, pass a bare tarball path with npm 8.19.0 or later. Add an external directory to each target separately.

Evidence

  • On the base revision, a root-only remove deleted app’s dependency. The updated CLI preserves app’s declaration, lockfile entry and working import. The npm 8.1 fixture also selects the outer docs package when an inner workspace has the same name.
  • The previous draft passed the project as --prefix. An install script then saw the project as its global npm prefix. The new offline fixture checks the script’s INIT_CWD, runs npm prefix -g, and resolves a workspace dependency from a fresh install.
  • npm 8.18 saved the root’s tarball path in the selected member. The updated CLI rejects that edit before writing. On npm 8.19 the same input succeeds, and the member still imports the package after root removal. Upstream npm fix
  • On macOS, 56 global CLI scenarios passed across seven npm versions from 8.1.0 to 12.2.0. Four project-local CLI scenarios passed on npm 8.18.0 and 11.19.0. Five focused CLI snapshots, just check, just test and just lint passed. The adapter and add guide also passed vp check.
  • GitHub Security Analysis reports RUSTSEC-2026-0387 for crypto-bigint 0.5.5. The base and head have the same Cargo lockfile. CI log

Merge Danger

Door · Two-way. Blast radius · npm workspace dependency edits.

Risk is medium. The adapter depends on npm’s internal configuration loader. A future npm change can select the wrong manifest or lockfile. The workspace and lifecycle fixtures exercise that boundary.

A workspace member can become an implicit target of npm install and uninstall. Resolve the owning project before a root-only dependency edit, while keeping relative package arguments in the calling directory.

Use npm to verify membership on early npm 8 and preserve explicit workspace selections. Cover member dependency and lockfile retention, including nested workspaces with the same package name.
PowerShell splits attached path options at the drive colon when it runs the npm shim with -File. Pass generated prefix, global config and caller-relative workspace paths as separate arguments so npm edits the intended project.

Extend the nested npm 8 fixture to remove a dependency from the outer docs workspace using a caller-relative selector.
Select the project through the active npm configuration while keeping the launcher and caller directory. This preserves lifecycle paths, global configuration, and workspace links during dependency edits.

Reject combined local adds before npm can save a path that fails from a member. Cover the old npm tarball boundary and run a lifecycle script in a fresh workspace.
@socket-security

socket-security Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​fixture-member@​1.0.0N/AN/AN/AN/AN/A

View full report

@SaKaNa-Y SaKaNa-Y closed this Nov 28, 2026
@SaKaNa-Y
SaKaNa-Y deleted the fix/npm-workspace-root-dependency-edits branch November 28, 2026 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant