@rushstack/webpack5-module-minifier-plugin 5.5.10 → 5.5.12
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 -24
- package/README.md +64 -64
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/Constants.js.map +1 -1
- package/lib/GenerateLicenseFileForAsset.js.map +1 -1
- package/lib/ModuleMinifierPlugin.js.map +1 -1
- package/lib/ModuleMinifierPlugin.types.js.map +1 -1
- package/lib/RehydrateAsset.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/package.json +4 -4
package/LICENSE
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
@rushstack/webpack5-module-minifier-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.
|
|
1
|
+
@rushstack/webpack5-module-minifier-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.
|
package/README.md
CHANGED
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
# @rushstack/webpack5-module-minifier-plugin
|
|
2
|
-
|
|
3
|
-
This package contains a plugin for webpack 5 that performs minification on a per-module basis rather than per-asset to deduplicate and parallelize compression work.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
`npm install @rushstack/webpack5-module-minifier-plugin --save-dev`
|
|
8
|
-
|
|
9
|
-
## Overview
|
|
10
|
-
|
|
11
|
-
This Webpack plugin performs minification of production assets on a per-module basis, rather than minifying an entire chunk at a time.
|
|
12
|
-
It issues async calls to the minifier for each unique module and each unique set of chunk boilerplate (i.e. the webpack runtime and the structure of the module list).
|
|
13
|
-
This improves minification time by:
|
|
14
|
-
- Avoiding duplicate work for each module that is included in multiple distinct assets/chunks (this is common with async chunks)
|
|
15
|
-
- Handing smaller code chunks to the minifier at a time (AST analysis is superlinear in size of the AST)
|
|
16
|
-
- Even single asset builds will likely still contain multiple modules in the final output, which can be split across available CPU cores
|
|
17
|
-
|
|
18
|
-
## Use with `[hash]` and `[contenthash]` tokens
|
|
19
|
-
The plugin will do its best to update webpack hashes if changing the direct inputs (`useSourceMap`) to the plugin, but if altering the `minifier` property itself, you may need to use the `output.hashSalt` property to force a change to the hashes, especially if leveraging the `MessagePortMinifier` or similar, since it has no direct access to the configuration of the minifier.
|
|
20
|
-
|
|
21
|
-
## Parallel execution
|
|
22
|
-
|
|
23
|
-
```js
|
|
24
|
-
const { ModuleMinifierPlugin } = require('@rushstack/webpack5-module-minifier-plugin');
|
|
25
|
-
const { WorkerPoolMinifier } = require('@rushstack/module-minifier');
|
|
26
|
-
|
|
27
|
-
// In your webpack options:
|
|
28
|
-
optimization: {
|
|
29
|
-
minimizer: [
|
|
30
|
-
new ModuleMinifierPlugin({
|
|
31
|
-
minifier: new WorkerPoolMinifier(),
|
|
32
|
-
// If not provided, the plugin will attempt to guess from `mode` and `devtool`.
|
|
33
|
-
// Providing it expressly gives better results
|
|
34
|
-
useSourceMap: true
|
|
35
|
-
})
|
|
36
|
-
]
|
|
37
|
-
}
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## Single-threaded execution
|
|
41
|
-
You can also run the ModuleMinifierPlugin in a single-threaded configuration.
|
|
42
|
-
|
|
43
|
-
```js
|
|
44
|
-
// webpack.config.js
|
|
45
|
-
const { ModuleMinifierPlugin } = require('@rushstack/webpack5-module-minifier-plugin');
|
|
46
|
-
const { LocalMinifier } = require('@rushstack/module-minifier');
|
|
47
|
-
|
|
48
|
-
// In your webpack options:
|
|
49
|
-
optimization: {
|
|
50
|
-
minimizer: [
|
|
51
|
-
new ModuleMinifierPlugin({
|
|
52
|
-
minifier: new LocalMinifier()
|
|
53
|
-
})
|
|
54
|
-
]
|
|
55
|
-
}
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
## Links
|
|
59
|
-
|
|
60
|
-
- [CHANGELOG.md](
|
|
61
|
-
https://github.com/microsoft/rushstack/blob/main/webpack/webpack5-module-minifier-plugin/CHANGELOG.md) - Find
|
|
62
|
-
out what's new in the latest version
|
|
63
|
-
|
|
64
|
-
`@rushstack/webpack5-module-minifier-plugin` is part of the [Rush Stack](https://rushstack.io/) family of projects.
|
|
1
|
+
# @rushstack/webpack5-module-minifier-plugin
|
|
2
|
+
|
|
3
|
+
This package contains a plugin for webpack 5 that performs minification on a per-module basis rather than per-asset to deduplicate and parallelize compression work.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
`npm install @rushstack/webpack5-module-minifier-plugin --save-dev`
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
This Webpack plugin performs minification of production assets on a per-module basis, rather than minifying an entire chunk at a time.
|
|
12
|
+
It issues async calls to the minifier for each unique module and each unique set of chunk boilerplate (i.e. the webpack runtime and the structure of the module list).
|
|
13
|
+
This improves minification time by:
|
|
14
|
+
- Avoiding duplicate work for each module that is included in multiple distinct assets/chunks (this is common with async chunks)
|
|
15
|
+
- Handing smaller code chunks to the minifier at a time (AST analysis is superlinear in size of the AST)
|
|
16
|
+
- Even single asset builds will likely still contain multiple modules in the final output, which can be split across available CPU cores
|
|
17
|
+
|
|
18
|
+
## Use with `[hash]` and `[contenthash]` tokens
|
|
19
|
+
The plugin will do its best to update webpack hashes if changing the direct inputs (`useSourceMap`) to the plugin, but if altering the `minifier` property itself, you may need to use the `output.hashSalt` property to force a change to the hashes, especially if leveraging the `MessagePortMinifier` or similar, since it has no direct access to the configuration of the minifier.
|
|
20
|
+
|
|
21
|
+
## Parallel execution
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
const { ModuleMinifierPlugin } = require('@rushstack/webpack5-module-minifier-plugin');
|
|
25
|
+
const { WorkerPoolMinifier } = require('@rushstack/module-minifier');
|
|
26
|
+
|
|
27
|
+
// In your webpack options:
|
|
28
|
+
optimization: {
|
|
29
|
+
minimizer: [
|
|
30
|
+
new ModuleMinifierPlugin({
|
|
31
|
+
minifier: new WorkerPoolMinifier(),
|
|
32
|
+
// If not provided, the plugin will attempt to guess from `mode` and `devtool`.
|
|
33
|
+
// Providing it expressly gives better results
|
|
34
|
+
useSourceMap: true
|
|
35
|
+
})
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Single-threaded execution
|
|
41
|
+
You can also run the ModuleMinifierPlugin in a single-threaded configuration.
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
// webpack.config.js
|
|
45
|
+
const { ModuleMinifierPlugin } = require('@rushstack/webpack5-module-minifier-plugin');
|
|
46
|
+
const { LocalMinifier } = require('@rushstack/module-minifier');
|
|
47
|
+
|
|
48
|
+
// In your webpack options:
|
|
49
|
+
optimization: {
|
|
50
|
+
minimizer: [
|
|
51
|
+
new ModuleMinifierPlugin({
|
|
52
|
+
minifier: new LocalMinifier()
|
|
53
|
+
})
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Links
|
|
59
|
+
|
|
60
|
+
- [CHANGELOG.md](
|
|
61
|
+
https://github.com/microsoft/rushstack/blob/main/webpack/webpack5-module-minifier-plugin/CHANGELOG.md) - Find
|
|
62
|
+
out what's new in the latest version
|
|
63
|
+
|
|
64
|
+
`@rushstack/webpack5-module-minifier-plugin` is part of the [Rush Stack](https://rushstack.io/) family of projects.
|
package/dist/tsdoc-metadata.json
CHANGED
package/lib/Constants.js.map
CHANGED
|
@@ -1 +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,kBAAkB,GAA+B,0BAA0B,CAAC;AAEzF;;;GAGG;AACU,QAAA,kBAAkB,GAAW,2CAA2C,CAAC;AAEtF;;;GAGG;AACU,QAAA,YAAY,GAAW,CAAC,KAAK,CAAC;AAC3C;;;GAGG;AACU,QAAA,WAAW,GAAQ,GAAG,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\
|
|
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,kBAAkB,GAA+B,0BAA0B,CAAC;AAEzF;;;GAGG;AACU,QAAA,kBAAkB,GAAW,2CAA2C,CAAC;AAEtF;;;GAGG;AACU,QAAA,YAAY,GAAW,CAAC,KAAK,CAAC;AAC3C;;;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 preceding a module id in the emitted asset so the minifier can operate on the Webpack runtime or chunk boilerplate in isolation\n * @public\n */\nexport const CHUNK_MODULE_TOKEN: '__WEBPACK_CHUNK_MODULE__' = '__WEBPACK_CHUNK_MODULE__';\n\n/**\n * RegExp for replacing chunk module placeholders\n * @public\n */\nexport const CHUNK_MODULE_REGEX: RegExp = /__WEBPACK_CHUNK_MODULE__([A-Za-z0-9$_]+)/g;\n\n/**\n * Stage # to use when this should be the first tap in the hook\n * @public\n */\nexport const STAGE_BEFORE: -10000 = -10000;\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenerateLicenseFileForAsset.js","sourceRoot":"","sources":["../src/GenerateLicenseFileForAsset.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,2CAA6B;AAM7B,SAAS,cAAc,CAAC,OAAyB;;IAC/C,MAAM,WAAW,GAAgB,IAAI,GAAG,EAAE,CAAC;IAE3C,KAAK,MAAM,aAAa,IAAI,OAAO,EAAE;QACnC,MAAM,UAAU,GAAqB,CAAC,aAAa,CAAC,OAAO,KAAK,IAAI;YACjE,aAAiD,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAClF,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE;YAClC,MAAM,iBAAiB,GAAkC,MACvD,SAAS,CAAC,WAGX,0CAAE,QAAQ,CAAC;YAEZ,IAAI,iBAAiB,EAAE;gBAC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Aa,GAAyB,IAAI,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC;QACpG,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC3B,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;QACH,MAAM,eAAe,GAAW,GAAG,SAAS,cAAc,CAAC;QAC3D,WAAW,CAAC,SAAS,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;QACtD,MAAM,GAAG,0CAA0C,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC;KAC1F;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AArBD,kEAqBC","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 type { Comment } from 'estree';\nimport type { Compilation, Module } from 'webpack';\nimport type { sources } from 'webpack';\nimport type { IAssetInfo } from './ModuleMinifierPlugin.types';\n\nfunction getAllComments(modules: Iterable<Module>): Set<string> {\n const allComments: Set<string> = new Set();\n\n for (const webpackModule of modules) {\n const submodules: Iterable<Module> = (webpackModule.context === null &&\n (webpackModule as { _modules?: Iterable<Module> })._modules) || [webpackModule];\n for (const submodule of submodules) {\n const subModuleComments: Iterable<Comment> | undefined = (\n submodule.factoryMeta as {\n comments?: Iterable<Comment>;\n }\n )?.comments;\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 * @public\n */\nexport function generateLicenseFileForAsset(compilation: Compilation, asset: IAssetInfo): string {\n // Extracted comments from the modules.\n const modules: Iterable<Module> = compilation.chunkGraph.getChunkModulesIterable(asset.chunk);\n const comments: Set<string> = getAllComments(modules);\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: sources.ConcatSource = new compilation.compiler.webpack.sources.ConcatSource();\n comments.forEach((comment) => {\n licenseSource.add(comment);\n });\n const licenseFileName: string = `${assetName}.LICENSE.txt`;\n compilation.emitAsset(licenseFileName, licenseSource);\n banner = `/*! For license information please see ${path.basename(licenseFileName)} */\\n`;\n }\n\n return banner;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModuleMinifierPlugin.js","sourceRoot":"","sources":["../src/ModuleMinifierPlugin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,mCAAoC;AAcpC,qCAAgF;AAEhF,2CAMqB;AAOrB,gEAA2D;AAc3D,+EAA4E;AAC5E,qDAAkD;AAElD,0CAA0C;AAC1C,MAAM,WAAW,GAA2B,sBAAsB,CAAC;AAEnE,mGAAmG;AACnG,uCAAuC;AACvC,MAAM,wBAAwB,GAAW,CAAC,CAAC;AAC3C,2CAA2C;AAC3C,oGAAoG;AACpG,MAAM,qBAAqB,GAAW,8BAA8B,CAAC;AAErE,MAAM,UAAU,GAAQ;IACtB,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE,wBAAY;CACpB,CAAC;AACF,MAAM,SAAS,GAAQ;IACrB,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE,uBAAW;CACnB,CAAC;AAYF,MAAM,sBAAsB,GAAqD,IAAI,OAAO,EAAE,CAAC;AAE/F,SAAS,gBAAgB,CAAC,IAAY;IACpC,OAAO,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACzD,CAAC;AAED;;;;;GAKG;AACH,SAAS,sBAAsB,CAC7B,gBAAmC,EACnC,WA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,IAAI,EAAQ,EAAE;gBAC/D,yBAAyB;gBACzB,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;gBAC1B,mCAAmC;gBACnC,IAAI,kBAAkB,EAAE;oBACtB,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;iBACpD;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AApaD,oDAoaC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { createHash } from 'crypto';\r\n\r\nimport type { Comment } from 'estree';\r\nimport type {\r\n Module,\r\n Compilation,\r\n WebpackPluginInstance,\r\n Compiler,\r\n javascript,\r\n WebpackError,\r\n ExternalModule,\r\n sources,\r\n Chunk\r\n} from 'webpack';\r\nimport { AsyncSeriesWaterfallHook, SyncWaterfallHook, type Tap } from 'tapable';\r\n\r\nimport {\r\n CHUNK_MODULE_TOKEN,\r\n MODULE_WRAPPER_PREFIX,\r\n MODULE_WRAPPER_SUFFIX,\r\n STAGE_BEFORE,\r\n STAGE_AFTER\r\n} from './Constants';\r\nimport type {\r\n IMinifierConnection,\r\n IModuleMinifier,\r\n IModuleMinificationResult,\r\n IModuleMinificationErrorResult\r\n} from '@rushstack/module-minifier';\r\nimport { getIdentifier } from '@rushstack/module-minifier';\r\n\r\nimport type {\r\n IModuleMinifierPluginOptions,\r\n IModuleMap,\r\n IAssetMap,\r\n IFactoryMeta,\r\n IModuleMinifierPluginHooks,\r\n IPostProcessFragmentContext,\r\n IDehydratedAssets,\r\n IModuleStats,\r\n IModuleMinifierPluginStats as IModuleMinifierPluginStats,\r\n IAssetStats\r\n} from './ModuleMinifierPlugin.types';\r\nimport { generateLicenseFileForAsset } from './GenerateLicenseFileForAsset';\r\nimport { rehydrateAsset } from './RehydrateAsset';\r\n\r\n// The name of the plugin, for use in taps\r\nconst PLUGIN_NAME: 'ModuleMinifierPlugin' = 'ModuleMinifierPlugin';\r\n\r\n// Monotonically increasing identifier to be incremented any time the code generation logic changes\r\n// Will be applied to the webpack hash.\r\nconst CODE_GENERATION_REVISION: number = 1;\r\n// Match behavior of terser's \"some\" option\r\n// https://github.com/terser/terser/blob/d3d924fa9e4c57bbe286b811c6068bcc7026e902/lib/output.js#L175\r\nconst LICENSE_COMMENT_REGEX: RegExp = /@preserve|@lic|@cc_on|^\\**!/i;\r\n\r\nconst TAP_BEFORE: Tap = {\r\n name: PLUGIN_NAME,\r\n stage: STAGE_BEFORE\r\n};\r\nconst TAP_AFTER: Tap = {\r\n name: PLUGIN_NAME,\r\n stage: STAGE_AFTER\r\n};\r\n\r\ninterface IOptionsForHash extends Omit<IModuleMinifierPluginOptions, 'minifier'> {\r\n revision: number;\r\n minifier: undefined;\r\n}\r\n\r\ninterface ISourceCacheEntry {\r\n source: sources.Source;\r\n hash: string;\r\n}\r\n\r\nconst compilationMetadataMap: WeakMap<Compilation, IModuleMinifierPluginStats> = new WeakMap();\r\n\r\nfunction hashCodeFragment(code: string): string {\r\n return createHash('sha256').update(code).digest('hex');\r\n}\r\n\r\n/**\r\n * Base implementation of asset rehydration\r\n *\r\n * @param dehydratedAssets The dehydrated assets\r\n * @param compilation The webpack compilation\r\n */\r\nfunction defaultRehydrateAssets(\r\n dehydratedAssets: IDehydratedAssets,\r\n compilation: Compilation\r\n): IDehydratedAssets {\r\n const { assets, modules } = dehydratedAssets;\r\n\r\n const compilationMetadata: IModuleMinifierPluginStats | undefined = compilationMetadataMap.get(compilation);\r\n if (!compilationMetadata) {\r\n throw new Error(`Could not get compilation metadata`);\r\n }\r\n\r\n const { metadataByAssetFileName } = compilationMetadata;\r\n\r\n // Now assets/modules contain fully minified code. Rehydrate.\r\n for (const [assetName, info] of assets) {\r\n const banner: string = info.type === 'javascript' ? generateLicenseFileForAsset(compilation, info) : '';\r\n\r\n const replacementSource: sources.Source = rehydrateAsset(compilation, info, modules, banner, true);\r\n metadataByAssetFileName.set(assetName, {\r\n positionByModuleId: info.renderInfo\r\n });\r\n compilation.updateAsset(assetName, replacementSource);\r\n }\r\n\r\n return dehydratedAssets;\r\n}\r\n\r\nfunction isMinificationResultError(\r\n result: IModuleMinificationResult\r\n): result is IModuleMinificationErrorResult {\r\n return !!result.error;\r\n}\r\n\r\nfunction isLicenseComment(comment: Comment): boolean {\r\n return LICENSE_COMMENT_REGEX.test(comment.value);\r\n}\r\n\r\n/**\r\n * Webpack plugin that minifies code on a per-module basis rather than per-asset. The actual minification is handled by the input `minifier` object.\r\n * @public\r\n */\r\nexport class ModuleMinifierPlugin implements WebpackPluginInstance {\r\n public readonly hooks: IModuleMinifierPluginHooks;\r\n public minifier: IModuleMinifier;\r\n\r\n private readonly _enhancers: WebpackPluginInstance[];\r\n private readonly _sourceMap: boolean | undefined;\r\n\r\n private readonly _optionsForHash: IOptionsForHash;\r\n\r\n public constructor(options: IModuleMinifierPluginOptions) {\r\n this.hooks = {\r\n rehydrateAssets: new AsyncSeriesWaterfallHook(['dehydratedContent', 'compilation']),\r\n\r\n postProcessCodeFragment: new SyncWaterfallHook(['code', 'context'])\r\n };\r\n\r\n const { minifier, sourceMap } = options;\r\n\r\n this._optionsForHash = {\r\n ...options,\r\n minifier: undefined,\r\n revision: CODE_GENERATION_REVISION\r\n };\r\n\r\n this._enhancers = [];\r\n\r\n this.hooks.rehydrateAssets.tap(PLUGIN_NAME, defaultRehydrateAssets);\r\n this.minifier = minifier;\r\n\r\n this._sourceMap = sourceMap;\r\n }\r\n\r\n public static getCompilationStatistics(compilation: Compilation): IModuleMinifierPluginStats | undefined {\r\n return compilationMetadataMap.get(compilation);\r\n }\r\n\r\n public apply(compiler: Compiler): void {\r\n for (const enhancer of this._enhancers) {\r\n enhancer.apply(compiler);\r\n }\r\n\r\n const {\r\n options: { devtool, mode },\r\n webpack\r\n } = compiler;\r\n\r\n webpack.Template.numberToIdentifier = getIdentifier;\r\n\r\n const { CachedSource, ConcatSource, RawSource, ReplaceSource, SourceMapSource } = webpack.sources;\r\n // The explicit setting is preferred due to accuracy, but try to guess based on devtool\r\n const useSourceMaps: boolean =\r\n typeof this._sourceMap === 'boolean'\r\n ? this._sourceMap\r\n : typeof devtool === 'string'\r\n ? devtool.endsWith('source-map')\r\n : mode === 'production' && devtool !== false;\r\n\r\n this._optionsForHash.sourceMap = useSourceMaps;\r\n const binaryConfig: Buffer = Buffer.from(JSON.stringify(this._optionsForHash), 'utf-8');\r\n\r\n compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation, compilationData) => {\r\n const { normalModuleFactory } = compilationData;\r\n\r\n function addCommentExtraction(parser: javascript.JavascriptParser): void {\r\n parser.hooks.program.tap(PLUGIN_NAME, (program: unknown, comments: Comment[]) => {\r\n const relevantComments: Comment[] = comments.filter(isLicenseComment);\r\n if (comments.length > 0) {\r\n const module: Module = parser.state.module;\r\n if (!module.factoryMeta) {\r\n module.factoryMeta = {\r\n comments: relevantComments\r\n };\r\n } else {\r\n (module.factoryMeta as IFactoryMeta).comments = relevantComments;\r\n }\r\n }\r\n });\r\n }\r\n\r\n normalModuleFactory.hooks.parser.for('javascript/auto').tap(PLUGIN_NAME, addCommentExtraction);\r\n normalModuleFactory.hooks.parser.for('javascript/dynamic').tap(PLUGIN_NAME, addCommentExtraction);\r\n normalModuleFactory.hooks.parser.for('javascript/esm').tap(PLUGIN_NAME, addCommentExtraction);\r\n\r\n /**\r\n * Set of local module ids that have been processed.\r\n */\r\n const submittedModules: Set<string | number> = new Set();\r\n\r\n /**\r\n * The text and comments of all minified modules.\r\n */\r\n const minifiedModules: IModuleMap = new Map();\r\n\r\n /**\r\n * The text and comments of all minified chunks. Most of these are trivial, but the runtime chunk is a bit larger.\r\n */\r\n const minifiedAssets: IAssetMap = new Map();\r\n\r\n const metadataByModule: WeakMap<Module, IModuleStats> = new WeakMap();\r\n const metadataByAssetFileName: Map<string, IAssetStats> = new Map();\r\n const compilationStatistics: IModuleMinifierPluginStats = {\r\n metadataByModule,\r\n metadataByAssetFileName\r\n };\r\n compilationMetadataMap.set(compilation, compilationStatistics);\r\n function getOrCreateMetadata(mod: Module): IModuleStats {\r\n let moduleStats: IModuleStats | undefined = metadataByModule.get(mod);\r\n if (!moduleStats) {\r\n moduleStats = {\r\n hashByChunk: new Map(),\r\n sizeByHash: new Map()\r\n };\r\n metadataByModule.set(mod, moduleStats);\r\n }\r\n return moduleStats;\r\n }\r\n\r\n let pendingMinificationRequests: number = 0;\r\n /**\r\n * Indicates that all files have been sent to the minifier and therefore that when pending hits 0, assets can be rehydrated.\r\n */\r\n let allRequestsIssued: boolean = false;\r\n\r\n let resolveMinifyPromise: () => void;\r\n\r\n const postProcessCode: (\r\n code: sources.ReplaceSource,\r\n context: IPostProcessFragmentContext\r\n ) => sources.ReplaceSource = (code: sources.ReplaceSource, context: IPostProcessFragmentContext) =>\r\n this.hooks.postProcessCodeFragment.call(code, context);\r\n\r\n /**\r\n * Callback to invoke when a file has finished minifying.\r\n */\r\n function onFileMinified(): void {\r\n if (--pendingMinificationRequests === 0 && allRequestsIssued) {\r\n resolveMinifyPromise();\r\n }\r\n }\r\n\r\n const { minifier } = this;\r\n\r\n let minifierConnection: IMinifierConnection | undefined;\r\n\r\n // Typings for this object are not exposed\r\n // eslint-disable-next-line @typescript-eslint/typedef\r\n const javascriptHooks = webpack.javascript.JavascriptModulesPlugin.getCompilationHooks(compilation);\r\n\r\n /**\r\n * The minifier needs to know if the module was wrapped in a factory function, because\r\n * function (module, exports, require) { // <implementation> }\r\n * minifies to nothing. Unfortunately we can't tell by inspection if the output was wrapped or not.\r\n * However, the JavaScriptModulesPlugin invokes three hooks in order when rendering a module:\r\n * 1) renderModuleContent - Invoked for every module.\r\n * 2) renderModuleContainer - Invoked when wrapping a module in a factory.\r\n * 3) renderModulePackage - Invoked for every module as the last hook.\r\n */\r\n let nextModule: Module | undefined;\r\n const sourceCache: WeakMap<sources.Source, ISourceCacheEntry> = new WeakMap();\r\n javascriptHooks.renderModuleContent.tap(TAP_AFTER, (source) => {\r\n // Clear the identification state of the current module.\r\n nextModule = undefined;\r\n return source;\r\n });\r\n javascriptHooks.renderModuleContainer.tap(TAP_AFTER, (source, mod) => {\r\n // Module is being wrapped in a factory, so it is safe for per-module minification\r\n // Leave external modules in-place to avoid needing special handling for externals\r\n if (mod.context !== null || !(mod as ExternalModule).externalType) {\r\n nextModule = mod;\r\n }\r\n return source;\r\n });\r\n javascriptHooks.renderModulePackage.tap(\r\n TAP_AFTER,\r\n /**\r\n * Extracts the code for the module and sends it to be minified.\r\n */\r\n function minifyModule(\r\n source: sources.Source,\r\n mod: Module,\r\n chunkRenderContext: { chunk: Chunk }\r\n ): sources.Source {\r\n if (nextModule !== mod) {\r\n // This module is being inlined. Abandon per-module minification.\r\n return source;\r\n }\r\n\r\n const id: string | number = compilation.chunkGraph.getModuleId(mod);\r\n\r\n const metadata: IModuleStats = getOrCreateMetadata(mod);\r\n const cachedResult: ISourceCacheEntry | undefined = sourceCache.get(source);\r\n if (cachedResult) {\r\n metadata.hashByChunk.set(chunkRenderContext.chunk, cachedResult.hash);\r\n return cachedResult.source;\r\n }\r\n\r\n // If this module is wrapped in a factory, need to add boilerplate so that the minifier keeps the function\r\n const wrapped: sources.Source = new ConcatSource(\r\n MODULE_WRAPPER_PREFIX + '\\n',\r\n source,\r\n '\\n' + MODULE_WRAPPER_SUFFIX\r\n );\r\n\r\n const nameForMap: string = `(modules)/${id}`;\r\n\r\n const { source: wrappedCodeRaw, map } = useSourceMaps\r\n ? wrapped.sourceAndMap()\r\n : {\r\n source: wrapped.source(),\r\n map: undefined\r\n };\r\n\r\n const wrappedCode: string = wrappedCodeRaw.toString();\r\n const hash: string = hashCodeFragment(wrappedCode);\r\n metadata.hashByChunk.set(chunkRenderContext.chunk, hash);\r\n if (!submittedModules.has(hash)) {\r\n submittedModules.add(hash);\r\n\r\n ++pendingMinificationRequests;\r\n\r\n minifier.minify(\r\n {\r\n hash,\r\n code: wrappedCode,\r\n nameForMap: useSourceMaps ? nameForMap : undefined,\r\n externals: undefined\r\n },\r\n (result: IModuleMinificationResult) => {\r\n if (isMinificationResultError(result)) {\r\n compilation.errors.push(result.error as WebpackError);\r\n } else {\r\n try {\r\n const { code: minified, map: minifierMap } = result;\r\n\r\n const rawOutput: sources.Source = useSourceMaps\r\n ? new SourceMapSource(\r\n minified, // Code\r\n nameForMap, // File\r\n minifierMap!, // Base source map\r\n wrappedCode, // Source from before transform\r\n map!, // Source Map from before transform\r\n true // Remove original source\r\n )\r\n : new RawSource(minified);\r\n\r\n const unwrapped: sources.ReplaceSource = new ReplaceSource(rawOutput);\r\n const len: number = minified.length;\r\n\r\n // Trim off the boilerplate used to preserve the factory\r\n unwrapped.replace(0, MODULE_WRAPPER_PREFIX.length - 1, '');\r\n unwrapped.replace(len - MODULE_WRAPPER_SUFFIX.length, len - 1, '');\r\n\r\n const withIds: sources.Source = postProcessCode(unwrapped, {\r\n compilation,\r\n module: mod,\r\n loggingName: mod.identifier()\r\n });\r\n const cached: sources.CachedSource = new CachedSource(withIds);\r\n\r\n const minifiedSize: number = Buffer.byteLength(cached.source(), 'utf-8');\r\n metadata.sizeByHash.set(hash, minifiedSize);\r\n\r\n minifiedModules.set(hash, {\r\n source: cached,\r\n module: mod,\r\n id\r\n });\r\n } catch (err) {\r\n compilation.errors.push(err);\r\n }\r\n }\r\n\r\n onFileMinified();\r\n }\r\n );\r\n }\r\n\r\n const result: sources.Source = new RawSource(`${CHUNK_MODULE_TOKEN}${hash}`);\r\n sourceCache.set(source, {\r\n hash,\r\n source: result\r\n });\r\n\r\n // Return an expression to replace later\r\n return result;\r\n }\r\n );\r\n\r\n // The optimizeChunkModules hook is the last async hook that occurs before chunk rendering\r\n compilation.hooks.optimizeChunkModules.tapPromise(PLUGIN_NAME, async () => {\r\n minifierConnection = await minifier.connect();\r\n\r\n submittedModules.clear();\r\n });\r\n\r\n const isJSAsset: RegExp = /\\.[cm]?js(\\?.+)?$/;\r\n\r\n // This should happen before any other tasks that operate during processAssets\r\n compilation.hooks.processAssets.tapPromise(TAP_BEFORE, async (): Promise<void> => {\r\n const { chunkGraph, chunks } = compilation;\r\n\r\n // Still need to minify the rendered assets\r\n for (const chunk of chunks) {\r\n const allChunkModules: Iterable<Module> | undefined =\r\n chunkGraph.getChunkModulesIterableBySourceType(chunk, 'javascript');\r\n if (!allChunkModules) {\r\n // This chunk does not contain javascript modules\r\n continue;\r\n }\r\n\r\n for (const assetName of chunk.files) {\r\n const asset: sources.Source = compilation.assets[assetName];\r\n\r\n // Verify that this is a JS asset\r\n if (isJSAsset.test(assetName)) {\r\n ++pendingMinificationRequests;\r\n\r\n const rawCode: string = asset.source() as string;\r\n const nameForMap: string = `(chunks)/${assetName}`;\r\n\r\n const hash: string = hashCodeFragment(rawCode);\r\n\r\n minifier.minify(\r\n {\r\n hash,\r\n code: rawCode,\r\n nameForMap: useSourceMaps ? nameForMap : undefined,\r\n externals: undefined\r\n },\r\n (result: IModuleMinificationResult) => {\r\n if (isMinificationResultError(result)) {\r\n compilation.errors.push(result.error as WebpackError);\r\n // eslint-disable-next-line no-console\r\n console.error(result.error);\r\n } else {\r\n try {\r\n const { code: minified, map: minifierMap } = result;\r\n\r\n const rawOutput: sources.Source = useSourceMaps\r\n ? new SourceMapSource(\r\n minified, // Code\r\n nameForMap, // File\r\n minifierMap!, // Base source map\r\n rawCode, // Source from before transform\r\n undefined, // Source Map from before transform\r\n true // Remove original source\r\n )\r\n : new RawSource(minified);\r\n\r\n const withIds: sources.Source = postProcessCode(new ReplaceSource(rawOutput), {\r\n compilation,\r\n module: undefined,\r\n loggingName: assetName\r\n });\r\n\r\n minifiedAssets.set(assetName, {\r\n source: new CachedSource(withIds),\r\n chunk,\r\n fileName: assetName,\r\n renderInfo: new Map(),\r\n type: 'javascript'\r\n });\r\n } catch (err) {\r\n compilation.errors.push(err);\r\n }\r\n }\r\n\r\n onFileMinified();\r\n }\r\n );\r\n } else {\r\n // This isn't a JS asset. Don't try to minify the asset wrapper, though if it contains modules, those might still get replaced with minified versions.\r\n minifiedAssets.set(assetName, {\r\n // Still need to restore ids\r\n source: postProcessCode(new ReplaceSource(asset), {\r\n compilation,\r\n module: undefined,\r\n loggingName: assetName\r\n }),\r\n chunk,\r\n fileName: assetName,\r\n renderInfo: new Map(),\r\n type: 'unknown'\r\n });\r\n }\r\n }\r\n }\r\n\r\n allRequestsIssued = true;\r\n\r\n if (pendingMinificationRequests) {\r\n await new Promise<void>((resolve) => {\r\n resolveMinifyPromise = resolve;\r\n });\r\n }\r\n\r\n // Handle any error from the minifier.\r\n await minifierConnection?.disconnect();\r\n\r\n // All assets and modules have been minified, hand them off to be rehydrated\r\n await this.hooks.rehydrateAssets.promise(\r\n {\r\n assets: minifiedAssets,\r\n modules: minifiedModules\r\n },\r\n compilation\r\n );\r\n });\r\n\r\n // Need to update chunk hashes with information from this plugin\r\n javascriptHooks.chunkHash.tap(PLUGIN_NAME, (chunk, hash): void => {\r\n // Apply the options hash\r\n hash.update(binaryConfig);\r\n // Apply the hash from the minifier\r\n if (minifierConnection) {\r\n hash.update(minifierConnection.configHash, 'utf8');\r\n }\r\n });\r\n });\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"ModuleMinifierPlugin.js","sourceRoot":"","sources":["../src/ModuleMinifierPlugin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,mCAAoC;AAcpC,qCAAgF;AAEhF,2CAMqB;AAOrB,gEAA2D;AAc3D,+EAA4E;AAC5E,qDAAkD;AAElD,0CAA0C;AAC1C,MAAM,WAAW,GAA2B,sBAAsB,CAAC;AAEnE,mGAAmG;AACnG,uCAAuC;AACvC,MAAM,wBAAwB,GAAW,CAAC,CAAC;AAC3C,2CAA2C;AAC3C,oGAAoG;AACpG,MAAM,qBAAqB,GAAW,8BAA8B,CAAC;AAErE,MAAM,UAAU,GAAQ;IACtB,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE,wBAAY;CACpB,CAAC;AACF,MAAM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AA,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAE,UAAU,EAAE,CAAA,CAAC;gBAEvC,4EAA4E;gBAC5E,MAAM,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,OAAO,CACtC;oBACE,MAAM,EAAE,cAAc;oBACtB,OAAO,EAAE,eAAe;iBACzB,EACD,WAAW,CACZ,CAAC;YACJ,CAAC,CAAC,CAAC;YAEH,gEAAgE;YAChE,eAAe,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,IAAI,EAAQ,EAAE;gBAC/D,yBAAyB;gBACzB,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;gBAC1B,mCAAmC;gBACnC,IAAI,kBAAkB,EAAE;oBACtB,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;iBACpD;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AApaD,oDAoaC","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 { createHash } from 'crypto';\n\nimport type { Comment } from 'estree';\nimport type {\n Module,\n Compilation,\n WebpackPluginInstance,\n Compiler,\n javascript,\n WebpackError,\n ExternalModule,\n sources,\n Chunk\n} from 'webpack';\nimport { AsyncSeriesWaterfallHook, SyncWaterfallHook, type Tap } from 'tapable';\n\nimport {\n CHUNK_MODULE_TOKEN,\n MODULE_WRAPPER_PREFIX,\n MODULE_WRAPPER_SUFFIX,\n STAGE_BEFORE,\n STAGE_AFTER\n} from './Constants';\nimport type {\n IMinifierConnection,\n IModuleMinifier,\n IModuleMinificationResult,\n IModuleMinificationErrorResult\n} from '@rushstack/module-minifier';\nimport { getIdentifier } from '@rushstack/module-minifier';\n\nimport type {\n IModuleMinifierPluginOptions,\n IModuleMap,\n IAssetMap,\n IFactoryMeta,\n IModuleMinifierPluginHooks,\n IPostProcessFragmentContext,\n IDehydratedAssets,\n IModuleStats,\n IModuleMinifierPluginStats as IModuleMinifierPluginStats,\n IAssetStats\n} from './ModuleMinifierPlugin.types';\nimport { generateLicenseFileForAsset } from './GenerateLicenseFileForAsset';\nimport { rehydrateAsset } from './RehydrateAsset';\n\n// The name of the plugin, for use in taps\nconst PLUGIN_NAME: 'ModuleMinifierPlugin' = 'ModuleMinifierPlugin';\n\n// Monotonically increasing identifier to be incremented any time the code generation logic changes\n// Will be applied to the webpack hash.\nconst CODE_GENERATION_REVISION: number = 1;\n// Match behavior of terser's \"some\" option\n// https://github.com/terser/terser/blob/d3d924fa9e4c57bbe286b811c6068bcc7026e902/lib/output.js#L175\nconst LICENSE_COMMENT_REGEX: RegExp = /@preserve|@lic|@cc_on|^\\**!/i;\n\nconst TAP_BEFORE: Tap = {\n name: PLUGIN_NAME,\n stage: STAGE_BEFORE\n};\nconst TAP_AFTER: Tap = {\n name: PLUGIN_NAME,\n stage: STAGE_AFTER\n};\n\ninterface IOptionsForHash extends Omit<IModuleMinifierPluginOptions, 'minifier'> {\n revision: number;\n minifier: undefined;\n}\n\ninterface ISourceCacheEntry {\n source: sources.Source;\n hash: string;\n}\n\nconst compilationMetadataMap: WeakMap<Compilation, IModuleMinifierPluginStats> = new WeakMap();\n\nfunction hashCodeFragment(code: string): string {\n return createHash('sha256').update(code).digest('hex');\n}\n\n/**\n * Base implementation of asset rehydration\n *\n * @param dehydratedAssets The dehydrated assets\n * @param compilation The webpack compilation\n */\nfunction defaultRehydrateAssets(\n dehydratedAssets: IDehydratedAssets,\n compilation: Compilation\n): IDehydratedAssets {\n const { assets, modules } = dehydratedAssets;\n\n const compilationMetadata: IModuleMinifierPluginStats | undefined = compilationMetadataMap.get(compilation);\n if (!compilationMetadata) {\n throw new Error(`Could not get compilation metadata`);\n }\n\n const { metadataByAssetFileName } = compilationMetadata;\n\n // Now assets/modules contain fully minified code. Rehydrate.\n for (const [assetName, info] of assets) {\n const banner: string = info.type === 'javascript' ? generateLicenseFileForAsset(compilation, info) : '';\n\n const replacementSource: sources.Source = rehydrateAsset(compilation, info, modules, banner, true);\n metadataByAssetFileName.set(assetName, {\n positionByModuleId: info.renderInfo\n });\n compilation.updateAsset(assetName, replacementSource);\n }\n\n return dehydratedAssets;\n}\n\nfunction isMinificationResultError(\n result: IModuleMinificationResult\n): result is IModuleMinificationErrorResult {\n return !!result.error;\n}\n\nfunction isLicenseComment(comment: Comment): boolean {\n return LICENSE_COMMENT_REGEX.test(comment.value);\n}\n\n/**\n * Webpack plugin that minifies code on a per-module basis rather than per-asset. The actual minification is handled by the input `minifier` object.\n * @public\n */\nexport class ModuleMinifierPlugin implements WebpackPluginInstance {\n public readonly hooks: IModuleMinifierPluginHooks;\n public minifier: IModuleMinifier;\n\n private readonly _enhancers: WebpackPluginInstance[];\n private readonly _sourceMap: boolean | undefined;\n\n private readonly _optionsForHash: IOptionsForHash;\n\n public constructor(options: IModuleMinifierPluginOptions) {\n this.hooks = {\n rehydrateAssets: new AsyncSeriesWaterfallHook(['dehydratedContent', 'compilation']),\n\n postProcessCodeFragment: new SyncWaterfallHook(['code', 'context'])\n };\n\n const { minifier, sourceMap } = options;\n\n this._optionsForHash = {\n ...options,\n minifier: undefined,\n revision: CODE_GENERATION_REVISION\n };\n\n this._enhancers = [];\n\n this.hooks.rehydrateAssets.tap(PLUGIN_NAME, defaultRehydrateAssets);\n this.minifier = minifier;\n\n this._sourceMap = sourceMap;\n }\n\n public static getCompilationStatistics(compilation: Compilation): IModuleMinifierPluginStats | undefined {\n return compilationMetadataMap.get(compilation);\n }\n\n public apply(compiler: Compiler): void {\n for (const enhancer of this._enhancers) {\n enhancer.apply(compiler);\n }\n\n const {\n options: { devtool, mode },\n webpack\n } = compiler;\n\n webpack.Template.numberToIdentifier = getIdentifier;\n\n const { CachedSource, ConcatSource, RawSource, ReplaceSource, SourceMapSource } = webpack.sources;\n // The explicit setting is preferred due to accuracy, but try to guess based on devtool\n const useSourceMaps: boolean =\n typeof this._sourceMap === 'boolean'\n ? this._sourceMap\n : typeof devtool === 'string'\n ? devtool.endsWith('source-map')\n : mode === 'production' && devtool !== false;\n\n this._optionsForHash.sourceMap = useSourceMaps;\n const binaryConfig: Buffer = Buffer.from(JSON.stringify(this._optionsForHash), 'utf-8');\n\n compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation, compilationData) => {\n const { normalModuleFactory } = compilationData;\n\n function addCommentExtraction(parser: javascript.JavascriptParser): void {\n parser.hooks.program.tap(PLUGIN_NAME, (program: unknown, comments: Comment[]) => {\n const relevantComments: Comment[] = comments.filter(isLicenseComment);\n if (comments.length > 0) {\n const module: Module = parser.state.module;\n if (!module.factoryMeta) {\n module.factoryMeta = {\n comments: relevantComments\n };\n } else {\n (module.factoryMeta as IFactoryMeta).comments = relevantComments;\n }\n }\n });\n }\n\n normalModuleFactory.hooks.parser.for('javascript/auto').tap(PLUGIN_NAME, addCommentExtraction);\n normalModuleFactory.hooks.parser.for('javascript/dynamic').tap(PLUGIN_NAME, addCommentExtraction);\n normalModuleFactory.hooks.parser.for('javascript/esm').tap(PLUGIN_NAME, addCommentExtraction);\n\n /**\n * Set of local module ids that have been processed.\n */\n const submittedModules: Set<string | number> = new Set();\n\n /**\n * The text and comments of all minified modules.\n */\n const minifiedModules: IModuleMap = new Map();\n\n /**\n * The text and comments of all minified chunks. Most of these are trivial, but the runtime chunk is a bit larger.\n */\n const minifiedAssets: IAssetMap = new Map();\n\n const metadataByModule: WeakMap<Module, IModuleStats> = new WeakMap();\n const metadataByAssetFileName: Map<string, IAssetStats> = new Map();\n const compilationStatistics: IModuleMinifierPluginStats = {\n metadataByModule,\n metadataByAssetFileName\n };\n compilationMetadataMap.set(compilation, compilationStatistics);\n function getOrCreateMetadata(mod: Module): IModuleStats {\n let moduleStats: IModuleStats | undefined = metadataByModule.get(mod);\n if (!moduleStats) {\n moduleStats = {\n hashByChunk: new Map(),\n sizeByHash: new Map()\n };\n metadataByModule.set(mod, moduleStats);\n }\n return moduleStats;\n }\n\n let pendingMinificationRequests: number = 0;\n /**\n * Indicates that all files have been sent to the minifier and therefore that when pending hits 0, assets can be rehydrated.\n */\n let allRequestsIssued: boolean = false;\n\n let resolveMinifyPromise: () => void;\n\n const postProcessCode: (\n code: sources.ReplaceSource,\n context: IPostProcessFragmentContext\n ) => sources.ReplaceSource = (code: sources.ReplaceSource, context: IPostProcessFragmentContext) =>\n this.hooks.postProcessCodeFragment.call(code, context);\n\n /**\n * Callback to invoke when a file has finished minifying.\n */\n function onFileMinified(): void {\n if (--pendingMinificationRequests === 0 && allRequestsIssued) {\n resolveMinifyPromise();\n }\n }\n\n const { minifier } = this;\n\n let minifierConnection: IMinifierConnection | undefined;\n\n // Typings for this object are not exposed\n // eslint-disable-next-line @typescript-eslint/typedef\n const javascriptHooks = webpack.javascript.JavascriptModulesPlugin.getCompilationHooks(compilation);\n\n /**\n * The minifier needs to know if the module was wrapped in a factory function, because\n * function (module, exports, require) { // <implementation> }\n * minifies to nothing. Unfortunately we can't tell by inspection if the output was wrapped or not.\n * However, the JavaScriptModulesPlugin invokes three hooks in order when rendering a module:\n * 1) renderModuleContent - Invoked for every module.\n * 2) renderModuleContainer - Invoked when wrapping a module in a factory.\n * 3) renderModulePackage - Invoked for every module as the last hook.\n */\n let nextModule: Module | undefined;\n const sourceCache: WeakMap<sources.Source, ISourceCacheEntry> = new WeakMap();\n javascriptHooks.renderModuleContent.tap(TAP_AFTER, (source) => {\n // Clear the identification state of the current module.\n nextModule = undefined;\n return source;\n });\n javascriptHooks.renderModuleContainer.tap(TAP_AFTER, (source, mod) => {\n // Module is being wrapped in a factory, so it is safe for per-module minification\n // Leave external modules in-place to avoid needing special handling for externals\n if (mod.context !== null || !(mod as ExternalModule).externalType) {\n nextModule = mod;\n }\n return source;\n });\n javascriptHooks.renderModulePackage.tap(\n TAP_AFTER,\n /**\n * Extracts the code for the module and sends it to be minified.\n */\n function minifyModule(\n source: sources.Source,\n mod: Module,\n chunkRenderContext: { chunk: Chunk }\n ): sources.Source {\n if (nextModule !== mod) {\n // This module is being inlined. Abandon per-module minification.\n return source;\n }\n\n const id: string | number = compilation.chunkGraph.getModuleId(mod);\n\n const metadata: IModuleStats = getOrCreateMetadata(mod);\n const cachedResult: ISourceCacheEntry | undefined = sourceCache.get(source);\n if (cachedResult) {\n metadata.hashByChunk.set(chunkRenderContext.chunk, cachedResult.hash);\n return cachedResult.source;\n }\n\n // If this module is wrapped in a factory, need to add boilerplate so that the minifier keeps the function\n const wrapped: sources.Source = new ConcatSource(\n MODULE_WRAPPER_PREFIX + '\\n',\n source,\n '\\n' + MODULE_WRAPPER_SUFFIX\n );\n\n const nameForMap: string = `(modules)/${id}`;\n\n const { source: wrappedCodeRaw, map } = useSourceMaps\n ? wrapped.sourceAndMap()\n : {\n source: wrapped.source(),\n map: undefined\n };\n\n const wrappedCode: string = wrappedCodeRaw.toString();\n const hash: string = hashCodeFragment(wrappedCode);\n metadata.hashByChunk.set(chunkRenderContext.chunk, hash);\n if (!submittedModules.has(hash)) {\n submittedModules.add(hash);\n\n ++pendingMinificationRequests;\n\n minifier.minify(\n {\n hash,\n code: wrappedCode,\n nameForMap: useSourceMaps ? nameForMap : undefined,\n externals: undefined\n },\n (result: IModuleMinificationResult) => {\n if (isMinificationResultError(result)) {\n compilation.errors.push(result.error as WebpackError);\n } else {\n try {\n const { code: minified, map: minifierMap } = result;\n\n const rawOutput: sources.Source = useSourceMaps\n ? new SourceMapSource(\n minified, // Code\n nameForMap, // File\n minifierMap!, // Base source map\n wrappedCode, // Source from before transform\n map!, // Source Map from before transform\n true // Remove original source\n )\n : new RawSource(minified);\n\n const unwrapped: sources.ReplaceSource = new ReplaceSource(rawOutput);\n const len: number = minified.length;\n\n // Trim off the boilerplate used to preserve the factory\n unwrapped.replace(0, MODULE_WRAPPER_PREFIX.length - 1, '');\n unwrapped.replace(len - MODULE_WRAPPER_SUFFIX.length, len - 1, '');\n\n const withIds: sources.Source = postProcessCode(unwrapped, {\n compilation,\n module: mod,\n loggingName: mod.identifier()\n });\n const cached: sources.CachedSource = new CachedSource(withIds);\n\n const minifiedSize: number = Buffer.byteLength(cached.source(), 'utf-8');\n metadata.sizeByHash.set(hash, minifiedSize);\n\n minifiedModules.set(hash, {\n source: cached,\n module: mod,\n id\n });\n } catch (err) {\n compilation.errors.push(err);\n }\n }\n\n onFileMinified();\n }\n );\n }\n\n const result: sources.Source = new RawSource(`${CHUNK_MODULE_TOKEN}${hash}`);\n sourceCache.set(source, {\n hash,\n source: result\n });\n\n // Return an expression to replace later\n return result;\n }\n );\n\n // The optimizeChunkModules hook is the last async hook that occurs before chunk rendering\n compilation.hooks.optimizeChunkModules.tapPromise(PLUGIN_NAME, async () => {\n minifierConnection = await minifier.connect();\n\n submittedModules.clear();\n });\n\n const isJSAsset: RegExp = /\\.[cm]?js(\\?.+)?$/;\n\n // This should happen before any other tasks that operate during processAssets\n compilation.hooks.processAssets.tapPromise(TAP_BEFORE, async (): Promise<void> => {\n const { chunkGraph, chunks } = compilation;\n\n // Still need to minify the rendered assets\n for (const chunk of chunks) {\n const allChunkModules: Iterable<Module> | undefined =\n chunkGraph.getChunkModulesIterableBySourceType(chunk, 'javascript');\n if (!allChunkModules) {\n // This chunk does not contain javascript modules\n continue;\n }\n\n for (const assetName of chunk.files) {\n const asset: sources.Source = compilation.assets[assetName];\n\n // Verify that this is a JS asset\n if (isJSAsset.test(assetName)) {\n ++pendingMinificationRequests;\n\n const rawCode: string = asset.source() as string;\n const nameForMap: string = `(chunks)/${assetName}`;\n\n const hash: string = hashCodeFragment(rawCode);\n\n minifier.minify(\n {\n hash,\n code: rawCode,\n nameForMap: useSourceMaps ? nameForMap : undefined,\n externals: undefined\n },\n (result: IModuleMinificationResult) => {\n if (isMinificationResultError(result)) {\n compilation.errors.push(result.error as WebpackError);\n // eslint-disable-next-line no-console\n console.error(result.error);\n } else {\n try {\n const { code: minified, map: minifierMap } = result;\n\n const rawOutput: sources.Source = useSourceMaps\n ? new SourceMapSource(\n minified, // Code\n nameForMap, // File\n minifierMap!, // Base source map\n rawCode, // Source from before transform\n undefined, // Source Map from before transform\n true // Remove original source\n )\n : new RawSource(minified);\n\n const withIds: sources.Source = postProcessCode(new ReplaceSource(rawOutput), {\n compilation,\n module: undefined,\n loggingName: assetName\n });\n\n minifiedAssets.set(assetName, {\n source: new CachedSource(withIds),\n chunk,\n fileName: assetName,\n renderInfo: new Map(),\n type: 'javascript'\n });\n } catch (err) {\n compilation.errors.push(err);\n }\n }\n\n onFileMinified();\n }\n );\n } else {\n // This isn't a JS asset. Don't try to minify the asset wrapper, though if it contains modules, those might still get replaced with minified versions.\n minifiedAssets.set(assetName, {\n // Still need to restore ids\n source: postProcessCode(new ReplaceSource(asset), {\n compilation,\n module: undefined,\n loggingName: assetName\n }),\n chunk,\n fileName: assetName,\n renderInfo: new Map(),\n type: 'unknown'\n });\n }\n }\n }\n\n allRequestsIssued = true;\n\n if (pendingMinificationRequests) {\n await new Promise<void>((resolve) => {\n resolveMinifyPromise = resolve;\n });\n }\n\n // Handle any error from the minifier.\n await minifierConnection?.disconnect();\n\n // All assets and modules have been minified, hand them off to be rehydrated\n await this.hooks.rehydrateAssets.promise(\n {\n assets: minifiedAssets,\n modules: minifiedModules\n },\n compilation\n );\n });\n\n // Need to update chunk hashes with information from this plugin\n javascriptHooks.chunkHash.tap(PLUGIN_NAME, (chunk, hash): void => {\n // Apply the options hash\n hash.update(binaryConfig);\n // Apply the hash from the minifier\n if (minifierConnection) {\n hash.update(minifierConnection.configHash, 'utf8');\n }\n });\n });\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModuleMinifierPlugin.types.js","sourceRoot":"","sources":["../src/ModuleMinifierPlugin.types.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\
|
|
1
|
+
{"version":3,"file":"ModuleMinifierPlugin.types.js","sourceRoot":"","sources":["../src/ModuleMinifierPlugin.types.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D","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 type { IModuleMinifier } from '@rushstack/module-minifier';\nimport type { AsyncSeriesWaterfallHook, SyncWaterfallHook } from 'tapable';\nimport type { Chunk, Compilation, Module, sources } from 'webpack';\nimport type { Comment } from 'estree';\n\n/**\n * Information about where the module was rendered in the emitted asset.\n * @public\n */\nexport interface IRenderedModulePosition {\n /**\n * The offset from the start of tha asset to the start of the module, in characters.\n */\n charOffset: number;\n /**\n * The length of the rendered module, in characters.\n */\n charLength: number;\n}\n\n/**\n * Information about a dehydrated webpack ECMAScript asset\n * @public\n */\nexport interface IAssetInfo {\n /**\n * The (minified) boilerplate code for the asset. Will contain a token to be replaced by the minified modules.\n */\n source: sources.Source;\n\n /**\n * The name of the asset, used to index into compilation.assets\n */\n fileName: string;\n\n /**\n * The raw chunk object from Webpack, in case information from it is necessary for reconstruction\n */\n chunk: Chunk;\n\n /**\n * Information about the offsets and character lengths for each rendered module in the final asset.\n */\n renderInfo: Map<string | number, IRenderedModulePosition>;\n\n /**\n * The type of the asset\n * @example 'javascript'\n * @example 'css'\n */\n type: string;\n}\n\n/**\n * Information about a minified module\n * @public\n */\nexport interface IModuleInfo {\n /**\n * The (minified) code of this module. Will be a function expression.\n */\n source: sources.Source;\n\n /**\n * The raw module object from Webpack, in case information from it is necessary for reconstruction\n */\n module: Module;\n\n /**\n * The id of the module, from the chunk graph.\n */\n id: string | number;\n}\n\n/**\n * This is the second parameter to the NormalModuleFactory `module` hook\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface _INormalModuleFactoryModuleData {\n resourceResolveData?: {\n /**\n * Contents of the description file (package.json) for the module\n */\n descriptionFileData?: {\n /**\n * The name of the package\n */\n name: string;\n };\n /**\n * Absolute path of the description file (package.json) for the module\n */\n descriptionFilePath?: string;\n /**\n * Absolute path of the directory containing the description file (package.json) for the module\n */\n descriptionFileRoot?: string;\n /**\n * Relative path from the description file (package.json) to the module\n */\n relativePath?: string;\n };\n}\n\n/**\n * Properties surfaced via the `factoryMeta` property on webpack modules\n * @public\n */\nexport interface IFactoryMeta {\n comments?: Comment[];\n skipMinification?: boolean;\n}\n\n/**\n * Statistics from the plugin. Namely module sizes.\n * @public\n */\nexport interface IModuleMinifierPluginStats {\n metadataByModule: WeakMap<Module, IModuleStats>;\n metadataByAssetFileName: Map<string, IAssetStats>;\n}\n\n/**\n * Module size data as a function of the target chunk.\n * @public\n */\nexport interface IModuleStats {\n hashByChunk: Map<Chunk, string>;\n sizeByHash: Map<string, number>;\n}\n\n/**\n * Rendered positional data\n * @public\n */\nexport interface IAssetStats {\n positionByModuleId: Map<string | number, IRenderedModulePosition>;\n}\n\n/**\n * A map from file names to dehydrated assets\n * @public\n */\nexport type IAssetMap = Map<string, IAssetInfo>;\n/**\n * A map from module ids to minified modules\n * @public\n */\nexport type IModuleMap = Map<string | number, IModuleInfo>;\n\n/**\n * Options to the ModuleMinifierPlugin constructor\n * @public\n */\nexport interface IModuleMinifierPluginOptions {\n /**\n * Minifier implementation to use. Required.\n */\n minifier: IModuleMinifier;\n\n /**\n * Whether to enable source map processing. If not provided, will attempt to guess based on `mode` and `devtool` in the webpack config.\n * Set to `false` for faster builds at the expense of debuggability.\n */\n sourceMap?: boolean;\n}\n\n/**\n * The set of data remaining to rehydrate in the current compilation\n * @public\n */\nexport interface IDehydratedAssets {\n /**\n * The set of remaining assets to rehydrate. Each tap may remove some or all assets from this collection\n */\n assets: IAssetMap;\n\n /**\n * The set of modules to use for rehydrating assets.\n */\n modules: IModuleMap;\n}\n\n/**\n * Argument to the postProcessCodeFragment hook for the current execution context\n * @public\n */\nexport interface IPostProcessFragmentContext {\n /**\n * The current webpack compilation, for error reporting\n */\n compilation: Compilation;\n /**\n * A name to use for logging\n */\n loggingName: string;\n /**\n * The current module being processed, or `undefined` if not in a module (e.g. the bootstrapper)\n */\n module: Module | undefined;\n}\n\n/**\n * Hooks provided by the ModuleMinifierPlugin\n * @public\n */\nexport interface IModuleMinifierPluginHooks {\n /**\n * Hook invoked at the start of optimizeChunkAssets to rehydrate the minified boilerplate and runtime into chunk assets.\n */\n rehydrateAssets: AsyncSeriesWaterfallHook<[IDehydratedAssets, Compilation]>;\n\n /**\n * Hook invoked on code after it has been returned from the minifier.\n */\n postProcessCodeFragment: SyncWaterfallHook<[sources.ReplaceSource, IPostProcessFragmentContext]>;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RehydrateAsset.js","sourceRoot":"","sources":["../src/RehydrateAsset.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAK3D,2CAAqE;AAGrE;;;;;;GAMG;AACH,SAAgB,cAAc,CAC5B,WAAwB,EACxB,KAAiB,EACjB,SAAqB,EACrB,MAAc,EACd,cAAwB;IAExB,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;IACtC,MAAM,EACJ,OAAO,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,EACnC,GAAG,WAAW,CAAC,QAAQ,CAAC;IAEzB,MAAM,SAAS,GAAW,WAAW,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC;IAE1D,MAAM,UAAU,GAAW,SAAS,CAAC,OAAO,CAAC,8BAAkB,CAAC,CAAC;IACjE,IAAI,UAAU,GAAG,CAAC,EAAE;QAClB,0BAA0B;QAC1B,OAAO,WAAW,CAAC;KACpB;IAED,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IAE9D,8BAAkB,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;IAClC,IAAI,SAAS,GAAW,CAAC,CAAC;IAE1B,MAAM,iBAAiB,GAAyB,IAAI,YAAY,CAAC,WAAW,CAAC,CAAC;IAE9E,MAAM,MAAM,GAA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AAC,MAAM,CAAC;SAClC;QAED,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACjB,UAAU,IAAI,CAAC,CAAC;KACjB;IAED,MAAM,CAAC,GAAG,CAAC,wBAAwB,CAAC,aAAa,EAAE,iBAAiB,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;IAE5F,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;AAClC,CAAC;AA9ED,wCA8EC;AAED,kKAAkK;AAClK,SAAS,wBAAwB,CAC/B,wBAAsD,EACtD,MAAsB,EACtB,KAAa,EACb,GAAW;IAEX,MAAM,MAAM,GAA0B,IAAI,wBAAwB,CAAC,MAAM,CAAC,CAAC;IAC3E,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;IAClC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;IACjC,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\
|
|
1
|
+
{"version":3,"file":"RehydrateAsset.js","sourceRoot":"","sources":["../src/RehydrateAsset.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAK3D,2CAAqE;AAGrE;;;;;;GAMG;AACH,SAAgB,cAAc,CAC5B,WAAwB,EACxB,KAAiB,EACjB,SAAqB,EACrB,MAAc,EACd,cAAwB;IAExB,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;IACtC,MAAM,EACJ,OAAO,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,EACnC,GAAG,WAAW,CAAC,QAAQ,CAAC;IAEzB,MAAM,SAAS,GAAW,WAAW,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC;IAE1D,MAAM,UAAU,GAAW,SAAS,CAAC,OAAO,CAAC,8BAAkB,CAAC,CAAC;IACjE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UAAU,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,EAAE;oBACpC,UAAU;oBACV,UAAU;iBACX,CAAC,CAAC;aACJ;YAED,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YAChC,UAAU,IAAI,UAAU,CAAC;SAC1B;aAAM;YACL,MAAM,WAAW,GAAW,oDAAoD,IAAI,OAAO,CAAC;YAE5F,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;YACxB,UAAU,IAAI,WAAW,CAAC,MAAM,CAAC;SAClC;QAED,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACjB,UAAU,IAAI,CAAC,CAAC;KACjB;IAED,MAAM,CAAC,GAAG,CAAC,wBAAwB,CAAC,aAAa,EAAE,iBAAiB,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;IAE5F,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;AAClC,CAAC;AA9ED,wCA8EC;AAED,kKAAkK;AAClK,SAAS,wBAAwB,CAC/B,wBAAsD,EACtD,MAAsB,EACtB,KAAa,EACb,GAAW;IAEX,MAAM,MAAM,GAA0B,IAAI,wBAAwB,CAAC,MAAM,CAAC,CAAC;IAC3E,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;IAClC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;IACjC,OAAO,MAAM,CAAC;AAChB,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 type { sources } from 'webpack';\nimport type { Compilation } from 'webpack';\n\nimport { CHUNK_MODULE_TOKEN, CHUNK_MODULE_REGEX } from './Constants';\nimport type { IAssetInfo, IModuleMap, IModuleInfo } from './ModuleMinifierPlugin.types';\n\n/**\n * Rehydrates an asset with minified modules.\n * @param asset - The asset\n * @param moduleMap - The minified modules\n * @param banner - A banner to inject for license information\n * @public\n */\nexport function rehydrateAsset(\n compilation: Compilation,\n asset: IAssetInfo,\n moduleMap: IModuleMap,\n banner: string,\n emitRenderInfo?: boolean\n): sources.Source {\n const { source: assetSource } = asset;\n const {\n webpack: { sources, WebpackError }\n } = compilation.compiler;\n\n const assetCode: string = assetSource.source().toString();\n\n const tokenIndex: number = assetCode.indexOf(CHUNK_MODULE_TOKEN);\n if (tokenIndex < 0) {\n // This is not a JS asset.\n return assetSource;\n }\n\n const { CachedSource, ConcatSource, ReplaceSource } = sources;\n\n CHUNK_MODULE_REGEX.lastIndex = -1;\n let lastStart: number = 0;\n\n const cachedAssetSource: sources.CachedSource = new CachedSource(assetSource);\n\n const source: sources.ConcatSource = new ConcatSource(banner);\n let charOffset: number = banner.length;\n\n // RegExp.exec uses null or an array as the return type, explicitly\n let match: RegExpExecArray | null = null;\n while ((match = CHUNK_MODULE_REGEX.exec(assetCode))) {\n const hash: string = match[1];\n\n const moduleSource: IModuleInfo | undefined = moduleMap.get(hash);\n if (moduleSource === undefined) {\n compilation.errors.push(new WebpackError(`Missing module source for ${hash} in ${asset.fileName}!`));\n }\n\n const separator: sources.ReplaceSource = extractSegmentFromSource(\n ReplaceSource,\n cachedAssetSource,\n lastStart,\n match.index\n );\n\n source.add(separator);\n charOffset += separator.size();\n\n lastStart = CHUNK_MODULE_REGEX.lastIndex;\n\n if (moduleSource) {\n const charLength: number = moduleSource.source.source().length;\n\n if (emitRenderInfo) {\n asset.renderInfo.set(moduleSource.id, {\n charOffset,\n charLength\n });\n }\n\n source.add(moduleSource.source);\n charOffset += charLength;\n } else {\n const errorModule: string = `()=>{throw new Error(\\`Missing module with hash \"${hash}\"\\`)}`;\n\n source.add(errorModule);\n charOffset += errorModule.length;\n }\n\n source.add('\\n');\n charOffset += 1;\n }\n\n source.add(extractSegmentFromSource(ReplaceSource, cachedAssetSource, lastStart, Infinity));\n\n return new CachedSource(source);\n}\n\n// In order to preserve source maps during substitution, have to use a ConcatSource instead of a ReplaceSource, so need to extract the segements from the original\nfunction extractSegmentFromSource(\n replaceSourceConstructor: typeof sources.ReplaceSource,\n source: sources.Source,\n start: number,\n end: number\n): sources.ReplaceSource {\n const result: sources.ReplaceSource = new replaceSourceConstructor(source);\n result.replace(end, Infinity, '');\n result.replace(0, start - 1, '');\n return result;\n}\n"]}
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;AAE3D,8CAA4B;AAC5B,gEAA8C;AAgB9C,yDAAuC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;AAE3D,8CAA4B;AAC5B,gEAA8C;AAgB9C,yDAAuC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nexport * from './Constants';\nexport * from './GenerateLicenseFileForAsset';\nexport type {\n IAssetInfo,\n IAssetMap,\n IAssetStats,\n IDehydratedAssets,\n IFactoryMeta,\n IModuleInfo,\n IModuleMap,\n IModuleMinifierPluginHooks,\n IModuleMinifierPluginOptions,\n IModuleMinifierPluginStats,\n IModuleStats,\n IPostProcessFragmentContext,\n IRenderedModulePosition\n} from './ModuleMinifierPlugin.types';\nexport * from './ModuleMinifierPlugin';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/webpack5-module-minifier-plugin",
|
|
3
|
-
"version": "5.5.
|
|
3
|
+
"version": "5.5.12",
|
|
4
4
|
"description": "This plugin splits minification of webpack compilations into smaller units.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "dist/webpack5-module-minifier-plugin.d.ts",
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
"@types/tapable": "1.0.6",
|
|
23
23
|
"@types/estree": "1.0.2",
|
|
24
24
|
"tapable": "2.2.1",
|
|
25
|
-
"@rushstack/worker-pool": "0.4.
|
|
25
|
+
"@rushstack/worker-pool": "0.4.12"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"memfs": "3.4.3",
|
|
29
29
|
"webpack": "~5.82.1",
|
|
30
|
-
"@rushstack/heft": "0.63.0",
|
|
31
30
|
"local-node-rig": "1.0.0",
|
|
32
|
-
"@rushstack/module-minifier": "0.4.
|
|
31
|
+
"@rushstack/module-minifier": "0.4.12",
|
|
32
|
+
"@rushstack/heft": "0.63.2"
|
|
33
33
|
},
|
|
34
34
|
"sideEffects": false,
|
|
35
35
|
"peerDependenciesMeta": {
|