Skip to content

fix(impact): fall back when an npm lockfile bump meets undeclared imports - #246

Merged
adityankale190895 merged 1 commit into
DiffCI:mainfrom
FredApps:fix/npm-lock-undeclared-imports
Nov 18, 2026
Merged

adityankale190895 merged 1 commit into
DiffCI:mainfrom
FredApps:fix/npm-lock-undeclared-imports

Conversation

@FredApps

Copy link
Copy Markdown
Contributor

Fixes #244

When the delta changes package-lock.json (so dependencyLockfile is neither Yarn nor pnpm), collectDependencyChangeTests now collects the external packages the graph resolved. It falls back if any of them is not in dependencies, devDependencies or the changed dependencies. This is the same check the pnpm path makes. The reason is npm lockfile changed and repository imports undeclared dependencies (<names>); full validation required. It is listed in docs/using-diffci.md next to the pnpm entry. Repositories that declare everything they import are unaffected.

Validation:

  • tests/repo/npm-lock-undeclared-imports.test.ts fails on main and passes here.
  • npm run typecheck, npm test (1169 pass), npm run build, npm run audit:boundary.

…orts

npm hoists transitive packages to the root node_modules, where repository code can import them without declaring them. npm lockfile attribution reaches only declared dependencies, so a bump of a hoisted package selected the tests of the declared package that pulls it in and skipped the tests that import it directly. The Yarn and pnpm paths already fall back in this case; npm now does too.

Signed-off-by: FredApps <[email protected]>

@FredApps FredApps left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cross-review of 08fb20a.

Checked:

  • The fix matches #244. A package-lock.json change now falls back when repository code imports an external package that package.json does not declare, as the Yarn and pnpm paths already do. The condition (!dependencyLockfile plus a changed root package-lock.json) cannot fire on a Yarn or pnpm change, and the new row in docs/using-diffci.md matches the reason text.
  • The new test fails with src/ reverted (1 of 2 fail) and passes with the fix. tests/repo/npm-lock-undeclared-imports.test.ts is listed in release-files.json. The commit is DCO-signed. The branch is level with main. CI is green, apart from the hosted "DiffCI change impact" check, which is still in progress and never blocks.

Fixed: nothing.

Still open (not blocking): the npm block is now the third near-copy of the undeclared-import check, after Yarn and pnpm. A shared helper would be a follow-up refactor and is out of scope here.

FredApps added a commit to FredApps/core that referenced this pull request Nov 18, 2026
…ffCI#246

The manifest is an unordered set, and the PRs listed above add their entries at the same line. Moving this entry one line away lets them merge in either order without a conflict.

Signed-off-by: FredApps <[email protected]>
@FredApps
FredApps marked this pull request as ready for review November 18, 2026 00:56
@adityankale190895
adityankale190895 merged commit cd11aa9 into DiffCI:main Nov 18, 2026
12 of 13 checks passed
adityankale190895 pushed a commit that referenced this pull request Nov 18, 2026
* fix(impact): cover a program the test script runs directly

A changed file that the root test script runs with an interpreter
("node scripts/check.mjs && node --test"), or code it imports, was only
an affected entry point: no test imports it, so the selection skipped it
and verify passed while npm test failed. It now runs that test-script
phase for callers that run phases, and the full suite otherwise.

Signed-off-by: FredApps <[email protected]>

* chore: move the release-files.json entry so it merges cleanly with #246

The manifest is an unordered set, and the PRs listed above add their entries at the same line. Moving this entry one line away lets them merge in either order without a conflict.

Signed-off-by: FredApps <[email protected]>

---------

Signed-off-by: FredApps <[email protected]>
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.

npm lockfile: a bump of a hoisted, undeclared import selects too few tests

2 participants