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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@rushstack/webpack-embedded-dependencies-plugin

v0.2.44

Published

This plugin analyzes bundled dependencies from Node Modules for use with Component Governance and License Scanning.

Downloads

264

Readme

webpack-embedded-dependencies-plugin

Installation

npm install @rushstack/webpack-embedded-dependencies-plugin --save

Overview

A webpack plugin for generating a list of embedded dependencies. Embedded dependencies are third-party packages which are being bundled into your released code and are oftentimes subject to license, security, and other legal requirements. This plugin aims to make it easier to generate a list of embedded dependencies and their associated metadata, so they can be analyzed by additional tools.

The plugin also includes the ability to generate a secondary asset which contains the license text for each embedded dependency into a single file called THIRD-PARTY-NOTICES.html. This is a common legal requirement when deploying services or products containing open-source code.

Plugin

// webpack.config.js
import EmbeddedDependenciesWebpackPlugin from '@rushstack/webpack-embedded-dependencies-plugin';

export default () => {
  /*...*/
  plugins: [
    new EmbeddedDependenciesWebpackPlugin( /* options */ )
  ]
}

Options

outputFileName: string

Name of the file to be generated. Defaults to embedded-dependencies.json

new EmbeddedDependenciesWebpackPlugin({
  outputFileName: 'my-custom-file-name.json'
})

generateLicenseFile: boolean

Whether to generate a license file. Defaults to false and will only generate the embedded-dependencies.json file

new EmbeddedDependenciesWebpackPlugin({
  generateLicenseFile: true
})

generateLicenseFileFunction: LicenseFileGeneratorFunction

Function that generates the license file. Defaults to the plugin's internal default generator function but allows you to override it.

new EmbeddedDependenciesWebpackPlugin({
  generateLicenseFile: true,
  generateLicenseFileFunction: (packages: IPackageData[]): string => {
    return packages
      .map((pkg) => {
        return `<h2>${pkg.name}</h2><p>${pkg.license}</p>`;
      }).join('');
  }
})

generatedLicenseFilename: LicenseFileName

new EmbeddedDependenciesWebpackPlugin({
  generateLicenseFile: true,
  generatedLicenseFilename: 'custom-license-file-name.html'
})

Name of the generated license file. Defaults to THIRD-PARTY-NOTICES.html but can be customized to any name you want.

packageFilterPredicate: (packageJson: IPackageData, filePath: string) => boolean

Function that allows you to filter out packages that you don't want to include in any generated files.

new EmbeddedDependenciesWebpackPlugin({
  packageFilterPredicate: (packageJson: IPackageData, filePath: string): boolean => {
    return packageJson.name !== 'my-package-to-exclude';
  }
})

Types

LicenseFileGeneratorFunction

export declare type LicenseFileGeneratorFunction = (packages: IPackageData[]) => string;

Function type that generates the license file.

const licenseFileGenerator: LicenseFileGeneratorFunction = (packages: IPackageData[]): string => {
  return packages
    .map((pkg) => {
      return `<h2>${pkg.name}</h2><p>${pkg.license}</p>`;
    }).join('');
}

LicenseFileName

export declare type LicenseFileName = `${string}.${'html' | 'md' | 'txt'}`;

Loose string type that represents the name of the generated license file. The string must have at least one character and must end with one of the following file extensions: html, md, or txt or else you'll receive a TypeScript error.

const licenseFileName: LicenseFileName = 'custom-license-file-name.html';
const licenseMarkdownFileName: LicenseFileName = 'custom-license-file-name.md';
const licenseTextFileName: LicenseFileName = 'custom-license-file-name.txt';

Links

@rushstack/webpack-embedded-dependencies-plugin is part of the Rush Stack family of projects.