@rushstack/webpack4-module-minifier-plugin 0.9.4
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/LICENSE +24 -0
- package/README.md +61 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/dist/webpack4-module-minifier-plugin.d.ts +346 -0
- package/lib/AsyncImportCompressionPlugin.d.ts +14 -0
- package/lib/AsyncImportCompressionPlugin.d.ts.map +1 -0
- package/lib/AsyncImportCompressionPlugin.js +200 -0
- package/lib/AsyncImportCompressionPlugin.js.map +1 -0
- package/lib/Constants.d.ts +28 -0
- package/lib/Constants.d.ts.map +1 -0
- package/lib/Constants.js +33 -0
- package/lib/Constants.js.map +1 -0
- package/lib/GenerateLicenseFileForAsset.d.ts +13 -0
- package/lib/GenerateLicenseFileForAsset.d.ts.map +1 -0
- package/lib/GenerateLicenseFileForAsset.js +79 -0
- package/lib/GenerateLicenseFileForAsset.js.map +1 -0
- package/lib/ModuleMinifierPlugin.d.ts +18 -0
- package/lib/ModuleMinifierPlugin.d.ts.map +1 -0
- package/lib/ModuleMinifierPlugin.js +439 -0
- package/lib/ModuleMinifierPlugin.js.map +1 -0
- package/lib/ModuleMinifierPlugin.types.d.ts +217 -0
- package/lib/ModuleMinifierPlugin.types.d.ts.map +1 -0
- package/lib/ModuleMinifierPlugin.types.js +5 -0
- package/lib/ModuleMinifierPlugin.types.js.map +1 -0
- package/lib/OverrideWebpackIdentifierAllocation.d.ts +2 -0
- package/lib/OverrideWebpackIdentifierAllocation.d.ts.map +1 -0
- package/lib/OverrideWebpackIdentifierAllocation.js +9 -0
- package/lib/OverrideWebpackIdentifierAllocation.js.map +1 -0
- package/lib/ParallelCompiler.d.ts +11 -0
- package/lib/ParallelCompiler.d.ts.map +1 -0
- package/lib/ParallelCompiler.js +90 -0
- package/lib/ParallelCompiler.js.map +1 -0
- package/lib/PortableMinifierIdsPlugin.d.ts +13 -0
- package/lib/PortableMinifierIdsPlugin.d.ts.map +1 -0
- package/lib/PortableMinifierIdsPlugin.js +129 -0
- package/lib/PortableMinifierIdsPlugin.js.map +1 -0
- package/lib/RehydrateAsset.d.ts +11 -0
- package/lib/RehydrateAsset.d.ts.map +1 -0
- package/lib/RehydrateAsset.js +143 -0
- package/lib/RehydrateAsset.js.map +1 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +32 -0
- package/lib/index.js.map +1 -0
- package/lib/workerPool/WebpackWorker.d.ts +2 -0
- package/lib/workerPool/WebpackWorker.d.ts.map +1 -0
- package/lib/workerPool/WebpackWorker.js +101 -0
- package/lib/workerPool/WebpackWorker.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AsyncImportCompressionPlugin.js","sourceRoot":"","sources":["../src/AsyncImportCompressionPlugin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;AAE3D,sDAAoD;AAIpD,MAAM,EAAE,QAAQ,EAAE,GAAG,iBAAO,CAAC;AAE7B,2CAA0C;AAO1C,MAAM,WAAW,GAAmC,8BAA8B,CAAC;AAEnF,MAAM,SAAS,GAAuB;IACpC,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE,uBAAW;CACnB,CAAC;AAEF,MAAM,mBAAmB,GAAqB,gBAAgB,CAAC;AAC/D,MAAM,kBAAkB,GAAW,uBAAuB,CAAC;AAsB3D,SAAS,mBAAmB,CAAC,WAA4C;IACvE,KAAK,MAAM,GAAG,IAAI,WAAW,CAAC,mBAAmB,CAAC,IAAI,EAAE,EAAE;QACxD,IAAI,GAAG,CAAC,IAAI,KAAK,kBAAkB,EAAE;YACnC,OAAO,GAAgD,CAAC;SACzD;KACF;IAED,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;AACtD,CAAC;AAED,SAAS,uBAAuB,CAC9B,MAAkC,EAClC,YAAwC;;IAExC,MAAM,WAAW,GAAuB,MAAA,MAAM,CAA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the MIT license.\n// See LICENSE in the project root for license information.\n\nimport webpack, { Compiler, Plugin } from 'webpack';\nimport { ReplaceSource } from 'webpack-sources';\nimport { Tapable, TapOptions } from 'tapable';\n\nconst { Template } = webpack;\n\nimport { STAGE_AFTER } from './Constants';\nimport {\n IExtendedModule,\n IModuleMinifierPluginHooks,\n IPostProcessFragmentContext\n} from './ModuleMinifierPlugin.types';\n\nconst PLUGIN_NAME: 'AsyncImportCompressionPlugin' = 'AsyncImportCompressionPlugin';\n\nconst TAP_AFTER: TapOptions<'sync'> = {\n name: PLUGIN_NAME,\n stage: STAGE_AFTER\n};\n\nconst ASYNC_IMPORT_PREFIX: '__IMPORT_ASYNC' = '__IMPORT_ASYNC';\nconst ASYNC_IMPORT_REGEX: RegExp = /__IMPORT_ASYNC[^\\)]+/g;\n\ndeclare class WebpackImportDependency extends webpack.compilation.Dependency {\n public module: webpack.compilation.Module;\n public block: {\n chunkGroup: webpack.compilation.ChunkGroup;\n range: [number, number];\n };\n}\n\ninterface IAsyncImportMetadata {\n chunkCount: number;\n chunkIds: number[];\n count: number;\n index: number;\n}\n\ninterface ILocalImportMetadata {\n meta: IAsyncImportMetadata;\n module: webpack.compilation.Module;\n}\n\nfunction getImportDependency(compilation: webpack.compilation.Compilation): typeof WebpackImportDependency {\n for (const key of compilation.dependencyTemplates.keys()) {\n if (key.name === 'ImportDependency') {\n return key as unknown as typeof WebpackImportDependency;\n }\n }\n\n throw new Error(`Could not find ImportDependency!`);\n}\n\nfunction getImportTypeExpression(\n module: webpack.compilation.Module,\n originModule: webpack.compilation.Module\n): string {\n const exportsType: string | undefined = module.buildMeta?.exportsType;\n const strict: boolean | undefined = originModule.buildMeta?.strictHarmonyModule;\n\n // Logic translated from:\n // https://github.com/webpack/webpack/blob/3956274f1eada621e105208dcab4608883cdfdb2/lib/RuntimeTemplate.js#L110-L122\n if (exportsType === 'namespace') {\n // Use the raw module directly\n return '';\n } else if (exportsType === 'named') {\n // Create a new namespace object and forward all exports\n return ',3';\n } else if (strict) {\n // Synthetic default export\n return ',1';\n } else {\n // If modules is marked __esModule, return raw module, otherwise create a new namespace object and forward all exports\n return ',7';\n }\n}\n\nfunction needChunkOnDemandLoadingCode(chunk: webpack.compilation.Chunk): boolean {\n for (const chunkGroup of chunk.groupsIterable) {\n if (chunkGroup.getNumberOfChildren() > 0) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Plugin that replaces `Promise.all([__webpack_require__.e(1), __webpack_require__.e(12)]).then(__webpack_require__.t.bind(123,7))`\n * with more concise expressions like `__webpack_require__.ee([1,12],123,7)`, etc.\n *\n * Also ensures that the code seen by the minifier does not contain chunk ids, and is therefore portable across chunks/compilations.\n */\nexport class AsyncImportCompressionPlugin implements Plugin {\n private readonly _minifierHooks: IModuleMinifierPluginHooks;\n\n public constructor(minifierHooks: IModuleMinifierPluginHooks) {\n this._minifierHooks = minifierHooks;\n }\n\n public apply(compiler: Compiler): void {\n const asyncImportMap: Map<webpack.compilation.Module, Map<string, ILocalImportMetadata>> = new Map();\n const asyncImportGroups: Map<string, IAsyncImportMetadata> = new Map();\n let rankedImportGroups: IAsyncImportMetadata[] | undefined;\n\n this._minifierHooks.postProcessCodeFragment.tap(\n {\n name: PLUGIN_NAME,\n stage: -1\n },\n (source: ReplaceSource, context: IPostProcessFragmentContext) => {\n const code: string = source.original().source() as string;\n\n let localImports: Map<string, ILocalImportMetadata> | undefined;\n\n ASYNC_IMPORT_REGEX.lastIndex = -1;\n // RegExp.exec uses null or an array as the return type, explicitly\n let match: RegExpExecArray | null = null;\n while ((match = ASYNC_IMPORT_REGEX.exec(code))) {\n const token: string = match[0];\n\n if (!localImports) {\n if (!context.module) {\n context.compilation.errors.push(\n new Error(`Unexpected async import ${token} in non-module context ${context.loggingName}`)\n );\n return source;\n }\n\n localImports = asyncImportMap.get(context.module);\n if (!localImports) {\n context.compilation.errors.push(\n new Error(`Unexpected async import ${token} in module ${context.loggingName}`)\n );\n return source;\n }\n }\n\n const localImport: ILocalImportMetadata | undefined = localImports.get(token);\n if (!localImport) {\n context.compilation.errors.push(\n new Error(`Missing metadata for ${token} in module ${context.loggingName}`)\n );\n return source;\n }\n const { meta, module } = localImport;\n\n const chunkExpression: string = meta.index < 0 ? JSON.stringify(meta.chunkIds) : `${meta.index}`;\n\n const mapped: string | number | undefined = this._minifierHooks.finalModuleId.call(\n module.id!,\n context.compilation\n );\n const idExpr: string | number = mapped === undefined ? module.id! : mapped;\n\n // Replace with a reference or array of ideas, the target module id, and the type of import\n source.replace(\n match.index,\n ASYNC_IMPORT_REGEX.lastIndex - 1,\n `${chunkExpression},${JSON.stringify(idExpr)}${getImportTypeExpression(module, context.module!)}`\n );\n }\n\n return source;\n }\n );\n\n compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation: webpack.compilation.Compilation) => {\n asyncImportMap.clear();\n asyncImportGroups.clear();\n\n compilation.hooks.beforeChunkAssets.tap(TAP_AFTER, () => {\n const ImportDependency: typeof WebpackImportDependency = getImportDependency(compilation);\n\n for (const module of compilation.modules) {\n const toProcess: IExtendedModule[] = module.modules || [module];\n\n for (const child of toProcess) {\n child.hasDependencies((dep: webpack.compilation.Dependency) => {\n if (dep instanceof ImportDependency) {\n const { module: targetModule } = dep;\n\n let localAsyncImports: Map<string, ILocalImportMetadata> | undefined =\n asyncImportMap.get(module);\n if (!localAsyncImports) {\n asyncImportMap.set(module, (localAsyncImports = new Map()));\n }\n\n const chunkGroup: webpack.compilation.ChunkGroup = dep.block.chunkGroup;\n const chunkIds: number[] = chunkGroup\n ? chunkGroup.chunks.map((chunk) => chunk.id!).sort()\n : [];\n const idString: string = chunkIds.join(';');\n\n let meta: IAsyncImportMetadata | undefined = asyncImportGroups.get(idString);\n if (!meta) {\n asyncImportGroups.set(\n idString,\n (meta = {\n chunkCount: chunkIds.length,\n chunkIds: chunkIds,\n count: 0,\n index: -1\n })\n );\n }\n meta.count++;\n\n const stringKey: string = `${targetModule.id}`.replace(/[^A-Za-z0-9_$]/g, '_');\n\n const key: string = `${ASYNC_IMPORT_PREFIX}${stringKey}`;\n localAsyncImports.set(key, {\n meta,\n module: targetModule\n });\n }\n });\n }\n }\n\n const rankedImports: [string, IAsyncImportMetadata][] = [...asyncImportGroups]\n .filter((x) => x[1].count > 1)\n .sort((x, y) => {\n let diff: number = y[1].count - x[1].count;\n if (!diff) {\n diff = y[1].chunkCount - x[1].chunkCount;\n }\n\n if (!diff) {\n diff = x[0] > y[0] ? 1 : x[0] < y[0] ? -1 : 0;\n }\n\n return diff;\n });\n\n for (let i: number = 0, len: number = rankedImports.length; i < len; i++) {\n rankedImports[i][1].index = i;\n // console.log(rankedImports[i]);\n }\n\n rankedImportGroups = rankedImports.map((x) => x[1]);\n\n // Have to do this after the official plugin in order to override\n compilation.dependencyTemplates.set(ImportDependency, {\n apply(dep: WebpackImportDependency, source: ReplaceSource): void {\n const stringKey: string = `${dep.module.id}`.replace(/[^A-Za-z0-9_$]/g, '_');\n const key: string = `${ASYNC_IMPORT_PREFIX}${stringKey}`;\n const content: string = `__webpack_require__.ee(${key})`;\n source.replace(dep.block.range[0], dep.block.range[1] - 1, content);\n }\n // Typings in webpack are incorrect. This is a DependencyTemplate object\n } as unknown as Tapable);\n });\n\n compilation.mainTemplate.hooks.requireExtensions.tap(\n PLUGIN_NAME,\n (source: string, chunk: webpack.compilation.Chunk) => {\n if (!needChunkOnDemandLoadingCode(chunk)) {\n return source;\n }\n\n const { requireFn } = compilation.mainTemplate;\n return Template.asString([\n `var asyncImportChunkGroups = [`,\n rankedImportGroups\n ? rankedImportGroups.map((x) => Template.indent(JSON.stringify(x.chunkIds))).join(',\\n')\n : '',\n `];`,\n `${requireFn}.ee = function (groupOrId, moduleId, importType) {`,\n Template.indent([\n `return Promise.all((Array.isArray(groupOrId) ? groupOrId : asyncImportChunkGroups[groupOrId]).map(function (x) { return ${requireFn}.e(x); }))`,\n `.then(importType ? ${requireFn}.t.bind(0,moduleId,importType) : ${requireFn}.bind(0,moduleId));`\n ]),\n `};`,\n source\n ]);\n }\n );\n });\n }\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prefix to wrap `function (module, __webpack_exports__, __webpack_require__) { ... }` so that the minifier doesn't delete it.
|
|
3
|
+
* Public because alternate Minifier implementations may wish to know about it.
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export declare const MODULE_WRAPPER_PREFIX: '__MINIFY_MODULE__(';
|
|
7
|
+
/**
|
|
8
|
+
* Suffix to wrap `function (module, __webpack_exports__, __webpack_require__) { ... }` so that the minifier doesn't delete it.
|
|
9
|
+
* Public because alternate Minifier implementations may wish to know about it.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare const MODULE_WRAPPER_SUFFIX: ');';
|
|
13
|
+
/**
|
|
14
|
+
* Token to replace the object or array of module definitions so that the minifier can operate on the Webpack runtime or chunk boilerplate in isolation
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export declare const CHUNK_MODULES_TOKEN: '__WEBPACK_CHUNK_MODULES__';
|
|
18
|
+
/**
|
|
19
|
+
* Stage # to use when this should be the first tap in the hook
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export declare const STAGE_BEFORE: -100;
|
|
23
|
+
/**
|
|
24
|
+
* Stage # to use when this should be the last tap in the hook
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export declare const STAGE_AFTER: 100;
|
|
28
|
+
//# sourceMappingURL=Constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Constants.d.ts","sourceRoot":"","sources":["../src/Constants.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,oBAA2C,CAAC;AAChF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,IAAW,CAAC;AAEhD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,2BAAyD,CAAC;AAE5F;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,CAAC,GAAU,CAAC;AACvC;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,GAAS,CAAC"}
|
package/lib/Constants.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.STAGE_AFTER = exports.STAGE_BEFORE = exports.CHUNK_MODULES_TOKEN = exports.MODULE_WRAPPER_SUFFIX = exports.MODULE_WRAPPER_PREFIX = void 0;
|
|
6
|
+
/**
|
|
7
|
+
* Prefix to wrap `function (module, __webpack_exports__, __webpack_require__) { ... }` so that the minifier doesn't delete it.
|
|
8
|
+
* Public because alternate Minifier implementations may wish to know about it.
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
exports.MODULE_WRAPPER_PREFIX = '__MINIFY_MODULE__(';
|
|
12
|
+
/**
|
|
13
|
+
* Suffix to wrap `function (module, __webpack_exports__, __webpack_require__) { ... }` so that the minifier doesn't delete it.
|
|
14
|
+
* Public because alternate Minifier implementations may wish to know about it.
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
exports.MODULE_WRAPPER_SUFFIX = ');';
|
|
18
|
+
/**
|
|
19
|
+
* Token to replace the object or array of module definitions so that the minifier can operate on the Webpack runtime or chunk boilerplate in isolation
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
exports.CHUNK_MODULES_TOKEN = '__WEBPACK_CHUNK_MODULES__';
|
|
23
|
+
/**
|
|
24
|
+
* Stage # to use when this should be the first tap in the hook
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
exports.STAGE_BEFORE = -100;
|
|
28
|
+
/**
|
|
29
|
+
* Stage # to use when this should be the last tap in the hook
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
exports.STAGE_AFTER = 100;
|
|
33
|
+
//# sourceMappingURL=Constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Constants.js","sourceRoot":"","sources":["../src/Constants.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D;;;;GAIG;AACU,QAAA,qBAAqB,GAAyB,oBAAoB,CAAC;AAChF;;;;GAIG;AACU,QAAA,qBAAqB,GAAS,IAAI,CAAC;AAEhD;;;GAGG;AACU,QAAA,mBAAmB,GAAgC,2BAA2B,CAAC;AAE5F;;;GAGG;AACU,QAAA,YAAY,GAAS,CAAC,GAAG,CAAC;AACvC;;;GAGG;AACU,QAAA,WAAW,GAAQ,GAAG,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 * Prefix to wrap `function (module, __webpack_exports__, __webpack_require__) { ... }` so that the minifier doesn't delete it.\n * Public because alternate Minifier implementations may wish to know about it.\n * @public\n */\nexport const MODULE_WRAPPER_PREFIX: '__MINIFY_MODULE__(' = '__MINIFY_MODULE__(';\n/**\n * Suffix to wrap `function (module, __webpack_exports__, __webpack_require__) { ... }` so that the minifier doesn't delete it.\n * Public because alternate Minifier implementations may wish to know about it.\n * @public\n */\nexport const MODULE_WRAPPER_SUFFIX: ');' = ');';\n\n/**\n * Token to replace the object or array of module definitions so that the minifier can operate on the Webpack runtime or chunk boilerplate in isolation\n * @public\n */\nexport const CHUNK_MODULES_TOKEN: '__WEBPACK_CHUNK_MODULES__' = '__WEBPACK_CHUNK_MODULES__';\n\n/**\n * Stage # to use when this should be the first tap in the hook\n * @public\n */\nexport const STAGE_BEFORE: -100 = -100;\n/**\n * Stage # to use when this should be the last tap in the hook\n * @public\n */\nexport const STAGE_AFTER: 100 = 100;\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as webpack from 'webpack';
|
|
2
|
+
import type { IAssetInfo, IModuleMap } from './ModuleMinifierPlugin.types';
|
|
3
|
+
/**
|
|
4
|
+
* Generates a companion asset containing all extracted comments. If it is non-empty, returns a banner comment directing users to said companion asset.
|
|
5
|
+
*
|
|
6
|
+
* @param compilation - The webpack compilation
|
|
7
|
+
* @param asset - The asset to process
|
|
8
|
+
* @param minifiedModules - The minified modules to pull comments from
|
|
9
|
+
* @param assetName - The name of the asset
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare function generateLicenseFileForAsset(compilation: webpack.compilation.Compilation, asset: IAssetInfo, minifiedModules: IModuleMap): string;
|
|
13
|
+
//# sourceMappingURL=GenerateLicenseFileForAsset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GenerateLicenseFileForAsset.d.ts","sourceRoot":"","sources":["../src/GenerateLicenseFileForAsset.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAEnC,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EAIX,MAAM,8BAA8B,CAAC;AA6BtC;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CACzC,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC,WAAW,EAC5C,KAAK,EAAE,UAAU,EACjB,eAAe,EAAE,UAAU,GAC1B,MAAM,CAoBR"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
+
}) : function(o, v) {
|
|
18
|
+
o["default"] = v;
|
|
19
|
+
});
|
|
20
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
21
|
+
if (mod && mod.__esModule) return mod;
|
|
22
|
+
var result = {};
|
|
23
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
|
+
__setModuleDefault(result, mod);
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.generateLicenseFileForAsset = void 0;
|
|
29
|
+
const path = __importStar(require("path"));
|
|
30
|
+
const webpack_sources_1 = require("webpack-sources");
|
|
31
|
+
function getAllComments(moduleIds, minifiedModules) {
|
|
32
|
+
const allComments = new Set();
|
|
33
|
+
for (const moduleId of moduleIds) {
|
|
34
|
+
const mod = minifiedModules.get(moduleId);
|
|
35
|
+
if (!mod) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const { module: webpackModule } = mod;
|
|
39
|
+
const modules = webpackModule.modules || [webpackModule];
|
|
40
|
+
for (const submodule of modules) {
|
|
41
|
+
const { comments: subModuleComments } = submodule.factoryMeta;
|
|
42
|
+
if (subModuleComments) {
|
|
43
|
+
for (const comment of subModuleComments) {
|
|
44
|
+
const value = comment.type === 'Line' ? `//${comment.value}\n` : `/*${comment.value}*/\n`;
|
|
45
|
+
allComments.add(value);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return allComments;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Generates a companion asset containing all extracted comments. If it is non-empty, returns a banner comment directing users to said companion asset.
|
|
54
|
+
*
|
|
55
|
+
* @param compilation - The webpack compilation
|
|
56
|
+
* @param asset - The asset to process
|
|
57
|
+
* @param minifiedModules - The minified modules to pull comments from
|
|
58
|
+
* @param assetName - The name of the asset
|
|
59
|
+
* @public
|
|
60
|
+
*/
|
|
61
|
+
function generateLicenseFileForAsset(compilation, asset, minifiedModules) {
|
|
62
|
+
// Extracted comments from the modules.
|
|
63
|
+
const comments = getAllComments(asset.modules, minifiedModules);
|
|
64
|
+
const assetName = asset.fileName;
|
|
65
|
+
let banner = '';
|
|
66
|
+
if (comments.size) {
|
|
67
|
+
// There are license comments in this chunk, so generate the companion file and inject a banner
|
|
68
|
+
const licenseSource = new webpack_sources_1.ConcatSource();
|
|
69
|
+
comments.forEach((comment) => {
|
|
70
|
+
licenseSource.add(comment);
|
|
71
|
+
});
|
|
72
|
+
const licenseFileName = `${assetName}.LICENSE.txt`;
|
|
73
|
+
compilation.assets[licenseFileName] = licenseSource;
|
|
74
|
+
banner = `/*! For license information please see ${path.basename(licenseFileName)} */\n`;
|
|
75
|
+
}
|
|
76
|
+
return banner;
|
|
77
|
+
}
|
|
78
|
+
exports.generateLicenseFileForAsset = generateLicenseFileForAsset;
|
|
79
|
+
//# sourceMappingURL=GenerateLicenseFileForAsset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GenerateLicenseFileForAsset.js","sourceRoot":"","sources":["../src/GenerateLicenseFileForAsset.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,2CAA6B;AAE7B,qDAA+C;AAS/C,SAAS,cAAc,CAAC,SAA8B,EAAE,eAA2B;IACjF,MAAM,WAAW,GAAgB,IAAI,GAAG,EAAE,CAAC;IAE3C,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;QAChC,MAAM,GAAG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AC3D,WAAW,CAAC,MAAM,CAAC,eAAe,CAAC,GAAG,aAAa,CAAC;QACpD,MAAM,GAAG,0CAA0C,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC;KAC1F;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAxBD,kEAwBC","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 * as path from 'path';\nimport * as webpack from 'webpack';\nimport { ConcatSource } from 'webpack-sources';\nimport type {\n IAssetInfo,\n IModuleMap,\n IModuleInfo,\n IExtendedModule,\n _IAcornComment\n} from './ModuleMinifierPlugin.types';\n\nfunction getAllComments(moduleIds: (string | number)[], minifiedModules: IModuleMap): Set<string> {\n const allComments: Set<string> = new Set();\n\n for (const moduleId of moduleIds) {\n const mod: IModuleInfo | undefined = minifiedModules.get(moduleId);\n if (!mod) {\n continue;\n }\n\n const { module: webpackModule } = mod;\n const modules: IExtendedModule[] = webpackModule.modules || [webpackModule];\n for (const submodule of modules) {\n const { comments: subModuleComments } = submodule.factoryMeta as {\n comments?: Set<_IAcornComment>;\n };\n if (subModuleComments) {\n for (const comment of subModuleComments) {\n const value: string = comment.type === 'Line' ? `//${comment.value}\\n` : `/*${comment.value}*/\\n`;\n allComments.add(value);\n }\n }\n }\n }\n\n return allComments;\n}\n\n/**\n * Generates a companion asset containing all extracted comments. If it is non-empty, returns a banner comment directing users to said companion asset.\n *\n * @param compilation - The webpack compilation\n * @param asset - The asset to process\n * @param minifiedModules - The minified modules to pull comments from\n * @param assetName - The name of the asset\n * @public\n */\nexport function generateLicenseFileForAsset(\n compilation: webpack.compilation.Compilation,\n asset: IAssetInfo,\n minifiedModules: IModuleMap\n): string {\n // Extracted comments from the modules.\n const comments: Set<string> = getAllComments(asset.modules, minifiedModules);\n\n const assetName: string = asset.fileName;\n\n let banner: string = '';\n\n if (comments.size) {\n // There are license comments in this chunk, so generate the companion file and inject a banner\n const licenseSource: ConcatSource = new ConcatSource();\n comments.forEach((comment) => {\n licenseSource.add(comment);\n });\n const licenseFileName: string = `${assetName}.LICENSE.txt`;\n compilation.assets[licenseFileName] = licenseSource;\n banner = `/*! For license information please see ${path.basename(licenseFileName)} */\\n`;\n }\n\n return banner;\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as webpack from 'webpack';
|
|
2
|
+
import type { IModuleMinifier } from '@rushstack/module-minifier';
|
|
3
|
+
import { IModuleMinifierPluginOptions, IModuleMinifierPluginHooks } from './ModuleMinifierPlugin.types';
|
|
4
|
+
import './OverrideWebpackIdentifierAllocation';
|
|
5
|
+
/**
|
|
6
|
+
* Webpack plugin that minifies code on a per-module basis rather than per-asset. The actual minification is handled by the input `minifier` object.
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export declare class ModuleMinifierPlugin implements webpack.Plugin {
|
|
10
|
+
readonly hooks: IModuleMinifierPluginHooks;
|
|
11
|
+
minifier: IModuleMinifier;
|
|
12
|
+
private readonly _enhancers;
|
|
13
|
+
private readonly _sourceMap;
|
|
14
|
+
private readonly _optionsForHash;
|
|
15
|
+
constructor(options: IModuleMinifierPluginOptions);
|
|
16
|
+
apply(compiler: webpack.Compiler): void;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=ModuleMinifierPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModuleMinifierPlugin.d.ts","sourceRoot":"","sources":["../src/ModuleMinifierPlugin.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAUnC,OAAO,KAAK,EAEV,eAAe,EAGhB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACL,4BAA4B,EAI5B,0BAA0B,EAK3B,MAAM,8BAA8B,CAAC;AAMtC,OAAO,uCAAuC,CAAC;AA+F/C;;;GAGG;AACH,qBAAa,oBAAqB,YAAW,OAAO,CAAC,MAAM;IACzD,SAAgB,KAAK,EAAE,0BAA0B,CAAC;IAC3C,QAAQ,EAAE,eAAe,CAAC;IAEjC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmB;IAC9C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAsB;IAEjD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAkB;gBAE/B,OAAO,EAAE,4BAA4B;IAiCjD,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,GAAG,IAAI;CAua/C"}
|