webpack 4.9.1 → 4.10.2
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/README.md +755 -755
- package/SECURITY.md +9 -9
- package/buildin/global.js +20 -20
- package/buildin/harmony-module.js +24 -24
- package/buildin/module.js +22 -22
- package/hot/dev-server.js +61 -61
- package/hot/log-apply-result.js +44 -44
- package/hot/log.js +45 -45
- package/hot/only-dev-server.js +105 -105
- package/hot/poll.js +37 -37
- package/hot/signal.js +62 -62
- package/lib/APIPlugin.js +84 -84
- package/lib/AmdMainTemplatePlugin.js +87 -75
- package/lib/AsyncDependenciesBlock.js +66 -66
- package/lib/AsyncDependencyToInitialChunkError.js +31 -21
- package/lib/AutomaticPrefetchPlugin.js +50 -50
- package/lib/BannerPlugin.js +3 -1
- package/lib/BasicEvaluatedExpression.js +211 -208
- package/lib/CachePlugin.js +102 -95
- package/lib/CaseSensitiveModulesWarning.js +71 -53
- package/lib/Chunk.js +750 -722
- package/lib/ChunkGroup.js +13 -5
- package/lib/ChunkRenderError.js +32 -32
- package/lib/CompatibilityPlugin.js +63 -63
- package/lib/Compilation.js +1947 -1905
- package/lib/Compiler.js +508 -496
- package/lib/ConcurrentCompilationError.js +19 -19
- package/lib/ConstPlugin.js +258 -242
- package/lib/ContextExclusionPlugin.js +17 -17
- package/lib/ContextModule.js +749 -710
- package/lib/ContextModuleFactory.js +256 -245
- package/lib/ContextReplacementPlugin.js +133 -126
- package/lib/DefinePlugin.js +206 -197
- package/lib/DelegatedModule.js +101 -101
- package/lib/DelegatedModuleFactoryPlugin.js +89 -89
- package/lib/DelegatedPlugin.js +39 -39
- package/lib/DependenciesBlock.js +89 -87
- package/lib/DependenciesBlockVariable.js +52 -51
- package/lib/Dependency.js +51 -51
- package/lib/DllEntryPlugin.js +51 -51
- package/lib/DllModule.js +54 -54
- package/lib/DllModuleFactory.js +29 -29
- package/lib/DllPlugin.js +44 -42
- package/lib/DllReferencePlugin.js +84 -84
- package/lib/DynamicEntryPlugin.js +73 -71
- package/lib/EntryOptionPlugin.js +33 -33
- package/lib/EnvironmentPlugin.js +65 -65
- package/lib/ErrorHelpers.js +60 -57
- package/lib/EvalDevToolModulePlugin.js +27 -27
- package/lib/EvalDevToolModuleTemplatePlugin.js +61 -61
- package/lib/EvalSourceMapDevToolPlugin.js +41 -40
- package/lib/ExportPropertyMainTemplatePlugin.js +53 -40
- package/lib/ExtendedAPIPlugin.js +84 -84
- package/lib/ExternalModule.js +159 -159
- package/lib/ExternalModuleFactoryPlugin.js +110 -110
- package/lib/ExternalsPlugin.js +23 -23
- package/lib/FlagDependencyExportsPlugin.js +146 -146
- package/lib/FlagDependencyUsagePlugin.js +110 -104
- package/lib/FlagInitialModulesAsUsedPlugin.js +36 -36
- package/lib/FunctionModulePlugin.js +19 -19
- package/lib/FunctionModuleTemplatePlugin.js +100 -98
- package/lib/GraphHelpers.js +64 -64
- package/lib/HarmonyLinkingError.js +18 -18
- package/lib/HashedModuleIdsPlugin.js +53 -53
- package/lib/HotModuleReplacement.runtime.js +7 -3
- package/lib/HotModuleReplacementPlugin.js +413 -406
- package/lib/HotUpdateChunk.js +16 -16
- package/lib/HotUpdateChunkTemplate.js +78 -78
- package/lib/IgnorePlugin.js +71 -71
- package/lib/JavascriptGenerator.js +229 -228
- package/lib/JavascriptModulesPlugin.js +179 -184
- package/lib/JsonGenerator.js +42 -42
- package/lib/JsonModulesPlugin.js +30 -30
- package/lib/JsonParser.js +27 -26
- package/lib/LibManifestPlugin.js +86 -86
- package/lib/LibraryTemplatePlugin.js +153 -119
- package/lib/LoaderOptionsPlugin.js +53 -52
- package/lib/LoaderTargetPlugin.js +24 -24
- package/lib/MainTemplate.js +34 -9
- package/lib/Module.js +381 -377
- package/lib/ModuleBuildError.js +42 -42
- package/lib/ModuleDependencyError.js +35 -25
- package/lib/ModuleDependencyWarning.js +25 -25
- package/lib/ModuleError.js +28 -28
- package/lib/ModuleFilenameHelpers.js +178 -166
- package/lib/ModuleParseError.js +44 -44
- package/lib/ModuleReason.js +40 -40
- package/lib/ModuleTemplate.js +84 -84
- package/lib/ModuleWarning.js +30 -30
- package/lib/MultiCompiler.js +283 -271
- package/lib/MultiEntryPlugin.js +58 -58
- package/lib/MultiModule.js +81 -78
- package/lib/MultiModuleFactory.js +23 -23
- package/lib/MultiStats.js +92 -92
- package/lib/MultiWatching.js +38 -38
- package/lib/NamedChunksPlugin.js +29 -29
- package/lib/NamedModulesPlugin.js +57 -57
- package/lib/NoEmitOnErrorsPlugin.js +20 -20
- package/lib/NoModeWarning.js +23 -23
- package/lib/NodeStuffPlugin.js +179 -178
- package/lib/NormalModule.js +497 -490
- package/lib/NormalModuleFactory.js +501 -483
- package/lib/NormalModuleReplacementPlugin.js +51 -51
- package/lib/OptionsDefaulter.js +84 -80
- package/lib/Parser.js +2164 -2086
- package/lib/ParserHelpers.js +103 -100
- package/lib/PrefetchPlugin.js +37 -37
- package/lib/ProgressPlugin.js +231 -231
- package/lib/ProvidePlugin.js +86 -86
- package/lib/RawModule.js +56 -54
- package/lib/RecordIdsPlugin.js +166 -162
- package/lib/RemovedPluginError.js +13 -13
- package/lib/RequestShortener.js +81 -74
- package/lib/RequireJsStuffPlugin.js +69 -69
- package/lib/ResolverFactory.js +64 -64
- package/lib/RuleSet.js +555 -534
- package/lib/RuntimeTemplate.js +320 -277
- package/lib/SetVarMainTemplatePlugin.js +69 -57
- package/lib/SingleEntryPlugin.js +44 -44
- package/lib/SizeFormatHelpers.js +24 -24
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +49 -49
- package/lib/SourceMapDevToolPlugin.js +301 -300
- package/lib/Stats.js +1408 -1367
- package/lib/Template.js +4 -2
- package/lib/TemplatedPathPlugin.js +173 -170
- package/lib/UmdMainTemplatePlugin.js +304 -264
- package/lib/UseStrictPlugin.js +48 -48
- package/lib/WarnCaseSensitiveModulesPlugin.js +37 -36
- package/lib/WarnNoModeSetPlugin.js +17 -17
- package/lib/WatchIgnorePlugin.js +100 -100
- package/lib/Watching.js +194 -193
- package/lib/WebpackError.js +25 -19
- package/lib/WebpackOptionsApply.js +421 -405
- package/lib/WebpackOptionsDefaulter.js +347 -344
- package/lib/WebpackOptionsValidationError.js +345 -316
- package/lib/compareLocations.js +56 -56
- package/lib/dependencies/AMDDefineDependency.js +137 -137
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +336 -327
- package/lib/dependencies/AMDPlugin.js +250 -250
- package/lib/dependencies/AMDRequireArrayDependency.js +49 -49
- package/lib/dependencies/AMDRequireContextDependency.js +20 -20
- package/lib/dependencies/AMDRequireDependenciesBlock.js +43 -43
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +273 -270
- package/lib/dependencies/AMDRequireDependency.js +135 -135
- package/lib/dependencies/CommonJsPlugin.js +161 -161
- package/lib/dependencies/CommonJsRequireContextDependency.js +23 -23
- package/lib/dependencies/CommonJsRequireDependencyParserPlugin.js +130 -130
- package/lib/dependencies/ConstDependency.js +33 -33
- package/lib/dependencies/ContextDependency.js +68 -68
- package/lib/dependencies/ContextDependencyTemplateAsId.js +42 -42
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +38 -38
- package/lib/dependencies/ContextElementDependency.js +21 -21
- package/lib/dependencies/DelegatedExportsDependency.js +33 -33
- package/lib/dependencies/DependencyReference.js +18 -18
- package/lib/dependencies/HarmonyAcceptDependency.js +45 -45
- package/lib/dependencies/HarmonyAcceptImportDependency.js +23 -23
- package/lib/dependencies/HarmonyCompatibilityDependency.js +31 -31
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +92 -90
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +139 -139
- package/lib/dependencies/HarmonyExportExpressionDependency.js +53 -53
- package/lib/dependencies/HarmonyExportHeaderDependency.js +30 -30
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +620 -603
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +54 -54
- package/lib/dependencies/HarmonyImportDependency.js +104 -94
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +217 -214
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +31 -31
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +166 -156
- package/lib/dependencies/HarmonyInitDependency.js +60 -60
- package/lib/dependencies/HarmonyModulesPlugin.js +146 -146
- package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +26 -26
- package/lib/dependencies/ImportContextDependency.js +23 -23
- package/lib/dependencies/ImportDependenciesBlock.js +18 -18
- package/lib/dependencies/ImportDependency.js +34 -34
- package/lib/dependencies/ImportEagerDependency.js +32 -32
- package/lib/dependencies/ImportParserPlugin.js +233 -232
- package/lib/dependencies/ImportPlugin.js +82 -82
- package/lib/dependencies/ImportWeakDependency.js +34 -34
- package/lib/dependencies/JsonExportsDependency.js +26 -26
- package/lib/dependencies/LoaderPlugin.js +98 -93
- package/lib/dependencies/LocalModuleDependency.js +28 -28
- package/lib/dependencies/LocalModulesHelpers.js +52 -45
- package/lib/dependencies/ModuleDependency.js +20 -20
- package/lib/dependencies/ModuleDependencyTemplateAsId.js +17 -17
- package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +17 -17
- package/lib/dependencies/MultiEntryDependency.js +20 -20
- package/lib/dependencies/NullDependency.js +20 -20
- package/lib/dependencies/RequireContextDependency.js +22 -22
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +56 -56
- package/lib/dependencies/RequireContextPlugin.js +143 -141
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +33 -33
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +116 -112
- package/lib/dependencies/RequireEnsureDependency.js +58 -58
- package/lib/dependencies/RequireEnsurePlugin.js +74 -74
- package/lib/dependencies/RequireHeaderDependency.js +26 -26
- package/lib/dependencies/RequireIncludeDependency.js +39 -39
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +23 -23
- package/lib/dependencies/RequireIncludePlugin.js +61 -61
- package/lib/dependencies/RequireResolveContextDependency.js +23 -23
- package/lib/dependencies/RequireResolveDependencyParserPlugin.js +85 -85
- package/lib/dependencies/RequireResolveHeaderDependency.js +26 -26
- package/lib/dependencies/SingleEntryDependency.js +18 -18
- package/lib/dependencies/SystemPlugin.js +125 -125
- package/lib/dependencies/UnsupportedDependency.js +27 -27
- package/lib/dependencies/WebAssemblyImportDependency.js +48 -44
- package/lib/dependencies/WebpackMissingModule.js +20 -20
- package/lib/dependencies/getFunctionExpression.js +52 -52
- package/lib/formatLocation.js +61 -53
- package/lib/node/NodeChunkTemplatePlugin.js +31 -31
- package/lib/node/NodeEnvironmentPlugin.js +28 -28
- package/lib/node/NodeHotUpdateChunkTemplatePlugin.js +36 -36
- package/lib/node/NodeMainTemplate.runtime.js +27 -27
- package/lib/node/NodeMainTemplateAsync.runtime.js +44 -44
- package/lib/node/NodeMainTemplatePlugin.js +323 -320
- package/lib/node/NodeSourcePlugin.js +144 -140
- package/lib/node/NodeTargetPlugin.js +18 -18
- package/lib/node/NodeTemplatePlugin.js +31 -31
- package/lib/node/NodeWatchFileSystem.js +99 -82
- package/lib/node/ReadFileCompileWasmTemplatePlugin.js +52 -52
- package/lib/optimize/AggressiveMergingPlugin.js +87 -87
- package/lib/optimize/AggressiveSplittingPlugin.js +287 -281
- package/lib/optimize/ChunkModuleIdRangePlugin.js +68 -68
- package/lib/optimize/ConcatenatedModule.js +1420 -1413
- package/lib/optimize/EnsureChunkConditionsPlugin.js +70 -70
- package/lib/optimize/FlagIncludedChunksPlugin.js +99 -99
- package/lib/optimize/LimitChunkCountPlugin.js +66 -66
- package/lib/optimize/MergeDuplicateChunksPlugin.js +78 -75
- package/lib/optimize/MinChunkSizePlugin.js +77 -77
- package/lib/optimize/ModuleConcatenationPlugin.js +470 -457
- package/lib/optimize/OccurrenceOrderPlugin.js +133 -126
- package/lib/optimize/RemoveParentModulesPlugin.js +127 -117
- package/lib/optimize/RuntimeChunkPlugin.js +41 -41
- package/lib/optimize/SideEffectsFlagPlugin.js +158 -156
- package/lib/optimize/SplitChunksPlugin.js +709 -696
- package/lib/performance/AssetsOverSizeLimitWarning.js +30 -30
- package/lib/performance/EntrypointsOverSizeLimitWarning.js +31 -31
- package/lib/performance/NoAsyncChunksWarning.js +21 -21
- package/lib/performance/SizeLimitsPlugin.js +105 -105
- package/lib/util/Semaphore.js +41 -41
- package/lib/util/SortableSet.js +5 -2
- package/lib/util/StackedSetMap.js +12 -5
- package/lib/util/TrackingSet.js +35 -35
- package/lib/util/cachedMerge.js +35 -35
- package/lib/util/createHash.js +77 -77
- package/lib/util/identifier.js +76 -76
- package/lib/validateSchema.js +67 -67
- package/lib/wasm/UnsupportedWebAssemblyFeatureError.js +18 -18
- package/lib/wasm/WasmMainTemplatePlugin.js +310 -304
- package/lib/wasm/WebAssemblyGenerator.js +143 -19
- package/lib/wasm/WebAssemblyJavascriptGenerator.js +90 -107
- package/lib/wasm/WebAssemblyModulesPlugin.js +80 -80
- package/lib/wasm/WebAssemblyParser.js +28 -5
- package/lib/wasm/WebAssemblyUtils.js +48 -0
- package/lib/web/FetchCompileWasmTemplatePlugin.js +25 -25
- package/lib/web/JsonpChunkTemplatePlugin.js +47 -47
- package/lib/web/JsonpExportMainTemplatePlugin.js +47 -47
- package/lib/web/JsonpHotUpdateChunkTemplatePlugin.js +39 -39
- package/lib/web/JsonpMainTemplate.runtime.js +65 -64
- package/lib/web/JsonpMainTemplatePlugin.js +576 -574
- package/lib/web/JsonpTemplatePlugin.js +23 -23
- package/lib/webpack.js +183 -182
- package/lib/webpack.web.js +31 -31
- package/lib/webworker/WebWorkerChunkTemplatePlugin.js +35 -35
- package/lib/webworker/WebWorkerHotUpdateChunkTemplatePlugin.js +40 -40
- package/lib/webworker/WebWorkerMainTemplate.runtime.js +65 -64
- package/lib/webworker/WebWorkerMainTemplatePlugin.js +179 -179
- package/lib/webworker/WebWorkerTemplatePlugin.js +25 -25
- package/package.json +9 -8
- package/schemas/WebpackOptions.json +1988 -1988
- package/schemas/ajv.absolutePath.js +55 -55
- package/schemas/plugins/DllPlugin.json +32 -32
- package/schemas/plugins/DllReferencePlugin.json +99 -99
- package/schemas/plugins/HashedModuleIdsPlugin.json +24 -24
- package/schemas/plugins/LoaderOptionsPlugin.json +26 -26
- package/schemas/plugins/SourceMapDevToolPlugin.json +187 -187
- package/schemas/plugins/WatchIgnorePlugin.json +16 -16
- package/schemas/plugins/debug/ProfilingPlugin.json +12 -12
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.json +22 -22
- package/schemas/plugins/optimize/LimitChunkCountPlugin.json +15 -15
- package/schemas/plugins/optimize/MinChunkSizePlugin.json +13 -13
package/lib/Stats.js
CHANGED
@@ -1,1367 +1,1408 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
"use strict";
|
6
|
-
|
7
|
-
const RequestShortener = require("./RequestShortener");
|
8
|
-
const SizeFormatHelpers = require("./SizeFormatHelpers");
|
9
|
-
const formatLocation = require("./formatLocation");
|
10
|
-
const identifierUtils = require("./util/identifier");
|
11
|
-
|
12
|
-
const optionsOrFallback = (...args) => {
|
13
|
-
let optionValues = [];
|
14
|
-
optionValues.push(...args);
|
15
|
-
return optionValues.find(optionValue => typeof optionValue !== "undefined");
|
16
|
-
};
|
17
|
-
|
18
|
-
class Stats {
|
19
|
-
constructor(compilation) {
|
20
|
-
this.compilation = compilation;
|
21
|
-
this.hash = compilation.hash;
|
22
|
-
this.startTime = undefined;
|
23
|
-
this.endTime = undefined;
|
24
|
-
}
|
25
|
-
|
26
|
-
static filterWarnings(warnings, warningsFilter) {
|
27
|
-
// we dont have anything to filter so all warnings can be shown
|
28
|
-
if (!warningsFilter) {
|
29
|
-
return warnings;
|
30
|
-
}
|
31
|
-
|
32
|
-
// create a chain of filters
|
33
|
-
// if they return "true" a warning should be suppressed
|
34
|
-
const normalizedWarningsFilters = [].concat(warningsFilter).map(filter => {
|
35
|
-
if (typeof filter === "string") {
|
36
|
-
return warning => warning.includes(filter);
|
37
|
-
}
|
38
|
-
|
39
|
-
if (filter instanceof RegExp) {
|
40
|
-
return warning => filter.test(warning);
|
41
|
-
}
|
42
|
-
|
43
|
-
if (typeof filter === "function") {
|
44
|
-
return filter;
|
45
|
-
}
|
46
|
-
|
47
|
-
throw new Error(
|
48
|
-
`Can only filter warnings with Strings or RegExps. (Given: ${filter})`
|
49
|
-
);
|
50
|
-
});
|
51
|
-
return warnings.filter(warning => {
|
52
|
-
return !normalizedWarningsFilters.some(check => check(warning));
|
53
|
-
});
|
54
|
-
}
|
55
|
-
|
56
|
-
formatFilePath(filePath) {
|
57
|
-
const OPTIONS_REGEXP = /^(\s|\S)*!/;
|
58
|
-
return filePath.includes("!")
|
59
|
-
? `${filePath.replace(OPTIONS_REGEXP, "")} (${filePath})\n`
|
60
|
-
: `${filePath}\n`;
|
61
|
-
}
|
62
|
-
|
63
|
-
hasWarnings() {
|
64
|
-
return (
|
65
|
-
this.compilation.warnings.length > 0 ||
|
66
|
-
this.compilation.children.some(child => child.getStats().hasWarnings())
|
67
|
-
);
|
68
|
-
}
|
69
|
-
|
70
|
-
hasErrors() {
|
71
|
-
return (
|
72
|
-
this.compilation.errors.length > 0 ||
|
73
|
-
this.compilation.children.some(child => child.getStats().hasErrors())
|
74
|
-
);
|
75
|
-
}
|
76
|
-
|
77
|
-
// remove a prefixed "!" that can be specified to reverse sort order
|
78
|
-
normalizeFieldKey(field) {
|
79
|
-
if (field[0] === "!") {
|
80
|
-
return field.substr(1);
|
81
|
-
}
|
82
|
-
return field;
|
83
|
-
}
|
84
|
-
|
85
|
-
// if a field is prefixed by a "!" reverse sort order
|
86
|
-
sortOrderRegular(field) {
|
87
|
-
if (field[0] === "!") {
|
88
|
-
return false;
|
89
|
-
}
|
90
|
-
return true;
|
91
|
-
}
|
92
|
-
|
93
|
-
toJson(options, forToString) {
|
94
|
-
if (typeof options === "boolean" || typeof options === "string") {
|
95
|
-
options = Stats.presetToOptions(options);
|
96
|
-
} else if (!options) {
|
97
|
-
options = {};
|
98
|
-
}
|
99
|
-
|
100
|
-
const optionOrLocalFallback = (v, def) =>
|
101
|
-
typeof v !== "undefined"
|
102
|
-
? v
|
103
|
-
: typeof options.all !== "undefined"
|
104
|
-
? options.all
|
105
|
-
: def;
|
106
|
-
|
107
|
-
const testAgainstGivenOption = item => {
|
108
|
-
if (typeof item === "string") {
|
109
|
-
const regExp = new RegExp(
|
110
|
-
`[\\\\/]${item.replace(
|
111
|
-
/[-[\]{}()*+?.\\^$|]/g,
|
112
|
-
"\\$&"
|
113
|
-
)}([\\\\/]|$|!|\\?)`
|
114
|
-
); // eslint-disable-line no-useless-escape
|
115
|
-
return ident => regExp.test(ident);
|
116
|
-
}
|
117
|
-
if (item && typeof item === "object" && typeof item.test === "function")
|
118
|
-
return ident => item.test(ident);
|
119
|
-
|
120
|
-
if (typeof item === "
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
const
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
const
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
const
|
138
|
-
const
|
139
|
-
const
|
140
|
-
const
|
141
|
-
|
142
|
-
|
143
|
-
);
|
144
|
-
const
|
145
|
-
const
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
);
|
150
|
-
const
|
151
|
-
const
|
152
|
-
options.
|
153
|
-
|
154
|
-
);
|
155
|
-
const
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
const
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
);
|
167
|
-
const
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
const
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
);
|
183
|
-
const
|
184
|
-
const
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
);
|
189
|
-
const
|
190
|
-
|
191
|
-
.
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
const
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
);
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
if (
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
e.
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
}
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
}
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
if (
|
356
|
-
obj.
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
const
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
}
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
{
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
}
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
colors.normal(" ");
|
806
|
-
colors.bold(
|
807
|
-
newline();
|
808
|
-
}
|
809
|
-
if (obj.
|
810
|
-
colors.normal("
|
811
|
-
colors.bold(
|
812
|
-
newline();
|
813
|
-
}
|
814
|
-
if (obj.
|
815
|
-
colors.normal("
|
816
|
-
colors.bold(obj.
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
if (
|
821
|
-
const
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
);
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
if (
|
995
|
-
colors.
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
}
|
1027
|
-
|
1028
|
-
|
1029
|
-
}
|
1030
|
-
if (
|
1031
|
-
|
1032
|
-
colors.normal(prefix);
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
colors.
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
}
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
colors.normal(
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
if (
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
if (
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
colors.normal(
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
}
|
1174
|
-
|
1175
|
-
colors.normal(
|
1176
|
-
colors.
|
1177
|
-
colors.normal("
|
1178
|
-
|
1179
|
-
|
1180
|
-
colors.normal("
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
colors.
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
colors.
|
1207
|
-
}
|
1208
|
-
|
1209
|
-
colors.
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
}
|
1223
|
-
|
1224
|
-
colors.normal("
|
1225
|
-
colors.
|
1226
|
-
colors.normal("
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
}
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
)
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1304
|
-
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
"use strict";
|
6
|
+
|
7
|
+
const RequestShortener = require("./RequestShortener");
|
8
|
+
const SizeFormatHelpers = require("./SizeFormatHelpers");
|
9
|
+
const formatLocation = require("./formatLocation");
|
10
|
+
const identifierUtils = require("./util/identifier");
|
11
|
+
|
12
|
+
const optionsOrFallback = (...args) => {
|
13
|
+
let optionValues = [];
|
14
|
+
optionValues.push(...args);
|
15
|
+
return optionValues.find(optionValue => typeof optionValue !== "undefined");
|
16
|
+
};
|
17
|
+
|
18
|
+
class Stats {
|
19
|
+
constructor(compilation) {
|
20
|
+
this.compilation = compilation;
|
21
|
+
this.hash = compilation.hash;
|
22
|
+
this.startTime = undefined;
|
23
|
+
this.endTime = undefined;
|
24
|
+
}
|
25
|
+
|
26
|
+
static filterWarnings(warnings, warningsFilter) {
|
27
|
+
// we dont have anything to filter so all warnings can be shown
|
28
|
+
if (!warningsFilter) {
|
29
|
+
return warnings;
|
30
|
+
}
|
31
|
+
|
32
|
+
// create a chain of filters
|
33
|
+
// if they return "true" a warning should be suppressed
|
34
|
+
const normalizedWarningsFilters = [].concat(warningsFilter).map(filter => {
|
35
|
+
if (typeof filter === "string") {
|
36
|
+
return warning => warning.includes(filter);
|
37
|
+
}
|
38
|
+
|
39
|
+
if (filter instanceof RegExp) {
|
40
|
+
return warning => filter.test(warning);
|
41
|
+
}
|
42
|
+
|
43
|
+
if (typeof filter === "function") {
|
44
|
+
return filter;
|
45
|
+
}
|
46
|
+
|
47
|
+
throw new Error(
|
48
|
+
`Can only filter warnings with Strings or RegExps. (Given: ${filter})`
|
49
|
+
);
|
50
|
+
});
|
51
|
+
return warnings.filter(warning => {
|
52
|
+
return !normalizedWarningsFilters.some(check => check(warning));
|
53
|
+
});
|
54
|
+
}
|
55
|
+
|
56
|
+
formatFilePath(filePath) {
|
57
|
+
const OPTIONS_REGEXP = /^(\s|\S)*!/;
|
58
|
+
return filePath.includes("!")
|
59
|
+
? `${filePath.replace(OPTIONS_REGEXP, "")} (${filePath})\n`
|
60
|
+
: `${filePath}\n`;
|
61
|
+
}
|
62
|
+
|
63
|
+
hasWarnings() {
|
64
|
+
return (
|
65
|
+
this.compilation.warnings.length > 0 ||
|
66
|
+
this.compilation.children.some(child => child.getStats().hasWarnings())
|
67
|
+
);
|
68
|
+
}
|
69
|
+
|
70
|
+
hasErrors() {
|
71
|
+
return (
|
72
|
+
this.compilation.errors.length > 0 ||
|
73
|
+
this.compilation.children.some(child => child.getStats().hasErrors())
|
74
|
+
);
|
75
|
+
}
|
76
|
+
|
77
|
+
// remove a prefixed "!" that can be specified to reverse sort order
|
78
|
+
normalizeFieldKey(field) {
|
79
|
+
if (field[0] === "!") {
|
80
|
+
return field.substr(1);
|
81
|
+
}
|
82
|
+
return field;
|
83
|
+
}
|
84
|
+
|
85
|
+
// if a field is prefixed by a "!" reverse sort order
|
86
|
+
sortOrderRegular(field) {
|
87
|
+
if (field[0] === "!") {
|
88
|
+
return false;
|
89
|
+
}
|
90
|
+
return true;
|
91
|
+
}
|
92
|
+
|
93
|
+
toJson(options, forToString) {
|
94
|
+
if (typeof options === "boolean" || typeof options === "string") {
|
95
|
+
options = Stats.presetToOptions(options);
|
96
|
+
} else if (!options) {
|
97
|
+
options = {};
|
98
|
+
}
|
99
|
+
|
100
|
+
const optionOrLocalFallback = (v, def) =>
|
101
|
+
typeof v !== "undefined"
|
102
|
+
? v
|
103
|
+
: typeof options.all !== "undefined"
|
104
|
+
? options.all
|
105
|
+
: def;
|
106
|
+
|
107
|
+
const testAgainstGivenOption = item => {
|
108
|
+
if (typeof item === "string") {
|
109
|
+
const regExp = new RegExp(
|
110
|
+
`[\\\\/]${item.replace(
|
111
|
+
/[-[\]{}()*+?.\\^$|]/g,
|
112
|
+
"\\$&"
|
113
|
+
)}([\\\\/]|$|!|\\?)`
|
114
|
+
); // eslint-disable-line no-useless-escape
|
115
|
+
return ident => regExp.test(ident);
|
116
|
+
}
|
117
|
+
if (item && typeof item === "object" && typeof item.test === "function") {
|
118
|
+
return ident => item.test(ident);
|
119
|
+
}
|
120
|
+
if (typeof item === "function") {
|
121
|
+
return item;
|
122
|
+
}
|
123
|
+
if (typeof item === "boolean") {
|
124
|
+
return () => item;
|
125
|
+
}
|
126
|
+
};
|
127
|
+
|
128
|
+
const compilation = this.compilation;
|
129
|
+
const context = optionsOrFallback(
|
130
|
+
options.context,
|
131
|
+
compilation.compiler.context
|
132
|
+
);
|
133
|
+
const requestShortener =
|
134
|
+
compilation.compiler.context === context
|
135
|
+
? compilation.requestShortener
|
136
|
+
: new RequestShortener(context);
|
137
|
+
const showPerformance = optionOrLocalFallback(options.performance, true);
|
138
|
+
const showHash = optionOrLocalFallback(options.hash, true);
|
139
|
+
const showEnv = optionOrLocalFallback(options.env, false);
|
140
|
+
const showVersion = optionOrLocalFallback(options.version, true);
|
141
|
+
const showTimings = optionOrLocalFallback(options.timings, true);
|
142
|
+
const showBuiltAt = optionOrLocalFallback(options.builtAt, true);
|
143
|
+
const showAssets = optionOrLocalFallback(options.assets, true);
|
144
|
+
const showEntrypoints = optionOrLocalFallback(options.entrypoints, true);
|
145
|
+
const showChunkGroups = optionOrLocalFallback(
|
146
|
+
options.chunkGroups,
|
147
|
+
!forToString
|
148
|
+
);
|
149
|
+
const showChunks = optionOrLocalFallback(options.chunks, !forToString);
|
150
|
+
const showChunkModules = optionOrLocalFallback(options.chunkModules, true);
|
151
|
+
const showChunkOrigins = optionOrLocalFallback(
|
152
|
+
options.chunkOrigins,
|
153
|
+
!forToString
|
154
|
+
);
|
155
|
+
const showModules = optionOrLocalFallback(options.modules, true);
|
156
|
+
const showNestedModules = optionOrLocalFallback(
|
157
|
+
options.nestedModules,
|
158
|
+
true
|
159
|
+
);
|
160
|
+
const showModuleAssets = optionOrLocalFallback(
|
161
|
+
options.moduleAssets,
|
162
|
+
!forToString
|
163
|
+
);
|
164
|
+
const showDepth = optionOrLocalFallback(options.depth, !forToString);
|
165
|
+
const showCachedModules = optionOrLocalFallback(options.cached, true);
|
166
|
+
const showCachedAssets = optionOrLocalFallback(options.cachedAssets, true);
|
167
|
+
const showReasons = optionOrLocalFallback(options.reasons, !forToString);
|
168
|
+
const showUsedExports = optionOrLocalFallback(
|
169
|
+
options.usedExports,
|
170
|
+
!forToString
|
171
|
+
);
|
172
|
+
const showProvidedExports = optionOrLocalFallback(
|
173
|
+
options.providedExports,
|
174
|
+
!forToString
|
175
|
+
);
|
176
|
+
const showOptimizationBailout = optionOrLocalFallback(
|
177
|
+
options.optimizationBailout,
|
178
|
+
!forToString
|
179
|
+
);
|
180
|
+
const showChildren = optionOrLocalFallback(options.children, true);
|
181
|
+
const showSource = optionOrLocalFallback(options.source, !forToString);
|
182
|
+
const showModuleTrace = optionOrLocalFallback(options.moduleTrace, true);
|
183
|
+
const showErrors = optionOrLocalFallback(options.errors, true);
|
184
|
+
const showErrorDetails = optionOrLocalFallback(
|
185
|
+
options.errorDetails,
|
186
|
+
!forToString
|
187
|
+
);
|
188
|
+
const showWarnings = optionOrLocalFallback(options.warnings, true);
|
189
|
+
const warningsFilter = optionsOrFallback(options.warningsFilter, null);
|
190
|
+
const showPublicPath = optionOrLocalFallback(
|
191
|
+
options.publicPath,
|
192
|
+
!forToString
|
193
|
+
);
|
194
|
+
const excludeModules = []
|
195
|
+
.concat(optionsOrFallback(options.excludeModules, options.exclude, []))
|
196
|
+
.map(testAgainstGivenOption);
|
197
|
+
const excludeAssets = []
|
198
|
+
.concat(optionsOrFallback(options.excludeAssets, []))
|
199
|
+
.map(testAgainstGivenOption);
|
200
|
+
const maxModules = optionsOrFallback(
|
201
|
+
options.maxModules,
|
202
|
+
forToString ? 15 : Infinity
|
203
|
+
);
|
204
|
+
const sortModules = optionsOrFallback(options.modulesSort, "id");
|
205
|
+
const sortChunks = optionsOrFallback(options.chunksSort, "id");
|
206
|
+
const sortAssets = optionsOrFallback(options.assetsSort, "");
|
207
|
+
const showOutputPath = optionOrLocalFallback(
|
208
|
+
options.outputPath,
|
209
|
+
!forToString
|
210
|
+
);
|
211
|
+
|
212
|
+
if (!showCachedModules) {
|
213
|
+
excludeModules.push((ident, module) => !module.built);
|
214
|
+
}
|
215
|
+
|
216
|
+
const createModuleFilter = () => {
|
217
|
+
let i = 0;
|
218
|
+
return module => {
|
219
|
+
if (excludeModules.length > 0) {
|
220
|
+
const ident = requestShortener.shorten(module.resource);
|
221
|
+
const excluded = excludeModules.some(fn => fn(ident, module));
|
222
|
+
if (excluded) return false;
|
223
|
+
}
|
224
|
+
const result = i < maxModules;
|
225
|
+
i++;
|
226
|
+
return result;
|
227
|
+
};
|
228
|
+
};
|
229
|
+
|
230
|
+
const createAssetFilter = () => {
|
231
|
+
return asset => {
|
232
|
+
if (excludeAssets.length > 0) {
|
233
|
+
const ident = asset.name;
|
234
|
+
const excluded = excludeAssets.some(fn => fn(ident, asset));
|
235
|
+
if (excluded) return false;
|
236
|
+
}
|
237
|
+
return showCachedAssets || asset.emitted;
|
238
|
+
};
|
239
|
+
};
|
240
|
+
|
241
|
+
const sortByFieldAndOrder = (fieldKey, a, b) => {
|
242
|
+
if (a[fieldKey] === null && b[fieldKey] === null) return 0;
|
243
|
+
if (a[fieldKey] === null) return 1;
|
244
|
+
if (b[fieldKey] === null) return -1;
|
245
|
+
if (a[fieldKey] === b[fieldKey]) return 0;
|
246
|
+
return a[fieldKey] < b[fieldKey] ? -1 : 1;
|
247
|
+
};
|
248
|
+
|
249
|
+
const sortByField = field => (a, b) => {
|
250
|
+
if (!field) {
|
251
|
+
return 0;
|
252
|
+
}
|
253
|
+
|
254
|
+
const fieldKey = this.normalizeFieldKey(field);
|
255
|
+
|
256
|
+
// if a field is prefixed with a "!" the sort is reversed!
|
257
|
+
const sortIsRegular = this.sortOrderRegular(field);
|
258
|
+
|
259
|
+
return sortByFieldAndOrder(
|
260
|
+
fieldKey,
|
261
|
+
sortIsRegular ? a : b,
|
262
|
+
sortIsRegular ? b : a
|
263
|
+
);
|
264
|
+
};
|
265
|
+
|
266
|
+
const formatError = e => {
|
267
|
+
let text = "";
|
268
|
+
if (typeof e === "string") {
|
269
|
+
e = { message: e };
|
270
|
+
}
|
271
|
+
if (e.chunk) {
|
272
|
+
text += `chunk ${e.chunk.name || e.chunk.id}${
|
273
|
+
e.chunk.hasRuntime()
|
274
|
+
? " [entry]"
|
275
|
+
: e.chunk.canBeInitial()
|
276
|
+
? " [initial]"
|
277
|
+
: ""
|
278
|
+
}\n`;
|
279
|
+
}
|
280
|
+
if (e.file) {
|
281
|
+
text += `${e.file}\n`;
|
282
|
+
}
|
283
|
+
if (
|
284
|
+
e.module &&
|
285
|
+
e.module.readableIdentifier &&
|
286
|
+
typeof e.module.readableIdentifier === "function"
|
287
|
+
) {
|
288
|
+
text += this.formatFilePath(
|
289
|
+
e.module.readableIdentifier(requestShortener)
|
290
|
+
);
|
291
|
+
}
|
292
|
+
text += e.message;
|
293
|
+
if (showErrorDetails && e.details) {
|
294
|
+
text += `\n${e.details}`;
|
295
|
+
}
|
296
|
+
if (showErrorDetails && e.missing) {
|
297
|
+
text += e.missing.map(item => `\n[${item}]`).join("");
|
298
|
+
}
|
299
|
+
if (showModuleTrace && e.origin) {
|
300
|
+
text += `\n @ ${e.origin.readableIdentifier(requestShortener)}`;
|
301
|
+
if (typeof e.originLoc === "object") {
|
302
|
+
const locInfo = formatLocation(e.originLoc);
|
303
|
+
if (locInfo) text += ` ${locInfo}`;
|
304
|
+
}
|
305
|
+
if (e.dependencies) {
|
306
|
+
for (const dep of e.dependencies) {
|
307
|
+
if (!dep.loc) continue;
|
308
|
+
if (typeof dep.loc === "string") continue;
|
309
|
+
const locInfo = formatLocation(dep.loc);
|
310
|
+
if (!locInfo) continue;
|
311
|
+
text += ` ${locInfo}`;
|
312
|
+
}
|
313
|
+
}
|
314
|
+
let current = e.origin;
|
315
|
+
while (current.issuer) {
|
316
|
+
current = current.issuer;
|
317
|
+
text += `\n @ ${current.readableIdentifier(requestShortener)}`;
|
318
|
+
}
|
319
|
+
}
|
320
|
+
return text;
|
321
|
+
};
|
322
|
+
|
323
|
+
const obj = {
|
324
|
+
errors: compilation.errors.map(formatError),
|
325
|
+
warnings: Stats.filterWarnings(
|
326
|
+
compilation.warnings.map(formatError),
|
327
|
+
warningsFilter
|
328
|
+
)
|
329
|
+
};
|
330
|
+
|
331
|
+
//We just hint other renderers since actually omitting
|
332
|
+
//errors/warnings from the JSON would be kind of weird.
|
333
|
+
Object.defineProperty(obj, "_showWarnings", {
|
334
|
+
value: showWarnings,
|
335
|
+
enumerable: false
|
336
|
+
});
|
337
|
+
Object.defineProperty(obj, "_showErrors", {
|
338
|
+
value: showErrors,
|
339
|
+
enumerable: false
|
340
|
+
});
|
341
|
+
|
342
|
+
if (showVersion) {
|
343
|
+
obj.version = require("../package.json").version;
|
344
|
+
}
|
345
|
+
|
346
|
+
if (showHash) obj.hash = this.hash;
|
347
|
+
if (showTimings && this.startTime && this.endTime) {
|
348
|
+
obj.time = this.endTime - this.startTime;
|
349
|
+
}
|
350
|
+
|
351
|
+
if (showBuiltAt && this.endTime) {
|
352
|
+
obj.builtAt = this.endTime;
|
353
|
+
}
|
354
|
+
|
355
|
+
if (showEnv && options._env) {
|
356
|
+
obj.env = options._env;
|
357
|
+
}
|
358
|
+
|
359
|
+
if (compilation.needAdditionalPass) {
|
360
|
+
obj.needAdditionalPass = true;
|
361
|
+
}
|
362
|
+
if (showPublicPath) {
|
363
|
+
obj.publicPath = this.compilation.mainTemplate.getPublicPath({
|
364
|
+
hash: this.compilation.hash
|
365
|
+
});
|
366
|
+
}
|
367
|
+
if (showOutputPath) {
|
368
|
+
obj.outputPath = this.compilation.mainTemplate.outputOptions.path;
|
369
|
+
}
|
370
|
+
if (showAssets) {
|
371
|
+
const assetsByFile = {};
|
372
|
+
const compilationAssets = Object.keys(compilation.assets);
|
373
|
+
obj.assetsByChunkName = {};
|
374
|
+
obj.assets = compilationAssets
|
375
|
+
.map(asset => {
|
376
|
+
const obj = {
|
377
|
+
name: asset,
|
378
|
+
size: compilation.assets[asset].size(),
|
379
|
+
chunks: [],
|
380
|
+
chunkNames: [],
|
381
|
+
emitted: compilation.assets[asset].emitted
|
382
|
+
};
|
383
|
+
|
384
|
+
if (showPerformance) {
|
385
|
+
obj.isOverSizeLimit = compilation.assets[asset].isOverSizeLimit;
|
386
|
+
}
|
387
|
+
|
388
|
+
assetsByFile[asset] = obj;
|
389
|
+
return obj;
|
390
|
+
})
|
391
|
+
.filter(createAssetFilter());
|
392
|
+
obj.filteredAssets = compilationAssets.length - obj.assets.length;
|
393
|
+
|
394
|
+
for (const chunk of compilation.chunks) {
|
395
|
+
for (const asset of chunk.files) {
|
396
|
+
if (assetsByFile[asset]) {
|
397
|
+
for (const id of chunk.ids) {
|
398
|
+
assetsByFile[asset].chunks.push(id);
|
399
|
+
}
|
400
|
+
if (chunk.name) {
|
401
|
+
assetsByFile[asset].chunkNames.push(chunk.name);
|
402
|
+
if (obj.assetsByChunkName[chunk.name]) {
|
403
|
+
obj.assetsByChunkName[chunk.name] = []
|
404
|
+
.concat(obj.assetsByChunkName[chunk.name])
|
405
|
+
.concat([asset]);
|
406
|
+
} else {
|
407
|
+
obj.assetsByChunkName[chunk.name] = asset;
|
408
|
+
}
|
409
|
+
}
|
410
|
+
}
|
411
|
+
}
|
412
|
+
}
|
413
|
+
obj.assets.sort(sortByField(sortAssets));
|
414
|
+
}
|
415
|
+
|
416
|
+
const fnChunkGroup = groupMap => {
|
417
|
+
const obj = {};
|
418
|
+
for (const keyValuePair of groupMap) {
|
419
|
+
const name = keyValuePair[0];
|
420
|
+
const cg = keyValuePair[1];
|
421
|
+
const children = cg.getChildrenByOrders();
|
422
|
+
obj[name] = {
|
423
|
+
chunks: cg.chunks.map(c => c.id),
|
424
|
+
assets: cg.chunks.reduce(
|
425
|
+
(array, c) => array.concat(c.files || []),
|
426
|
+
[]
|
427
|
+
),
|
428
|
+
children: Object.keys(children).reduce((obj, key) => {
|
429
|
+
const groups = children[key];
|
430
|
+
obj[key] = groups.map(group => ({
|
431
|
+
name: group.name,
|
432
|
+
chunks: group.chunks.map(c => c.id),
|
433
|
+
assets: group.chunks.reduce(
|
434
|
+
(array, c) => array.concat(c.files || []),
|
435
|
+
[]
|
436
|
+
)
|
437
|
+
}));
|
438
|
+
return obj;
|
439
|
+
}, Object.create(null)),
|
440
|
+
childAssets: Object.keys(children).reduce((obj, key) => {
|
441
|
+
const groups = children[key];
|
442
|
+
obj[key] = Array.from(
|
443
|
+
groups.reduce((set, group) => {
|
444
|
+
for (const chunk of group.chunks) {
|
445
|
+
for (const asset of chunk.files) {
|
446
|
+
set.add(asset);
|
447
|
+
}
|
448
|
+
}
|
449
|
+
return set;
|
450
|
+
}, new Set())
|
451
|
+
);
|
452
|
+
return obj;
|
453
|
+
}, Object.create(null))
|
454
|
+
};
|
455
|
+
if (showPerformance) {
|
456
|
+
obj[name].isOverSizeLimit = cg.isOverSizeLimit;
|
457
|
+
}
|
458
|
+
}
|
459
|
+
|
460
|
+
return obj;
|
461
|
+
};
|
462
|
+
|
463
|
+
if (showEntrypoints) {
|
464
|
+
obj.entrypoints = fnChunkGroup(compilation.entrypoints);
|
465
|
+
}
|
466
|
+
|
467
|
+
if (showChunkGroups) {
|
468
|
+
obj.namedChunkGroups = fnChunkGroup(compilation.namedChunkGroups);
|
469
|
+
}
|
470
|
+
|
471
|
+
const fnModule = module => {
|
472
|
+
const path = [];
|
473
|
+
let current = module;
|
474
|
+
while (current.issuer) {
|
475
|
+
path.push((current = current.issuer));
|
476
|
+
}
|
477
|
+
path.reverse();
|
478
|
+
const obj = {
|
479
|
+
id: module.id,
|
480
|
+
identifier: module.identifier(),
|
481
|
+
name: module.readableIdentifier(requestShortener),
|
482
|
+
index: module.index,
|
483
|
+
index2: module.index2,
|
484
|
+
size: module.size(),
|
485
|
+
cacheable: module.buildInfo.cacheable,
|
486
|
+
built: !!module.built,
|
487
|
+
optional: module.optional,
|
488
|
+
prefetched: module.prefetched,
|
489
|
+
chunks: Array.from(module.chunksIterable, chunk => chunk.id),
|
490
|
+
issuer: module.issuer && module.issuer.identifier(),
|
491
|
+
issuerId: module.issuer && module.issuer.id,
|
492
|
+
issuerName:
|
493
|
+
module.issuer && module.issuer.readableIdentifier(requestShortener),
|
494
|
+
issuerPath:
|
495
|
+
module.issuer &&
|
496
|
+
path.map(module => ({
|
497
|
+
id: module.id,
|
498
|
+
identifier: module.identifier(),
|
499
|
+
name: module.readableIdentifier(requestShortener),
|
500
|
+
profile: module.profile
|
501
|
+
})),
|
502
|
+
profile: module.profile,
|
503
|
+
failed: !!module.error,
|
504
|
+
errors: module.errors ? module.errors.length : 0,
|
505
|
+
warnings: module.warnings ? module.warnings.length : 0
|
506
|
+
};
|
507
|
+
if (showModuleAssets) {
|
508
|
+
obj.assets = Object.keys(module.buildInfo.assets || {});
|
509
|
+
}
|
510
|
+
if (showReasons) {
|
511
|
+
obj.reasons = module.reasons
|
512
|
+
.map(reason => {
|
513
|
+
const obj = {
|
514
|
+
moduleId: reason.module ? reason.module.id : null,
|
515
|
+
moduleIdentifier: reason.module
|
516
|
+
? reason.module.identifier()
|
517
|
+
: null,
|
518
|
+
module: reason.module
|
519
|
+
? reason.module.readableIdentifier(requestShortener)
|
520
|
+
: null,
|
521
|
+
moduleName: reason.module
|
522
|
+
? reason.module.readableIdentifier(requestShortener)
|
523
|
+
: null,
|
524
|
+
type: reason.dependency ? reason.dependency.type : null,
|
525
|
+
explanation: reason.explanation,
|
526
|
+
userRequest: reason.dependency
|
527
|
+
? reason.dependency.userRequest
|
528
|
+
: null
|
529
|
+
};
|
530
|
+
if (reason.dependency) {
|
531
|
+
const locInfo = formatLocation(reason.dependency.loc);
|
532
|
+
if (locInfo) {
|
533
|
+
obj.loc = locInfo;
|
534
|
+
}
|
535
|
+
}
|
536
|
+
return obj;
|
537
|
+
})
|
538
|
+
.sort((a, b) => a.moduleId - b.moduleId);
|
539
|
+
}
|
540
|
+
if (showUsedExports) {
|
541
|
+
if (module.used === true) {
|
542
|
+
obj.usedExports = module.usedExports;
|
543
|
+
} else if (module.used === false) {
|
544
|
+
obj.usedExports = false;
|
545
|
+
}
|
546
|
+
}
|
547
|
+
if (showProvidedExports) {
|
548
|
+
obj.providedExports = Array.isArray(module.buildMeta.providedExports)
|
549
|
+
? module.buildMeta.providedExports
|
550
|
+
: null;
|
551
|
+
}
|
552
|
+
if (showOptimizationBailout) {
|
553
|
+
obj.optimizationBailout = module.optimizationBailout.map(item => {
|
554
|
+
if (typeof item === "function") return item(requestShortener);
|
555
|
+
return item;
|
556
|
+
});
|
557
|
+
}
|
558
|
+
if (showDepth) {
|
559
|
+
obj.depth = module.depth;
|
560
|
+
}
|
561
|
+
if (showNestedModules) {
|
562
|
+
if (module.modules) {
|
563
|
+
const modules = module.modules;
|
564
|
+
obj.modules = modules
|
565
|
+
.sort(sortByField("depth"))
|
566
|
+
.filter(createModuleFilter())
|
567
|
+
.map(fnModule);
|
568
|
+
obj.filteredModules = modules.length - obj.modules.length;
|
569
|
+
obj.modules.sort(sortByField(sortModules));
|
570
|
+
}
|
571
|
+
}
|
572
|
+
if (showSource && module._source) {
|
573
|
+
obj.source = module._source.source();
|
574
|
+
}
|
575
|
+
return obj;
|
576
|
+
};
|
577
|
+
if (showChunks) {
|
578
|
+
obj.chunks = compilation.chunks.map(chunk => {
|
579
|
+
const parents = new Set();
|
580
|
+
const children = new Set();
|
581
|
+
const siblings = new Set();
|
582
|
+
const childIdByOrder = chunk.getChildIdsByOrders();
|
583
|
+
for (const chunkGroup of chunk.groupsIterable) {
|
584
|
+
for (const parentGroup of chunkGroup.parentsIterable) {
|
585
|
+
for (const chunk of parentGroup.chunks) {
|
586
|
+
parents.add(chunk.id);
|
587
|
+
}
|
588
|
+
}
|
589
|
+
for (const childGroup of chunkGroup.childrenIterable) {
|
590
|
+
for (const chunk of childGroup.chunks) {
|
591
|
+
children.add(chunk.id);
|
592
|
+
}
|
593
|
+
}
|
594
|
+
for (const sibling of chunkGroup.chunks) {
|
595
|
+
if (sibling !== chunk) siblings.add(sibling.id);
|
596
|
+
}
|
597
|
+
}
|
598
|
+
const obj = {
|
599
|
+
id: chunk.id,
|
600
|
+
rendered: chunk.rendered,
|
601
|
+
initial: chunk.canBeInitial(),
|
602
|
+
entry: chunk.hasRuntime(),
|
603
|
+
recorded: chunk.recorded,
|
604
|
+
reason: chunk.chunkReason,
|
605
|
+
size: chunk.modulesSize(),
|
606
|
+
names: chunk.name ? [chunk.name] : [],
|
607
|
+
files: chunk.files.slice(),
|
608
|
+
hash: chunk.renderedHash,
|
609
|
+
siblings: Array.from(siblings).sort(),
|
610
|
+
parents: Array.from(parents).sort(),
|
611
|
+
children: Array.from(children).sort(),
|
612
|
+
childrenByOrder: childIdByOrder
|
613
|
+
};
|
614
|
+
if (showChunkModules) {
|
615
|
+
obj.modules = chunk
|
616
|
+
.getModules()
|
617
|
+
.sort(sortByField("depth"))
|
618
|
+
.filter(createModuleFilter())
|
619
|
+
.map(fnModule);
|
620
|
+
obj.filteredModules = chunk.getNumberOfModules() - obj.modules.length;
|
621
|
+
obj.modules.sort(sortByField(sortModules));
|
622
|
+
}
|
623
|
+
if (showChunkOrigins) {
|
624
|
+
obj.origins = Array.from(chunk.groupsIterable, g => g.origins)
|
625
|
+
.reduce((a, b) => a.concat(b), [])
|
626
|
+
.map(origin => ({
|
627
|
+
moduleId: origin.module ? origin.module.id : undefined,
|
628
|
+
module: origin.module ? origin.module.identifier() : "",
|
629
|
+
moduleIdentifier: origin.module ? origin.module.identifier() : "",
|
630
|
+
moduleName: origin.module
|
631
|
+
? origin.module.readableIdentifier(requestShortener)
|
632
|
+
: "",
|
633
|
+
loc: formatLocation(origin.loc),
|
634
|
+
request: origin.request,
|
635
|
+
reasons: origin.reasons || []
|
636
|
+
}))
|
637
|
+
.sort((a, b) => {
|
638
|
+
if (
|
639
|
+
typeof a.moduleId === "number" &&
|
640
|
+
typeof b.moduleId !== "number"
|
641
|
+
)
|
642
|
+
return 1;
|
643
|
+
if (
|
644
|
+
typeof a.moduleId !== "number" &&
|
645
|
+
typeof b.moduleId === "number"
|
646
|
+
)
|
647
|
+
return -1;
|
648
|
+
if (
|
649
|
+
typeof a.moduleId === "number" &&
|
650
|
+
typeof b.moduleId === "number"
|
651
|
+
) {
|
652
|
+
const diffId = a.moduleId - b.moduleId;
|
653
|
+
if (diffId !== 0) return diffId;
|
654
|
+
}
|
655
|
+
if (a.loc < b.loc) return -1;
|
656
|
+
if (a.loc > b.loc) return 1;
|
657
|
+
return 0;
|
658
|
+
});
|
659
|
+
}
|
660
|
+
return obj;
|
661
|
+
});
|
662
|
+
obj.chunks.sort(sortByField(sortChunks));
|
663
|
+
}
|
664
|
+
if (showModules) {
|
665
|
+
obj.modules = compilation.modules
|
666
|
+
.slice()
|
667
|
+
.sort(sortByField("depth"))
|
668
|
+
.filter(createModuleFilter())
|
669
|
+
.map(fnModule);
|
670
|
+
obj.filteredModules = compilation.modules.length - obj.modules.length;
|
671
|
+
obj.modules.sort(sortByField(sortModules));
|
672
|
+
}
|
673
|
+
if (showChildren) {
|
674
|
+
obj.children = compilation.children.map((child, idx) => {
|
675
|
+
const childOptions = Stats.getChildOptions(options, idx);
|
676
|
+
const obj = new Stats(child).toJson(childOptions, forToString);
|
677
|
+
delete obj.hash;
|
678
|
+
delete obj.version;
|
679
|
+
if (child.name) {
|
680
|
+
obj.name = identifierUtils.makePathsRelative(
|
681
|
+
context,
|
682
|
+
child.name,
|
683
|
+
compilation.cache
|
684
|
+
);
|
685
|
+
}
|
686
|
+
return obj;
|
687
|
+
});
|
688
|
+
}
|
689
|
+
|
690
|
+
return obj;
|
691
|
+
}
|
692
|
+
|
693
|
+
toString(options) {
|
694
|
+
if (typeof options === "boolean" || typeof options === "string") {
|
695
|
+
options = Stats.presetToOptions(options);
|
696
|
+
} else if (!options) {
|
697
|
+
options = {};
|
698
|
+
}
|
699
|
+
|
700
|
+
const useColors = optionsOrFallback(options.colors, false);
|
701
|
+
|
702
|
+
const obj = this.toJson(options, true);
|
703
|
+
|
704
|
+
return Stats.jsonToString(obj, useColors);
|
705
|
+
}
|
706
|
+
|
707
|
+
static jsonToString(obj, useColors) {
|
708
|
+
const buf = [];
|
709
|
+
|
710
|
+
const defaultColors = {
|
711
|
+
bold: "\u001b[1m",
|
712
|
+
yellow: "\u001b[1m\u001b[33m",
|
713
|
+
red: "\u001b[1m\u001b[31m",
|
714
|
+
green: "\u001b[1m\u001b[32m",
|
715
|
+
cyan: "\u001b[1m\u001b[36m",
|
716
|
+
magenta: "\u001b[1m\u001b[35m"
|
717
|
+
};
|
718
|
+
|
719
|
+
const colors = Object.keys(defaultColors).reduce(
|
720
|
+
(obj, color) => {
|
721
|
+
obj[color] = str => {
|
722
|
+
if (useColors) {
|
723
|
+
buf.push(
|
724
|
+
useColors === true || useColors[color] === undefined
|
725
|
+
? defaultColors[color]
|
726
|
+
: useColors[color]
|
727
|
+
);
|
728
|
+
}
|
729
|
+
buf.push(str);
|
730
|
+
if (useColors) {
|
731
|
+
buf.push("\u001b[39m\u001b[22m");
|
732
|
+
}
|
733
|
+
};
|
734
|
+
return obj;
|
735
|
+
},
|
736
|
+
{
|
737
|
+
normal: str => buf.push(str)
|
738
|
+
}
|
739
|
+
);
|
740
|
+
|
741
|
+
const coloredTime = time => {
|
742
|
+
let times = [800, 400, 200, 100];
|
743
|
+
if (obj.time) {
|
744
|
+
times = [obj.time / 2, obj.time / 4, obj.time / 8, obj.time / 16];
|
745
|
+
}
|
746
|
+
if (time < times[3]) colors.normal(`${time}ms`);
|
747
|
+
else if (time < times[2]) colors.bold(`${time}ms`);
|
748
|
+
else if (time < times[1]) colors.green(`${time}ms`);
|
749
|
+
else if (time < times[0]) colors.yellow(`${time}ms`);
|
750
|
+
else colors.red(`${time}ms`);
|
751
|
+
};
|
752
|
+
|
753
|
+
const newline = () => buf.push("\n");
|
754
|
+
|
755
|
+
const getText = (arr, row, col) => {
|
756
|
+
return arr[row][col].value;
|
757
|
+
};
|
758
|
+
|
759
|
+
const table = (array, align, splitter) => {
|
760
|
+
const rows = array.length;
|
761
|
+
const cols = array[0].length;
|
762
|
+
const colSizes = new Array(cols);
|
763
|
+
for (let col = 0; col < cols; col++) {
|
764
|
+
colSizes[col] = 0;
|
765
|
+
}
|
766
|
+
for (let row = 0; row < rows; row++) {
|
767
|
+
for (let col = 0; col < cols; col++) {
|
768
|
+
const value = `${getText(array, row, col)}`;
|
769
|
+
if (value.length > colSizes[col]) {
|
770
|
+
colSizes[col] = value.length;
|
771
|
+
}
|
772
|
+
}
|
773
|
+
}
|
774
|
+
for (let row = 0; row < rows; row++) {
|
775
|
+
for (let col = 0; col < cols; col++) {
|
776
|
+
const format = array[row][col].color;
|
777
|
+
const value = `${getText(array, row, col)}`;
|
778
|
+
let l = value.length;
|
779
|
+
if (align[col] === "l") {
|
780
|
+
format(value);
|
781
|
+
}
|
782
|
+
for (; l < colSizes[col] && col !== cols - 1; l++) {
|
783
|
+
colors.normal(" ");
|
784
|
+
}
|
785
|
+
if (align[col] === "r") {
|
786
|
+
format(value);
|
787
|
+
}
|
788
|
+
if (col + 1 < cols && colSizes[col] !== 0) {
|
789
|
+
colors.normal(splitter || " ");
|
790
|
+
}
|
791
|
+
}
|
792
|
+
newline();
|
793
|
+
}
|
794
|
+
};
|
795
|
+
|
796
|
+
const getAssetColor = (asset, defaultColor) => {
|
797
|
+
if (asset.isOverSizeLimit) {
|
798
|
+
return colors.yellow;
|
799
|
+
}
|
800
|
+
|
801
|
+
return defaultColor;
|
802
|
+
};
|
803
|
+
|
804
|
+
if (obj.hash) {
|
805
|
+
colors.normal("Hash: ");
|
806
|
+
colors.bold(obj.hash);
|
807
|
+
newline();
|
808
|
+
}
|
809
|
+
if (obj.version) {
|
810
|
+
colors.normal("Version: webpack ");
|
811
|
+
colors.bold(obj.version);
|
812
|
+
newline();
|
813
|
+
}
|
814
|
+
if (typeof obj.time === "number") {
|
815
|
+
colors.normal("Time: ");
|
816
|
+
colors.bold(obj.time);
|
817
|
+
colors.normal("ms");
|
818
|
+
newline();
|
819
|
+
}
|
820
|
+
if (typeof obj.builtAt === "number") {
|
821
|
+
const builtAtDate = new Date(obj.builtAt);
|
822
|
+
colors.normal("Built at: ");
|
823
|
+
colors.normal(
|
824
|
+
builtAtDate.toLocaleDateString(undefined, {
|
825
|
+
day: "2-digit",
|
826
|
+
month: "2-digit",
|
827
|
+
year: "numeric"
|
828
|
+
})
|
829
|
+
);
|
830
|
+
colors.normal(" ");
|
831
|
+
colors.bold(builtAtDate.toLocaleTimeString());
|
832
|
+
newline();
|
833
|
+
}
|
834
|
+
if (obj.env) {
|
835
|
+
colors.normal("Environment (--env): ");
|
836
|
+
colors.bold(JSON.stringify(obj.env, null, 2));
|
837
|
+
newline();
|
838
|
+
}
|
839
|
+
if (obj.publicPath) {
|
840
|
+
colors.normal("PublicPath: ");
|
841
|
+
colors.bold(obj.publicPath);
|
842
|
+
newline();
|
843
|
+
}
|
844
|
+
|
845
|
+
if (obj.assets && obj.assets.length > 0) {
|
846
|
+
const t = [
|
847
|
+
[
|
848
|
+
{
|
849
|
+
value: "Asset",
|
850
|
+
color: colors.bold
|
851
|
+
},
|
852
|
+
{
|
853
|
+
value: "Size",
|
854
|
+
color: colors.bold
|
855
|
+
},
|
856
|
+
{
|
857
|
+
value: "Chunks",
|
858
|
+
color: colors.bold
|
859
|
+
},
|
860
|
+
{
|
861
|
+
value: "",
|
862
|
+
color: colors.bold
|
863
|
+
},
|
864
|
+
{
|
865
|
+
value: "",
|
866
|
+
color: colors.bold
|
867
|
+
},
|
868
|
+
{
|
869
|
+
value: "Chunk Names",
|
870
|
+
color: colors.bold
|
871
|
+
}
|
872
|
+
]
|
873
|
+
];
|
874
|
+
for (const asset of obj.assets) {
|
875
|
+
t.push([
|
876
|
+
{
|
877
|
+
value: asset.name,
|
878
|
+
color: getAssetColor(asset, colors.green)
|
879
|
+
},
|
880
|
+
{
|
881
|
+
value: SizeFormatHelpers.formatSize(asset.size),
|
882
|
+
color: getAssetColor(asset, colors.normal)
|
883
|
+
},
|
884
|
+
{
|
885
|
+
value: asset.chunks.join(", "),
|
886
|
+
color: colors.bold
|
887
|
+
},
|
888
|
+
{
|
889
|
+
value: asset.emitted ? "[emitted]" : "",
|
890
|
+
color: colors.green
|
891
|
+
},
|
892
|
+
{
|
893
|
+
value: asset.isOverSizeLimit ? "[big]" : "",
|
894
|
+
color: getAssetColor(asset, colors.normal)
|
895
|
+
},
|
896
|
+
{
|
897
|
+
value: asset.chunkNames.join(", "),
|
898
|
+
color: colors.normal
|
899
|
+
}
|
900
|
+
]);
|
901
|
+
}
|
902
|
+
table(t, "rrrlll");
|
903
|
+
}
|
904
|
+
if (obj.filteredAssets > 0) {
|
905
|
+
colors.normal(" ");
|
906
|
+
if (obj.assets.length > 0) colors.normal("+ ");
|
907
|
+
colors.normal(obj.filteredAssets);
|
908
|
+
if (obj.assets.length > 0) colors.normal(" hidden");
|
909
|
+
colors.normal(obj.filteredAssets !== 1 ? " assets" : " asset");
|
910
|
+
newline();
|
911
|
+
}
|
912
|
+
|
913
|
+
const processChunkGroups = (namedGroups, prefix) => {
|
914
|
+
for (const name of Object.keys(namedGroups)) {
|
915
|
+
const cg = namedGroups[name];
|
916
|
+
colors.normal(`${prefix} `);
|
917
|
+
colors.bold(name);
|
918
|
+
if (cg.isOverSizeLimit) {
|
919
|
+
colors.normal(" ");
|
920
|
+
colors.yellow("[big]");
|
921
|
+
}
|
922
|
+
colors.normal(" =");
|
923
|
+
for (const asset of cg.assets) {
|
924
|
+
colors.normal(" ");
|
925
|
+
colors.green(asset);
|
926
|
+
}
|
927
|
+
for (const name of Object.keys(cg.childAssets)) {
|
928
|
+
const assets = cg.childAssets[name];
|
929
|
+
if (assets && assets.length > 0) {
|
930
|
+
colors.normal(" ");
|
931
|
+
colors.magenta(`(${name}:`);
|
932
|
+
for (const asset of assets) {
|
933
|
+
colors.normal(" ");
|
934
|
+
colors.green(asset);
|
935
|
+
}
|
936
|
+
colors.magenta(")");
|
937
|
+
}
|
938
|
+
}
|
939
|
+
newline();
|
940
|
+
}
|
941
|
+
};
|
942
|
+
|
943
|
+
if (obj.entrypoints) {
|
944
|
+
processChunkGroups(obj.entrypoints, "Entrypoint");
|
945
|
+
}
|
946
|
+
|
947
|
+
if (obj.namedChunkGroups) {
|
948
|
+
let outputChunkGroups = obj.namedChunkGroups;
|
949
|
+
if (obj.entrypoints) {
|
950
|
+
outputChunkGroups = Object.keys(outputChunkGroups)
|
951
|
+
.filter(name => !obj.entrypoints[name])
|
952
|
+
.reduce((result, name) => {
|
953
|
+
result[name] = obj.namedChunkGroups[name];
|
954
|
+
return result;
|
955
|
+
}, {});
|
956
|
+
}
|
957
|
+
processChunkGroups(outputChunkGroups, "Chunk Group");
|
958
|
+
}
|
959
|
+
|
960
|
+
const modulesByIdentifier = {};
|
961
|
+
if (obj.modules) {
|
962
|
+
for (const module of obj.modules) {
|
963
|
+
modulesByIdentifier[`$${module.identifier}`] = module;
|
964
|
+
}
|
965
|
+
} else if (obj.chunks) {
|
966
|
+
for (const chunk of obj.chunks) {
|
967
|
+
if (chunk.modules) {
|
968
|
+
for (const module of chunk.modules) {
|
969
|
+
modulesByIdentifier[`$${module.identifier}`] = module;
|
970
|
+
}
|
971
|
+
}
|
972
|
+
}
|
973
|
+
}
|
974
|
+
|
975
|
+
const processModuleAttributes = module => {
|
976
|
+
colors.normal(" ");
|
977
|
+
colors.normal(SizeFormatHelpers.formatSize(module.size));
|
978
|
+
if (module.chunks) {
|
979
|
+
for (const chunk of module.chunks) {
|
980
|
+
colors.normal(" {");
|
981
|
+
colors.yellow(chunk);
|
982
|
+
colors.normal("}");
|
983
|
+
}
|
984
|
+
}
|
985
|
+
if (typeof module.depth === "number") {
|
986
|
+
colors.normal(` [depth ${module.depth}]`);
|
987
|
+
}
|
988
|
+
if (module.cacheable === false) {
|
989
|
+
colors.red(" [not cacheable]");
|
990
|
+
}
|
991
|
+
if (module.optional) {
|
992
|
+
colors.yellow(" [optional]");
|
993
|
+
}
|
994
|
+
if (module.built) {
|
995
|
+
colors.green(" [built]");
|
996
|
+
}
|
997
|
+
if (module.assets && module.assets.length) {
|
998
|
+
colors.magenta(
|
999
|
+
` [${module.assets.length} asset${
|
1000
|
+
module.assets.length === 1 ? "" : "s"
|
1001
|
+
}]`
|
1002
|
+
);
|
1003
|
+
}
|
1004
|
+
if (module.prefetched) {
|
1005
|
+
colors.magenta(" [prefetched]");
|
1006
|
+
}
|
1007
|
+
if (module.failed) colors.red(" [failed]");
|
1008
|
+
if (module.warnings) {
|
1009
|
+
colors.yellow(
|
1010
|
+
` [${module.warnings} warning${module.warnings === 1 ? "" : "s"}]`
|
1011
|
+
);
|
1012
|
+
}
|
1013
|
+
if (module.errors) {
|
1014
|
+
colors.red(
|
1015
|
+
` [${module.errors} error${module.errors === 1 ? "" : "s"}]`
|
1016
|
+
);
|
1017
|
+
}
|
1018
|
+
};
|
1019
|
+
|
1020
|
+
const processModuleContent = (module, prefix) => {
|
1021
|
+
if (Array.isArray(module.providedExports)) {
|
1022
|
+
colors.normal(prefix);
|
1023
|
+
if (module.providedExports.length === 0) {
|
1024
|
+
colors.cyan("[no exports]");
|
1025
|
+
} else {
|
1026
|
+
colors.cyan(`[exports: ${module.providedExports.join(", ")}]`);
|
1027
|
+
}
|
1028
|
+
newline();
|
1029
|
+
}
|
1030
|
+
if (module.usedExports !== undefined) {
|
1031
|
+
if (module.usedExports !== true) {
|
1032
|
+
colors.normal(prefix);
|
1033
|
+
if (module.usedExports === null) {
|
1034
|
+
colors.cyan("[used exports unknown]");
|
1035
|
+
} else if (module.usedExports === false) {
|
1036
|
+
colors.cyan("[no exports used]");
|
1037
|
+
} else if (
|
1038
|
+
Array.isArray(module.usedExports) &&
|
1039
|
+
module.usedExports.length === 0
|
1040
|
+
) {
|
1041
|
+
colors.cyan("[no exports used]");
|
1042
|
+
} else if (Array.isArray(module.usedExports)) {
|
1043
|
+
const providedExportsCount = Array.isArray(module.providedExports)
|
1044
|
+
? module.providedExports.length
|
1045
|
+
: null;
|
1046
|
+
if (
|
1047
|
+
providedExportsCount !== null &&
|
1048
|
+
providedExportsCount === module.usedExports.length
|
1049
|
+
) {
|
1050
|
+
colors.cyan("[all exports used]");
|
1051
|
+
} else {
|
1052
|
+
colors.cyan(
|
1053
|
+
`[only some exports used: ${module.usedExports.join(", ")}]`
|
1054
|
+
);
|
1055
|
+
}
|
1056
|
+
}
|
1057
|
+
newline();
|
1058
|
+
}
|
1059
|
+
}
|
1060
|
+
if (Array.isArray(module.optimizationBailout)) {
|
1061
|
+
for (const item of module.optimizationBailout) {
|
1062
|
+
colors.normal(prefix);
|
1063
|
+
colors.yellow(item);
|
1064
|
+
newline();
|
1065
|
+
}
|
1066
|
+
}
|
1067
|
+
if (module.reasons) {
|
1068
|
+
for (const reason of module.reasons) {
|
1069
|
+
colors.normal(prefix);
|
1070
|
+
if (reason.type) {
|
1071
|
+
colors.normal(reason.type);
|
1072
|
+
colors.normal(" ");
|
1073
|
+
}
|
1074
|
+
if (reason.userRequest) {
|
1075
|
+
colors.cyan(reason.userRequest);
|
1076
|
+
colors.normal(" ");
|
1077
|
+
}
|
1078
|
+
if (reason.moduleId !== null) {
|
1079
|
+
colors.normal("[");
|
1080
|
+
colors.normal(reason.moduleId);
|
1081
|
+
colors.normal("]");
|
1082
|
+
}
|
1083
|
+
if (reason.module && reason.module !== reason.moduleId) {
|
1084
|
+
colors.normal(" ");
|
1085
|
+
colors.magenta(reason.module);
|
1086
|
+
}
|
1087
|
+
if (reason.loc) {
|
1088
|
+
colors.normal(" ");
|
1089
|
+
colors.normal(reason.loc);
|
1090
|
+
}
|
1091
|
+
if (reason.explanation) {
|
1092
|
+
colors.normal(" ");
|
1093
|
+
colors.cyan(reason.explanation);
|
1094
|
+
}
|
1095
|
+
newline();
|
1096
|
+
}
|
1097
|
+
}
|
1098
|
+
if (module.profile) {
|
1099
|
+
colors.normal(prefix);
|
1100
|
+
let sum = 0;
|
1101
|
+
if (module.issuerPath) {
|
1102
|
+
for (const m of module.issuerPath) {
|
1103
|
+
colors.normal("[");
|
1104
|
+
colors.normal(m.id);
|
1105
|
+
colors.normal("] ");
|
1106
|
+
if (m.profile) {
|
1107
|
+
const time = (m.profile.factory || 0) + (m.profile.building || 0);
|
1108
|
+
coloredTime(time);
|
1109
|
+
sum += time;
|
1110
|
+
colors.normal(" ");
|
1111
|
+
}
|
1112
|
+
colors.normal("-> ");
|
1113
|
+
}
|
1114
|
+
}
|
1115
|
+
for (const key of Object.keys(module.profile)) {
|
1116
|
+
colors.normal(`${key}:`);
|
1117
|
+
const time = module.profile[key];
|
1118
|
+
coloredTime(time);
|
1119
|
+
colors.normal(" ");
|
1120
|
+
sum += time;
|
1121
|
+
}
|
1122
|
+
colors.normal("= ");
|
1123
|
+
coloredTime(sum);
|
1124
|
+
newline();
|
1125
|
+
}
|
1126
|
+
if (module.modules) {
|
1127
|
+
processModulesList(module, prefix + "| ");
|
1128
|
+
}
|
1129
|
+
};
|
1130
|
+
|
1131
|
+
const processModulesList = (obj, prefix) => {
|
1132
|
+
if (obj.modules) {
|
1133
|
+
let maxModuleId = 0;
|
1134
|
+
for (const module of obj.modules) {
|
1135
|
+
if (typeof module.id === "number") {
|
1136
|
+
if (maxModuleId < module.id) maxModuleId = module.id;
|
1137
|
+
}
|
1138
|
+
}
|
1139
|
+
let contentPrefix = prefix + " ";
|
1140
|
+
if (maxModuleId >= 10) contentPrefix += " ";
|
1141
|
+
if (maxModuleId >= 100) contentPrefix += " ";
|
1142
|
+
if (maxModuleId >= 1000) contentPrefix += " ";
|
1143
|
+
for (const module of obj.modules) {
|
1144
|
+
colors.normal(prefix);
|
1145
|
+
const name = module.name || module.identifier;
|
1146
|
+
if (typeof module.id === "string" || typeof module.id === "number") {
|
1147
|
+
if (typeof module.id === "number") {
|
1148
|
+
if (module.id < 1000 && maxModuleId >= 1000) colors.normal(" ");
|
1149
|
+
if (module.id < 100 && maxModuleId >= 100) colors.normal(" ");
|
1150
|
+
if (module.id < 10 && maxModuleId >= 10) colors.normal(" ");
|
1151
|
+
} else {
|
1152
|
+
if (maxModuleId >= 1000) colors.normal(" ");
|
1153
|
+
if (maxModuleId >= 100) colors.normal(" ");
|
1154
|
+
if (maxModuleId >= 10) colors.normal(" ");
|
1155
|
+
}
|
1156
|
+
if (name !== module.id) {
|
1157
|
+
colors.normal("[");
|
1158
|
+
colors.normal(module.id);
|
1159
|
+
colors.normal("]");
|
1160
|
+
colors.normal(" ");
|
1161
|
+
} else {
|
1162
|
+
colors.normal("[");
|
1163
|
+
colors.bold(module.id);
|
1164
|
+
colors.normal("]");
|
1165
|
+
}
|
1166
|
+
}
|
1167
|
+
if (name !== module.id) {
|
1168
|
+
colors.bold(name);
|
1169
|
+
}
|
1170
|
+
processModuleAttributes(module);
|
1171
|
+
newline();
|
1172
|
+
processModuleContent(module, contentPrefix);
|
1173
|
+
}
|
1174
|
+
if (obj.filteredModules > 0) {
|
1175
|
+
colors.normal(prefix);
|
1176
|
+
colors.normal(" ");
|
1177
|
+
if (obj.modules.length > 0) colors.normal(" + ");
|
1178
|
+
colors.normal(obj.filteredModules);
|
1179
|
+
if (obj.modules.length > 0) colors.normal(" hidden");
|
1180
|
+
colors.normal(obj.filteredModules !== 1 ? " modules" : " module");
|
1181
|
+
newline();
|
1182
|
+
}
|
1183
|
+
}
|
1184
|
+
};
|
1185
|
+
|
1186
|
+
if (obj.chunks) {
|
1187
|
+
for (const chunk of obj.chunks) {
|
1188
|
+
colors.normal("chunk ");
|
1189
|
+
if (chunk.id < 1000) colors.normal(" ");
|
1190
|
+
if (chunk.id < 100) colors.normal(" ");
|
1191
|
+
if (chunk.id < 10) colors.normal(" ");
|
1192
|
+
colors.normal("{");
|
1193
|
+
colors.yellow(chunk.id);
|
1194
|
+
colors.normal("} ");
|
1195
|
+
colors.green(chunk.files.join(", "));
|
1196
|
+
if (chunk.names && chunk.names.length > 0) {
|
1197
|
+
colors.normal(" (");
|
1198
|
+
colors.normal(chunk.names.join(", "));
|
1199
|
+
colors.normal(")");
|
1200
|
+
}
|
1201
|
+
colors.normal(" ");
|
1202
|
+
colors.normal(SizeFormatHelpers.formatSize(chunk.size));
|
1203
|
+
for (const id of chunk.parents) {
|
1204
|
+
colors.normal(" <{");
|
1205
|
+
colors.yellow(id);
|
1206
|
+
colors.normal("}>");
|
1207
|
+
}
|
1208
|
+
for (const id of chunk.siblings) {
|
1209
|
+
colors.normal(" ={");
|
1210
|
+
colors.yellow(id);
|
1211
|
+
colors.normal("}=");
|
1212
|
+
}
|
1213
|
+
for (const id of chunk.children) {
|
1214
|
+
colors.normal(" >{");
|
1215
|
+
colors.yellow(id);
|
1216
|
+
colors.normal("}<");
|
1217
|
+
}
|
1218
|
+
if (chunk.childrenByOrder) {
|
1219
|
+
for (const name of Object.keys(chunk.childrenByOrder)) {
|
1220
|
+
const children = chunk.childrenByOrder[name];
|
1221
|
+
colors.normal(" ");
|
1222
|
+
colors.magenta(`(${name}:`);
|
1223
|
+
for (const id of children) {
|
1224
|
+
colors.normal(" {");
|
1225
|
+
colors.yellow(id);
|
1226
|
+
colors.normal("}");
|
1227
|
+
}
|
1228
|
+
colors.magenta(")");
|
1229
|
+
}
|
1230
|
+
}
|
1231
|
+
if (chunk.entry) {
|
1232
|
+
colors.yellow(" [entry]");
|
1233
|
+
} else if (chunk.initial) {
|
1234
|
+
colors.yellow(" [initial]");
|
1235
|
+
}
|
1236
|
+
if (chunk.rendered) {
|
1237
|
+
colors.green(" [rendered]");
|
1238
|
+
}
|
1239
|
+
if (chunk.recorded) {
|
1240
|
+
colors.green(" [recorded]");
|
1241
|
+
}
|
1242
|
+
if (chunk.reason) {
|
1243
|
+
colors.yellow(` ${chunk.reason}`);
|
1244
|
+
}
|
1245
|
+
newline();
|
1246
|
+
if (chunk.origins) {
|
1247
|
+
for (const origin of chunk.origins) {
|
1248
|
+
colors.normal(" > ");
|
1249
|
+
if (origin.reasons && origin.reasons.length) {
|
1250
|
+
colors.yellow(origin.reasons.join(" "));
|
1251
|
+
colors.normal(" ");
|
1252
|
+
}
|
1253
|
+
if (origin.request) {
|
1254
|
+
colors.normal(origin.request);
|
1255
|
+
colors.normal(" ");
|
1256
|
+
}
|
1257
|
+
if (origin.module) {
|
1258
|
+
colors.normal("[");
|
1259
|
+
colors.normal(origin.moduleId);
|
1260
|
+
colors.normal("] ");
|
1261
|
+
const module = modulesByIdentifier[`$${origin.module}`];
|
1262
|
+
if (module) {
|
1263
|
+
colors.bold(module.name);
|
1264
|
+
colors.normal(" ");
|
1265
|
+
}
|
1266
|
+
}
|
1267
|
+
if (origin.loc) {
|
1268
|
+
colors.normal(origin.loc);
|
1269
|
+
}
|
1270
|
+
newline();
|
1271
|
+
}
|
1272
|
+
}
|
1273
|
+
processModulesList(chunk, " ");
|
1274
|
+
}
|
1275
|
+
}
|
1276
|
+
|
1277
|
+
processModulesList(obj, "");
|
1278
|
+
|
1279
|
+
if (obj._showWarnings && obj.warnings) {
|
1280
|
+
for (const warning of obj.warnings) {
|
1281
|
+
newline();
|
1282
|
+
colors.yellow(`WARNING in ${warning}`);
|
1283
|
+
newline();
|
1284
|
+
}
|
1285
|
+
}
|
1286
|
+
if (obj._showErrors && obj.errors) {
|
1287
|
+
for (const error of obj.errors) {
|
1288
|
+
newline();
|
1289
|
+
colors.red(`ERROR in ${error}`);
|
1290
|
+
newline();
|
1291
|
+
}
|
1292
|
+
}
|
1293
|
+
if (obj.children) {
|
1294
|
+
for (const child of obj.children) {
|
1295
|
+
const childString = Stats.jsonToString(child, useColors);
|
1296
|
+
if (childString) {
|
1297
|
+
if (child.name) {
|
1298
|
+
colors.normal("Child ");
|
1299
|
+
colors.bold(child.name);
|
1300
|
+
colors.normal(":");
|
1301
|
+
} else {
|
1302
|
+
colors.normal("Child");
|
1303
|
+
}
|
1304
|
+
newline();
|
1305
|
+
buf.push(" ");
|
1306
|
+
buf.push(childString.replace(/\n/g, "\n "));
|
1307
|
+
newline();
|
1308
|
+
}
|
1309
|
+
}
|
1310
|
+
}
|
1311
|
+
if (obj.needAdditionalPass) {
|
1312
|
+
colors.yellow(
|
1313
|
+
"Compilation needs an additional pass and will compile again."
|
1314
|
+
);
|
1315
|
+
}
|
1316
|
+
|
1317
|
+
while (buf[buf.length - 1] === "\n") {
|
1318
|
+
buf.pop();
|
1319
|
+
}
|
1320
|
+
return buf.join("");
|
1321
|
+
}
|
1322
|
+
|
1323
|
+
static presetToOptions(name) {
|
1324
|
+
// Accepted values: none, errors-only, minimal, normal, detailed, verbose
|
1325
|
+
// Any other falsy value will behave as 'none', truthy values as 'normal'
|
1326
|
+
const pn =
|
1327
|
+
(typeof name === "string" && name.toLowerCase()) || name || "none";
|
1328
|
+
switch (pn) {
|
1329
|
+
case "none":
|
1330
|
+
return {
|
1331
|
+
all: false
|
1332
|
+
};
|
1333
|
+
case "verbose":
|
1334
|
+
return {
|
1335
|
+
entrypoints: true,
|
1336
|
+
chunkGroups: true,
|
1337
|
+
modules: false,
|
1338
|
+
chunks: true,
|
1339
|
+
chunkModules: true,
|
1340
|
+
chunkOrigins: true,
|
1341
|
+
depth: true,
|
1342
|
+
env: true,
|
1343
|
+
reasons: true,
|
1344
|
+
usedExports: true,
|
1345
|
+
providedExports: true,
|
1346
|
+
optimizationBailout: true,
|
1347
|
+
errorDetails: true,
|
1348
|
+
publicPath: true,
|
1349
|
+
exclude: false,
|
1350
|
+
maxModules: Infinity
|
1351
|
+
};
|
1352
|
+
case "detailed":
|
1353
|
+
return {
|
1354
|
+
entrypoints: true,
|
1355
|
+
chunkGroups: true,
|
1356
|
+
chunks: true,
|
1357
|
+
chunkModules: false,
|
1358
|
+
chunkOrigins: true,
|
1359
|
+
depth: true,
|
1360
|
+
usedExports: true,
|
1361
|
+
providedExports: true,
|
1362
|
+
optimizationBailout: true,
|
1363
|
+
errorDetails: true,
|
1364
|
+
publicPath: true,
|
1365
|
+
exclude: false,
|
1366
|
+
maxModules: Infinity
|
1367
|
+
};
|
1368
|
+
case "minimal":
|
1369
|
+
return {
|
1370
|
+
all: false,
|
1371
|
+
modules: true,
|
1372
|
+
maxModules: 0,
|
1373
|
+
errors: true,
|
1374
|
+
warnings: true
|
1375
|
+
};
|
1376
|
+
case "errors-only":
|
1377
|
+
return {
|
1378
|
+
all: false,
|
1379
|
+
errors: true,
|
1380
|
+
moduleTrace: true
|
1381
|
+
};
|
1382
|
+
default:
|
1383
|
+
return {};
|
1384
|
+
}
|
1385
|
+
}
|
1386
|
+
|
1387
|
+
static getChildOptions(options, idx) {
|
1388
|
+
let innerOptions;
|
1389
|
+
if (Array.isArray(options.children)) {
|
1390
|
+
if (idx < options.children.length) {
|
1391
|
+
innerOptions = options.children[idx];
|
1392
|
+
}
|
1393
|
+
} else if (typeof options.children === "object" && options.children) {
|
1394
|
+
innerOptions = options.children;
|
1395
|
+
}
|
1396
|
+
if (typeof innerOptions === "boolean" || typeof innerOptions === "string") {
|
1397
|
+
innerOptions = Stats.presetToOptions(innerOptions);
|
1398
|
+
}
|
1399
|
+
if (!innerOptions) {
|
1400
|
+
return options;
|
1401
|
+
}
|
1402
|
+
const childOptions = Object.assign({}, options);
|
1403
|
+
delete childOptions.children; // do not inherit children
|
1404
|
+
return Object.assign(childOptions, innerOptions);
|
1405
|
+
}
|
1406
|
+
}
|
1407
|
+
|
1408
|
+
module.exports = Stats;
|