webpack 5.112.0 → 5.112.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/webpack.js +13 -7
- package/lib/Compilation.js +152 -60
- package/lib/Compiler.js +12 -25
- package/lib/asset/AssetBytesGenerator.js +14 -6
- package/lib/asset/AssetBytesParser.js +10 -8
- package/lib/asset/AssetGenerator.js +36 -48
- package/lib/asset/AssetModule.js +11 -0
- package/lib/asset/AssetModulesPlugin.js +5 -4
- package/lib/asset/AssetParser.js +8 -8
- package/lib/asset/AssetSourceGenerator.js +16 -8
- package/lib/asset/AssetSourceParser.js +10 -8
- package/lib/asset/WebManifestGenerator.js +11 -6
- package/lib/asset/WebManifestParser.js +3 -3
- package/lib/async-modules/AsyncModuleHelpers.js +8 -2
- package/lib/async-modules/InferAsyncModulesPlugin.js +7 -2
- package/lib/cache/CacheFacade.js +1 -1
- package/lib/cache/PackFileCacheStrategy.js +6 -10
- package/lib/cache/ResolverCachePlugin.js +58 -8
- package/lib/config/WebpackOptionsApply.js +8 -28
- package/lib/config/cli.js +9 -6
- package/lib/config/defaults.js +24 -13
- package/lib/config/getClaimedAssetTypes.js +2 -2
- package/lib/config/target.js +1 -1
- package/lib/context/ContextModule.js +1 -1
- package/lib/context/ContextModuleFactory.js +1 -1
- package/lib/context/ContextReplacementPlugin.js +3 -9
- package/lib/css/CssGenerator.js +40 -37
- package/lib/css/CssModule.js +10 -0
- package/lib/css/CssModulesPlugin.js +2 -2
- package/lib/css/CssParser.js +33 -32
- package/lib/css/conventions.js +1 -1
- package/lib/css/data.js +224 -219
- package/lib/css/syntax-parser.js +1159 -298
- package/lib/css/syntax-printer.js +90 -35
- package/lib/debug/ProfilingPlugin.js +65 -43
- package/lib/define/DefinePlugin.js +10 -15
- package/lib/define/DotenvPlugin.js +10 -6
- package/lib/define/EnvironmentPlugin.js +4 -2
- package/lib/dependencies/amd/AMDDefineDependencyParserPlugin.js +1 -2
- package/lib/dependencies/amd/AMDRequireDependenciesBlockParserPlugin.js +4 -1
- package/lib/dependencies/commonjs/CommonJsExportRequireDependency.js +1 -4
- package/lib/dependencies/commonjs/CommonJsExportsParserPlugin.js +18 -33
- package/lib/dependencies/commonjs/CommonJsImportsParserPlugin.js +1 -3
- package/lib/dependencies/commonjs/CommonJsObjectExportDependency.js +4 -4
- package/lib/dependencies/commonjs/CommonJsPlugin.js +2 -5
- package/lib/dependencies/commonjs/RequireEnsureDependenciesBlockParserPlugin.js +4 -1
- package/lib/dependencies/context/ImportMetaContextDependencyParserPlugin.js +1 -2
- package/lib/dependencies/context/ImportMetaGlobDependencyParserPlugin.js +4 -7
- package/lib/dependencies/context/ImportMetaGlobHelpers.js +8 -10
- package/lib/dependencies/core/CachedConstDependency.js +9 -6
- package/lib/dependencies/css/CssIcssExportDependency.js +6 -7
- package/lib/dependencies/css/CssIcssImportDependency.js +1 -3
- package/lib/dependencies/css/CssUrlDependency.js +2 -6
- package/lib/dependencies/esm/ESMDetectionParserPlugin.js +2 -4
- package/lib/dependencies/esm/ESMExportExpressionDependency.js +2 -2
- package/lib/dependencies/esm/ESMExportImportedSpecifierDependency.js +16 -18
- package/lib/dependencies/esm/ESMExportSpecifierDependency.js +20 -3
- package/lib/dependencies/esm/ESMExports.js +2 -10
- package/lib/dependencies/esm/ESMImportDependency.js +17 -2
- package/lib/dependencies/esm/ESMImportDependencyParserPlugin.js +6 -17
- package/lib/dependencies/esm/ESMImportGuard.js +11 -23
- package/lib/dependencies/esm/ESMImportSideEffectDependency.js +1 -1
- package/lib/dependencies/esm/ESMImportSpecifierDependency.js +4 -1
- package/lib/dependencies/esm/ESMLiveExportDependency.js +311 -0
- package/lib/dependencies/esm/ESMLiveExportParserPlugin.js +862 -0
- package/lib/dependencies/esm/ESMModulesPlugin.js +1 -3
- package/lib/dependencies/esm/TopLevelAwaitDependency.js +1 -8
- package/lib/dependencies/helpers/DynamicExports.js +4 -6
- package/lib/dependencies/html/HtmlEntryDependency.js +5 -14
- package/lib/dependencies/html/HtmlInlineHtmlDependency.js +1 -4
- package/lib/dependencies/html/HtmlInlineScriptDependency.js +2 -6
- package/lib/dependencies/html/HtmlInlineStyleDependency.js +1 -4
- package/lib/dependencies/import/ImportParserPlugin.js +3 -6
- package/lib/dependencies/import-meta/ImportMetaPlugin.js +4 -6
- package/lib/dependencies/url/URLParserPlugin.js +1 -1
- package/lib/dependencies/worker/WorkerAndWorkletPlugin.js +51 -20
- package/lib/devtool/ModuleFilenameHelpers.js +1 -1
- package/lib/devtool/SourceMapDevToolPlugin.js +1 -1
- package/lib/dll/DelegatedModule.js +3 -3
- package/lib/dll/DllModule.js +3 -1
- package/lib/dll/DllReferencePlugin.js +1 -4
- package/lib/errors/AbstractMethodError.js +1 -1
- package/lib/errors/ErrorHelpers.js +2 -1
- package/lib/errors/HookWebpackError.js +2 -1
- package/lib/errors/JSONParseError.js +4 -4
- package/lib/errors/WebpackError.js +3 -2
- package/lib/esm/ModuleChunkFormatPlugin.js +36 -1
- package/lib/externals/ExternalModule.js +12 -9
- package/lib/externals/ExternalModuleFactoryPlugin.js +1 -2
- package/lib/externals/ExternalsPlugin.js +1 -1
- package/lib/fs/FileSystemInfo.js +4 -4
- package/lib/graph/AsyncDependenciesBlock.js +1 -1
- package/lib/graph/ChunkGraph.js +5 -0
- package/lib/graph/Dependency.js +8 -2
- package/lib/graph/ExportsInfo.js +1 -1
- package/lib/graph/ModuleGraph.js +14 -3
- package/lib/graph/buildChunkGraph.js +17 -19
- package/lib/graph/findGraphRoots.js +1 -1
- package/lib/hmr/HotModuleReplacement.runtime.js +10 -9
- package/lib/hmr/HotModuleReplacementPlugin.js +5 -11
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +16 -19
- package/lib/hmr/LazyCompilationPlugin.js +1 -7
- package/lib/html/HtmlGenerator.js +25 -17
- package/lib/html/HtmlModule.js +11 -1
- package/lib/html/HtmlModulesPlugin.js +12 -11
- package/lib/html/HtmlParser.js +10 -9
- package/lib/html/builtinEmbeddedRenderer.js +31 -33
- package/lib/html/data.js +42 -21
- package/lib/html/htmlMinify.js +4 -1
- package/lib/html/syntax-parser.js +34 -35
- package/lib/html/syntax-printer.js +2 -3
- package/lib/html/xmlMinify.js +4 -1
- package/lib/ids/HashedModuleIdsPlugin.js +1 -1
- package/lib/index.js +13 -12
- package/lib/javascript/APIPlugin.js +7 -13
- package/lib/javascript/BasicEvaluatedExpression.js +5 -5
- package/lib/javascript/CommonJsChunkFormatPlugin.js +2 -7
- package/lib/javascript/ConstPlugin.js +1 -1
- package/lib/javascript/JavascriptGenerator.js +16 -11
- package/lib/javascript/JavascriptMetaInfoPlugin.js +3 -15
- package/lib/javascript/JavascriptModule.js +10 -0
- package/lib/javascript/JavascriptModulesPlugin.js +2 -4
- package/lib/javascript/JavascriptParser.js +99 -11
- package/lib/javascript/ScopeAnalyzer.js +183 -107
- package/lib/javascript/UseStrictPlugin.js +2 -5
- package/lib/javascript/jsMinify.js +1 -1
- package/lib/javascript/regexp.js +2 -2
- package/lib/javascript/syntax-parser.js +2114 -1506
- package/lib/javascript/syntax-printer-data.js +167 -1
- package/lib/javascript/syntax-printer.js +9554 -2782
- package/lib/json/JsonGenerator.js +15 -7
- package/lib/json/JsonModule.js +11 -0
- package/lib/json/JsonParser.js +7 -6
- package/lib/library/AssignLibraryPlugin.js +1 -1
- package/lib/library/JsonpLibraryPlugin.js +1 -1
- package/lib/library/ModuleLibraryPlugin.js +399 -23
- package/lib/loaders/LoaderRunner.js +76 -38
- package/lib/loaders/loadLoader.js +16 -10
- package/lib/module/Generator.js +17 -9
- package/lib/module/Module.js +2 -2
- package/lib/module/NormalModule.js +7 -5
- package/lib/module/NormalModuleFactory.js +11 -17
- package/lib/module/Parser.js +9 -2
- package/lib/module/extractSourceMap.js +69 -18
- package/lib/module/findCaseMismatch.js +2 -2
- package/lib/node/ExternalModuleInitFragment.js +2 -2
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +4 -12
- package/lib/node/ReadFileCompileWasmPlugin.js +2 -6
- package/lib/node/nodeConsole.js +4 -3
- package/lib/optimize/CircularModulesPlugin.js +1 -1
- package/lib/optimize/ConcatenatedModule.js +2 -6
- package/lib/optimize/FlagDependencyExportsPlugin.js +6 -11
- package/lib/optimize/FlagDependencyUsagePlugin.js +28 -3
- package/lib/optimize/InlineExports.js +4 -7
- package/lib/optimize/LazyBarrels.js +41 -5
- package/lib/optimize/ModuleConcatenationPlugin.js +8 -10
- package/lib/optimize/RealContentHashPlugin.js +2 -6
- package/lib/optimize/SideEffectsFlagPlugin.js +7 -21
- package/lib/optimize/SplitChunksPlugin.js +11 -24
- package/lib/optimize/TupleQueue.js +1 -1
- package/lib/output/CleanPlugin.js +3 -1
- package/lib/output/CopyPlugin.js +3 -4
- package/lib/performance/EvalUsagePlugin.js +1 -3
- package/lib/performance/HotspotsPlugin.js +33 -9
- package/lib/performance/PureAnnotationsPlugin.js +16 -10
- package/lib/performance/TopLevelThisPlugin.js +17 -9
- package/lib/prefetch/ResourceHintPlugin.js +1 -1
- package/lib/provide/ProvidedDependency.js +36 -4
- package/lib/rules/BasicEffectRulePlugin.js +1 -1
- package/lib/rules/RuleSetCompiler.js +15 -5
- package/lib/rules/UseEffectRulePlugin.js +1 -3
- package/lib/runtime/AsyncModuleRuntimeModule.js +7 -1
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +1 -5
- package/lib/runtime/RuntimeGlobals.js +6 -0
- package/lib/runtime/RuntimePlugin.js +2 -0
- package/lib/schemes/HttpUriPlugin.js +1 -2
- package/lib/schemes/VirtualUrlPlugin.js +3 -1
- package/lib/serialization/AggregateErrorSerializer.js +3 -3
- package/lib/serialization/BinaryMiddleware.js +4 -1
- package/lib/serialization/ErrorObjectSerializer.js +2 -5
- package/lib/serialization/ObjectMiddleware.js +17 -15
- package/lib/serialization/PlainObjectSerializer.js +3 -7
- package/lib/serialization/Serializer.js +21 -11
- package/lib/serialization/SerializerMiddleware.js +8 -6
- package/lib/stats/DefaultStatsFactoryPlugin.js +35 -35
- package/lib/stats/DefaultStatsPresetPlugin.js +2 -6
- package/lib/stats/DefaultStatsPrinterPlugin.js +12 -11
- package/lib/stats/StatsFactory.js +194 -24
- package/lib/stats/StatsPrinter.js +126 -13
- package/lib/template/DependencyTemplate.js +1 -1
- package/lib/template/RuntimeTemplate.js +13 -32
- package/lib/template/Template.js +1 -1
- package/lib/util/SourceProcessor.js +98 -15
- package/lib/util/WeakTupleMap.js +10 -4
- package/lib/util/cleverMerge.js +61 -33
- package/lib/util/comparators.js +9 -5
- package/lib/util/dataURL.js +2 -0
- package/lib/util/deprecation.js +4 -3
- package/lib/util/globUtils.js +1 -4
- package/lib/util/internalSerializables.js +2 -0
- package/lib/util/makeSerializable.js +6 -4
- package/lib/util/memoize.js +1 -1
- package/lib/util/parseJson.js +2 -2
- package/lib/util/serialization.js +31 -27
- package/lib/wasm/AsyncWasmModule.js +12 -2
- package/lib/wasm/AsyncWebAssemblyGenerator.js +12 -4
- package/lib/wasm/AsyncWebAssemblyJavascriptGenerator.js +13 -5
- package/lib/wasm/AsyncWebAssemblyParser.js +7 -5
- package/lib/wasm/UniversalCompileAsyncWasmPlugin.js +2 -6
- package/lib/wasm-sync/SyncWasmModule.js +16 -1
- package/lib/wasm-sync/WebAssemblyGenerator.js +15 -10
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +13 -5
- package/lib/wasm-sync/WebAssemblyParser.js +10 -12
- package/lib/web/FetchCompileAsyncWasmPlugin.js +4 -12
- package/lib/web/FetchCompileWasmPlugin.js +2 -6
- package/package.json +16 -18
- package/schemas/WebpackOptions.check.js +3 -3
- package/schemas/WebpackOptions.json +2 -2
- package/schemas/plugins/BannerPlugin.check.js +3 -3
- package/schemas/plugins/HtmlGeneratorOptions.check.js +3 -3
- package/schemas/plugins/HtmlParserOptions.check.js +3 -3
- package/schemas/plugins/IgnorePlugin.check.js +3 -3
- package/schemas/plugins/LoaderOptionsPlugin.check.js +3 -3
- package/schemas/plugins/ManifestPlugin.check.js +3 -3
- package/schemas/plugins/ProgressPlugin.check.js +3 -3
- package/schemas/plugins/SSRManifestPlugin.check.js +3 -3
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +3 -3
- package/schemas/plugins/WatchIgnorePlugin.check.js +3 -3
- package/schemas/plugins/asset/AssetGeneratorOptions.check.js +3 -3
- package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.js +3 -3
- package/schemas/plugins/asset/AssetParserOptions.check.js +3 -3
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +3 -3
- package/schemas/plugins/container/ContainerPlugin.check.js +3 -3
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +3 -3
- package/schemas/plugins/container/ExternalsType.check.js +3 -3
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +3 -3
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +3 -3
- package/schemas/plugins/css/CssGeneratorOptions.check.js +3 -3
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +3 -3
- package/schemas/plugins/css/CssModuleParserOptions.check.js +3 -3
- package/schemas/plugins/css/CssParserOptions.check.js +3 -3
- package/schemas/plugins/debug/ProfilingPlugin.check.js +3 -3
- package/schemas/plugins/define/DotenvPluginOptions.check.js +7 -0
- package/schemas/plugins/define/DotenvPluginOptions.json +3 -0
- package/schemas/plugins/dll/DllPlugin.check.js +3 -3
- package/schemas/plugins/dll/DllReferencePlugin.check.js +3 -3
- package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +3 -3
- package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.js +3 -3
- package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.js +3 -3
- package/schemas/plugins/json/JsonModulesPluginGenerator.check.js +3 -3
- package/schemas/plugins/json/JsonModulesPluginParser.check.js +3 -3
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.js +3 -3
- package/schemas/plugins/optimize/LimitChunkCountPlugin.check.js +3 -3
- package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.js +3 -3
- package/schemas/plugins/optimize/MinChunkSizePlugin.check.js +3 -3
- package/schemas/plugins/output/CleanOptions.check.js +7 -0
- package/schemas/plugins/output/CleanOptions.json +3 -0
- package/schemas/plugins/schemes/HttpUriPlugin.check.js +3 -3
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +3 -3
- package/schemas/plugins/sharing/ConsumeSharedPlugin.check.js +3 -3
- package/schemas/plugins/sharing/ProvideSharedPlugin.check.js +3 -3
- package/schemas/plugins/sharing/SharePlugin.check.js +3 -3
- package/types.d.ts +1482 -358
|
@@ -97,11 +97,7 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
|
|
|
97
97
|
* @returns {string} re-encoded hash
|
|
98
98
|
*/
|
|
99
99
|
const reEncode = (value, digest, length) => {
|
|
100
|
-
const hash = reEncodeDigest(
|
|
101
|
-
value,
|
|
102
|
-
/** @type {string} */ (sourceDigest),
|
|
103
|
-
digest
|
|
104
|
-
);
|
|
100
|
+
const hash = reEncodeDigest(value, sourceDigest, digest);
|
|
105
101
|
return length ? hash.slice(0, length) : hash;
|
|
106
102
|
};
|
|
107
103
|
|
|
@@ -328,6 +328,12 @@ module.exports.instantiateWasm = "__webpack_require__.v";
|
|
|
328
328
|
*/
|
|
329
329
|
module.exports.interceptModuleExecution = "__webpack_require__.i";
|
|
330
330
|
|
|
331
|
+
/**
|
|
332
|
+
* the setters a module library registers for the bindings it exports from hot modules,
|
|
333
|
+
* keyed by module id and local name; an updated module writes through them.
|
|
334
|
+
*/
|
|
335
|
+
module.exports.liveExportSetters = "__webpack_require__.lE";
|
|
336
|
+
|
|
331
337
|
/**
|
|
332
338
|
* function to load a script tag.
|
|
333
339
|
* Arguments: (url: string, done: (event) => void), key?: string | number, chunkId?: string | number) => void
|
|
@@ -143,6 +143,7 @@ const GLOBALS_ON_REQUIRE = [
|
|
|
143
143
|
RuntimeGlobals.definePropertyGetters,
|
|
144
144
|
RuntimeGlobals.ensureChunk,
|
|
145
145
|
RuntimeGlobals.entryModuleId,
|
|
146
|
+
RuntimeGlobals.cssInjectStyle,
|
|
146
147
|
RuntimeGlobals.getCssServerStyles,
|
|
147
148
|
RuntimeGlobals.getFullHash,
|
|
148
149
|
RuntimeGlobals.global,
|
|
@@ -181,6 +182,7 @@ const MODULE_DEPENDENCIES = {
|
|
|
181
182
|
};
|
|
182
183
|
|
|
183
184
|
const TREE_DEPENDENCIES = {
|
|
185
|
+
[RuntimeGlobals.asyncModuleExportSymbol]: [RuntimeGlobals.asyncModule],
|
|
184
186
|
[RuntimeGlobals.definePropertyGetters]: [RuntimeGlobals.hasOwnProperty],
|
|
185
187
|
[RuntimeGlobals.compatGetDefaultExport]: [
|
|
186
188
|
RuntimeGlobals.definePropertyGetters
|
|
@@ -1204,8 +1204,7 @@ class HttpUriPlugin {
|
|
|
1204
1204
|
resolveContent(url, null, (err, result) => {
|
|
1205
1205
|
if (err) return callback(err);
|
|
1206
1206
|
storeResult(
|
|
1207
|
-
|
|
1208
|
-
(lockfile),
|
|
1207
|
+
lockfile,
|
|
1209
1208
|
url,
|
|
1210
1209
|
/** @type {ResolveContentResult} */
|
|
1211
1210
|
(result),
|
|
@@ -58,7 +58,7 @@ const PLUGIN_NAME = "VirtualUrlPlugin";
|
|
|
58
58
|
/**
|
|
59
59
|
* @inline
|
|
60
60
|
* @tsType import('./VirtualUrlPlugin').SourceFn
|
|
61
|
-
* @typedef {(loaderContext: LoaderContext<
|
|
61
|
+
* @typedef {(loaderContext: LoaderContext<LoaderOptions>) => Promise<string | Buffer> | string | Buffer} SourceFn
|
|
62
62
|
*/
|
|
63
63
|
/**
|
|
64
64
|
* @inline
|
|
@@ -67,6 +67,8 @@ const PLUGIN_NAME = "VirtualUrlPlugin";
|
|
|
67
67
|
*/
|
|
68
68
|
/** @typedef {{ [key: string]: VirtualModuleContent }} VirtualModules */
|
|
69
69
|
|
|
70
|
+
/** @import { LoaderOptions } from "../loaders/LoaderRunner" */
|
|
71
|
+
|
|
70
72
|
/**
|
|
71
73
|
* Defines the loader context type used by this module.
|
|
72
74
|
* @template T
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
/** @typedef {import("./ObjectMiddleware").ObjectDeserializerContext<ComplexSerializableType[]>} ObjectDeserializerContext */
|
|
9
9
|
/** @typedef {import("./ObjectMiddleware").ObjectSerializerContext<ComplexSerializableType[]>} ObjectSerializerContext */
|
|
10
10
|
|
|
11
|
-
/** @typedef {Error & { cause?:
|
|
11
|
+
/** @typedef {Error & { cause?: ComplexSerializableType, errors: ComplexSerializableType[] }} AggregateError */
|
|
12
12
|
|
|
13
13
|
class AggregateErrorSerializer {
|
|
14
14
|
/**
|
|
@@ -20,7 +20,7 @@ class AggregateErrorSerializer {
|
|
|
20
20
|
context.write(obj.errors);
|
|
21
21
|
context.write(obj.message);
|
|
22
22
|
context.write(obj.stack);
|
|
23
|
-
context.write(
|
|
23
|
+
context.write(obj.cause);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
@@ -37,7 +37,7 @@ class AggregateErrorSerializer {
|
|
|
37
37
|
err.stack = /** @type {string | undefined} */ (context.read());
|
|
38
38
|
err.cause = context.read();
|
|
39
39
|
|
|
40
|
-
return err;
|
|
40
|
+
return /** @type {AggregateError} */ (err);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -484,7 +484,10 @@ class BinaryMiddleware extends SerializerMiddleware {
|
|
|
484
484
|
sectionStart = i + 1;
|
|
485
485
|
const operation =
|
|
486
486
|
/** @type {MEASURE_START_OPERATION_TYPE | MEASURE_END_OPERATION_TYPE} */
|
|
487
|
-
(
|
|
487
|
+
(
|
|
488
|
+
/** @type {typeof thing | MEASURE_START_OPERATION_TYPE | MEASURE_END_OPERATION_TYPE} */
|
|
489
|
+
(thing)
|
|
490
|
+
);
|
|
488
491
|
if (operation === MEASURE_START_OPERATION) {
|
|
489
492
|
measureStack.push(writtenBytes);
|
|
490
493
|
} else if (operation === MEASURE_END_OPERATION) {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
/** @typedef {import("./ObjectMiddleware").ObjectDeserializerContext<ComplexSerializableType[]>} ObjectDeserializerContext */
|
|
9
9
|
/** @typedef {import("./ObjectMiddleware").ObjectSerializerContext<ComplexSerializableType[]>} ObjectSerializerContext */
|
|
10
10
|
|
|
11
|
-
/** @typedef {Error & { cause?:
|
|
11
|
+
/** @typedef {Error & { cause?: ComplexSerializableType }} ErrorWithCause */
|
|
12
12
|
|
|
13
13
|
class ErrorObjectSerializer {
|
|
14
14
|
/**
|
|
@@ -27,10 +27,7 @@ class ErrorObjectSerializer {
|
|
|
27
27
|
serialize(obj, context) {
|
|
28
28
|
context.write(obj.message);
|
|
29
29
|
context.write(obj.stack);
|
|
30
|
-
context.write(
|
|
31
|
-
/** @type {ComplexSerializableType} */
|
|
32
|
-
(/** @type {ErrorWithCause} */ (obj).cause)
|
|
33
|
-
);
|
|
30
|
+
context.write(/** @type {ErrorWithCause} */ (obj).cause);
|
|
34
31
|
}
|
|
35
32
|
|
|
36
33
|
/**
|
|
@@ -49,7 +49,7 @@ const SetObjectSerializer = require("./SetObjectSerializer");
|
|
|
49
49
|
* } from "./types"
|
|
50
50
|
*/
|
|
51
51
|
|
|
52
|
-
/** @typedef {new (...params:
|
|
52
|
+
/** @typedef {abstract new (...params: never[]) => EXPECTED_OBJECT} Constructor */
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* Defines the object serializer snapshot type used by this module.
|
|
@@ -65,35 +65,36 @@ const SetObjectSerializer = require("./SetObjectSerializer");
|
|
|
65
65
|
/** @typedef {EXPECTED_OBJECT | string} ReferenceableItem */
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
|
-
* First tuple element; element type for an open array; `
|
|
69
|
-
*
|
|
70
|
-
* @
|
|
68
|
+
* First tuple element; element type for an open array; `never` once exhausted,
|
|
69
|
+
* so a read or write past the declared tuple fails to type-check.
|
|
70
|
+
* @template T
|
|
71
|
+
* @typedef {T extends readonly [infer H, ...infer _Rest] ? H : T extends readonly [] ? never : T extends readonly (infer E)[] ? E : never} Head
|
|
71
72
|
*/
|
|
72
73
|
|
|
73
74
|
/**
|
|
74
75
|
* Tuple without its first element; unchanged when `T` is an open array.
|
|
75
|
-
* @template
|
|
76
|
+
* @template T
|
|
76
77
|
* @typedef {T extends readonly [infer _First, ...infer R] ? R : T} Tail
|
|
77
78
|
*/
|
|
78
79
|
|
|
79
80
|
/**
|
|
80
81
|
* Defines the object serializer context type used by this module.
|
|
81
82
|
* `T` is the tuple of values written in order; each `write` consumes the head.
|
|
82
|
-
* @template
|
|
83
|
+
* @template [T=readonly EXPECTED_ANY[]]
|
|
83
84
|
* @typedef {object} ObjectSerializerContext
|
|
84
85
|
* @property {(value: Head<T>) => ObjectSerializerContext<Tail<T>>} write
|
|
85
86
|
* @property {(value: ReferenceableItem) => void} setCircularReference
|
|
86
87
|
* @property {() => ObjectSerializerSnapshot} snapshot
|
|
87
88
|
* @property {(snapshot: ObjectSerializerSnapshot) => void} rollback
|
|
88
89
|
* @property {((item: ComplexSerializableType) => void)=} writeLazy
|
|
89
|
-
* @property {((item: ComplexSerializableType, obj: LazyOptions | undefined) => import("./SerializerMiddleware").LazyFunction<EXPECTED_ANY,
|
|
90
|
+
* @property {((item: ComplexSerializableType, obj: LazyOptions | undefined) => import("./SerializerMiddleware").LazyFunction<EXPECTED_ANY, PrimitiveSerializableType[], LazyTarget, LazyOptions>)=} writeSeparate
|
|
90
91
|
*/
|
|
91
92
|
|
|
92
93
|
/**
|
|
93
94
|
* Defines the object deserializer context type used by this module.
|
|
94
95
|
* `T` is the tuple of values read in order: `read` returns the head, and `rest`
|
|
95
96
|
* re-types the same context to `Tail<T>` so successive reads stay positional.
|
|
96
|
-
* @template
|
|
97
|
+
* @template [T=readonly EXPECTED_ANY[]]
|
|
97
98
|
* @typedef {object} ObjectDeserializerContext
|
|
98
99
|
* @property {() => Head<T>} read
|
|
99
100
|
* @property {ObjectDeserializerContext<Tail<T>>} rest
|
|
@@ -102,9 +103,9 @@ const SetObjectSerializer = require("./SetObjectSerializer");
|
|
|
102
103
|
|
|
103
104
|
/**
|
|
104
105
|
* Defines the object serializer type used by this module.
|
|
105
|
-
*
|
|
106
|
-
* @
|
|
107
|
-
* @
|
|
106
|
+
* Methods, so a serializer may narrow `value` to the class it is registered for.
|
|
107
|
+
* @template {EXPECTED_OBJECT} [T=EXPECTED_OBJECT]
|
|
108
|
+
* @typedef {{ serialize(value: T, context: ObjectSerializerContext): void, deserialize(context: ObjectDeserializerContext): EXPECTED_OBJECT }} ObjectSerializer
|
|
108
109
|
*/
|
|
109
110
|
|
|
110
111
|
/**
|
|
@@ -255,10 +256,11 @@ class ObjectMiddleware extends SerializerMiddleware {
|
|
|
255
256
|
|
|
256
257
|
/**
|
|
257
258
|
* Processes the provided constructor.
|
|
258
|
-
* @
|
|
259
|
+
* @template {Constructor} C
|
|
260
|
+
* @param {C} Constructor the constructor
|
|
259
261
|
* @param {string} request the request which will be required when deserializing
|
|
260
262
|
* @param {string | null} name the name to make multiple serializer unique when sharing a request
|
|
261
|
-
* @param {ObjectSerializer} serializer the serializer
|
|
263
|
+
* @param {ObjectSerializer<InstanceType<C>>} serializer the serializer
|
|
262
264
|
* @returns {void}
|
|
263
265
|
*/
|
|
264
266
|
static register(Constructor, request, name, serializer) {
|
|
@@ -811,7 +813,7 @@ class ObjectMiddleware extends SerializerMiddleware {
|
|
|
811
813
|
bufferDedupeMap =
|
|
812
814
|
objectTypeLookup =
|
|
813
815
|
ctx =
|
|
814
|
-
/** @type {
|
|
816
|
+
/** @type {never} */
|
|
815
817
|
(undefined);
|
|
816
818
|
}
|
|
817
819
|
}
|
|
@@ -1011,7 +1013,7 @@ class ObjectMiddleware extends SerializerMiddleware {
|
|
|
1011
1013
|
data =
|
|
1012
1014
|
objectTypeLookup =
|
|
1013
1015
|
ctx =
|
|
1014
|
-
/** @type {
|
|
1016
|
+
/** @type {never} */
|
|
1015
1017
|
(undefined);
|
|
1016
1018
|
}
|
|
1017
1019
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"use strict";
|
|
6
6
|
/** @import { ObjectDeserializerContext, ObjectSerializerContext } from "./ObjectMiddleware" */
|
|
7
7
|
|
|
8
|
-
/** @typedef {
|
|
8
|
+
/** @typedef {(value: never) => EXPECTED_OBJECT} CacheAssoc */
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Defines the shared type used by this module.
|
|
@@ -114,14 +114,10 @@ class PlainObjectSerializer {
|
|
|
114
114
|
const obj = /** @type {T} */ ({});
|
|
115
115
|
if (Array.isArray(keys)) {
|
|
116
116
|
for (const key of keys) {
|
|
117
|
-
obj[
|
|
118
|
-
context.read()
|
|
119
|
-
);
|
|
117
|
+
obj[key] = /** @type {T[keyof T]} */ (context.read());
|
|
120
118
|
}
|
|
121
119
|
} else if (keys !== null) {
|
|
122
|
-
obj[
|
|
123
|
-
context.read()
|
|
124
|
-
);
|
|
120
|
+
obj[keys] = /** @type {T[keyof T]} */ (context.read());
|
|
125
121
|
}
|
|
126
122
|
return obj;
|
|
127
123
|
}
|
|
@@ -6,10 +6,14 @@
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Defines the serializer middleware type used by this module.
|
|
9
|
-
* @template T
|
|
9
|
+
* @template [T=ComplexSerializableType]
|
|
10
|
+
* @template [K=ComplexSerializableType]
|
|
11
|
+
* @template [C=EXPECTED_OBJECT]
|
|
10
12
|
* @typedef {import("./SerializerMiddleware")<T, K, C>} SerializerMiddleware
|
|
11
13
|
*/
|
|
12
14
|
|
|
15
|
+
/** @import { ComplexSerializableType } from "./types" */
|
|
16
|
+
|
|
13
17
|
/**
|
|
14
18
|
* Represents Serializer.
|
|
15
19
|
* @template DeserializedValue
|
|
@@ -19,7 +23,7 @@
|
|
|
19
23
|
class Serializer {
|
|
20
24
|
/**
|
|
21
25
|
* Creates an instance of Serializer.
|
|
22
|
-
* @param {SerializerMiddleware
|
|
26
|
+
* @param {SerializerMiddleware[]} middlewares serializer middlewares
|
|
23
27
|
* @param {Context=} context context
|
|
24
28
|
*/
|
|
25
29
|
constructor(middlewares, context) {
|
|
@@ -38,15 +42,18 @@ class Serializer {
|
|
|
38
42
|
*/
|
|
39
43
|
serialize(obj, context) {
|
|
40
44
|
const ctx = { ...context, ...this.context };
|
|
41
|
-
let current =
|
|
45
|
+
let current =
|
|
46
|
+
/** @type {ComplexSerializableType | Promise<ComplexSerializableType>} */
|
|
47
|
+
(obj);
|
|
42
48
|
for (const middleware of this.serializeMiddlewares) {
|
|
43
49
|
if (
|
|
44
50
|
current &&
|
|
45
|
-
typeof (
|
|
46
|
-
|
|
51
|
+
typeof (
|
|
52
|
+
/** @type {Promise<ComplexSerializableType>} */ (current).then
|
|
53
|
+
) === "function"
|
|
47
54
|
) {
|
|
48
55
|
current =
|
|
49
|
-
/** @type {Promise<
|
|
56
|
+
/** @type {Promise<ComplexSerializableType>} */
|
|
50
57
|
(current).then((data) => data && middleware.serialize(data, ctx));
|
|
51
58
|
} else if (current) {
|
|
52
59
|
try {
|
|
@@ -70,14 +77,17 @@ class Serializer {
|
|
|
70
77
|
*/
|
|
71
78
|
deserialize(value, context) {
|
|
72
79
|
const ctx = { ...context, ...this.context };
|
|
73
|
-
let current =
|
|
80
|
+
let current =
|
|
81
|
+
/** @type {ComplexSerializableType | Promise<ComplexSerializableType>} */
|
|
82
|
+
(value);
|
|
74
83
|
for (const middleware of this.deserializeMiddlewares) {
|
|
75
84
|
current =
|
|
76
85
|
current &&
|
|
77
|
-
typeof (
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
86
|
+
typeof (
|
|
87
|
+
/** @type {Promise<ComplexSerializableType>} */ (current).then
|
|
88
|
+
) === "function"
|
|
89
|
+
? /** @type {Promise<ComplexSerializableType>} */ (current).then(
|
|
90
|
+
(data) => middleware.deserialize(data, ctx)
|
|
81
91
|
)
|
|
82
92
|
: middleware.deserialize(current, ctx);
|
|
83
93
|
}
|
|
@@ -9,7 +9,9 @@ const memoize = require("../util/memoize");
|
|
|
9
9
|
const LAZY_TARGET = Symbol("lazy serialization target");
|
|
10
10
|
const LAZY_SERIALIZED_VALUE = Symbol("lazy serialization data");
|
|
11
11
|
|
|
12
|
-
/** @
|
|
12
|
+
/** @import { ComplexSerializableType } from "./types" */
|
|
13
|
+
|
|
14
|
+
/** @typedef {SerializerMiddleware} LazyTarget */
|
|
13
15
|
/** @typedef {{ name?: string, size?: number }} LazyOptions */
|
|
14
16
|
|
|
15
17
|
/**
|
|
@@ -23,9 +25,9 @@ const LAZY_SERIALIZED_VALUE = Symbol("lazy serialization data");
|
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
27
|
* Represents SerializerMiddleware.
|
|
26
|
-
* @template DeserializedType
|
|
27
|
-
* @template SerializedType
|
|
28
|
-
* @template Context
|
|
28
|
+
* @template [DeserializedType=ComplexSerializableType]
|
|
29
|
+
* @template [SerializedType=ComplexSerializableType]
|
|
30
|
+
* @template [Context=EXPECTED_OBJECT]
|
|
29
31
|
*/
|
|
30
32
|
class SerializerMiddleware {
|
|
31
33
|
/* istanbul ignore next */
|
|
@@ -117,8 +119,8 @@ class SerializerMiddleware {
|
|
|
117
119
|
* @template TLazyOutputValue
|
|
118
120
|
* @template {LazyTarget} TLazyTarget
|
|
119
121
|
* @template {LazyOptions} TLazyOptions
|
|
120
|
-
* @param {LazyFunction<TLazyInputValue, TLazyOutputValue, TLazyTarget, TLazyOptions>
|
|
121
|
-
* @returns {TLazyOutputValue | undefined} serialized value
|
|
122
|
+
* @param {LazyFunction<TLazyInputValue, TLazyOutputValue, TLazyTarget, TLazyOptions>} fn lazy function
|
|
123
|
+
* @returns {TLazyOutputValue | LazyFunction<TLazyOutputValue, TLazyInputValue, TLazyTarget, TLazyOptions> | undefined} serialized value
|
|
122
124
|
*/
|
|
123
125
|
static getLazySerializedValue(fn) {
|
|
124
126
|
if (typeof fn !== "function") return;
|
|
@@ -39,7 +39,6 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
|
39
39
|
* Asset,
|
|
40
40
|
* AssetInfo,
|
|
41
41
|
* ExcludeModulesType,
|
|
42
|
-
* KnownNormalizedStatsOptions,
|
|
43
42
|
* NormalizedStatsOptions
|
|
44
43
|
* } from "../Compilation"
|
|
45
44
|
*/
|
|
@@ -74,11 +73,19 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
|
74
73
|
* @typedef {import("./smartGrouping").GroupConfig<I, G>} GroupConfig
|
|
75
74
|
*/
|
|
76
75
|
|
|
77
|
-
/**
|
|
76
|
+
/**
|
|
77
|
+
* A value stats JSON holds; `undefined` stands for a field left out and `Buffer` for a binary module source.
|
|
78
|
+
* @typedef {string | number | boolean | null | undefined | Buffer | StatsJsonArray | { [key: string]: StatsJsonValue }} StatsJsonValue
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
// A separate alias: JSDoc rejects `StatsJsonValue[]` inside its own definition.
|
|
82
|
+
/** @typedef {StatsJsonValue[]} StatsJsonArray */
|
|
83
|
+
|
|
84
|
+
/** @typedef {KnownStatsCompilation & Record<string, StatsJsonValue>} StatsCompilation */
|
|
78
85
|
/**
|
|
79
86
|
* Defines the known stats compilation type used by this module.
|
|
80
87
|
* @typedef {object} KnownStatsCompilation
|
|
81
|
-
* @property {
|
|
88
|
+
* @property {StatsJsonValue=} env
|
|
82
89
|
* @property {string=} name
|
|
83
90
|
* @property {string=} hash
|
|
84
91
|
* @property {string=} version
|
|
@@ -107,7 +114,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
|
107
114
|
* @property {number=} filteredErrorDetailsCount
|
|
108
115
|
*/
|
|
109
116
|
|
|
110
|
-
/** @typedef {KnownStatsLogging & Record<string,
|
|
117
|
+
/** @typedef {KnownStatsLogging & Record<string, StatsJsonValue>} StatsLogging */
|
|
111
118
|
/**
|
|
112
119
|
* Defines the known stats logging type used by this module.
|
|
113
120
|
* @typedef {object} KnownStatsLogging
|
|
@@ -116,7 +123,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
|
116
123
|
* @property {boolean} debug
|
|
117
124
|
*/
|
|
118
125
|
|
|
119
|
-
/** @typedef {KnownStatsLoggingEntry & Record<string,
|
|
126
|
+
/** @typedef {KnownStatsLoggingEntry & Record<string, StatsJsonValue>} StatsLoggingEntry */
|
|
120
127
|
/**
|
|
121
128
|
* Defines the known stats logging entry type used by this module.
|
|
122
129
|
* @typedef {object} KnownStatsLoggingEntry
|
|
@@ -128,7 +135,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
|
128
135
|
* @property {number=} time
|
|
129
136
|
*/
|
|
130
137
|
|
|
131
|
-
/** @typedef {KnownStatsAsset & Record<string,
|
|
138
|
+
/** @typedef {KnownStatsAsset & Record<string, StatsJsonValue>} StatsAsset */
|
|
132
139
|
/** @typedef {string[]} ChunkIdHints */
|
|
133
140
|
/**
|
|
134
141
|
* Defines the known stats asset type used by this module.
|
|
@@ -151,7 +158,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
|
151
158
|
* @property {boolean=} isOverSizeLimit
|
|
152
159
|
*/
|
|
153
160
|
|
|
154
|
-
/** @typedef {KnownStatsChunkGroup & Record<string,
|
|
161
|
+
/** @typedef {KnownStatsChunkGroup & Record<string, StatsJsonValue>} StatsChunkGroup */
|
|
155
162
|
/**
|
|
156
163
|
* Defines the known stats chunk group type used by this module.
|
|
157
164
|
* @typedef {object} KnownStatsChunkGroup
|
|
@@ -169,7 +176,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
|
169
176
|
*/
|
|
170
177
|
|
|
171
178
|
/** @typedef {Module[]} ModuleIssuerPath */
|
|
172
|
-
/** @typedef {KnownStatsModule & Record<string,
|
|
179
|
+
/** @typedef {KnownStatsModule & Record<string, StatsJsonValue>} StatsModule */
|
|
173
180
|
/**
|
|
174
181
|
* Defines the known stats module type used by this module.
|
|
175
182
|
* @typedef {object} KnownStatsModule
|
|
@@ -215,7 +222,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
|
215
222
|
* @property {ReturnType<Source["source"]>=} source
|
|
216
223
|
*/
|
|
217
224
|
|
|
218
|
-
/** @typedef {KnownStatsProfile & Record<string,
|
|
225
|
+
/** @typedef {KnownStatsProfile & Record<string, StatsJsonValue>} StatsProfile */
|
|
219
226
|
/**
|
|
220
227
|
* Defines the known stats profile type used by this module.
|
|
221
228
|
* @typedef {object} KnownStatsProfile
|
|
@@ -231,7 +238,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
|
231
238
|
* @property {number} dependencies
|
|
232
239
|
*/
|
|
233
240
|
|
|
234
|
-
/** @typedef {KnownStatsModuleIssuer & Record<string,
|
|
241
|
+
/** @typedef {KnownStatsModuleIssuer & Record<string, StatsJsonValue>} StatsModuleIssuer */
|
|
235
242
|
/**
|
|
236
243
|
* Defines the known stats module issuer type used by this module.
|
|
237
244
|
* @typedef {object} KnownStatsModuleIssuer
|
|
@@ -241,7 +248,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
|
241
248
|
* @property {StatsProfile} profile
|
|
242
249
|
*/
|
|
243
250
|
|
|
244
|
-
/** @typedef {KnownStatsModuleReason & Record<string,
|
|
251
|
+
/** @typedef {KnownStatsModuleReason & Record<string, StatsJsonValue>} StatsModuleReason */
|
|
245
252
|
/**
|
|
246
253
|
* Defines the known stats module reason type used by this module.
|
|
247
254
|
* @typedef {object} KnownStatsModuleReason
|
|
@@ -259,7 +266,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
|
259
266
|
* @property {ModuleId | null=} resolvedModuleId
|
|
260
267
|
*/
|
|
261
268
|
|
|
262
|
-
/** @typedef {KnownStatsChunk & Record<string,
|
|
269
|
+
/** @typedef {KnownStatsChunk & Record<string, StatsJsonValue>} StatsChunk */
|
|
263
270
|
/**
|
|
264
271
|
* Defines the known stats chunk type used by this module.
|
|
265
272
|
* @typedef {object} KnownStatsChunk
|
|
@@ -286,7 +293,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
|
286
293
|
* @property {StatsChunkOrigin[]=} origins
|
|
287
294
|
*/
|
|
288
295
|
|
|
289
|
-
/** @typedef {KnownStatsChunkOrigin & Record<string,
|
|
296
|
+
/** @typedef {KnownStatsChunkOrigin & Record<string, StatsJsonValue>} StatsChunkOrigin */
|
|
290
297
|
/**
|
|
291
298
|
* Defines the known stats chunk origin type used by this module.
|
|
292
299
|
* @typedef {object} KnownStatsChunkOrigin
|
|
@@ -298,7 +305,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
|
298
305
|
* @property {ModuleId=} moduleId
|
|
299
306
|
*/
|
|
300
307
|
|
|
301
|
-
/** @typedef {KnownStatsModuleTraceItem & Record<string,
|
|
308
|
+
/** @typedef {KnownStatsModuleTraceItem & Record<string, StatsJsonValue>} StatsModuleTraceItem */
|
|
302
309
|
/**
|
|
303
310
|
* Defines the known stats module trace item type used by this module.
|
|
304
311
|
* @typedef {object} KnownStatsModuleTraceItem
|
|
@@ -311,14 +318,14 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
|
311
318
|
* @property {ModuleId=} moduleId
|
|
312
319
|
*/
|
|
313
320
|
|
|
314
|
-
/** @typedef {KnownStatsModuleTraceDependency & Record<string,
|
|
321
|
+
/** @typedef {KnownStatsModuleTraceDependency & Record<string, StatsJsonValue>} StatsModuleTraceDependency */
|
|
315
322
|
/**
|
|
316
323
|
* Defines the known stats module trace dependency type used by this module.
|
|
317
324
|
* @typedef {object} KnownStatsModuleTraceDependency
|
|
318
325
|
* @property {string=} loc
|
|
319
326
|
*/
|
|
320
327
|
|
|
321
|
-
/** @typedef {KnownStatsError & Record<string,
|
|
328
|
+
/** @typedef {KnownStatsError & Record<string, StatsJsonValue>} StatsError */
|
|
322
329
|
/**
|
|
323
330
|
* Defines the known stats error type used by this module.
|
|
324
331
|
* @typedef {object} KnownStatsError
|
|
@@ -870,10 +877,7 @@ const SIMPLE_EXTRACTORS = {
|
|
|
870
877
|
compilationFileToChunks,
|
|
871
878
|
compilationAuxiliaryFileToChunks
|
|
872
879
|
});
|
|
873
|
-
const limited = spaceLimited(
|
|
874
|
-
groupedAssets,
|
|
875
|
-
/** @type {number} */ (options.assetsSpace)
|
|
876
|
-
);
|
|
880
|
+
const limited = spaceLimited(groupedAssets, options.assetsSpace);
|
|
877
881
|
object.assets = limited.children;
|
|
878
882
|
object.filteredAssets = limited.filteredChildren;
|
|
879
883
|
},
|
|
@@ -1022,10 +1026,7 @@ const SIMPLE_EXTRACTORS = {
|
|
|
1022
1026
|
) => {
|
|
1023
1027
|
const { type, cachedGetWarnings } = context;
|
|
1024
1028
|
object.warningsCount = countWithChildren(compilation, (c, childType) => {
|
|
1025
|
-
if (
|
|
1026
|
-
/** @type {KnownNormalizedStatsOptions["warningsFilter"]} */
|
|
1027
|
-
(warningsFilter).length === 0
|
|
1028
|
-
) {
|
|
1029
|
+
if (warningsFilter.length === 0) {
|
|
1029
1030
|
return cachedGetWarnings(c);
|
|
1030
1031
|
}
|
|
1031
1032
|
return factory
|
|
@@ -1132,8 +1133,7 @@ const SIMPLE_EXTRACTORS = {
|
|
|
1132
1133
|
context
|
|
1133
1134
|
);
|
|
1134
1135
|
object.filteredRelated = asset.related
|
|
1135
|
-
? asset.related.length -
|
|
1136
|
-
/** @type {StatsAsset[]} */ (object.related).length
|
|
1136
|
+
? asset.related.length - object.related.length
|
|
1137
1137
|
: undefined;
|
|
1138
1138
|
},
|
|
1139
1139
|
ids: (
|
|
@@ -1293,7 +1293,7 @@ const SIMPLE_EXTRACTORS = {
|
|
|
1293
1293
|
module: {
|
|
1294
1294
|
_: (object, module, context, options, factory) => {
|
|
1295
1295
|
const { type } = context;
|
|
1296
|
-
const compilation =
|
|
1296
|
+
const compilation = context.compilation;
|
|
1297
1297
|
const built = compilation.builtModules.has(module);
|
|
1298
1298
|
const codeGenerated = compilation.codeGeneratedModules.has(module);
|
|
1299
1299
|
const buildTimeExecuted =
|
|
@@ -1324,7 +1324,7 @@ const SIMPLE_EXTRACTORS = {
|
|
|
1324
1324
|
module$visible: {
|
|
1325
1325
|
_: (object, module, context, { requestShortener }, factory) => {
|
|
1326
1326
|
const { type, rootModules } = context;
|
|
1327
|
-
const compilation =
|
|
1327
|
+
const compilation = context.compilation;
|
|
1328
1328
|
const { moduleGraph } = compilation;
|
|
1329
1329
|
/** @type {ModuleIssuerPath} */
|
|
1330
1330
|
const path = [];
|
|
@@ -1514,7 +1514,7 @@ const SIMPLE_EXTRACTORS = {
|
|
|
1514
1514
|
moduleIssuer: {
|
|
1515
1515
|
_: (object, module, context, { requestShortener }, factory) => {
|
|
1516
1516
|
const { type } = context;
|
|
1517
|
-
const compilation =
|
|
1517
|
+
const compilation = context.compilation;
|
|
1518
1518
|
const { moduleGraph } = compilation;
|
|
1519
1519
|
const profile = moduleGraph.getProfile(module);
|
|
1520
1520
|
// assign fields directly to avoid an intermediate object + copy per issuer
|
|
@@ -2617,7 +2617,7 @@ const sortOrderRegular = (field) => {
|
|
|
2617
2617
|
*/
|
|
2618
2618
|
const noSort = (a, b) => 0;
|
|
2619
2619
|
|
|
2620
|
-
/** @type {Map<string,
|
|
2620
|
+
/** @type {Map<string, Comparator<{ [field: string]: string | number }>>} */
|
|
2621
2621
|
const sortByFieldCache = new Map();
|
|
2622
2622
|
|
|
2623
2623
|
/**
|
|
@@ -2632,7 +2632,7 @@ const sortByField = (field) => {
|
|
|
2632
2632
|
// memoize per field: the comparator (and its selector) is pure, so building it
|
|
2633
2633
|
// once keeps compareSelect's cache warm instead of allocating a new entry per sort
|
|
2634
2634
|
let sortFn = sortByFieldCache.get(field);
|
|
2635
|
-
if (sortFn !== undefined) return sortFn;
|
|
2635
|
+
if (sortFn !== undefined) return /** @type {Comparator<T>} */ (sortFn);
|
|
2636
2636
|
|
|
2637
2637
|
const fieldKey = normalizeFieldKey(field);
|
|
2638
2638
|
|
|
@@ -2645,7 +2645,7 @@ const sortByField = (field) => {
|
|
|
2645
2645
|
}
|
|
2646
2646
|
|
|
2647
2647
|
sortByFieldCache.set(field, sortFn);
|
|
2648
|
-
return sortFn;
|
|
2648
|
+
return /** @type {Comparator<T>} */ (sortFn);
|
|
2649
2649
|
};
|
|
2650
2650
|
|
|
2651
2651
|
/**
|
|
@@ -2815,7 +2815,7 @@ class DefaultStatsFactoryPlugin {
|
|
|
2815
2815
|
(stats, options) => {
|
|
2816
2816
|
iterateConfig(SIMPLE_EXTRACTORS, options, (hookFor, fn) => {
|
|
2817
2817
|
stats.hooks.extract
|
|
2818
|
-
.for(hookFor)
|
|
2818
|
+
.for(/** @type {string} */ (hookFor))
|
|
2819
2819
|
.tap(PLUGIN_NAME, (obj, data, ctx) =>
|
|
2820
2820
|
fn(obj, data, ctx, options, stats)
|
|
2821
2821
|
);
|
|
@@ -2843,14 +2843,14 @@ class DefaultStatsFactoryPlugin {
|
|
|
2843
2843
|
});
|
|
2844
2844
|
iterateConfig(RESULT_SORTERS, options, (hookFor, fn) => {
|
|
2845
2845
|
stats.hooks.sortResults
|
|
2846
|
-
.for(hookFor)
|
|
2846
|
+
.for(/** @type {string} */ (hookFor))
|
|
2847
2847
|
.tap(PLUGIN_NAME, (comparators, ctx) =>
|
|
2848
2848
|
fn(comparators, ctx, options)
|
|
2849
2849
|
);
|
|
2850
2850
|
});
|
|
2851
2851
|
iterateConfig(RESULT_GROUPERS, options, (hookFor, fn) => {
|
|
2852
2852
|
stats.hooks.groupResults
|
|
2853
|
-
.for(hookFor)
|
|
2853
|
+
.for(/** @type {string} */ (hookFor))
|
|
2854
2854
|
.tap(PLUGIN_NAME, (groupConfigs, ctx) =>
|
|
2855
2855
|
fn(groupConfigs, ctx, options)
|
|
2856
2856
|
);
|
|
@@ -318,7 +318,7 @@ const normalizeFilter = (item) => {
|
|
|
318
318
|
const regExp = new RegExp(
|
|
319
319
|
`[\\\\/]${item.replace(/[-[\]{}()*+?.\\^$|]/g, "\\$&")}([\\\\/]|$|!|\\?)`
|
|
320
320
|
);
|
|
321
|
-
return (ident) => regExp.test(
|
|
321
|
+
return (ident) => regExp.test(ident);
|
|
322
322
|
}
|
|
323
323
|
if (item && typeof item === "object" && typeof item.test === "function") {
|
|
324
324
|
return (ident) => item.test(ident);
|
|
@@ -418,11 +418,7 @@ class DefaultStatsPresetPlugin {
|
|
|
418
418
|
compilation.hooks.statsNormalize.tap(PLUGIN_NAME, (options, context) => {
|
|
419
419
|
for (const key of Object.keys(DEFAULTS)) {
|
|
420
420
|
if (options[key] === undefined) {
|
|
421
|
-
options[key] = DEFAULTS[
|
|
422
|
-
options,
|
|
423
|
-
context,
|
|
424
|
-
compilation
|
|
425
|
-
);
|
|
421
|
+
options[key] = DEFAULTS[key](options, context, compilation);
|
|
426
422
|
}
|
|
427
423
|
}
|
|
428
424
|
for (const key of Object.keys(NORMALIZER)) {
|