npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

browser-extension-manifest-fields

v2.2.1

Published

Parse and resolve browser extension manifest fields to absolute paths.

Readme

Empowering Extension.js Version Downloads workflow

browser-extension-manifest-fields

Parse and resolve browser extension manifest fields to absolute paths.

Parse a manifest.json and resolve file paths for HTML, icons, JSON, scripts, locales, web accessible resources; also surface theme image paths and semantic fields used for restart-required decisions.

What it does

  • HTML, icons, JSON, and scripts declared in the manifest are resolved to absolute file system paths, with public-root inputs normalized (e.g., /something, /public/something, public/something).
  • Browser-prefixed manifest keys are honored using the current target browser (e.g., chromium:action for Chrome vs gecko:action for Firefox/Gecko).
  • content_scripts entries include both JS and CSS assets when present, preserving ordering.
  • web_accessible_resources are passed through as-is for MV3, or strings for MV2.
  • Locales under _locales/* are discovered if present.
  • In development, manifest data cooperates with the reload pipeline: CSP and permissions are patched, and minimal background entries are ensured so the reloader can be injected.

Usage

import { getManifestFieldsData } from "browser-extension-manifest-fields";

// Resolve manifest field paths
const fields = getManifestFieldsData({
  manifestPath: "/abs/path/to/manifest.json",
});

Sample output:

{
  "html": {
    "action/index": "/abs/path/to/public/chrome-popup.html",
    "options/index": "/abs/path/to/public/options.html"
  },
  "icons": {
    "action": "/abs/path/to/icons/action.png",
    "icons": ["/abs/path/to/icons/16.png", "/abs/path/to/icons/48.png"]
  },
  "json": {
    "declarative_net_request": [
      {
        "id": "rules",
        "enabled": true,
        "path": "/abs/path/to/rules/rules_1.json"
      }
    ]
  },
  "scripts": {
    "background/service_worker": "/abs/path/to/src/background.js",
    "content_scripts/content-0": [
      "/abs/path/to/src/content.js",
      "/abs/path/to/src/content.css"
    ]
  },
  "web_accessible_resources": [
    {
      "resources": ["/abs/path/to/assets/*"],
      "matches": ["<all_urls>"]
    }
  ],
  "theme": {
    "theme/images/frame.png": "/abs/path/to/public/theme/frame.png"
  },
  "semantic": {
    "permissions": ["storage"],
    "host_permissions": ["https://*/*"],
    "csp": {"mv": 3, "extension_pages": "script-src 'self'"}
  }
}

API

// manifest-fields
export interface ManifestFields {
  html: Record<string, any>
  icons: Record<string, any>
  json: Record<string, any>
  locales?: string[] | undefined
  scripts: Record<string, any>
  web_accessible_resources?: Array<string | Record<string, any>> | undefined
  theme?: Record<string, string> | undefined
  semantic?:
    | {
        permissions?: string[]
        optional_permissions?: string[]
        host_permissions?: string[]
        csp?:
          | {mv: 2; value?: string}
          | {
              mv: 3
              extension_pages?: string
              sandbox?: string
              raw?: Record<string, any>
            }
        externally_connectable?: Record<string, any>
        gecko_id?: string
      }
    | undefined
}

export function getManifestFieldsData(args: {
  manifestPath: string;
  browser?: string;
}): ManifestFields;

Special folders helper

import {getSpecialFoldersData} from 'browser-extension-manifest-fields'

// Discovers assets under public/, html pages/ and script entries
const entries = getSpecialFoldersData({manifestPath: '/abs/path/manifest.json'})
// entries: {
//   public: Record<string, string>
//   pages: Record<string, string>
//   scripts: Record<string, string>
// }

Publish provenance helper

import {getProvenanceData} from 'browser-extension-manifest-fields'

const prov = getProvenanceData({manifestPath: '/abs/path/manifest.json'})
// prov.enabled is true when package.json has publishConfig.provenance=true and
// CI workflows request id-token: write and use `--provenance` on publish.
// You can inspect prov.workflows for details.

Path resolution conventions

  • Relative paths resolve from the manifest directory.
  • Leading / resolves from the extension root (package root), not the OS root.
  • OS-absolute filesystem paths are not part of the browser extension spec; prefer relative or /public/... references instead.

License

MIT (c) Cezar Augusto