@rushstack/webpack-embedded-dependencies-plugin 0.3.15 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "@rushstack/webpack-embedded-dependencies-plugin",
3
3
  "entries": [
4
+ {
5
+ "version": "0.4.1",
6
+ "tag": "@rushstack/webpack-embedded-dependencies-plugin_v0.4.1",
7
+ "date": "Thu, 19 Feb 2026 01:30:06 GMT",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "comment": "Add missing LICENSE file to package."
12
+ }
13
+ ],
14
+ "dependency": [
15
+ {
16
+ "comment": "Updating dependency \"@rushstack/webpack-plugin-utilities\" to `0.6.1`"
17
+ }
18
+ ]
19
+ }
20
+ },
21
+ {
22
+ "version": "0.4.0",
23
+ "tag": "@rushstack/webpack-embedded-dependencies-plugin_v0.4.0",
24
+ "date": "Thu, 19 Feb 2026 00:04:53 GMT",
25
+ "comments": {
26
+ "minor": [
27
+ {
28
+ "comment": "Normalize package layout. CommonJS is now under `lib-commonjs`, DTS is now under `lib-dts`, and ESM is now under `lib-esm`. Imports to `lib` still work as before, handled by the `\"exports\"` field in `package.json`."
29
+ }
30
+ ],
31
+ "dependency": [
32
+ {
33
+ "comment": "Updating dependency \"@rushstack/node-core-library\" to `5.20.0`"
34
+ },
35
+ {
36
+ "comment": "Updating dependency \"@rushstack/webpack-plugin-utilities\" to `0.6.0`"
37
+ },
38
+ {
39
+ "comment": "Updating dependency \"@rushstack/heft\" to `1.2.0`"
40
+ }
41
+ ]
42
+ }
43
+ },
4
44
  {
5
45
  "version": "0.3.15",
6
46
  "tag": "@rushstack/webpack-embedded-dependencies-plugin_v0.3.15",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,20 @@
1
1
  # Change Log - @rushstack/webpack-embedded-dependencies-plugin
2
2
 
3
- This log was last generated on Sat, 07 Feb 2026 01:13:26 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 19 Feb 2026 01:30:06 GMT and should not be manually modified.
4
+
5
+ ## 0.4.1
6
+ Thu, 19 Feb 2026 01:30:06 GMT
7
+
8
+ ### Patches
9
+
10
+ - Add missing LICENSE file to package.
11
+
12
+ ## 0.4.0
13
+ Thu, 19 Feb 2026 00:04:53 GMT
14
+
15
+ ### Minor changes
16
+
17
+ - Normalize package layout. CommonJS is now under `lib-commonjs`, DTS is now under `lib-dts`, and ESM is now under `lib-esm`. Imports to `lib` still work as before, handled by the `"exports"` field in `package.json`.
4
18
 
5
19
  ## 0.3.15
6
20
  Sat, 07 Feb 2026 01:13:26 GMT
package/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ @rushstack/webpack-embedded-dependencies-plugin
2
+
3
+ Copyright (c) Microsoft Corporation. All rights reserved.
4
+
5
+ MIT License
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining
8
+ a copy of this software and associated documentation files (the
9
+ "Software"), to deal in the Software without restriction, including
10
+ without limitation the rights to use, copy, modify, merge, publish,
11
+ distribute, sublicense, and/or sell copies of the Software, and to
12
+ permit persons to whom the Software is furnished to do so, subject to
13
+ the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be
16
+ included in all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.56.2"
8
+ "packageVersion": "7.57.0"
9
9
  }
10
10
  ]
11
11
  }
