Repository navigation
exclude npm devOptional dependencies by default - #5065
Open
Kunalbehbud wants to merge 1 commit into
Open
Kunalbehbud wants to merge 1 commit into
Kunalbehbud wants to merge 1 commit into
Conversation
npm marks packages that are only needed by dev dependencies (or that are both dev and optional) with "devOptional": true in package-lock.json. Treat those the same as dev dependencies so they are excluded from the catalog unless IncludeDevDependencies is set. Closes anchore#4982 Signed-off-by: Kunalbehbud <b.kunal2002@gmail.com>
Kunalbehbud
force-pushed
the
npm-exclude-dev-optional
branch
from
November 13, 2026 21:12
7bfe0ee to
a53f04a
Compare
Author
|
rebased onto main. the v1 lockfile walk got refactored upstream, so the devOptional check now lives in the recursive walk next to the dev one. javascript cataloger tests pass |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
npm records packages that are only reachable through dev dependencies (or that are simultaneously
devandoptional) with"devOptional": trueinpackage-lock.json. Syft already skips"dev": truepackages when dev dependencies are excluded, butdevOptionalones slipped through and ended up in the catalog.This treats
devOptionalthe same asdev: such packages are skipped unlessIncludeDevDependenciesis enabled, for both the v1 (dependencies) and v2/v3 (packages) lockfile layouts.Per @kzantow's request on the issue, the change is exercised by a small
package-lock.jsonfixture (testdata/pkg-lock/package-lock-dev-optional.json) that contains adevOptionalentry, with tests asserting it is excluded by default and included whenIncludeDevDependenciesis set.Closes #4982