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

@darcas/rollup-plugin-license-json

v2.0.1

Published

A Vite plugin to generate a JSON file with detailed information about third-party licenses.

Readme

Rollup License JSON

NPM Last Update NPM Version NPM Downloads

NPM License

Buy me a coffee

Rollup License JSON is a Vite-compatible Rollup plugin that scans your project's dependencies and generates a JSON file containing detailed information about their licenses. It is a native implementation (since 2.0.0).

Installation

To use this plugin, install it via npm:

npm install @darcas/rollup-plugin-license-json

Or, if you're using yarn:

yarn add @darcas/rollup-plugin-license-json

Usage

In your vite.config.mts just add:

import LicensePluginJson from '@darcas/rollup-plugin-license-json';
import { fileURLToPath } from 'node:url';
import { defineConfig } from 'vite';

export default defineConfig({
    //...
    plugins: [
        //...
        LicensePluginJson(fileURLToPath(new URL('./dist/licenses.json', import.meta.url)), {
            debug: true,
            thirdParty: {
                includePrivate: true,
                multipleVersions: true,
            }
        }),
        //...
    ],
    //...
});

Parameters

LicensePluginJson accepts 2 parameters:

  • file (string, required): The path where the JSON file will be generated.
  • options (object, optional): Plugin options.

Available options:

| Option | Type | Default | Description | | --- | --- | --- | --- | | cwd | string | process.cwd() | Directory used as the project root for "self" detection and package discovery. | | debug | boolean | false | Log debug information about scanned modules. | | thirdParty.allow | string \| function \| object | — | SPDX expression string (e.g. 'MIT', '(MIT OR Apache-2.0)'), a validator function, or { test, failOnUnlicensed?, failOnViolation? }. Validation is skipped if omitted. | | thirdParty.includePrivate | boolean | false | Include packages marked private. | | thirdParty.includeSelf | boolean | false | Include the project itself. | | thirdParty.multipleVersions | boolean | false | Keep multiple installed versions of the same package (instead of deduplicating by name). |

You can't override the output path (always file).

Output

The plugin generates a JSON file with the following structure for each dependency:

type LicensePluginJsonRecord = {
    readonly author: {
        readonly name: string
        readonly email: string | null
        readonly url: string | null
    } | null
    readonly description: string
    readonly homepage: string | null
    readonly license: string
    readonly licenseText: string
    readonly name: string
    readonly version: string
}

Key Notes

  • licenseText: If the license text is empty or unavailable, it will be omitted.
  • Formatting: HTML tags are removed, and newlines are replaced with <br> tags to preserve readability.

Example

Assuming your project contains the following dependencies:

  • axios
  • lodash

The generated JSON file might look like this:

[
  {
    "name": "axios",
    "version": "0.21.4",
    "author": {
      "name": "Matt Zabriskie",
      "email": "[email protected]"
    },
    "description": "Promise based HTTP client for the browser and node.js",
    "homepage": "https://axios-http.com/",
    "license": "MIT",
    "licenseText": "Permission is hereby granted, free of charge, to any person..."
  },
  {
    "name": "lodash",
    "version": "4.17.21",
    "author": {
      "name": "John-David Dalton",
      "email": "[email protected]"
    },
    "description": "A modern JavaScript utility library delivering modularity, performance, and extras.",
    "homepage": "https://lodash.com/",
    "license": "MIT",
    "licenseText": "Permission is hereby granted, free of charge, to any person..."
  }
]

How to use

<script lang="ts" setup>
import { onMounted, ref } from 'vue';
import type { LicensePluginJsonRecord } from '@darcas/rollup-plugin-license-json';

const licenses = ref<LicensePluginJsonRecord[]>([]);

onMounted(async () => {
    const response = await fetch('/licenses.json', {
        headers: {
            Accept: 'application/json',
        },
    });

    if (response.ok) {
        const records = (await response.json()) as LicensePluginJsonRecord[];
        licenses.value = [...records].sort((a, b) => a.name.localeCompare(b.name));
    }
});
</script>

Compatibility

LicensePluginJson is a native Rollup plugin implemented via the renderChunk and generateBundle hooks. Because Vite uses Rollup under the hood, it works in both Vite and Rollup projects. It has no runtime dependency.

Contributing

If you'd like to contribute to the project, feel free to fork it and create a pull request. Please ensure that your changes are well-tested and properly documented.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Made with ❤️ by Dario Casertano (DarCas).