@@ -0,0 +1,208 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+ import path from 'node:path';
4
+ import { Async, Sort, LegacyAdapters, FileSystem } from '@rushstack/node-core-library';
5
+ import { LICENSE_FILES_REGEXP, COPYRIGHT_REGEX } from './regexpUtils';
6
+ const PLUGIN_NAME = 'EmbeddedDependenciesWebpackPlugin';
7
+ const PLUGIN_ERROR_PREFIX = '[embedded-dependencies-webpack-plugin]';
8
+ const DEFAULT_GENERATED_LICENSE_FILE_NAME = 'THIRD-PARTY-NOTICES.html';
9
+ const DEFAULT_EMBEDDED_DEPENDENCIES_FILE_NAME = 'embedded-dependencies.json';
10
+ const DEFAULT_PACKAGE_FILTER_FUNCTION = () => true;
11
+ /**
12
+ * @beta
13
+ * Webpack plugin that generates a file with the list of embedded dependencies
14
+ * and their licenses.
15
+ */
16
+ export default class EmbeddedDependenciesWebpackPlugin {
17
+ constructor(options) {
18
+ this._outputFileName = (options === null || options === void 0 ? void 0 : options.outputFileName) || DEFAULT_EMBEDDED_DEPENDENCIES_FILE_NAME;
19
+ this._generateLicenseFile = (options === null || options === void 0 ? void 0 : options.generateLicenseFile) || false;
20
+ this._generateLicenseFileFunction =
21
+ (options === null || options === void 0 ? void 0 : options.generateLicenseFileFunction) || this._defaultLicenseFileGenerator;
22
+ this._generatedLicenseFilename = (options === null || options === void 0 ? void 0 : options.generatedLicenseFilename) || DEFAULT_GENERATED_LICENSE_FILE_NAME;
23
+ this._packageFilterFunction = (options === null || options === void 0 ? void 0 : options.packageFilterPredicate) || DEFAULT_PACKAGE_FILTER_FUNCTION;
24
+ }
25
+ /**
26
+ * @beta
27
+ * Webpack plugin apply method. This method is called by the webpack compiler to apply the plugin, however it not usually
28
+ * needed to be invoked manually by the developer in a webpack configuration. However, if you are calling this plugin (applying it from another plugin)
29
+ * you can call `plugin.apply(compiler)` to apply the plugin and invoke it.
30
+ * @param compiler - The webpack compiler instance.
31
+ */
32
+ apply(compiler) {
33
+ const { sources, Compilation } = compiler.webpack;
34
+ // Tap into compilation so we can tap into compilation.hooks.processAssets
35
+ compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation, { normalModuleFactory }) => {
36
+ const thirdPartyPackages = new Map();
37
+ normalModuleFactory.hooks.module.tap(PLUGIN_NAME, (module, moduleCreateData, resolveData) => {
38
+ /* moduleCreateData.resourceResolveData is typed as 'unknown' in Webpack's typings, so we cast it to our expected shape (IResourceResolveData)
39
+ to access its properties safely.*/
40
+ const resourceResolveData = moduleCreateData.resourceResolveData;
41
+ const pkg = resourceResolveData === null || resourceResolveData === void 0 ? void 0 : resourceResolveData.descriptionFileData;
42
+ const filePath = resourceResolveData === null || resourceResolveData === void 0 ? void 0 : resourceResolveData.descriptionFileRoot;
43
+ if (pkg &&
44
+ filePath &&
45
+ this._packageFilterFunction(pkg, filePath) &&
46
+ (filePath === null || filePath === void 0 ? void 0 : filePath.includes('node_modules'))) {
47
+ const key = makePackageMapKeyForPackage(pkg);
48
+ thirdPartyPackages.set(key, { packageFolderPath: filePath, packageJsonData: pkg });
49
+ }
50
+ return module;
51
+ });
52
+ compilation.hooks.processAssets.tapPromise({ name: PLUGIN_NAME, stage: Compilation.PROCESS_ASSETS_STAGE_REPORT }, async (assets) => {
53
+ const packages = [];
54
+ try {
55
+ await Async.forEachAsync(thirdPartyPackages, async ([, { packageFolderPath: dir, packageJsonData: data }]) => {
56
+ const { name, version } = data;
57
+ let licenseSource;
58
+ const license = parseLicense(data);
59
+ const licensePath = await this._getLicenseFilePathAsync(dir, compiler);
60
+ if (licensePath) {
61
+ licenseSource = await FileSystem.readFileAsync(licensePath);
62
+ const copyright = this._parseCopyright(licenseSource) || parsePackageAuthor(data);
63
+ packages.push({
64
+ name,
65
+ version,
66
+ license,
67
+ licenseSource,
68
+ copyright
69
+ });
70
+ }
71
+ else {
72
+ // If there is no license file path, we still should populate the other required fields
73
+ const copyright = parsePackageAuthor(data);
74
+ packages.push({
75
+ name,
76
+ version,
77
+ license,
78
+ copyright
79
+ });
80
+ }
81
+ });
82
+ }
83
+ catch (error) {
84
+ this._emitWebpackError(compilation, 'Failed to process embedded dependencies', error);
85
+ }
86
+ finally {
87
+ Sort.sortBy(packages, (pkg) => pkg.name);
88
+ }
89
+ const dataToStringify = {
90
+ embeddedDependencies: packages
91
+ };
92
+ compilation.emitAsset(this._outputFileName, new sources.RawSource(JSON.stringify(dataToStringify)));
93
+ if (this._generateLicenseFile) {
94
+ // We should try catch here because generator function can be output from user config
95
+ try {
96
+ compilation.emitAsset(this._generatedLicenseFilename, new sources.RawSource(this._generateLicenseFileFunction(packages)));
97
+ }
98
+ catch (error) {
99
+ this._emitWebpackError(compilation, 'Failed to generate license file', error);
100
+ }
101
+ }
102
+ return;
103
+ });
104
+ });
105
+ }
106
+ /**
107
+ * Default error handler for try/catch blocks in the plugin
108
+ * try/catches emit errors of type `unknown` and we need to handle them based on what
109
+ * type the error is. This function provides a convenient way to handle errors and then
110
+ * propagate them to webpack as WebpackError objects on `compilation.errors` array.
111
+ *
112
+ * @remarks
113
+ * _If we need to push errors to `compilation.warnings` array, we should just create a companion function
114
+ * that does the same thing but pushes to `compilation.warnings` array instead._
115
+ *
116
+ * @example
117
+ * ```typescript
118
+ * try {
119
+ * // do some operation
120
+ * FileSystem.readFile('some-file');
121
+ * } catch (error: unknown) {
122
+ * this._emitWebpackError(compilation, 'Failed to do some operation', error);
123
+ * }
124
+ * ```
125
+ */
126
+ _emitWebpackError(compilation, errorMessage, error) {
127
+ let emittedError;
128
+ const { WebpackError } = compilation.compiler.webpack;
129
+ // If the error is a string, we can just emit it as is with message prefix and error message
130
+ if (typeof error === 'string') {
131
+ emittedError = new WebpackError(`${PLUGIN_ERROR_PREFIX}: ${errorMessage}: ${error}`);
132
+ // If error is an instance of Error, we can emit it with message prefix, error message and stack trace
133
+ }
134
+ else if (error instanceof Error) {
135
+ emittedError = new WebpackError(`${PLUGIN_ERROR_PREFIX}: ${errorMessage}: ${error.message}\n${error.stack || ''}`);
136
+ // If error is not a string or an instance of Error, we can emit it with message prefix and error message and JSON.stringify it
137
+ }
138
+ else {
139
+ emittedError = new WebpackError(`${PLUGIN_ERROR_PREFIX}: ${errorMessage}: ${JSON.stringify(error || '')}`);
140
+ }
141
+ compilation.errors.push(emittedError);
142
+ }
143
+ /**
144
+ * Searches a third party package directory for a license file.
145
+ */
146
+ async _getLicenseFilePathAsync(modulePath, compiler) {
147
+ const { inputFileSystem } = compiler;
148
+ if (!inputFileSystem) {
149
+ throw new Error(`Compiler.inputFileSystem is not defined`);
150
+ }
151
+ const files = await LegacyAdapters.convertCallbackToPromise(inputFileSystem.readdir, modulePath, { withFileTypes: true, encoding: 'buffer' });
152
+ if (!files) {
153
+ return;
154
+ }
155
+ for (const file of files) {
156
+ const fileName = file.name.toString();
157
+ if (file.isFile() && LICENSE_FILES_REGEXP.test(fileName)) {
158
+ // Grabbing the first license file if multiple are found
159
+ return path.join(modulePath, fileName);
160
+ }
161
+ }
162
+ }
163
+ /**
164
+ * Given a module path, try to parse the module's copyright attribution.
165
+ */
166
+ _parseCopyright(licenseSource) {
167
+ const match = licenseSource.match(COPYRIGHT_REGEX);
168
+ if (match) {
169
+ return match[0];
170
+ }
171
+ return undefined;
172
+ }
173
+ _defaultLicenseFileGenerator(packages) {
174
+ const licenseContent = (pkg) => pkg.licenseSource || pkg.copyright || 'License or Copyright not found';
175
+ const licenseTemplateForPackage = (pkg) => {
176
+ return `<hr />${pkg.name} - ${pkg.version}<br /><br />${licenseContent(pkg)}`;
177
+ };
178
+ return packages.map(licenseTemplateForPackage).join('\n');
179
+ }
180
+ }
181
+ function makePackageMapKeyForPackage(pkg) {
182
+ return `${pkg.name}@${pkg.version}`;
183
+ }
184
+ /**
185
+ * Returns the license type
186
+ */
187
+ function parseLicense(packageData) {
188
+ var _a;
189
+ if (packageData.license) {
190
+ return packageData.license;
191
+ }
192
+ else if (typeof packageData.licenses === 'string') {
193
+ return packageData.licenses;
194
+ }
195
+ else if ((_a = packageData.licenses) === null || _a === void 0 ? void 0 : _a.length) {
196
+ return packageData.licenses.length === 1
197
+ ? packageData.licenses[0].type
198
+ : `(${packageData.licenses
199
+ .map((license) => license.type)
200
+ .join(' OR ')})`;
201
+ }
202
+ return undefined;
203
+ }
204
+ function parsePackageAuthor(p) {
205
+ var _a;
206
+ return typeof p.author === 'string' ? p.author : (_a = p.author) === null || _a === void 0 ? void 0 : _a.name;
207
+ }
208
+ //# sourceMappingURL=EmbeddedDependenciesWebpackPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmbeddedDependenciesWebpackPlugin.js","sourceRoot":"","sources":["../src/EmbeddedDependenciesWebpackPlugin.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAGvF,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEtE,MAAM,WAAW,GAAwC,mCAAmC,CAAC;AAC7F,MAAM,mBAAmB,GAAW,wCAAwC,CAAC;AAC7E,MAAM,mCAAmC,GAA+B,0BAA0B,CAAC;AACnG,MAAM,uCAAuC,GAAiC,4BAA4B,CAAC;AAC3G,MAAM,+BAA+B,GAA6D,GAAG,EAAE,CAAC,IAAI,CAAC;AAgI7G;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,iCAAiC;IAOpD,YAAmB,OAAmD;QACpE,IAAI,CAAC,eAAe,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,cAAc,KAAI,uCAAuC,CAAC;QAC1F,IAAI,CAAC,oBAAoB,GAAG,C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SAAM,IAAI,MAAA,WAAW,CAAC,QAAQ,0CAAE,MAAM,EAAE,CAAC;QACxC,OAAO,WAAW,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC;YACtC,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI;YAC9B,CAAC,CAAC,IAAI,WAAW,CAAC,QAAQ;iBACrB,GAAG,CAAC,CAAC,OAAsC,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;iBAC7D,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;IACzB,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,kBAAkB,CAAC,CAAe;;IACzC,OAAO,OAAO,CAAC,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAA,CAAC,CAAC,MAAM,0CAAE,IAAI,CAAC;AAClE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport path from 'node:path';\n\nimport type { Compiler, Compilation, WebpackPluginInstance, WebpackError, InputFileSystem } from 'webpack';\n\nimport { Async, Sort, LegacyAdapters, FileSystem } from '@rushstack/node-core-library';\nimport type { IPackageJson } from '@rushstack/node-core-library';\n\nimport { LICENSE_FILES_REGEXP, COPYRIGHT_REGEX } from './regexpUtils';\n\nconst PLUGIN_NAME: 'EmbeddedDependenciesWebpackPlugin' = 'EmbeddedDependenciesWebpackPlugin';\nconst PLUGIN_ERROR_PREFIX: string = '[embedded-dependencies-webpack-plugin]';\nconst DEFAULT_GENERATED_LICENSE_FILE_NAME: 'THIRD-PARTY-NOTICES.html' = 'THIRD-PARTY-NOTICES.html';\nconst DEFAULT_EMBEDDED_DEPENDENCIES_FILE_NAME: 'embedded-dependencies.json' = 'embedded-dependencies.json';\nconst DEFAULT_PACKAGE_FILTER_FUNCTION: (packageJson: IPackageData, filePath: string) => boolean = () => true;\n\ninterface IEmbeddedDependenciesFile {\n name?: string;\n version?: string;\n embeddedDependencies: IPackageData[];\n}\n\ninterface IResourceResolveData {\n descriptionFileData?: IPackageData;\n descriptionFileRoot?: string;\n relativePath?: string;\n}\n\n/**\n * @beta\n * Data type for a package.json file. This is a superset of the full package.json file and includes additional fields\n * that are generated by the plugin, including licenseSource, licenses, copyright, and author.\n */\nexport interface IPackageData extends IPackageJson {\n /**\n * A small string subset which is used for copyright extraction from a licenseSource file.\n */\n copyright: string | undefined;\n /**\n * The author of the package. This is a superset of the full package.json author field.\n * Grabs either the author field or author.name field from package.json.\n */\n author?: string | { name?: string };\n /**\n * Additional license metadata if present. May contain information about a project which has multiple licenses.\n */\n licenses?: { type: string; url: string }[];\n\n /**\n * The source of the license file itself used for generating THIRD-PARTY-NOTICES.html or custom license files.\n */\n licenseSource?: string;\n}\n\n/**\n * @beta\n * Plugin options for EmbeddedDependenciesWebpackPlugin\n *\n * @param outputFileName - Name of the file to be generated. Defaults to embedded-dependencies.json\n * @param generateLicenseFile - Whether to generate a license file. Defaults to false and will only generate the embedded-dependencies.json file\n * @param generateLicenseFileFunction - Function that generates the license file. Defaults to the plugin's internal default generator function but allows you to override it\n * @param generatedLicenseFilename - Name of the generated license file. Defaults to THIRD-PARTY-NOTICES.html\n *\n * @example\n * ```ts\n * // webpack.config.js\n * plugins: [\n * new EmbeddedDependenciesWebpackPlugin({\n * outputFileName: 'custom-file-name.json',\n * generateLicenseFile: true,\n * generateLicenseFileFunction: (packages: IPackageData[]) => {\n * return packages\n * .map((pkg) => {\n * return `<h2>${pkg.name}</h2><p>${pkg.license}</p>`;\n * }).join('');\n * },\n * generatedLicenseFilename: 'custom-license-file-name.html'\n * })\n * ]\n * ```\n */\nexport interface IEmbeddedDependenciesWebpackPluginOptions {\n /**\n * Name of the file to be generated. Defaults to embedded-dependencies.json\n */\n outputFileName?: string;\n /**\n * Whether to generate a license file. Defaults to false and will only generate the embedded-dependencies.json file\n */\n generateLicenseFile?: boolean;\n /**\n * Function that generates the license file. Defaults to the plugin's internal default generator function but allows you to override it\n */\n generateLicenseFileFunction?: LicenseFileGeneratorFunction;\n /**\n * Name of the generated license file. Defaults to THIRD-PARTY-NOTICES.html\n */\n generatedLicenseFilename?: LicenseFileName;\n\n /**\n * Predicate function that determines whether a package should be included in the embedded\n * dependencies file or the generated license file.\n */\n packageFilterPredicate?: (packageJson: IPackageData, filePath: string) => boolean;\n}\n\n/**\n * @beta\n * Function type that generates the license file.\n *\n * @example\n * ```ts\n * const licenseFileGenerator: LicenseFileGeneratorFunction = (packages: IPackageData[]): string => {\n * return packages\n * .map((pkg) => {\n * return `<h2>${pkg.name}</h2><p>${pkg.license}</p>`;\n * }).join('');\n * }\n * ```\n */\nexport type LicenseFileGeneratorFunction = (packages: IPackageData[]) => string;\n\n/**\n * @beta\n * Loose string type that represents the name of the generated license file.\n *\n * @example\n * ```ts\n * const licenseFileName: LicenseFileName = 'custom-license-file-name.html';\n * const licenseMarkdownFileName: LicenseFileName = 'custom-license-file-name.md';\n * const licenseTextFileName: LicenseFileName = 'custom-license-file-name.txt';\n * ```\n */\nexport type LicenseFileName = `${string}.${'html' | 'md' | 'txt'}`;\n\ntype PackageNameAndVersion = `${string}@${string}`;\ntype ThirdPartyPackageMap = Map<\n PackageNameAndVersion,\n { packageFolderPath: string; packageJsonData: IPackageData }\n>;\ntype DefaultLicenseTemplate = `<hr />${string}<br /><br />${string}`;\n\n/**\n * @beta\n * Webpack plugin that generates a file with the list of embedded dependencies\n * and their licenses.\n */\nexport default class EmbeddedDependenciesWebpackPlugin implements WebpackPluginInstance {\n private readonly _outputFileName: string;\n private readonly _generateLicenseFile: boolean;\n private readonly _generateLicenseFileFunction: LicenseFileGeneratorFunction;\n private readonly _generatedLicenseFilename: LicenseFileName;\n private readonly _packageFilterFunction: (packageJson: IPackageData, filePath: string) => boolean;\n\n public constructor(options?: IEmbeddedDependenciesWebpackPluginOptions) {\n this._outputFileName = options?.outputFileName || DEFAULT_EMBEDDED_DEPENDENCIES_FILE_NAME;\n this._generateLicenseFile = options?.generateLicenseFile || false;\n this._generateLicenseFileFunction =\n options?.generateLicenseFileFunction || this._defaultLicenseFileGenerator;\n this._generatedLicenseFilename = options?.generatedLicenseFilename || DEFAULT_GENERATED_LICENSE_FILE_NAME;\n this._packageFilterFunction = options?.packageFilterPredicate || DEFAULT_PACKAGE_FILTER_FUNCTION;\n }\n\n /**\n * @beta\n * Webpack plugin apply method. This method is called by the webpack compiler to apply the plugin, however it not usually\n * needed to be invoked manually by the developer in a webpack configuration. However, if you are calling this plugin (applying it from another plugin)\n * you can call `plugin.apply(compiler)` to apply the plugin and invoke it.\n * @param compiler - The webpack compiler instance.\n */\n public apply(compiler: Compiler): void {\n const { sources, Compilation } = compiler.webpack;\n // Tap into compilation so we can tap into compilation.hooks.processAssets\n compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation, { normalModuleFactory }) => {\n const thirdPartyPackages: ThirdPartyPackageMap = new Map();\n\n normalModuleFactory.hooks.module.tap(PLUGIN_NAME, (module, moduleCreateData, resolveData) => {\n /* moduleCreateData.resourceResolveData is typed as 'unknown' in Webpack's typings, so we cast it to our expected shape (IResourceResolveData)\n to access its properties safely.*/\n const resourceResolveData: IResourceResolveData | undefined = moduleCreateData.resourceResolveData as\n | IResourceResolveData\n | undefined;\n const pkg: IPackageData | undefined = resourceResolveData?.descriptionFileData;\n const filePath: string | undefined = resourceResolveData?.descriptionFileRoot;\n\n if (\n pkg &&\n filePath &&\n this._packageFilterFunction(pkg, filePath) &&\n filePath?.includes('node_modules')\n ) {\n const key: PackageNameAndVersion = makePackageMapKeyForPackage(pkg);\n thirdPartyPackages.set(key, { packageFolderPath: filePath, packageJsonData: pkg });\n }\n\n return module;\n });\n\n compilation.hooks.processAssets.tapPromise(\n { name: PLUGIN_NAME, stage: Compilation.PROCESS_ASSETS_STAGE_REPORT },\n async (assets) => {\n const packages: IPackageData[] = [];\n\n try {\n await Async.forEachAsync(\n thirdPartyPackages,\n async ([, { packageFolderPath: dir, packageJsonData: data }]) => {\n const { name, version } = data;\n let licenseSource: string | undefined;\n const license: string | undefined = parseLicense(data);\n const licensePath: string | undefined = await this._getLicenseFilePathAsync(dir, compiler);\n if (licensePath) {\n licenseSource = await FileSystem.readFileAsync(licensePath);\n\n const copyright: string | undefined =\n this._parseCopyright(licenseSource) || parsePackageAuthor(data);\n\n packages.push({\n name,\n version,\n license,\n licenseSource,\n copyright\n });\n } else {\n // If there is no license file path, we still should populate the other required fields\n const copyright: string | undefined = parsePackageAuthor(data);\n\n packages.push({\n name,\n version,\n license,\n copyright\n });\n }\n }\n );\n } catch (error) {\n this._emitWebpackError(compilation, 'Failed to process embedded dependencies', error);\n } finally {\n Sort.sortBy(packages, (pkg) => pkg.name);\n }\n\n const dataToStringify: IEmbeddedDependenciesFile = {\n embeddedDependencies: packages\n };\n\n compilation.emitAsset(this._outputFileName, new sources.RawSource(JSON.stringify(dataToStringify)));\n\n if (this._generateLicenseFile) {\n // We should try catch here because generator function can be output from user config\n try {\n compilation.emitAsset(\n this._generatedLicenseFilename,\n new sources.RawSource(this._generateLicenseFileFunction(packages))\n );\n } catch (error: unknown) {\n this._emitWebpackError(compilation, 'Failed to generate license file', error);\n }\n }\n\n return;\n }\n );\n });\n }\n\n /**\n * Default error handler for try/catch blocks in the plugin\n * try/catches emit errors of type `unknown` and we need to handle them based on what\n * type the error is. This function provides a convenient way to handle errors and then\n * propagate them to webpack as WebpackError objects on `compilation.errors` array.\n *\n * @remarks\n * _If we need to push errors to `compilation.warnings` array, we should just create a companion function\n * that does the same thing but pushes to `compilation.warnings` array instead._\n *\n * @example\n * ```typescript\n * try {\n * // do some operation\n * FileSystem.readFile('some-file');\n * } catch (error: unknown) {\n * this._emitWebpackError(compilation, 'Failed to do some operation', error);\n * }\n * ```\n */\n private _emitWebpackError(compilation: Compilation, errorMessage: string, error: unknown): void {\n let emittedError: WebpackError;\n const { WebpackError } = compilation.compiler.webpack;\n // If the error is a string, we can just emit it as is with message prefix and error message\n if (typeof error === 'string') {\n emittedError = new WebpackError(`${PLUGIN_ERROR_PREFIX}: ${errorMessage}: ${error}`);\n // If error is an instance of Error, we can emit it with message prefix, error message and stack trace\n } else if (error instanceof Error) {\n emittedError = new WebpackError(\n `${PLUGIN_ERROR_PREFIX}: ${errorMessage}: ${error.message}\\n${error.stack || ''}`\n );\n // If error is not a string or an instance of Error, we can emit it with message prefix and error message and JSON.stringify it\n } else {\n emittedError = new WebpackError(\n `${PLUGIN_ERROR_PREFIX}: ${errorMessage}: ${JSON.stringify(error || '')}`\n );\n }\n\n compilation.errors.push(emittedError);\n }\n\n /**\n * Searches a third party package directory for a license file.\n */\n private async _getLicenseFilePathAsync(\n modulePath: string,\n compiler: Compiler\n ): Promise<string | undefined> {\n type InputFileSystemReadDirResults = Parameters<Parameters<InputFileSystem['readdir']>[2]>[1];\n\n const { inputFileSystem } = compiler;\n if (!inputFileSystem) {\n throw new Error(`Compiler.inputFileSystem is not defined`);\n }\n\n const files: InputFileSystemReadDirResults = await LegacyAdapters.convertCallbackToPromise(\n inputFileSystem.readdir,\n modulePath,\n { withFileTypes: true, encoding: 'buffer' }\n );\n\n if (!files) {\n return;\n }\n\n for (const file of files) {\n const fileName: string = file.name.toString();\n if (file.isFile() && LICENSE_FILES_REGEXP.test(fileName)) {\n // Grabbing the first license file if multiple are found\n return path.join(modulePath, fileName);\n }\n }\n }\n\n /**\n * Given a module path, try to parse the module's copyright attribution.\n */\n private _parseCopyright(licenseSource: string): string | undefined {\n const match: RegExpMatchArray | null = licenseSource.match(COPYRIGHT_REGEX);\n\n if (match) {\n return match[0];\n }\n\n return undefined;\n }\n\n private _defaultLicenseFileGenerator(packages: IPackageData[]): string {\n const licenseContent = (pkg: IPackageData): string =>\n pkg.licenseSource || pkg.copyright || 'License or Copyright not found';\n\n const licenseTemplateForPackage = (pkg: IPackageData): DefaultLicenseTemplate => {\n return `<hr />${pkg.name} - ${pkg.version}<br /><br />${licenseContent(pkg)}`;\n };\n\n return packages.map(licenseTemplateForPackage).join('\\n');\n }\n}\n\nfunction makePackageMapKeyForPackage(pkg: IPackageData): PackageNameAndVersion {\n return `${pkg.name}@${pkg.version}`;\n}\n\n/**\n * Returns the license type\n */\nfunction parseLicense(packageData: IPackageData): string | undefined {\n if (packageData.license) {\n return packageData.license;\n } else if (typeof packageData.licenses === 'string') {\n return packageData.licenses;\n } else if (packageData.licenses?.length) {\n return packageData.licenses.length === 1\n ? packageData.licenses[0].type\n : `(${packageData.licenses\n .map((license: { type: string; url: string }) => license.type)\n .join(' OR ')})`;\n }\n\n return undefined;\n}\n\nfunction parsePackageAuthor(p: IPackageData): string | undefined {\n return typeof p.author === 'string' ? p.author : p.author?.name;\n}\n"]}
@@ -0,0 +1,16 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+ /**
4
+ * A webpack plugin for generating a list of embedded dependencies. Embedded dependencies are third-party packages which are being
5
+ * bundled into your released code and are often times subject to license, security, and other legal requirements. This plugin
6
+ * aims to make it easier to generate a list of embedded dependencies and their associated metadata, so they can be analyzed by additional tools.
7
+ *
8
+ * @remarks
9
+ * 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
10
+ * THIRD-PARTY-NOTICES.html. This is a common legal requirement for large companies deploying commercial services/products containing open source code.
11
+ *
12
+ * @packageDocumentation
13
+ */
14
+ import EmbeddedDependenciesWebpackPlugin from './EmbeddedDependenciesWebpackPlugin';
15
+ export default EmbeddedDependenciesWebpackPlugin;
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D;;;;;;;;;;GAUG;AAEH,OAAO,iCAAiC,MAAM,qCAAqC,CAAC;AASpF,eAAe,iCAAiC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/**\n * A webpack plugin for generating a list of embedded dependencies. Embedded dependencies are third-party packages which are being\n * bundled into your released code and are often times subject to license, security, and other legal requirements. This plugin\n * aims to make it easier to generate a list of embedded dependencies and their associated metadata, so they can be analyzed by additional tools.\n *\n * @remarks\n * 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\n * THIRD-PARTY-NOTICES.html. This is a common legal requirement for large companies deploying commercial services/products containing open source code.\n *\n * @packageDocumentation\n */\n\nimport EmbeddedDependenciesWebpackPlugin from './EmbeddedDependenciesWebpackPlugin';\n\nexport type {\n IPackageData,\n IEmbeddedDependenciesWebpackPluginOptions,\n LicenseFileGeneratorFunction,\n LicenseFileName\n} from './EmbeddedDependenciesWebpackPlugin';\n\nexport default EmbeddedDependenciesWebpackPlugin;\n"]}
@@ -0,0 +1,28 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+ /**
4
+ * Regular expression used to match common license file names.
5
+ *
6
+ * @remarks The following file names are covered via unit tests to be matched:
7
+ *
8
+ * - `'LICENSE'`
9
+ * - `'LICENSE.txt'`
10
+ * - `'LICENSE.md'`
11
+ * - `'LICENSE-MIT.txt'`
12
+ * - `'license'`
13
+ * - `'license.txt'`
14
+ */
15
+ export const LICENSE_FILES_REGEXP = /^LICENSE(-[A-Z-]+)?(\.(txt|md))?$/i;
16
+ /**
17
+ * Regular expression used to match common copyright statements. It is by no means exhaustive however it
18
+ * should cover the majority of cases that we come across in the wild.
19
+ *
20
+ * @remarks The following copyright statements are covered via unit tests to be matched:
21
+ *
22
+ * - `'Copyright © 2023 FAKE-PACKAGE-MIT-LICENSE'`
23
+ * - `'Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>'`
24
+ * - `'Copyright 2023 Some Licenser Name'`
25
+ *
26
+ */
27
+ export const COPYRIGHT_REGEX = /Copyright\s*(\(c\)|©)?\s*\d{4}\s*.*$/im;
28
+ //# sourceMappingURL=regexpUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"regexpUtils.js","sourceRoot":"","sources":["../src/regexpUtils.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAW,oCAAoC,CAAC;AAEjF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,eAAe,GAAW,wCAAwC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/**\n * Regular expression used to match common license file names.\n *\n * @remarks The following file names are covered via unit tests to be matched:\n *\n * - `'LICENSE'`\n * - `'LICENSE.txt'`\n * - `'LICENSE.md'`\n * - `'LICENSE-MIT.txt'`\n * - `'license'`\n * - `'license.txt'`\n */\nexport const LICENSE_FILES_REGEXP: RegExp = /^LICENSE(-[A-Z-]+)?(\\.(txt|md))?$/i;\n\n/**\n * Regular expression used to match common copyright statements. It is by no means exhaustive however it\n * should cover the majority of cases that we come across in the wild.\n *\n * @remarks The following copyright statements are covered via unit tests to be matched:\n *\n * - `'Copyright © 2023 FAKE-PACKAGE-MIT-LICENSE'`\n * - `'Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>'`\n * - `'Copyright 2023 Some Licenser Name'`\n *\n */\nexport const COPYRIGHT_REGEX: RegExp = /Copyright\\s*(\\(c\\)|©)?\\s*\\d{4}\\s*.*$/im;\n"]}
package/package.json CHANGED
@@ -1,9 +1,30 @@
1
1
  {
2
2
  "name": "@rushstack/webpack-embedded-dependencies-plugin",
3
- "version": "0.3.15",
3
+ "version": "0.4.1",
4
4
  "description": "This plugin analyzes bundled dependencies from Node Modules for use with Component Governance and License Scanning.",
5
- "main": "lib/index.js",
6
- "typings": "dist/webpack-embedded-dependencies-plugin.d.ts",
5
+ "main": "./lib-commonjs/index.js",
6
+ "module": "./lib-esm/index.js",
7
+ "types": "./dist/webpack-embedded-dependencies-plugin.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/webpack-embedded-dependencies-plugin.d.ts",
11
+ "import": "./lib-esm/index.js",
12
+ "require": "./lib-commonjs/index.js"
13
+ },
14
+ "./lib/*": {
15
+ "types": "./lib-dts/*.d.ts",
16
+ "import": "./lib-esm/*.js",
17
+ "require": "./lib-commonjs/*.js"
18
+ },
19
+ "./package.json": "./package.json"
20
+ },
21
+ "typesVersions": {
22
+ "*": {
23
+ "lib/*": [
24
+ "lib-dts/*"
25
+ ]
26
+ }
27
+ },
7
28
  "license": "MIT",
8
29
  "repository": {
9
30
  "type": "git",
@@ -11,7 +32,7 @@
11
32
  "directory": "webpack/webpack-embedded-dependencies-plugin"
12
33
  },
13
34
  "dependencies": {
14
- "@rushstack/node-core-library": "5.19.1"
35
+ "@rushstack/node-core-library": "5.20.0"
15
36
  },
16
37
  "peerDependencies": {
17
38
  "webpack": "^5.35.1"
@@ -23,12 +44,13 @@
23
44
  },
24
45
  "devDependencies": {
25
46
  "eslint": "~9.37.0",
26
- "webpack": "~5.105.0",
47
+ "webpack": "~5.105.2",
27
48
  "memfs": "4.12.0",
28
- "@rushstack/webpack-plugin-utilities": "0.5.14",
29
- "@rushstack/heft": "1.1.14",
49
+ "@rushstack/heft": "1.2.0",
50
+ "@rushstack/webpack-plugin-utilities": "0.6.1",
30
51
  "local-node-rig": "1.0.0"
31
52
  },
53
+ "sideEffects": false,
32
54
  "scripts": {
33
55
  "build": "heft build --clean",
34
56
  "test": "heft run --only test",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes