webpack 1.13.3 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -22
- package/README.md +310 -310
- package/buildin/amd-define.js +1 -1
- package/buildin/amd-options.js +1 -1
- package/buildin/module.js +10 -10
- package/hot/dev-server.js +63 -63
- package/hot/log-apply-result.js +25 -25
- package/hot/only-dev-server.js +77 -77
- package/hot/poll.js +37 -37
- package/hot/signal.js +65 -65
- package/lib/APIPlugin.js +49 -49
- package/lib/AbstractPlugin.js +22 -22
- package/lib/AmdMainTemplatePlugin.js +43 -43
- package/lib/ArrayMap.js +50 -50
- package/lib/AsyncDependenciesBlock.js +39 -39
- package/lib/AutomaticPrefetchPlugin.js +35 -35
- package/lib/BannerPlugin.js +34 -34
- package/lib/BasicEvaluatedExpression.js +140 -140
- package/lib/CachePlugin.js +43 -43
- package/lib/CaseSensitiveModulesWarning.js +16 -16
- package/lib/Chunk.js +252 -252
- package/lib/ChunkRenderError.js +17 -17
- package/lib/ChunkTemplate.js +37 -37
- package/lib/CompatibilityPlugin.js +42 -42
- package/lib/Compilation.js +891 -891
- package/lib/Compiler.js +407 -407
- package/lib/ConcatSource.js +5 -5
- package/lib/ConstPlugin.js +54 -54
- package/lib/ContextModule.js +130 -130
- package/lib/ContextModuleFactory.js +132 -132
- package/lib/ContextReplacementPlugin.js +93 -93
- package/lib/CriticalDependenciesWarning.js +24 -24
- package/lib/DefinePlugin.js +126 -126
- package/lib/DelegatedModule.js +69 -69
- package/lib/DelegatedModuleFactoryPlugin.js +51 -51
- package/lib/DelegatedPlugin.js +21 -21
- package/lib/DependenciesBlock.js +57 -57
- package/lib/DependenciesBlockVariable.js +41 -41
- package/lib/Dependency.js +54 -54
- package/lib/DllEntryPlugin.js +32 -32
- package/lib/DllModule.js +55 -55
- package/lib/DllModuleFactory.js +18 -18
- package/lib/DllPlugin.js +30 -30
- package/lib/DllReferencePlugin.js +26 -26
- package/lib/EntryModuleNotFoundError.js +15 -15
- package/lib/EntryOptionPlugin.js +28 -28
- package/lib/EnvironmentPlugin.js +28 -28
- package/lib/EvalDevToolModulePlugin.js +17 -17
- package/lib/EvalDevToolModuleTemplatePlugin.js +29 -29
- package/lib/EvalSourceMapDevToolModuleTemplatePlugin.js +68 -68
- package/lib/EvalSourceMapDevToolPlugin.js +25 -25
- package/lib/ExtendedAPIPlugin.js +45 -45
- package/lib/ExternalModule.js +89 -89
- package/lib/ExternalModuleFactoryPlugin.js +86 -86
- package/lib/ExternalsPlugin.js +16 -16
- package/lib/FunctionModulePlugin.js +18 -18
- package/lib/FunctionModuleTemplatePlugin.js +39 -39
- package/lib/HotModuleReplacement.runtime.js +486 -486
- package/lib/HotModuleReplacementPlugin.js +223 -223
- package/lib/HotUpdateChunkTemplate.js +28 -28
- package/lib/IgnorePlugin.js +32 -32
- package/lib/JsonpChunkTemplatePlugin.js +26 -26
- package/lib/JsonpExportMainTemplatePlugin.js +28 -28
- package/lib/JsonpHotUpdateChunkTemplatePlugin.js +26 -26
- package/lib/JsonpMainTemplate.runtime.js +56 -56
- package/lib/JsonpMainTemplatePlugin.js +162 -162
- package/lib/JsonpTemplatePlugin.js +17 -17
- package/lib/LibManifestPlugin.js +49 -49
- package/lib/LibraryTemplatePlugin.js +77 -77
- package/lib/LoaderTargetPlugin.js +16 -16
- package/lib/MainTemplate.js +169 -169
- package/lib/MemoryOutputFileSystem.js +5 -5
- package/lib/Module.js +116 -116
- package/lib/ModuleFilenameHelpers.js +157 -157
- package/lib/ModuleNotFoundError.js +17 -17
- package/lib/ModuleParseError.js +26 -26
- package/lib/ModuleParserHelpers.js +21 -21
- package/lib/ModuleReason.js +9 -9
- package/lib/ModuleTemplate.js +23 -23
- package/lib/MovedToPluginWarningPlugin.js +17 -17
- package/lib/MultiCompiler.js +166 -166
- package/lib/MultiEntryPlugin.js +31 -31
- package/lib/MultiModule.js +71 -71
- package/lib/MultiModuleFactory.js +18 -18
- package/lib/NamedModulesPlugin.js +21 -21
- package/lib/NewWatchingPlugin.js +12 -12
- package/lib/NoErrorsPlugin.js +18 -18
- package/lib/NodeStuffPlugin.js +99 -99
- package/lib/NormalModule.js +322 -322
- package/lib/NormalModuleFactory.js +171 -171
- package/lib/NormalModuleReplacementPlugin.js +40 -40
- package/lib/NullFactory.js +10 -10
- package/lib/OldWatchingPlugin.js +14 -14
- package/lib/OptionsApply.js +10 -10
- package/lib/OriginalSource.js +5 -5
- package/lib/Parser.js +938 -938
- package/lib/PrefetchPlugin.js +25 -25
- package/lib/ProgressPlugin.js +80 -80
- package/lib/ProvidePlugin.js +48 -48
- package/lib/RawModule.js +65 -65
- package/lib/RawSource.js +5 -5
- package/lib/RecordIdsPlugin.js +130 -130
- package/lib/RequestShortener.js +56 -56
- package/lib/RequireJsStuffPlugin.js +38 -38
- package/lib/ResolverPlugin.js +34 -34
- package/lib/SetVarMainTemplatePlugin.js +36 -36
- package/lib/SingleEntryPlugin.js +24 -24
- package/lib/Source.js +5 -5
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +33 -33
- package/lib/SourceMapDevToolPlugin.js +168 -168
- package/lib/SourceMapSource.js +5 -5
- package/lib/Stats.js +732 -732
- package/lib/Template.js +119 -119
- package/lib/TemplatedPathPlugin.js +111 -111
- package/lib/UmdMainTemplatePlugin.js +146 -146
- package/lib/UnsupportedFeatureWarning.js +14 -14
- package/lib/WarnCaseSensitiveModulesPlugin.js +27 -27
- package/lib/WatchIgnorePlugin.js +45 -45
- package/lib/WebpackOptionsApply.js +376 -376
- package/lib/WebpackOptionsDefaulter.js +112 -112
- package/lib/dependencies/AMDDefineDependency.js +63 -63
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +240 -240
- package/lib/dependencies/AMDPlugin.js +115 -115
- package/lib/dependencies/AMDRequireArrayDependency.js +34 -34
- package/lib/dependencies/AMDRequireContextDependency.js +18 -18
- package/lib/dependencies/AMDRequireDependenciesBlock.js +25 -25
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +145 -145
- package/lib/dependencies/AMDRequireDependency.js +64 -64
- package/lib/dependencies/AMDRequireItemDependency.js +17 -17
- package/lib/dependencies/CommonJsPlugin.js +93 -93
- package/lib/dependencies/CommonJsRequireContextDependency.js +18 -18
- package/lib/dependencies/CommonJsRequireDependency.js +17 -17
- package/lib/dependencies/CommonJsRequireDependencyParserPlugin.js +91 -91
- package/lib/dependencies/ConstDependency.js +29 -29
- package/lib/dependencies/ContextDependency.js +24 -24
- package/lib/dependencies/ContextDependencyHelpers.js +34 -34
- package/lib/dependencies/ContextDependencyTemplateAsId.js +22 -22
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +31 -31
- package/lib/dependencies/ContextElementDependency.js +17 -17
- package/lib/dependencies/DelegatedSourceDependency.js +14 -14
- package/lib/dependencies/DepBlockHelpers.js +41 -41
- package/lib/dependencies/DllEntryDependency.js +17 -17
- package/lib/dependencies/LabeledExportsDependency.js +21 -21
- package/lib/dependencies/LabeledModuleDependency.js +36 -36
- package/lib/dependencies/LabeledModuleDependencyParserPlugin.js +76 -76
- package/lib/dependencies/LabeledModulesPlugin.js +26 -26
- package/lib/dependencies/LoaderDependency.js +14 -14
- package/lib/dependencies/LoaderPlugin.js +61 -61
- package/lib/dependencies/LocalModule.js +19 -19
- package/lib/dependencies/LocalModuleDependency.js +23 -23
- package/lib/dependencies/LocalModulesHelpers.js +43 -43
- package/lib/dependencies/ModuleDependency.js +20 -20
- package/lib/dependencies/ModuleDependencyTemplateAsId.js +22 -22
- package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +22 -22
- package/lib/dependencies/ModuleHotAcceptDependency.js +18 -18
- package/lib/dependencies/ModuleHotDeclineDependency.js +18 -18
- package/lib/dependencies/MultiEntryDependency.js +16 -16
- package/lib/dependencies/NullDependency.js +17 -17
- package/lib/dependencies/NullDependencyTemplate.js +8 -8
- package/lib/dependencies/PrefetchDependency.js +14 -14
- package/lib/dependencies/RequireContextDependency.js +17 -17
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +33 -33
- package/lib/dependencies/RequireContextPlugin.js +64 -64
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +20 -20
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +66 -66
- package/lib/dependencies/RequireEnsureDependency.js +29 -29
- package/lib/dependencies/RequireEnsureItemDependency.js +16 -16
- package/lib/dependencies/RequireEnsurePlugin.js +38 -38
- package/lib/dependencies/RequireHeaderDependency.js +25 -25
- package/lib/dependencies/RequireIncludeDependency.js +25 -25
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +18 -18
- package/lib/dependencies/RequireIncludePlugin.js +31 -31
- package/lib/dependencies/RequireResolveContextDependency.js +18 -18
- package/lib/dependencies/RequireResolveDependency.js +17 -17
- package/lib/dependencies/RequireResolveDependencyParserPlugin.js +69 -69
- package/lib/dependencies/RequireResolveHeaderDependency.js +25 -25
- package/lib/dependencies/SingleEntryDependency.js +14 -14
- package/lib/dependencies/TemplateArgumentDependency.js +26 -26
- package/lib/dependencies/WebpackMissingModule.js +23 -23
- package/lib/dependencies/getFunctionExpression.js +43 -43
- package/lib/node/NodeChunkTemplatePlugin.js +22 -22
- package/lib/node/NodeEnvironmentPlugin.js +25 -25
- package/lib/node/NodeHotUpdateChunkTemplatePlugin.js +24 -24
- package/lib/node/NodeMainTemplate.runtime.js +20 -20
- package/lib/node/NodeMainTemplateAsync.runtime.js +34 -34
- package/lib/node/NodeMainTemplatePlugin.js +164 -164
- package/lib/node/NodeOutputFileSystem.js +17 -17
- package/lib/node/NodeSourcePlugin.js +85 -75
- package/lib/node/NodeTargetPlugin.js +12 -12
- package/lib/node/NodeTemplatePlugin.js +21 -21
- package/lib/node/NodeWatchFileSystem.js +65 -65
- package/lib/node/OldNodeWatchFileSystem.js +265 -265
- package/lib/optimize/AggressiveMergingPlugin.js +115 -115
- package/lib/optimize/CommonsChunkPlugin.js +178 -178
- package/lib/optimize/DedupePlugin.js +227 -227
- package/lib/optimize/FlagIncludedChunksPlugin.js +24 -24
- package/lib/optimize/LimitChunkCountPlugin.js +55 -55
- package/lib/optimize/MergeDuplicateChunksPlugin.js +30 -30
- package/lib/optimize/MinChunkSizePlugin.js +61 -61
- package/lib/optimize/OccurenceOrderPlugin.js +5 -5
- package/lib/optimize/OccurrenceOrderPlugin.js +91 -91
- package/lib/optimize/RemoveEmptyChunksPlugin.js +19 -19
- package/lib/optimize/RemoveParentModulesPlugin.js +50 -50
- package/lib/optimize/UglifyJsPlugin.js +146 -146
- package/lib/removeAndDo.js +13 -13
- package/lib/web/WebEnvironmentPlugin.js +16 -16
- package/lib/webpack.js +113 -113
- package/lib/webpack.web.js +27 -27
- package/lib/webworker/WebWorkerChunkTemplatePlugin.js +26 -26
- package/lib/webworker/WebWorkerMainTemplatePlugin.js +78 -78
- package/lib/webworker/WebWorkerTemplatePlugin.js +15 -15
- package/package.json +4 -4
package/lib/Stats.js
CHANGED
@@ -1,732 +1,732 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
var RequestShortener = require("./RequestShortener");
|
6
|
-
|
7
|
-
function Stats(compilation) {
|
8
|
-
this.compilation = compilation;
|
9
|
-
this.hash = compilation.hash;
|
10
|
-
}
|
11
|
-
module.exports = Stats;
|
12
|
-
|
13
|
-
Stats.prototype.hasWarnings = function() {
|
14
|
-
return this.compilation.warnings.length > 0;
|
15
|
-
};
|
16
|
-
|
17
|
-
Stats.prototype.hasErrors = function() {
|
18
|
-
return this.compilation.errors.length > 0;
|
19
|
-
};
|
20
|
-
|
21
|
-
Stats.prototype.toJson = function toJson(options, forToString) {
|
22
|
-
if(typeof options === "boolean" || typeof options === "string") {
|
23
|
-
options = Stats.presetToOptions(options);
|
24
|
-
} else if(!options) {
|
25
|
-
options = {};
|
26
|
-
}
|
27
|
-
|
28
|
-
function d(v, def) {
|
29
|
-
return v === undefined ? def : v;
|
30
|
-
}
|
31
|
-
var compilation = this.compilation;
|
32
|
-
var requestShortener = new RequestShortener(d(options.context, process.cwd()));
|
33
|
-
var showHash = d(options.hash, true);
|
34
|
-
var showVersion = d(options.version, true);
|
35
|
-
var showTimings = d(options.timings, true);
|
36
|
-
var showAssets = d(options.assets, true);
|
37
|
-
var showChunks = d(options.chunks, true);
|
38
|
-
var showChunkModules = d(options.chunkModules, !!forToString);
|
39
|
-
var showChunkOrigins = d(options.chunkOrigins, !forToString);
|
40
|
-
var showModules = d(options.modules, !forToString);
|
41
|
-
var showCachedModules = d(options.cached, true);
|
42
|
-
var showCachedAssets = d(options.cachedAssets, true);
|
43
|
-
var showReasons = d(options.reasons, !forToString);
|
44
|
-
var showChildren = d(options.children, true);
|
45
|
-
var showSource = d(options.source, !forToString);
|
46
|
-
var showErrors = d(options.errors, true);
|
47
|
-
var showErrorDetails = d(options.errorDetails, !forToString);
|
48
|
-
var showWarnings = d(options.warnings, true);
|
49
|
-
var showPublicPath = d(options.publicPath, !forToString);
|
50
|
-
var excludeModules = [].concat(d(options.exclude, [])).map(function(str) {
|
51
|
-
if(typeof str !== "string") return str;
|
52
|
-
return new RegExp("[\\\\/]" + str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&") + "([\\\\/]|$|!|\\?)");
|
53
|
-
});
|
54
|
-
var sortModules = d(options.modulesSort, "id");
|
55
|
-
var sortChunks = d(options.chunksSort, "id");
|
56
|
-
var sortAssets = d(options.assetsSort, "");
|
57
|
-
|
58
|
-
function moduleFilter(module) {
|
59
|
-
if(!showCachedModules && !module.built) {
|
60
|
-
return false;
|
61
|
-
}
|
62
|
-
if(excludeModules.length === 0)
|
63
|
-
return true;
|
64
|
-
var ident = module.identifier();
|
65
|
-
return !excludeModules.some(function(regExp) {
|
66
|
-
return regExp.test(ident);
|
67
|
-
});
|
68
|
-
}
|
69
|
-
|
70
|
-
function sortByField(field) {
|
71
|
-
if(!field) return function() {
|
72
|
-
return 0;
|
73
|
-
};
|
74
|
-
if(field[0] === "!") {
|
75
|
-
field = field.substr(1);
|
76
|
-
return function(a, b) {
|
77
|
-
if(a[field] === b[field]) return 0;
|
78
|
-
return a[field] < b[field] ? 1 : -1;
|
79
|
-
};
|
80
|
-
}
|
81
|
-
return function(a, b) {
|
82
|
-
if(a[field] === b[field]) return 0;
|
83
|
-
return a[field] < b[field] ? -1 : 1;
|
84
|
-
};
|
85
|
-
}
|
86
|
-
|
87
|
-
function formatError(e) {
|
88
|
-
var text = "";
|
89
|
-
if(typeof e === "string")
|
90
|
-
e = {
|
91
|
-
message: e
|
92
|
-
};
|
93
|
-
if(e.chunk) {
|
94
|
-
text += "chunk " + (e.chunk.name || e.chunk.id) +
|
95
|
-
(e.chunk.entry ? " [entry]" : e.chunk.initial ? " [initial]" : "") + "\n";
|
96
|
-
}
|
97
|
-
if(e.file) {
|
98
|
-
text += e.file + "\n";
|
99
|
-
}
|
100
|
-
if(e.module && e.module.readableIdentifier && typeof e.module.readableIdentifier === "function") {
|
101
|
-
text += e.module.readableIdentifier(requestShortener) + "\n";
|
102
|
-
}
|
103
|
-
text += e.message;
|
104
|
-
if(showErrorDetails && e.details) text += "\n" + e.details;
|
105
|
-
if(showErrorDetails && e.missing) text += e.missing.map(function(item) {
|
106
|
-
return "\n[" + item + "]";
|
107
|
-
}).join("");
|
108
|
-
if(e.dependencies && e.origin) {
|
109
|
-
text += "\n @ " + e.origin.readableIdentifier(requestShortener);
|
110
|
-
e.dependencies.forEach(function(dep) {
|
111
|
-
if(!dep.loc) return;
|
112
|
-
if(typeof dep.loc === "string") return;
|
113
|
-
if(!dep.loc.start) return;
|
114
|
-
if(!dep.loc.end) return;
|
115
|
-
text += " " + dep.loc.start.line + ":" + dep.loc.start.column + "-" +
|
116
|
-
(dep.loc.start.line !== dep.loc.end.line ? dep.loc.end.line + ":" : "") + dep.loc.end.column;
|
117
|
-
});
|
118
|
-
}
|
119
|
-
return text;
|
120
|
-
}
|
121
|
-
|
122
|
-
var obj = {
|
123
|
-
errors: compilation.errors.map(formatError),
|
124
|
-
warnings: compilation.warnings.map(formatError)
|
125
|
-
};
|
126
|
-
|
127
|
-
//We just hint other renderers since actually omitting
|
128
|
-
//errors/warnings from the JSON would be kind of weird.
|
129
|
-
Object.defineProperty(obj, "_showWarnings", {
|
130
|
-
value: showWarnings,
|
131
|
-
enumerable: false
|
132
|
-
});
|
133
|
-
Object.defineProperty(obj, "_showErrors", {
|
134
|
-
value: showErrors,
|
135
|
-
enumerable: false
|
136
|
-
});
|
137
|
-
|
138
|
-
if(showVersion) {
|
139
|
-
obj.version = require("../package.json").version;
|
140
|
-
}
|
141
|
-
|
142
|
-
if(showHash) obj.hash = this.hash;
|
143
|
-
if(showTimings && this.startTime && this.endTime) {
|
144
|
-
obj.time = this.endTime - this.startTime;
|
145
|
-
}
|
146
|
-
if(showPublicPath) {
|
147
|
-
obj.publicPath = this.compilation.mainTemplate.getPublicPath({
|
148
|
-
hash: this.compilation.hash
|
149
|
-
});
|
150
|
-
}
|
151
|
-
if(showAssets) {
|
152
|
-
var assetsByFile = {};
|
153
|
-
obj.assetsByChunkName = {};
|
154
|
-
obj.assets = Object.keys(compilation.assets).map(function(asset) {
|
155
|
-
var obj = {
|
156
|
-
name: asset,
|
157
|
-
size: compilation.assets[asset].size(),
|
158
|
-
chunks: [],
|
159
|
-
chunkNames: [],
|
160
|
-
emitted: compilation.assets[asset].emitted
|
161
|
-
};
|
162
|
-
assetsByFile[asset] = obj;
|
163
|
-
return obj;
|
164
|
-
}).filter(function(asset) {
|
165
|
-
return showCachedAssets || asset.emitted;
|
166
|
-
});
|
167
|
-
compilation.chunks.forEach(function(chunk) {
|
168
|
-
chunk.files.forEach(function(asset) {
|
169
|
-
if(assetsByFile[asset]) {
|
170
|
-
chunk.ids.forEach(function(id) {
|
171
|
-
assetsByFile[asset].chunks.push(id);
|
172
|
-
});
|
173
|
-
if(chunk.name) {
|
174
|
-
assetsByFile[asset].chunkNames.push(chunk.name);
|
175
|
-
if(obj.assetsByChunkName[chunk.name])
|
176
|
-
obj.assetsByChunkName[chunk.name] = [].concat(obj.assetsByChunkName[chunk.name]).concat([asset]);
|
177
|
-
else
|
178
|
-
obj.assetsByChunkName[chunk.name] = asset;
|
179
|
-
}
|
180
|
-
}
|
181
|
-
});
|
182
|
-
});
|
183
|
-
obj.assets.sort(sortByField(sortAssets));
|
184
|
-
}
|
185
|
-
|
186
|
-
function fnModule(module) {
|
187
|
-
var obj = {
|
188
|
-
id: module.id,
|
189
|
-
identifier: module.identifier(),
|
190
|
-
name: module.readableIdentifier(requestShortener),
|
191
|
-
index: module.index,
|
192
|
-
index2: module.index2,
|
193
|
-
size: module.size(),
|
194
|
-
cacheable: !!module.cacheable,
|
195
|
-
built: !!module.built,
|
196
|
-
optional: !!module.optional,
|
197
|
-
prefetched: !!module.prefetched,
|
198
|
-
chunks: module.chunks.map(function(chunk) {
|
199
|
-
return chunk.id;
|
200
|
-
}),
|
201
|
-
assets: Object.keys(module.assets || {}),
|
202
|
-
issuer: module.issuer,
|
203
|
-
profile: module.profile,
|
204
|
-
failed: !!module.error,
|
205
|
-
errors: module.errors && module.dependenciesErrors && (module.errors.length + module.dependenciesErrors.length),
|
206
|
-
warnings: module.errors && module.dependenciesErrors && (module.warnings.length + module.dependenciesWarnings.length)
|
207
|
-
};
|
208
|
-
if(showReasons) {
|
209
|
-
obj.reasons = module.reasons.filter(function(reason) {
|
210
|
-
return reason.dependency && reason.module;
|
211
|
-
}).map(function(reason) {
|
212
|
-
var obj = {
|
213
|
-
moduleId: reason.module.id,
|
214
|
-
moduleIdentifier: reason.module.identifier(),
|
215
|
-
module: reason.module.readableIdentifier(requestShortener),
|
216
|
-
moduleName: reason.module.readableIdentifier(requestShortener),
|
217
|
-
type: reason.dependency.type,
|
218
|
-
userRequest: reason.dependency.userRequest
|
219
|
-
};
|
220
|
-
var dep = reason.dependency;
|
221
|
-
if(dep.templateModules) obj.templateModules = dep.templateModules.map(function(module) {
|
222
|
-
return module.id;
|
223
|
-
});
|
224
|
-
if(typeof dep.loc === "object") obj.loc = dep.loc.start.line + ":" + dep.loc.start.column + "-" +
|
225
|
-
(dep.loc.start.line !== dep.loc.end.line ? dep.loc.end.line + ":" : "") + dep.loc.end.column;
|
226
|
-
return obj;
|
227
|
-
}).sort(function(a, b) {
|
228
|
-
return a.moduleId - b.moduleId;
|
229
|
-
});
|
230
|
-
}
|
231
|
-
if(showSource && module._source) {
|
232
|
-
obj.source = module._source.source();
|
233
|
-
}
|
234
|
-
return obj;
|
235
|
-
}
|
236
|
-
if(showChunks) {
|
237
|
-
obj.chunks = compilation.chunks.map(function(chunk) {
|
238
|
-
var obj = {
|
239
|
-
id: chunk.id,
|
240
|
-
rendered: chunk.rendered,
|
241
|
-
initial: !!chunk.initial,
|
242
|
-
entry: !!chunk.entry,
|
243
|
-
extraAsync: !!chunk.extraAsync,
|
244
|
-
size: chunk.modules.reduce(function(size, module) {
|
245
|
-
return size + module.size();
|
246
|
-
}, 0),
|
247
|
-
names: chunk.name ? [chunk.name] : [],
|
248
|
-
files: chunk.files.slice(),
|
249
|
-
hash: chunk.renderedHash,
|
250
|
-
parents: chunk.parents.map(function(c) {
|
251
|
-
return c.id;
|
252
|
-
})
|
253
|
-
};
|
254
|
-
if(showChunkModules) {
|
255
|
-
obj.modules = chunk.modules.filter(moduleFilter).map(fnModule);
|
256
|
-
obj.filteredModules = chunk.modules.length - obj.modules.length;
|
257
|
-
obj.modules.sort(sortByField(sortModules));
|
258
|
-
}
|
259
|
-
if(showChunkOrigins) {
|
260
|
-
obj.origins = chunk.origins.map(function(origin) {
|
261
|
-
return {
|
262
|
-
moduleId: origin.module ? origin.module.id : undefined,
|
263
|
-
module: origin.module ? origin.module.identifier() : "",
|
264
|
-
moduleIdentifier: origin.module ? origin.module.identifier() : "",
|
265
|
-
moduleName: origin.module ? origin.module.readableIdentifier(requestShortener) : "",
|
266
|
-
loc: typeof origin.loc === "object" ? obj.loc = origin.loc.start.line + ":" + origin.loc.start.column + "-" +
|
267
|
-
(origin.loc.start.line !== origin.loc.end.line ? origin.loc.end.line + ":" : "") + origin.loc.end.column : "",
|
268
|
-
name: origin.name,
|
269
|
-
reasons: origin.reasons || []
|
270
|
-
};
|
271
|
-
});
|
272
|
-
}
|
273
|
-
return obj;
|
274
|
-
});
|
275
|
-
obj.chunks.sort(sortByField(sortChunks));
|
276
|
-
}
|
277
|
-
if(showModules) {
|
278
|
-
obj.modules = compilation.modules.filter(moduleFilter).map(fnModule);
|
279
|
-
obj.filteredModules = compilation.modules.length - obj.modules.length;
|
280
|
-
obj.modules.sort(sortByField(sortModules));
|
281
|
-
}
|
282
|
-
if(showChildren) {
|
283
|
-
obj.children = compilation.children.map(function(child) {
|
284
|
-
var obj = new Stats(child).toJson(options, forToString);
|
285
|
-
delete obj.hash;
|
286
|
-
delete obj.version;
|
287
|
-
obj.name = child.name;
|
288
|
-
return obj;
|
289
|
-
});
|
290
|
-
}
|
291
|
-
return obj;
|
292
|
-
};
|
293
|
-
|
294
|
-
Stats.prototype.toString = function toString(options) {
|
295
|
-
if(typeof options === "boolean" || typeof options === "string") {
|
296
|
-
options = Stats.presetToOptions(options);
|
297
|
-
} else if(!options) options = {};
|
298
|
-
|
299
|
-
function d(v, def) {
|
300
|
-
return v === undefined ? def : v;
|
301
|
-
}
|
302
|
-
var useColors = d(options.colors, false);
|
303
|
-
|
304
|
-
var obj = this.toJson(options, true);
|
305
|
-
|
306
|
-
return Stats.jsonToString(obj, useColors);
|
307
|
-
};
|
308
|
-
|
309
|
-
Stats.jsonToString = function jsonToString(obj, useColors) {
|
310
|
-
var buf = [];
|
311
|
-
|
312
|
-
function normal(str) {
|
313
|
-
buf.push(str);
|
314
|
-
}
|
315
|
-
|
316
|
-
function bold(str) {
|
317
|
-
if(useColors) buf.push("\u001b[1m");
|
318
|
-
buf.push(str);
|
319
|
-
if(useColors) buf.push("\u001b[22m");
|
320
|
-
}
|
321
|
-
|
322
|
-
function yellow(str) {
|
323
|
-
if(useColors) buf.push("\u001b[1m\u001b[33m");
|
324
|
-
buf.push(str);
|
325
|
-
if(useColors) buf.push("\u001b[39m\u001b[22m");
|
326
|
-
}
|
327
|
-
|
328
|
-
function red(str) {
|
329
|
-
if(useColors) buf.push("\u001b[1m\u001b[31m");
|
330
|
-
buf.push(str);
|
331
|
-
if(useColors) buf.push("\u001b[39m\u001b[22m");
|
332
|
-
}
|
333
|
-
|
334
|
-
function green(str) {
|
335
|
-
if(useColors) buf.push("\u001b[1m\u001b[32m");
|
336
|
-
buf.push(str);
|
337
|
-
if(useColors) buf.push("\u001b[39m\u001b[22m");
|
338
|
-
}
|
339
|
-
|
340
|
-
function cyan(str) {
|
341
|
-
if(useColors) buf.push("\u001b[1m\u001b[36m");
|
342
|
-
buf.push(str);
|
343
|
-
if(useColors) buf.push("\u001b[39m\u001b[22m");
|
344
|
-
}
|
345
|
-
|
346
|
-
function magenta(str) {
|
347
|
-
if(useColors) buf.push("\u001b[1m\u001b[35m");
|
348
|
-
buf.push(str);
|
349
|
-
if(useColors) buf.push("\u001b[39m\u001b[22m");
|
350
|
-
}
|
351
|
-
|
352
|
-
function coloredTime(time) {
|
353
|
-
var times = [800, 400, 200, 100];
|
354
|
-
if(obj.time) {
|
355
|
-
times = [obj.time / 2, obj.time / 4, obj.time / 8, obj.time / 16];
|
356
|
-
}
|
357
|
-
if(time < times[3])
|
358
|
-
normal(time + "ms");
|
359
|
-
else if(time < times[2])
|
360
|
-
bold(time + "ms");
|
361
|
-
else if(time < times[1])
|
362
|
-
green(time + "ms");
|
363
|
-
else if(time < times[0])
|
364
|
-
yellow(time + "ms");
|
365
|
-
else
|
366
|
-
red(time + "ms");
|
367
|
-
}
|
368
|
-
|
369
|
-
function newline() {
|
370
|
-
buf.push("\n");
|
371
|
-
}
|
372
|
-
|
373
|
-
function table(array, formats, align, splitter) {
|
374
|
-
var rows = array.length;
|
375
|
-
var cols = array[0].length;
|
376
|
-
var colSizes = new Array(cols);
|
377
|
-
for(var col = 0; col < cols; col++)
|
378
|
-
colSizes[col] = 3;
|
379
|
-
for(var row = 0; row < rows; row++) {
|
380
|
-
for(var col = 0; col < cols; col++) {
|
381
|
-
var value = array[row][col] + "";
|
382
|
-
if(value.length > colSizes[col]) {
|
383
|
-
colSizes[col] = value.length;
|
384
|
-
}
|
385
|
-
}
|
386
|
-
}
|
387
|
-
for(var row = 0; row < rows; row++) {
|
388
|
-
for(var col = 0; col < cols; col++) {
|
389
|
-
var format = row === 0 ? bold : formats[col];
|
390
|
-
var value = array[row][col] + "";
|
391
|
-
var l = value.length;
|
392
|
-
if(align[col] === "l")
|
393
|
-
format(value);
|
394
|
-
for(; l < colSizes[col] && col !== cols - 1; l++)
|
395
|
-
normal(" ");
|
396
|
-
if(align[col] === "r")
|
397
|
-
format(value);
|
398
|
-
if(col + 1 < cols)
|
399
|
-
normal(splitter || " ");
|
400
|
-
}
|
401
|
-
newline();
|
402
|
-
}
|
403
|
-
}
|
404
|
-
|
405
|
-
function formatSize(size) {
|
406
|
-
if(size <= 0) return "0 bytes";
|
407
|
-
|
408
|
-
var abbreviations = ["bytes", "kB", "MB", "GB"];
|
409
|
-
var index = Math.floor(Math.log(size) / Math.log(1000));
|
410
|
-
|
411
|
-
return +(size / Math.pow(1000, index))
|
412
|
-
.toPrecision(3) + " " + abbreviations[index];
|
413
|
-
}
|
414
|
-
|
415
|
-
if(obj.hash) {
|
416
|
-
normal("Hash: ");
|
417
|
-
bold(obj.hash);
|
418
|
-
newline();
|
419
|
-
}
|
420
|
-
if(obj.version) {
|
421
|
-
normal("Version: webpack ");
|
422
|
-
bold(obj.version);
|
423
|
-
newline();
|
424
|
-
}
|
425
|
-
if(typeof obj.time === "number") {
|
426
|
-
normal("Time: ");
|
427
|
-
bold(obj.time);
|
428
|
-
normal("ms");
|
429
|
-
newline();
|
430
|
-
}
|
431
|
-
if(obj.publicPath) {
|
432
|
-
normal("PublicPath: ");
|
433
|
-
bold(obj.publicPath);
|
434
|
-
newline();
|
435
|
-
}
|
436
|
-
if(obj.assets && obj.assets.length > 0) {
|
437
|
-
var t = [
|
438
|
-
["Asset", "Size", "Chunks", "", "Chunk Names"]
|
439
|
-
];
|
440
|
-
obj.assets.forEach(function(asset) {
|
441
|
-
t.push([
|
442
|
-
asset.name,
|
443
|
-
formatSize(asset.size),
|
444
|
-
asset.chunks.join(", "),
|
445
|
-
asset.emitted ? "[emitted]" : "",
|
446
|
-
asset.chunkNames.join(", ")
|
447
|
-
]);
|
448
|
-
});
|
449
|
-
table(t, [green, normal, bold, green, normal], "rrrll");
|
450
|
-
}
|
451
|
-
var modulesByIdentifier = {};
|
452
|
-
if(obj.modules) {
|
453
|
-
obj.modules.forEach(function(module) {
|
454
|
-
modulesByIdentifier["$" + module.identifier] = module;
|
455
|
-
});
|
456
|
-
} else if(obj.chunks) {
|
457
|
-
obj.chunks.forEach(function(chunk) {
|
458
|
-
if(chunk.modules) {
|
459
|
-
chunk.modules.forEach(function(module) {
|
460
|
-
modulesByIdentifier["$" + module.identifier] = module;
|
461
|
-
});
|
462
|
-
}
|
463
|
-
});
|
464
|
-
}
|
465
|
-
|
466
|
-
function processProfile(module) {
|
467
|
-
if(module.profile) {
|
468
|
-
normal(" ");
|
469
|
-
var sum = 0,
|
470
|
-
allowSum = true;
|
471
|
-
var path = [];
|
472
|
-
var current = module;
|
473
|
-
while(current.issuer) {
|
474
|
-
if(!modulesByIdentifier["$" + current.issuer]) {
|
475
|
-
normal(" ... ->");
|
476
|
-
allowSum = false;
|
477
|
-
break;
|
478
|
-
}
|
479
|
-
path.unshift(current = modulesByIdentifier["$" + current.issuer]);
|
480
|
-
}
|
481
|
-
path.forEach(function(module) {
|
482
|
-
normal(" [");
|
483
|
-
normal(module.id);
|
484
|
-
normal("] ");
|
485
|
-
if(module.profile) {
|
486
|
-
var time = (module.profile.factory || 0) + (module.profile.building || 0);
|
487
|
-
coloredTime(time);
|
488
|
-
sum += time;
|
489
|
-
normal(" ");
|
490
|
-
}
|
491
|
-
normal("->");
|
492
|
-
});
|
493
|
-
Object.keys(module.profile).forEach(function(key) {
|
494
|
-
normal(" " + key + ":");
|
495
|
-
var time = module.profile[key];
|
496
|
-
coloredTime(time);
|
497
|
-
sum += time;
|
498
|
-
});
|
499
|
-
if(allowSum) {
|
500
|
-
normal(" = ");
|
501
|
-
coloredTime(sum);
|
502
|
-
}
|
503
|
-
newline();
|
504
|
-
}
|
505
|
-
}
|
506
|
-
|
507
|
-
function processModuleAttributes(module) {
|
508
|
-
normal(" ");
|
509
|
-
normal(formatSize(module.size));
|
510
|
-
if(module.chunks) {
|
511
|
-
module.chunks.forEach(function(chunk) {
|
512
|
-
normal(" {");
|
513
|
-
yellow(chunk);
|
514
|
-
normal("}");
|
515
|
-
});
|
516
|
-
}
|
517
|
-
if(!module.cacheable) {
|
518
|
-
red(" [not cacheable]");
|
519
|
-
}
|
520
|
-
if(module.optional) {
|
521
|
-
yellow(" [optional]");
|
522
|
-
}
|
523
|
-
if(module.built) {
|
524
|
-
green(" [built]");
|
525
|
-
}
|
526
|
-
if(module.prefetched) {
|
527
|
-
magenta(" [prefetched]");
|
528
|
-
}
|
529
|
-
if(module.failed)
|
530
|
-
red(" [failed]");
|
531
|
-
if(module.warnings)
|
532
|
-
yellow(" [" + module.warnings + " warning" + (module.warnings === 1 ? "" : "s") + "]");
|
533
|
-
if(module.errors)
|
534
|
-
red(" [" + module.errors + " error" + (module.errors === 1 ? "" : "s") + "]");
|
535
|
-
}
|
536
|
-
if(obj.chunks) {
|
537
|
-
obj.chunks.forEach(function(chunk) {
|
538
|
-
normal("chunk ");
|
539
|
-
if(chunk.id < 1000) normal(" ");
|
540
|
-
if(chunk.id < 100) normal(" ");
|
541
|
-
if(chunk.id < 10) normal(" ");
|
542
|
-
normal("{");
|
543
|
-
yellow(chunk.id);
|
544
|
-
normal("} ");
|
545
|
-
green(chunk.files.join(", "));
|
546
|
-
if(chunk.names && chunk.names.length > 0) {
|
547
|
-
normal(" (");
|
548
|
-
normal(chunk.names.join(", "));
|
549
|
-
normal(")");
|
550
|
-
}
|
551
|
-
normal(" ");
|
552
|
-
normal(formatSize(chunk.size));
|
553
|
-
chunk.parents.forEach(function(id) {
|
554
|
-
normal(" {");
|
555
|
-
yellow(id);
|
556
|
-
normal("}");
|
557
|
-
});
|
558
|
-
if(chunk.rendered) {
|
559
|
-
green(" [rendered]");
|
560
|
-
}
|
561
|
-
newline();
|
562
|
-
if(chunk.origins) {
|
563
|
-
chunk.origins.forEach(function(origin) {
|
564
|
-
normal(" > ");
|
565
|
-
if(origin.reasons && origin.reasons.length) {
|
566
|
-
yellow(origin.reasons.join(" "));
|
567
|
-
normal(" ");
|
568
|
-
}
|
569
|
-
if(origin.name) {
|
570
|
-
normal(origin.name);
|
571
|
-
normal(" ");
|
572
|
-
}
|
573
|
-
if(origin.module) {
|
574
|
-
normal("[");
|
575
|
-
normal(origin.moduleId);
|
576
|
-
normal("] ");
|
577
|
-
var module = modulesByIdentifier["$" + origin.module];
|
578
|
-
if(module) {
|
579
|
-
bold(module.name);
|
580
|
-
normal(" ");
|
581
|
-
}
|
582
|
-
if(origin.loc) {
|
583
|
-
normal(origin.loc);
|
584
|
-
}
|
585
|
-
}
|
586
|
-
newline();
|
587
|
-
});
|
588
|
-
}
|
589
|
-
if(chunk.modules) {
|
590
|
-
chunk.modules.forEach(function(module) {
|
591
|
-
normal(" ");
|
592
|
-
if(module.id < 1000) normal(" ");
|
593
|
-
if(module.id < 100) normal(" ");
|
594
|
-
if(module.id < 10) normal(" ");
|
595
|
-
normal("[");
|
596
|
-
normal(module.id);
|
597
|
-
normal("] ");
|
598
|
-
bold(module.name);
|
599
|
-
processModuleAttributes(module);
|
600
|
-
newline();
|
601
|
-
if(module.reasons) {
|
602
|
-
module.reasons.forEach(function(reason) {
|
603
|
-
normal(" ");
|
604
|
-
normal(reason.type);
|
605
|
-
normal(" ");
|
606
|
-
cyan(reason.userRequest);
|
607
|
-
if(reason.templateModules) cyan(reason.templateModules.join(" "));
|
608
|
-
normal(" [");
|
609
|
-
normal(reason.moduleId);
|
610
|
-
normal("] ");
|
611
|
-
magenta(reason.module);
|
612
|
-
if(reason.loc) {
|
613
|
-
normal(" ");
|
614
|
-
normal(reason.loc);
|
615
|
-
}
|
616
|
-
newline();
|
617
|
-
});
|
618
|
-
}
|
619
|
-
processProfile(module);
|
620
|
-
});
|
621
|
-
if(chunk.filteredModules > 0) {
|
622
|
-
normal(" + " + chunk.filteredModules + " hidden modules");
|
623
|
-
newline();
|
624
|
-
}
|
625
|
-
}
|
626
|
-
});
|
627
|
-
}
|
628
|
-
if(obj.modules) {
|
629
|
-
obj.modules.forEach(function(module) {
|
630
|
-
if(module.id < 1000) normal(" ");
|
631
|
-
if(module.id < 100) normal(" ");
|
632
|
-
if(module.id < 10) normal(" ");
|
633
|
-
normal("[");
|
634
|
-
normal(module.id);
|
635
|
-
normal("] ");
|
636
|
-
bold(module.name || module.identifier);
|
637
|
-
processModuleAttributes(module);
|
638
|
-
newline();
|
639
|
-
if(module.reasons) {
|
640
|
-
module.reasons.forEach(function(reason) {
|
641
|
-
normal(" ");
|
642
|
-
normal(reason.type);
|
643
|
-
normal(" ");
|
644
|
-
cyan(reason.userRequest);
|
645
|
-
if(reason.templateModules) cyan(reason.templateModules.join(" "));
|
646
|
-
normal(" [");
|
647
|
-
normal(reason.moduleId);
|
648
|
-
normal("] ");
|
649
|
-
magenta(reason.module);
|
650
|
-
if(reason.loc) {
|
651
|
-
normal(" ");
|
652
|
-
normal(reason.loc);
|
653
|
-
}
|
654
|
-
newline();
|
655
|
-
});
|
656
|
-
}
|
657
|
-
processProfile(module);
|
658
|
-
});
|
659
|
-
if(obj.filteredModules > 0) {
|
660
|
-
normal(" + " + obj.filteredModules + " hidden modules");
|
661
|
-
newline();
|
662
|
-
}
|
663
|
-
}
|
664
|
-
if(obj._showWarnings && obj.warnings) {
|
665
|
-
obj.warnings.forEach(function(warning) {
|
666
|
-
newline();
|
667
|
-
yellow("WARNING in " + warning);
|
668
|
-
newline();
|
669
|
-
});
|
670
|
-
}
|
671
|
-
if(obj._showErrors && obj.errors) {
|
672
|
-
obj.errors.forEach(function(error) {
|
673
|
-
newline();
|
674
|
-
red("ERROR in " + error);
|
675
|
-
newline();
|
676
|
-
});
|
677
|
-
}
|
678
|
-
if(obj.children) {
|
679
|
-
obj.children.forEach(function(child) {
|
680
|
-
if(child.name) {
|
681
|
-
normal("Child ");
|
682
|
-
bold(child.name);
|
683
|
-
normal(":");
|
684
|
-
} else {
|
685
|
-
normal("Child");
|
686
|
-
}
|
687
|
-
newline();
|
688
|
-
buf.push(" ");
|
689
|
-
buf.push(Stats.jsonToString(child, useColors).replace(/\n/g, "\n "));
|
690
|
-
newline();
|
691
|
-
});
|
692
|
-
}
|
693
|
-
|
694
|
-
while(buf[buf.length - 1] === "\n") buf.pop();
|
695
|
-
return buf.join("");
|
696
|
-
};
|
697
|
-
|
698
|
-
Stats.presetToOptions = function(name) {
|
699
|
-
//Accepted values: none, errors-only, minimal, normal, verbose
|
700
|
-
//Any other falsy value will behave as 'none', truthy values as 'normal'
|
701
|
-
var pn = (typeof name === "string") && name.toLowerCase() || name;
|
702
|
-
if(pn === "none" || !pn) {
|
703
|
-
return {
|
704
|
-
hash: false,
|
705
|
-
version: false,
|
706
|
-
timings: false,
|
707
|
-
assets: false,
|
708
|
-
chunks: false,
|
709
|
-
modules: false,
|
710
|
-
reasons: false,
|
711
|
-
children: false,
|
712
|
-
source: false,
|
713
|
-
errors: false,
|
714
|
-
errorDetails: false,
|
715
|
-
warnings: false,
|
716
|
-
publicPath: false
|
717
|
-
};
|
718
|
-
} else {
|
719
|
-
return {
|
720
|
-
assets: pn === "verbose",
|
721
|
-
version: pn === "verbose",
|
722
|
-
timings: pn !== "errors-only" && pn !== "minimal",
|
723
|
-
hash: pn !== "errors-only" && pn !== "minimal",
|
724
|
-
chunks: pn !== "errors-only",
|
725
|
-
chunkModules: pn === "verbose",
|
726
|
-
//warnings: pn !== "errors-only",
|
727
|
-
errorDetails: pn !== "errors-only" && pn !== "minimal",
|
728
|
-
reasons: pn === "verbose",
|
729
|
-
colors: true
|
730
|
-
};
|
731
|
-
}
|
732
|
-
};
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
var RequestShortener = require("./RequestShortener");
|
6
|
+
|
7
|
+
function Stats(compilation) {
|
8
|
+
this.compilation = compilation;
|
9
|
+
this.hash = compilation.hash;
|
10
|
+
}
|
11
|
+
module.exports = Stats;
|
12
|
+
|
13
|
+
Stats.prototype.hasWarnings = function() {
|
14
|
+
return this.compilation.warnings.length > 0;
|
15
|
+
};
|
16
|
+
|
17
|
+
Stats.prototype.hasErrors = function() {
|
18
|
+
return this.compilation.errors.length > 0;
|
19
|
+
};
|
20
|
+
|
21
|
+
Stats.prototype.toJson = function toJson(options, forToString) {
|
22
|
+
if(typeof options === "boolean" || typeof options === "string") {
|
23
|
+
options = Stats.presetToOptions(options);
|
24
|
+
} else if(!options) {
|
25
|
+
options = {};
|
26
|
+
}
|
27
|
+
|
28
|
+
function d(v, def) {
|
29
|
+
return v === undefined ? def : v;
|
30
|
+
}
|
31
|
+
var compilation = this.compilation;
|
32
|
+
var requestShortener = new RequestShortener(d(options.context, process.cwd()));
|
33
|
+
var showHash = d(options.hash, true);
|
34
|
+
var showVersion = d(options.version, true);
|
35
|
+
var showTimings = d(options.timings, true);
|
36
|
+
var showAssets = d(options.assets, true);
|
37
|
+
var showChunks = d(options.chunks, true);
|
38
|
+
var showChunkModules = d(options.chunkModules, !!forToString);
|
39
|
+
var showChunkOrigins = d(options.chunkOrigins, !forToString);
|
40
|
+
var showModules = d(options.modules, !forToString);
|
41
|
+
var showCachedModules = d(options.cached, true);
|
42
|
+
var showCachedAssets = d(options.cachedAssets, true);
|
43
|
+
var showReasons = d(options.reasons, !forToString);
|
44
|
+
var showChildren = d(options.children, true);
|
45
|
+
var showSource = d(options.source, !forToString);
|
46
|
+
var showErrors = d(options.errors, true);
|
47
|
+
var showErrorDetails = d(options.errorDetails, !forToString);
|
48
|
+
var showWarnings = d(options.warnings, true);
|
49
|
+
var showPublicPath = d(options.publicPath, !forToString);
|
50
|
+
var excludeModules = [].concat(d(options.exclude, [])).map(function(str) {
|
51
|
+
if(typeof str !== "string") return str;
|
52
|
+
return new RegExp("[\\\\/]" + str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&") + "([\\\\/]|$|!|\\?)");
|
53
|
+
});
|
54
|
+
var sortModules = d(options.modulesSort, "id");
|
55
|
+
var sortChunks = d(options.chunksSort, "id");
|
56
|
+
var sortAssets = d(options.assetsSort, "");
|
57
|
+
|
58
|
+
function moduleFilter(module) {
|
59
|
+
if(!showCachedModules && !module.built) {
|
60
|
+
return false;
|
61
|
+
}
|
62
|
+
if(excludeModules.length === 0)
|
63
|
+
return true;
|
64
|
+
var ident = module.identifier();
|
65
|
+
return !excludeModules.some(function(regExp) {
|
66
|
+
return regExp.test(ident);
|
67
|
+
});
|
68
|
+
}
|
69
|
+
|
70
|
+
function sortByField(field) {
|
71
|
+
if(!field) return function() {
|
72
|
+
return 0;
|
73
|
+
};
|
74
|
+
if(field[0] === "!") {
|
75
|
+
field = field.substr(1);
|
76
|
+
return function(a, b) {
|
77
|
+
if(a[field] === b[field]) return 0;
|
78
|
+
return a[field] < b[field] ? 1 : -1;
|
79
|
+
};
|
80
|
+
}
|
81
|
+
return function(a, b) {
|
82
|
+
if(a[field] === b[field]) return 0;
|
83
|
+
return a[field] < b[field] ? -1 : 1;
|
84
|
+
};
|
85
|
+
}
|
86
|
+
|
87
|
+
function formatError(e) {
|
88
|
+
var text = "";
|
89
|
+
if(typeof e === "string")
|
90
|
+
e = {
|
91
|
+
message: e
|
92
|
+
};
|
93
|
+
if(e.chunk) {
|
94
|
+
text += "chunk " + (e.chunk.name || e.chunk.id) +
|
95
|
+
(e.chunk.entry ? " [entry]" : e.chunk.initial ? " [initial]" : "") + "\n";
|
96
|
+
}
|
97
|
+
if(e.file) {
|
98
|
+
text += e.file + "\n";
|
99
|
+
}
|
100
|
+
if(e.module && e.module.readableIdentifier && typeof e.module.readableIdentifier === "function") {
|
101
|
+
text += e.module.readableIdentifier(requestShortener) + "\n";
|
102
|
+
}
|
103
|
+
text += e.message;
|
104
|
+
if(showErrorDetails && e.details) text += "\n" + e.details;
|
105
|
+
if(showErrorDetails && e.missing) text += e.missing.map(function(item) {
|
106
|
+
return "\n[" + item + "]";
|
107
|
+
}).join("");
|
108
|
+
if(e.dependencies && e.origin) {
|
109
|
+
text += "\n @ " + e.origin.readableIdentifier(requestShortener);
|
110
|
+
e.dependencies.forEach(function(dep) {
|
111
|
+
if(!dep.loc) return;
|
112
|
+
if(typeof dep.loc === "string") return;
|
113
|
+
if(!dep.loc.start) return;
|
114
|
+
if(!dep.loc.end) return;
|
115
|
+
text += " " + dep.loc.start.line + ":" + dep.loc.start.column + "-" +
|
116
|
+
(dep.loc.start.line !== dep.loc.end.line ? dep.loc.end.line + ":" : "") + dep.loc.end.column;
|
117
|
+
});
|
118
|
+
}
|
119
|
+
return text;
|
120
|
+
}
|
121
|
+
|
122
|
+
var obj = {
|
123
|
+
errors: compilation.errors.map(formatError),
|
124
|
+
warnings: compilation.warnings.map(formatError)
|
125
|
+
};
|
126
|
+
|
127
|
+
//We just hint other renderers since actually omitting
|
128
|
+
//errors/warnings from the JSON would be kind of weird.
|
129
|
+
Object.defineProperty(obj, "_showWarnings", {
|
130
|
+
value: showWarnings,
|
131
|
+
enumerable: false
|
132
|
+
});
|
133
|
+
Object.defineProperty(obj, "_showErrors", {
|
134
|
+
value: showErrors,
|
135
|
+
enumerable: false
|
136
|
+
});
|
137
|
+
|
138
|
+
if(showVersion) {
|
139
|
+
obj.version = require("../package.json").version;
|
140
|
+
}
|
141
|
+
|
142
|
+
if(showHash) obj.hash = this.hash;
|
143
|
+
if(showTimings && this.startTime && this.endTime) {
|
144
|
+
obj.time = this.endTime - this.startTime;
|
145
|
+
}
|
146
|
+
if(showPublicPath) {
|
147
|
+
obj.publicPath = this.compilation.mainTemplate.getPublicPath({
|
148
|
+
hash: this.compilation.hash
|
149
|
+
});
|
150
|
+
}
|
151
|
+
if(showAssets) {
|
152
|
+
var assetsByFile = {};
|
153
|
+
obj.assetsByChunkName = {};
|
154
|
+
obj.assets = Object.keys(compilation.assets).map(function(asset) {
|
155
|
+
var obj = {
|
156
|
+
name: asset,
|
157
|
+
size: compilation.assets[asset].size(),
|
158
|
+
chunks: [],
|
159
|
+
chunkNames: [],
|
160
|
+
emitted: compilation.assets[asset].emitted
|
161
|
+
};
|
162
|
+
assetsByFile[asset] = obj;
|
163
|
+
return obj;
|
164
|
+
}).filter(function(asset) {
|
165
|
+
return showCachedAssets || asset.emitted;
|
166
|
+
});
|
167
|
+
compilation.chunks.forEach(function(chunk) {
|
168
|
+
chunk.files.forEach(function(asset) {
|
169
|
+
if(assetsByFile[asset]) {
|
170
|
+
chunk.ids.forEach(function(id) {
|
171
|
+
assetsByFile[asset].chunks.push(id);
|
172
|
+
});
|
173
|
+
if(chunk.name) {
|
174
|
+
assetsByFile[asset].chunkNames.push(chunk.name);
|
175
|
+
if(obj.assetsByChunkName[chunk.name])
|
176
|
+
obj.assetsByChunkName[chunk.name] = [].concat(obj.assetsByChunkName[chunk.name]).concat([asset]);
|
177
|
+
else
|
178
|
+
obj.assetsByChunkName[chunk.name] = asset;
|
179
|
+
}
|
180
|
+
}
|
181
|
+
});
|
182
|
+
});
|
183
|
+
obj.assets.sort(sortByField(sortAssets));
|
184
|
+
}
|
185
|
+
|
186
|
+
function fnModule(module) {
|
187
|
+
var obj = {
|
188
|
+
id: module.id,
|
189
|
+
identifier: module.identifier(),
|
190
|
+
name: module.readableIdentifier(requestShortener),
|
191
|
+
index: module.index,
|
192
|
+
index2: module.index2,
|
193
|
+
size: module.size(),
|
194
|
+
cacheable: !!module.cacheable,
|
195
|
+
built: !!module.built,
|
196
|
+
optional: !!module.optional,
|
197
|
+
prefetched: !!module.prefetched,
|
198
|
+
chunks: module.chunks.map(function(chunk) {
|
199
|
+
return chunk.id;
|
200
|
+
}),
|
201
|
+
assets: Object.keys(module.assets || {}),
|
202
|
+
issuer: module.issuer,
|
203
|
+
profile: module.profile,
|
204
|
+
failed: !!module.error,
|
205
|
+
errors: module.errors && module.dependenciesErrors && (module.errors.length + module.dependenciesErrors.length),
|
206
|
+
warnings: module.errors && module.dependenciesErrors && (module.warnings.length + module.dependenciesWarnings.length)
|
207
|
+
};
|
208
|
+
if(showReasons) {
|
209
|
+
obj.reasons = module.reasons.filter(function(reason) {
|
210
|
+
return reason.dependency && reason.module;
|
211
|
+
}).map(function(reason) {
|
212
|
+
var obj = {
|
213
|
+
moduleId: reason.module.id,
|
214
|
+
moduleIdentifier: reason.module.identifier(),
|
215
|
+
module: reason.module.readableIdentifier(requestShortener),
|
216
|
+
moduleName: reason.module.readableIdentifier(requestShortener),
|
217
|
+
type: reason.dependency.type,
|
218
|
+
userRequest: reason.dependency.userRequest
|
219
|
+
};
|
220
|
+
var dep = reason.dependency;
|
221
|
+
if(dep.templateModules) obj.templateModules = dep.templateModules.map(function(module) {
|
222
|
+
return module.id;
|
223
|
+
});
|
224
|
+
if(typeof dep.loc === "object") obj.loc = dep.loc.start.line + ":" + dep.loc.start.column + "-" +
|
225
|
+
(dep.loc.start.line !== dep.loc.end.line ? dep.loc.end.line + ":" : "") + dep.loc.end.column;
|
226
|
+
return obj;
|
227
|
+
}).sort(function(a, b) {
|
228
|
+
return a.moduleId - b.moduleId;
|
229
|
+
});
|
230
|
+
}
|
231
|
+
if(showSource && module._source) {
|
232
|
+
obj.source = module._source.source();
|
233
|
+
}
|
234
|
+
return obj;
|
235
|
+
}
|
236
|
+
if(showChunks) {
|
237
|
+
obj.chunks = compilation.chunks.map(function(chunk) {
|
238
|
+
var obj = {
|
239
|
+
id: chunk.id,
|
240
|
+
rendered: chunk.rendered,
|
241
|
+
initial: !!chunk.initial,
|
242
|
+
entry: !!chunk.entry,
|
243
|
+
extraAsync: !!chunk.extraAsync,
|
244
|
+
size: chunk.modules.reduce(function(size, module) {
|
245
|
+
return size + module.size();
|
246
|
+
}, 0),
|
247
|
+
names: chunk.name ? [chunk.name] : [],
|
248
|
+
files: chunk.files.slice(),
|
249
|
+
hash: chunk.renderedHash,
|
250
|
+
parents: chunk.parents.map(function(c) {
|
251
|
+
return c.id;
|
252
|
+
})
|
253
|
+
};
|
254
|
+
if(showChunkModules) {
|
255
|
+
obj.modules = chunk.modules.filter(moduleFilter).map(fnModule);
|
256
|
+
obj.filteredModules = chunk.modules.length - obj.modules.length;
|
257
|
+
obj.modules.sort(sortByField(sortModules));
|
258
|
+
}
|
259
|
+
if(showChunkOrigins) {
|
260
|
+
obj.origins = chunk.origins.map(function(origin) {
|
261
|
+
return {
|
262
|
+
moduleId: origin.module ? origin.module.id : undefined,
|
263
|
+
module: origin.module ? origin.module.identifier() : "",
|
264
|
+
moduleIdentifier: origin.module ? origin.module.identifier() : "",
|
265
|
+
moduleName: origin.module ? origin.module.readableIdentifier(requestShortener) : "",
|
266
|
+
loc: typeof origin.loc === "object" ? obj.loc = origin.loc.start.line + ":" + origin.loc.start.column + "-" +
|
267
|
+
(origin.loc.start.line !== origin.loc.end.line ? origin.loc.end.line + ":" : "") + origin.loc.end.column : "",
|
268
|
+
name: origin.name,
|
269
|
+
reasons: origin.reasons || []
|
270
|
+
};
|
271
|
+
});
|
272
|
+
}
|
273
|
+
return obj;
|
274
|
+
});
|
275
|
+
obj.chunks.sort(sortByField(sortChunks));
|
276
|
+
}
|
277
|
+
if(showModules) {
|
278
|
+
obj.modules = compilation.modules.filter(moduleFilter).map(fnModule);
|
279
|
+
obj.filteredModules = compilation.modules.length - obj.modules.length;
|
280
|
+
obj.modules.sort(sortByField(sortModules));
|
281
|
+
}
|
282
|
+
if(showChildren) {
|
283
|
+
obj.children = compilation.children.map(function(child) {
|
284
|
+
var obj = new Stats(child).toJson(options, forToString);
|
285
|
+
delete obj.hash;
|
286
|
+
delete obj.version;
|
287
|
+
obj.name = child.name;
|
288
|
+
return obj;
|
289
|
+
});
|
290
|
+
}
|
291
|
+
return obj;
|
292
|
+
};
|
293
|
+
|
294
|
+
Stats.prototype.toString = function toString(options) {
|
295
|
+
if(typeof options === "boolean" || typeof options === "string") {
|
296
|
+
options = Stats.presetToOptions(options);
|
297
|
+
} else if(!options) options = {};
|
298
|
+
|
299
|
+
function d(v, def) {
|
300
|
+
return v === undefined ? def : v;
|
301
|
+
}
|
302
|
+
var useColors = d(options.colors, false);
|
303
|
+
|
304
|
+
var obj = this.toJson(options, true);
|
305
|
+
|
306
|
+
return Stats.jsonToString(obj, useColors);
|
307
|
+
};
|
308
|
+
|
309
|
+
Stats.jsonToString = function jsonToString(obj, useColors) {
|
310
|
+
var buf = [];
|
311
|
+
|
312
|
+
function normal(str) {
|
313
|
+
buf.push(str);
|
314
|
+
}
|
315
|
+
|
316
|
+
function bold(str) {
|
317
|
+
if(useColors) buf.push("\u001b[1m");
|
318
|
+
buf.push(str);
|
319
|
+
if(useColors) buf.push("\u001b[22m");
|
320
|
+
}
|
321
|
+
|
322
|
+
function yellow(str) {
|
323
|
+
if(useColors) buf.push("\u001b[1m\u001b[33m");
|
324
|
+
buf.push(str);
|
325
|
+
if(useColors) buf.push("\u001b[39m\u001b[22m");
|
326
|
+
}
|
327
|
+
|
328
|
+
function red(str) {
|
329
|
+
if(useColors) buf.push("\u001b[1m\u001b[31m");
|
330
|
+
buf.push(str);
|
331
|
+
if(useColors) buf.push("\u001b[39m\u001b[22m");
|
332
|
+
}
|
333
|
+
|
334
|
+
function green(str) {
|
335
|
+
if(useColors) buf.push("\u001b[1m\u001b[32m");
|
336
|
+
buf.push(str);
|
337
|
+
if(useColors) buf.push("\u001b[39m\u001b[22m");
|
338
|
+
}
|
339
|
+
|
340
|
+
function cyan(str) {
|
341
|
+
if(useColors) buf.push("\u001b[1m\u001b[36m");
|
342
|
+
buf.push(str);
|
343
|
+
if(useColors) buf.push("\u001b[39m\u001b[22m");
|
344
|
+
}
|
345
|
+
|
346
|
+
function magenta(str) {
|
347
|
+
if(useColors) buf.push("\u001b[1m\u001b[35m");
|
348
|
+
buf.push(str);
|
349
|
+
if(useColors) buf.push("\u001b[39m\u001b[22m");
|
350
|
+
}
|
351
|
+
|
352
|
+
function coloredTime(time) {
|
353
|
+
var times = [800, 400, 200, 100];
|
354
|
+
if(obj.time) {
|
355
|
+
times = [obj.time / 2, obj.time / 4, obj.time / 8, obj.time / 16];
|
356
|
+
}
|
357
|
+
if(time < times[3])
|
358
|
+
normal(time + "ms");
|
359
|
+
else if(time < times[2])
|
360
|
+
bold(time + "ms");
|
361
|
+
else if(time < times[1])
|
362
|
+
green(time + "ms");
|
363
|
+
else if(time < times[0])
|
364
|
+
yellow(time + "ms");
|
365
|
+
else
|
366
|
+
red(time + "ms");
|
367
|
+
}
|
368
|
+
|
369
|
+
function newline() {
|
370
|
+
buf.push("\n");
|
371
|
+
}
|
372
|
+
|
373
|
+
function table(array, formats, align, splitter) {
|
374
|
+
var rows = array.length;
|
375
|
+
var cols = array[0].length;
|
376
|
+
var colSizes = new Array(cols);
|
377
|
+
for(var col = 0; col < cols; col++)
|
378
|
+
colSizes[col] = 3;
|
379
|
+
for(var row = 0; row < rows; row++) {
|
380
|
+
for(var col = 0; col < cols; col++) {
|
381
|
+
var value = array[row][col] + "";
|
382
|
+
if(value.length > colSizes[col]) {
|
383
|
+
colSizes[col] = value.length;
|
384
|
+
}
|
385
|
+
}
|
386
|
+
}
|
387
|
+
for(var row = 0; row < rows; row++) {
|
388
|
+
for(var col = 0; col < cols; col++) {
|
389
|
+
var format = row === 0 ? bold : formats[col];
|
390
|
+
var value = array[row][col] + "";
|
391
|
+
var l = value.length;
|
392
|
+
if(align[col] === "l")
|
393
|
+
format(value);
|
394
|
+
for(; l < colSizes[col] && col !== cols - 1; l++)
|
395
|
+
normal(" ");
|
396
|
+
if(align[col] === "r")
|
397
|
+
format(value);
|
398
|
+
if(col + 1 < cols)
|
399
|
+
normal(splitter || " ");
|
400
|
+
}
|
401
|
+
newline();
|
402
|
+
}
|
403
|
+
}
|
404
|
+
|
405
|
+
function formatSize(size) {
|
406
|
+
if(size <= 0) return "0 bytes";
|
407
|
+
|
408
|
+
var abbreviations = ["bytes", "kB", "MB", "GB"];
|
409
|
+
var index = Math.floor(Math.log(size) / Math.log(1000));
|
410
|
+
|
411
|
+
return +(size / Math.pow(1000, index))
|
412
|
+
.toPrecision(3) + " " + abbreviations[index];
|
413
|
+
}
|
414
|
+
|
415
|
+
if(obj.hash) {
|
416
|
+
normal("Hash: ");
|
417
|
+
bold(obj.hash);
|
418
|
+
newline();
|
419
|
+
}
|
420
|
+
if(obj.version) {
|
421
|
+
normal("Version: webpack ");
|
422
|
+
bold(obj.version);
|
423
|
+
newline();
|
424
|
+
}
|
425
|
+
if(typeof obj.time === "number") {
|
426
|
+
normal("Time: ");
|
427
|
+
bold(obj.time);
|
428
|
+
normal("ms");
|
429
|
+
newline();
|
430
|
+
}
|
431
|
+
if(obj.publicPath) {
|
432
|
+
normal("PublicPath: ");
|
433
|
+
bold(obj.publicPath);
|
434
|
+
newline();
|
435
|
+
}
|
436
|
+
if(obj.assets && obj.assets.length > 0) {
|
437
|
+
var t = [
|
438
|
+
["Asset", "Size", "Chunks", "", "Chunk Names"]
|
439
|
+
];
|
440
|
+
obj.assets.forEach(function(asset) {
|
441
|
+
t.push([
|
442
|
+
asset.name,
|
443
|
+
formatSize(asset.size),
|
444
|
+
asset.chunks.join(", "),
|
445
|
+
asset.emitted ? "[emitted]" : "",
|
446
|
+
asset.chunkNames.join(", ")
|
447
|
+
]);
|
448
|
+
});
|
449
|
+
table(t, [green, normal, bold, green, normal], "rrrll");
|
450
|
+
}
|
451
|
+
var modulesByIdentifier = {};
|
452
|
+
if(obj.modules) {
|
453
|
+
obj.modules.forEach(function(module) {
|
454
|
+
modulesByIdentifier["$" + module.identifier] = module;
|
455
|
+
});
|
456
|
+
} else if(obj.chunks) {
|
457
|
+
obj.chunks.forEach(function(chunk) {
|
458
|
+
if(chunk.modules) {
|
459
|
+
chunk.modules.forEach(function(module) {
|
460
|
+
modulesByIdentifier["$" + module.identifier] = module;
|
461
|
+
});
|
462
|
+
}
|
463
|
+
});
|
464
|
+
}
|
465
|
+
|
466
|
+
function processProfile(module) {
|
467
|
+
if(module.profile) {
|
468
|
+
normal(" ");
|
469
|
+
var sum = 0,
|
470
|
+
allowSum = true;
|
471
|
+
var path = [];
|
472
|
+
var current = module;
|
473
|
+
while(current.issuer) {
|
474
|
+
if(!modulesByIdentifier["$" + current.issuer]) {
|
475
|
+
normal(" ... ->");
|
476
|
+
allowSum = false;
|
477
|
+
break;
|
478
|
+
}
|
479
|
+
path.unshift(current = modulesByIdentifier["$" + current.issuer]);
|
480
|
+
}
|
481
|
+
path.forEach(function(module) {
|
482
|
+
normal(" [");
|
483
|
+
normal(module.id);
|
484
|
+
normal("] ");
|
485
|
+
if(module.profile) {
|
486
|
+
var time = (module.profile.factory || 0) + (module.profile.building || 0);
|
487
|
+
coloredTime(time);
|
488
|
+
sum += time;
|
489
|
+
normal(" ");
|
490
|
+
}
|
491
|
+
normal("->");
|
492
|
+
});
|
493
|
+
Object.keys(module.profile).forEach(function(key) {
|
494
|
+
normal(" " + key + ":");
|
495
|
+
var time = module.profile[key];
|
496
|
+
coloredTime(time);
|
497
|
+
sum += time;
|
498
|
+
});
|
499
|
+
if(allowSum) {
|
500
|
+
normal(" = ");
|
501
|
+
coloredTime(sum);
|
502
|
+
}
|
503
|
+
newline();
|
504
|
+
}
|
505
|
+
}
|
506
|
+
|
507
|
+
function processModuleAttributes(module) {
|
508
|
+
normal(" ");
|
509
|
+
normal(formatSize(module.size));
|
510
|
+
if(module.chunks) {
|
511
|
+
module.chunks.forEach(function(chunk) {
|
512
|
+
normal(" {");
|
513
|
+
yellow(chunk);
|
514
|
+
normal("}");
|
515
|
+
});
|
516
|
+
}
|
517
|
+
if(!module.cacheable) {
|
518
|
+
red(" [not cacheable]");
|
519
|
+
}
|
520
|
+
if(module.optional) {
|
521
|
+
yellow(" [optional]");
|
522
|
+
}
|
523
|
+
if(module.built) {
|
524
|
+
green(" [built]");
|
525
|
+
}
|
526
|
+
if(module.prefetched) {
|
527
|
+
magenta(" [prefetched]");
|
528
|
+
}
|
529
|
+
if(module.failed)
|
530
|
+
red(" [failed]");
|
531
|
+
if(module.warnings)
|
532
|
+
yellow(" [" + module.warnings + " warning" + (module.warnings === 1 ? "" : "s") + "]");
|
533
|
+
if(module.errors)
|
534
|
+
red(" [" + module.errors + " error" + (module.errors === 1 ? "" : "s") + "]");
|
535
|
+
}
|
536
|
+
if(obj.chunks) {
|
537
|
+
obj.chunks.forEach(function(chunk) {
|
538
|
+
normal("chunk ");
|
539
|
+
if(chunk.id < 1000) normal(" ");
|
540
|
+
if(chunk.id < 100) normal(" ");
|
541
|
+
if(chunk.id < 10) normal(" ");
|
542
|
+
normal("{");
|
543
|
+
yellow(chunk.id);
|
544
|
+
normal("} ");
|
545
|
+
green(chunk.files.join(", "));
|
546
|
+
if(chunk.names && chunk.names.length > 0) {
|
547
|
+
normal(" (");
|
548
|
+
normal(chunk.names.join(", "));
|
549
|
+
normal(")");
|
550
|
+
}
|
551
|
+
normal(" ");
|
552
|
+
normal(formatSize(chunk.size));
|
553
|
+
chunk.parents.forEach(function(id) {
|
554
|
+
normal(" {");
|
555
|
+
yellow(id);
|
556
|
+
normal("}");
|
557
|
+
});
|
558
|
+
if(chunk.rendered) {
|
559
|
+
green(" [rendered]");
|
560
|
+
}
|
561
|
+
newline();
|
562
|
+
if(chunk.origins) {
|
563
|
+
chunk.origins.forEach(function(origin) {
|
564
|
+
normal(" > ");
|
565
|
+
if(origin.reasons && origin.reasons.length) {
|
566
|
+
yellow(origin.reasons.join(" "));
|
567
|
+
normal(" ");
|
568
|
+
}
|
569
|
+
if(origin.name) {
|
570
|
+
normal(origin.name);
|
571
|
+
normal(" ");
|
572
|
+
}
|
573
|
+
if(origin.module) {
|
574
|
+
normal("[");
|
575
|
+
normal(origin.moduleId);
|
576
|
+
normal("] ");
|
577
|
+
var module = modulesByIdentifier["$" + origin.module];
|
578
|
+
if(module) {
|
579
|
+
bold(module.name);
|
580
|
+
normal(" ");
|
581
|
+
}
|
582
|
+
if(origin.loc) {
|
583
|
+
normal(origin.loc);
|
584
|
+
}
|
585
|
+
}
|
586
|
+
newline();
|
587
|
+
});
|
588
|
+
}
|
589
|
+
if(chunk.modules) {
|
590
|
+
chunk.modules.forEach(function(module) {
|
591
|
+
normal(" ");
|
592
|
+
if(module.id < 1000) normal(" ");
|
593
|
+
if(module.id < 100) normal(" ");
|
594
|
+
if(module.id < 10) normal(" ");
|
595
|
+
normal("[");
|
596
|
+
normal(module.id);
|
597
|
+
normal("] ");
|
598
|
+
bold(module.name);
|
599
|
+
processModuleAttributes(module);
|
600
|
+
newline();
|
601
|
+
if(module.reasons) {
|
602
|
+
module.reasons.forEach(function(reason) {
|
603
|
+
normal(" ");
|
604
|
+
normal(reason.type);
|
605
|
+
normal(" ");
|
606
|
+
cyan(reason.userRequest);
|
607
|
+
if(reason.templateModules) cyan(reason.templateModules.join(" "));
|
608
|
+
normal(" [");
|
609
|
+
normal(reason.moduleId);
|
610
|
+
normal("] ");
|
611
|
+
magenta(reason.module);
|
612
|
+
if(reason.loc) {
|
613
|
+
normal(" ");
|
614
|
+
normal(reason.loc);
|
615
|
+
}
|
616
|
+
newline();
|
617
|
+
});
|
618
|
+
}
|
619
|
+
processProfile(module);
|
620
|
+
});
|
621
|
+
if(chunk.filteredModules > 0) {
|
622
|
+
normal(" + " + chunk.filteredModules + " hidden modules");
|
623
|
+
newline();
|
624
|
+
}
|
625
|
+
}
|
626
|
+
});
|
627
|
+
}
|
628
|
+
if(obj.modules) {
|
629
|
+
obj.modules.forEach(function(module) {
|
630
|
+
if(module.id < 1000) normal(" ");
|
631
|
+
if(module.id < 100) normal(" ");
|
632
|
+
if(module.id < 10) normal(" ");
|
633
|
+
normal("[");
|
634
|
+
normal(module.id);
|
635
|
+
normal("] ");
|
636
|
+
bold(module.name || module.identifier);
|
637
|
+
processModuleAttributes(module);
|
638
|
+
newline();
|
639
|
+
if(module.reasons) {
|
640
|
+
module.reasons.forEach(function(reason) {
|
641
|
+
normal(" ");
|
642
|
+
normal(reason.type);
|
643
|
+
normal(" ");
|
644
|
+
cyan(reason.userRequest);
|
645
|
+
if(reason.templateModules) cyan(reason.templateModules.join(" "));
|
646
|
+
normal(" [");
|
647
|
+
normal(reason.moduleId);
|
648
|
+
normal("] ");
|
649
|
+
magenta(reason.module);
|
650
|
+
if(reason.loc) {
|
651
|
+
normal(" ");
|
652
|
+
normal(reason.loc);
|
653
|
+
}
|
654
|
+
newline();
|
655
|
+
});
|
656
|
+
}
|
657
|
+
processProfile(module);
|
658
|
+
});
|
659
|
+
if(obj.filteredModules > 0) {
|
660
|
+
normal(" + " + obj.filteredModules + " hidden modules");
|
661
|
+
newline();
|
662
|
+
}
|
663
|
+
}
|
664
|
+
if(obj._showWarnings && obj.warnings) {
|
665
|
+
obj.warnings.forEach(function(warning) {
|
666
|
+
newline();
|
667
|
+
yellow("WARNING in " + warning);
|
668
|
+
newline();
|
669
|
+
});
|
670
|
+
}
|
671
|
+
if(obj._showErrors && obj.errors) {
|
672
|
+
obj.errors.forEach(function(error) {
|
673
|
+
newline();
|
674
|
+
red("ERROR in " + error);
|
675
|
+
newline();
|
676
|
+
});
|
677
|
+
}
|
678
|
+
if(obj.children) {
|
679
|
+
obj.children.forEach(function(child) {
|
680
|
+
if(child.name) {
|
681
|
+
normal("Child ");
|
682
|
+
bold(child.name);
|
683
|
+
normal(":");
|
684
|
+
} else {
|
685
|
+
normal("Child");
|
686
|
+
}
|
687
|
+
newline();
|
688
|
+
buf.push(" ");
|
689
|
+
buf.push(Stats.jsonToString(child, useColors).replace(/\n/g, "\n "));
|
690
|
+
newline();
|
691
|
+
});
|
692
|
+
}
|
693
|
+
|
694
|
+
while(buf[buf.length - 1] === "\n") buf.pop();
|
695
|
+
return buf.join("");
|
696
|
+
};
|
697
|
+
|
698
|
+
Stats.presetToOptions = function(name) {
|
699
|
+
//Accepted values: none, errors-only, minimal, normal, verbose
|
700
|
+
//Any other falsy value will behave as 'none', truthy values as 'normal'
|
701
|
+
var pn = (typeof name === "string") && name.toLowerCase() || name;
|
702
|
+
if(pn === "none" || !pn) {
|
703
|
+
return {
|
704
|
+
hash: false,
|
705
|
+
version: false,
|
706
|
+
timings: false,
|
707
|
+
assets: false,
|
708
|
+
chunks: false,
|
709
|
+
modules: false,
|
710
|
+
reasons: false,
|
711
|
+
children: false,
|
712
|
+
source: false,
|
713
|
+
errors: false,
|
714
|
+
errorDetails: false,
|
715
|
+
warnings: false,
|
716
|
+
publicPath: false
|
717
|
+
};
|
718
|
+
} else {
|
719
|
+
return {
|
720
|
+
assets: pn === "verbose",
|
721
|
+
version: pn === "verbose",
|
722
|
+
timings: pn !== "errors-only" && pn !== "minimal",
|
723
|
+
hash: pn !== "errors-only" && pn !== "minimal",
|
724
|
+
chunks: pn !== "errors-only",
|
725
|
+
chunkModules: pn === "verbose",
|
726
|
+
//warnings: pn !== "errors-only",
|
727
|
+
errorDetails: pn !== "errors-only" && pn !== "minimal",
|
728
|
+
reasons: pn === "verbose",
|
729
|
+
colors: true
|
730
|
+
};
|
731
|
+
}
|
732
|
+
};
|