Skip to content

[RRFC] Add an icon url field #852

Open

Description

@justjam2013

Add a icon url field to the package.json spec, which would be returned in the search results.

Edit: This link would be available in the search API results.

So, using the example result from a search below, a field would be returned in the package object:

{
  "objects": [
    {
      "downloads": {
        "monthly": 17877,
        "weekly": 3863
      },
      "dependents": "177",
      "updated": "2025-12-22T14:06:11.084Z",
      "searchScore": 294.53653,
      "package": {
        "name": "homebridge-lib",
        "keywords": [
          "homekit",
          "homebridge"
        ],
        "version": "7.2.0",
        "description": "Library for homebridge plugins",
        "sanitized_name": "homebridge-lib",
        "icon": "https://github.com/ebaauw/homebridge-lib/path/to/icon_file.png",
        "publisher": {
          "email": "[email protected]",
          "username": "ebaauw"
        },
        "maintainers": [
          {
            "email": "[email protected]",
            "username": "ebaauw"
          }
        ],
        "license": "Apache-2.0",
        "date": "2025-12-08T13:57:14.187Z",
        "links": {
          "homepage": "https://github.com/ebaauw/homebridge-lib#readme",
          "repository": "git+https://github.com/ebaauw/homebridge-lib.git",
          "bugs": "https://github.com/ebaauw/homebridge-lib/issues",
          "npm": "https://www.npmjs.com/package/homebridge-lib"
        }
      },
      "score": {
        "final": 294.53653,
        "detail": {
          "popularity": 1,
          "quality": 1,
          "maintenance": 1
        }
      },
      "flags": {
        "insecure": 0
      }
    }
  ],
  "total": 1,
  "time": "2025-12-25T20:42:48.227Z"
}

Activity

  1. justjam2013 commented on Dec 29, 2025

    @justjam2013
    Author
  2. ljharb commented on Dec 30, 2025

    @ljharb
    Contributor

    If it's a URL that's hardcoded into the packument, then what happens if npm is unable to download the image? What happens when the URL eventually changes its contents, or when the URL goes offline?

    If it's an included file, then that would inflate the size of every tarball published with an icon, but the unreliability and mutability of URLs doesn't apply.

  3. justjam2013 commented on Dec 30, 2025

    @justjam2013
    Author

    what happens if npm is unable to download the image?

    I never said that npm downloads the image. Npm simply provides the link in the search results. The client receiving the results can choose to download the icon or not download it.

    What happens when the URL eventually changes its contents

    The new icon is available for download. The icon can be updated without having to publish a new release.

    or when the URL goes offline?

    The icon is no longer available for download. Seems logical.

    This icon field would not be required, but it would allow for sharing an icon primarily from a github repo without packaging it into the tarball, as you mentioned. Maybe it could be placed in the links object:

            "links": {
              "homepage": "https://github.com/ebaauw/homebridge-lib#readme",
              "repository": "git+https://github.com/ebaauw/homebridge-lib.git",
              "bugs": "https://github.com/ebaauw/homebridge-lib/issues",
              "icon": "https://github.com/ebaauw/homebridge-lib/path/to/icon_file.png",
              "npm": "https://www.npmjs.com/package/homebridge-lib"
            }
    

    None of the links is required and if the links go dead, then no more homepage, repository, icon, etc.

  4. adithya1770 commented on Dec 30, 2025

    @adithya1770

    If it's a URL that's hardcoded into the packument, then what happens if npm is unable to download the image? What happens when the URL eventually changes its contents, or when the URL goes offline?

    If it's an included file, then that would inflate the size of every tarball published with an icon, but the unreliability and mutability of URLs doesn't apply.

    Multiple fallback links could be used instead of a single URL. If none of them work, a temporary placeholder icon can be shown until it’s fixed. Since this is just a web link, it doesn’t need to be included in the package.

  5. ljharb commented on Dec 30, 2025

    @ljharb
    Contributor

    The icon is no longer available for download. Seems logical.

    I think it's pretty illogical to add information to a packument that isn't immutably stored forever (and I'm including the target of the URL as well as the URL itself - I'm aware that there's lots of URLs npm doesn't cache but those already exist)

  6. justjam2013 commented on Dec 30, 2025

    @justjam2013
    Author
            "links": {
              "homepage": "https://github.com/ebaauw/homebridge-lib#readme",
              "repository": "git+https://github.com/ebaauw/homebridge-lib.git",
              "bugs": "https://github.com/ebaauw/homebridge-lib/issues",
              ...
            }
    

    What happens when the author of a package decides to delete the github repo, or their entire github account?

            "publisher": {
              "email": "[email protected]",
              ...
            },
            "maintainers": [
              {
                "email": "[email protected]",
              ...
              }
            ],
    

    What happens when someone closes an email account they no longer use?

    Removing those entries above, in case those scenarios happen, just to be on the safe side, would be illogical. Circumstances change and you cannot control for all of them. Arguing against adding a useful feature because someone might abandon a package, along with what all that entails, means not adding any functionality at all where you cannot control the future.

    or when the URL goes offline?

    The icon is no longer available for download. Seems logical.

    At the point when this happens, the fact that the icon is missing is quite likely going to be a potential symptom of a much larger problem. And you deal with this if and when it happens. Maybe by someone else taking over the package maintenance, or migrating to a currently maintained package. I have seen a number of packages on npm with 100+ open bugs and that haven't been updated in 5+ years or longer. Worrying about a missing icon seems to be missing the forest for the trees.

  7. ljharb commented on Dec 30, 2025

    @ljharb
    Contributor

    Indeed, those are examples of pre existing non immutable things. I’m suggesting that no new ones should be added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions