0.2.42 • Published 3 days ago

@rushstack/webpack-embedded-dependencies-plugin v0.2.42

Weekly downloads
-
License
MIT
Repository
github
Last release
3 days ago

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.

0.2.42

3 days ago

0.2.41

29 days ago

0.2.40

2 months ago

0.2.39

2 months ago

0.2.38

2 months ago

0.2.37

2 months ago

0.2.36

2 months ago

0.2.35

2 months ago

0.2.34

2 months ago

0.2.33

2 months ago

0.2.32

2 months ago

0.2.31

3 months ago

0.2.30

3 months ago

0.2.29

3 months ago

0.2.28

3 months ago

0.2.26

3 months ago

0.2.25

3 months ago

0.2.24

3 months ago

0.2.23

3 months ago

0.2.22

3 months ago

0.2.21

4 months ago

0.2.20

4 months ago

0.2.19

4 months ago

0.2.18

4 months ago

0.2.17

4 months ago

0.2.16

4 months ago

0.2.15

5 months ago

0.2.14

5 months ago

0.2.13

5 months ago

0.2.12

6 months ago

0.2.11

6 months ago

0.2.10

6 months ago

0.1.30

10 months ago

0.1.31

10 months ago

0.1.32

10 months ago

0.1.33

10 months ago

0.1.34

10 months ago

0.1.35

10 months ago

0.1.36

9 months ago

0.1.37

9 months ago

0.1.27

10 months ago

0.1.28

10 months ago

0.1.29

10 months ago

0.1.26

10 months ago

0.2.1

8 months ago

0.2.0

8 months ago

0.2.7

7 months ago

0.2.6

8 months ago

0.2.9

7 months ago

0.2.8

7 months ago

0.2.3

8 months ago

0.2.2

8 months ago

0.2.5

8 months ago

0.2.4

8 months ago

0.1.10

12 months ago

0.1.11

12 months ago

0.1.12

11 months ago

0.1.13

11 months ago

0.1.14

11 months ago

0.1.15

11 months ago

0.1.20

11 months ago

0.1.21

11 months ago

0.1.22

11 months ago

0.1.23

11 months ago

0.1.24

11 months ago

0.1.25

11 months ago

0.1.16

11 months ago

0.1.8

1 year ago

0.1.17

11 months ago

0.1.7

1 year ago

0.1.18

11 months ago

0.1.19

11 months ago

0.1.9

12 months ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago