webpack 3.8.1 → 3.11.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 +20 -20
- package/README.md +721 -716
- package/bin/webpack.js +12 -8
- package/buildin/.eslintrc +7 -7
- package/buildin/amd-define.js +3 -3
- package/buildin/amd-options.js +2 -2
- package/buildin/global.js +21 -21
- package/buildin/harmony-module.js +24 -24
- package/buildin/module.js +22 -22
- package/buildin/system.js +7 -7
- package/hot/.eslintrc +9 -9
- package/hot/dev-server.js +53 -53
- package/hot/emitter.js +2 -2
- package/hot/log-apply-result.js +38 -38
- package/hot/log.js +44 -44
- package/hot/only-dev-server.js +71 -71
- package/hot/poll.js +34 -34
- package/hot/signal.js +52 -51
- package/lib/APIPlugin.js +45 -45
- package/lib/AsyncDependenciesBlock.js +43 -43
- package/lib/AutomaticPrefetchPlugin.js +36 -36
- package/lib/BannerPlugin.js +4 -2
- package/lib/BasicEvaluatedExpression.js +203 -203
- package/lib/CaseSensitiveModulesWarning.js +49 -49
- package/lib/Chunk.js +2 -2
- package/lib/ChunkRenderError.js +24 -24
- package/lib/ChunkTemplate.js +36 -36
- package/lib/CompatibilityPlugin.js +57 -57
- package/lib/Compilation.js +81 -92
- package/lib/Compiler.js +519 -523
- package/lib/ConstPlugin.js +60 -60
- package/lib/ContextModule.js +431 -431
- package/lib/ContextReplacementPlugin.js +111 -111
- package/lib/DefinePlugin.js +123 -123
- package/lib/DelegatedModule.js +98 -98
- package/lib/DelegatedModuleFactoryPlugin.js +59 -59
- package/lib/DelegatedPlugin.js +30 -30
- package/lib/DependenciesBlockVariable.js +51 -51
- package/lib/DllEntryPlugin.js +37 -37
- package/lib/DllModule.js +58 -58
- package/lib/DllModuleFactory.js +20 -20
- package/lib/DllPlugin.js +38 -38
- package/lib/DllReferencePlugin.js +62 -62
- package/lib/DynamicEntryPlugin.js +59 -59
- package/lib/EntryModuleNotFoundError.js +22 -22
- package/lib/EntryOptionPlugin.js +31 -31
- package/lib/EnvironmentPlugin.js +60 -50
- package/lib/ErrorHelpers.js +31 -31
- package/lib/EvalDevToolModulePlugin.js +22 -22
- package/lib/EvalDevToolModuleTemplatePlugin.js +33 -33
- package/lib/EvalSourceMapDevToolModuleTemplatePlugin.js +75 -75
- package/lib/EvalSourceMapDevToolPlugin.js +32 -32
- package/lib/ExportPropertyMainTemplatePlugin.js +31 -31
- package/lib/ExtendedAPIPlugin.js +47 -47
- package/lib/ExternalModuleFactoryPlugin.js +91 -91
- package/lib/ExternalsPlugin.js +21 -21
- package/lib/FlagDependencyExportsPlugin.js +101 -101
- package/lib/FlagDependencyUsagePlugin.js +1 -1
- package/lib/FunctionModulePlugin.js +24 -24
- package/lib/HashedModuleIdsPlugin.js +42 -42
- package/lib/HotModuleReplacementPlugin.js +5 -5
- package/lib/HotUpdateChunkTemplate.js +31 -31
- package/lib/IgnorePlugin.js +69 -69
- package/lib/JsonpExportMainTemplatePlugin.js +37 -37
- package/lib/JsonpHotUpdateChunkTemplatePlugin.js +27 -27
- package/lib/JsonpMainTemplatePlugin.js +4 -3
- package/lib/JsonpTemplatePlugin.js +21 -21
- package/lib/LibManifestPlugin.js +63 -63
- package/lib/LibraryTemplatePlugin.js +92 -92
- package/lib/LoaderOptionsPlugin.js +36 -36
- package/lib/LoaderTargetPlugin.js +19 -19
- package/lib/MainTemplate.js +3 -1
- package/lib/MemoryOutputFileSystem.js +5 -5
- package/lib/ModuleBuildError.js +42 -42
- package/lib/ModuleDependencyError.js +22 -22
- package/lib/ModuleDependencyWarning.js +22 -22
- package/lib/ModuleError.js +24 -24
- package/lib/ModuleFilenameHelpers.js +162 -162
- package/lib/ModuleNotFoundError.js +26 -26
- package/lib/ModuleReason.js +50 -50
- package/lib/ModuleTemplate.js +23 -23
- package/lib/ModuleWarning.js +24 -24
- package/lib/MovedToPluginWarningPlugin.js +21 -21
- package/lib/MultiCompiler.js +164 -164
- package/lib/MultiEntryPlugin.js +39 -39
- package/lib/MultiModuleFactory.js +19 -19
- package/lib/MultiStats.js +79 -79
- package/lib/MultiWatching.js +32 -32
- package/lib/NamedChunksPlugin.js +30 -30
- package/lib/NamedModulesPlugin.js +27 -27
- package/lib/NewWatchingPlugin.js +15 -15
- package/lib/NoEmitOnErrorsPlugin.js +22 -22
- package/lib/NoErrorsPlugin.js +29 -29
- package/lib/NodeStuffPlugin.js +97 -97
- package/lib/NormalModuleFactory.js +3 -1
- package/lib/NormalModuleReplacementPlugin.js +45 -45
- package/lib/NullFactory.js +12 -12
- package/lib/OptionsApply.js +10 -10
- package/lib/OptionsDefaulter.js +2 -2
- package/lib/Parser.js +79 -0
- package/lib/ParserHelpers.js +85 -85
- package/lib/PrefetchPlugin.js +31 -31
- package/lib/ProgressPlugin.js +192 -192
- package/lib/ProvidePlugin.js +55 -55
- package/lib/RawModule.js +54 -54
- package/lib/RequestShortener.js +63 -63
- package/lib/RequireJsStuffPlugin.js +31 -31
- package/lib/RuleSet.js +444 -444
- package/lib/SetVarMainTemplatePlugin.js +41 -41
- package/lib/SingleEntryPlugin.js +35 -35
- package/lib/SizeFormatHelpers.js +18 -18
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +37 -37
- package/lib/SourceMapDevToolPlugin.js +3 -3
- package/lib/Stats.js +4 -2
- package/lib/TemplatedPathPlugin.js +6 -2
- package/lib/UmdMainTemplatePlugin.js +1 -1
- package/lib/UnsupportedFeatureWarning.js +21 -21
- package/lib/UseStrictPlugin.js +34 -34
- package/lib/WarnCaseSensitiveModulesPlugin.js +31 -31
- package/lib/WatchIgnorePlugin.js +49 -49
- package/lib/WebpackError.js +11 -11
- package/lib/WebpackOptionsDefaulter.js +130 -129
- package/lib/WebpackOptionsValidationError.js +219 -196
- package/lib/compareLocations.js +36 -36
- package/lib/dependencies/AMDDefineDependency.js +142 -142
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +18 -6
- package/lib/dependencies/AMDPlugin.js +119 -119
- package/lib/dependencies/AMDRequireDependenciesBlock.js +33 -33
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +177 -177
- package/lib/dependencies/AMDRequireDependency.js +67 -67
- package/lib/dependencies/AMDRequireItemDependency.js +22 -22
- package/lib/dependencies/CommonJsRequireDependency.js +22 -22
- package/lib/dependencies/CommonJsRequireDependencyParserPlugin.js +89 -89
- package/lib/dependencies/ConstDependency.js +32 -32
- package/lib/dependencies/ContextDependencyHelpers.js +71 -71
- package/lib/dependencies/ContextElementDependency.js +21 -21
- package/lib/dependencies/CriticalDependencyWarning.js +20 -20
- package/lib/dependencies/DelegatedExportsDependency.js +33 -33
- package/lib/dependencies/DelegatedSourceDependency.js +18 -18
- package/lib/dependencies/DllEntryDependency.js +20 -20
- package/lib/dependencies/HarmonyCompatibilityDependency.js +30 -30
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +2 -2
- package/lib/dependencies/HarmonyExportHeaderDependency.js +28 -28
- package/lib/dependencies/HarmonyImportDependency.js +1 -1
- package/lib/dependencies/ImportDependenciesBlock.js +17 -17
- package/lib/dependencies/ImportEagerContextDependency.js +22 -22
- package/lib/dependencies/ImportLazyContextDependency.js +22 -22
- package/lib/dependencies/ImportLazyOnceContextDependency.js +22 -22
- package/lib/dependencies/ImportParserPlugin.js +89 -89
- package/lib/dependencies/ImportPlugin.js +60 -60
- package/lib/dependencies/ImportWeakContextDependency.js +22 -22
- package/lib/dependencies/LoaderDependency.js +18 -18
- package/lib/dependencies/LoaderPlugin.js +60 -60
- package/lib/dependencies/LocalModule.js +23 -23
- package/lib/dependencies/LocalModuleDependency.js +24 -24
- package/lib/dependencies/LocalModulesHelpers.js +46 -46
- package/lib/dependencies/ModuleDependency.js +23 -23
- package/lib/dependencies/ModuleHotAcceptDependency.js +23 -23
- package/lib/dependencies/ModuleHotDeclineDependency.js +23 -23
- package/lib/dependencies/MultiEntryDependency.js +20 -20
- package/lib/dependencies/NullDependency.js +24 -24
- package/lib/dependencies/PrefetchDependency.js +18 -18
- package/lib/dependencies/RequireContextDependency.js +26 -26
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +50 -50
- package/lib/dependencies/RequireContextPlugin.js +96 -96
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +22 -22
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +102 -102
- package/lib/dependencies/RequireEnsureDependency.js +38 -38
- package/lib/dependencies/RequireEnsureItemDependency.js +21 -21
- package/lib/dependencies/RequireEnsurePlugin.js +40 -40
- package/lib/dependencies/RequireHeaderDependency.js +26 -26
- package/lib/dependencies/RequireIncludeDependency.js +8 -0
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +21 -21
- package/lib/dependencies/RequireIncludePlugin.js +33 -33
- package/lib/dependencies/RequireResolveDependency.js +22 -22
- package/lib/dependencies/RequireResolveDependencyParserPlugin.js +71 -71
- package/lib/dependencies/RequireResolveHeaderDependency.js +26 -26
- package/lib/dependencies/SingleEntryDependency.js +18 -18
- package/lib/dependencies/SystemPlugin.js +44 -44
- package/lib/dependencies/UnsupportedDependency.js +23 -23
- package/lib/dependencies/WebpackMissingModule.js +18 -18
- package/lib/dependencies/getFunctionExpression.js +44 -44
- package/lib/formatLocation.js +54 -54
- package/lib/node/NodeChunkTemplatePlugin.js +27 -27
- package/lib/node/NodeEnvironmentPlugin.js +25 -25
- package/lib/node/NodeHotUpdateChunkTemplatePlugin.js +27 -27
- package/lib/node/NodeMainTemplate.runtime.js +24 -24
- package/lib/node/NodeMainTemplateAsync.runtime.js +40 -40
- package/lib/node/NodeOutputFileSystem.js +22 -22
- package/lib/node/NodeSourcePlugin.js +88 -88
- package/lib/node/NodeTargetPlugin.js +17 -15
- package/lib/node/NodeTemplatePlugin.js +27 -27
- package/lib/node/NodeWatchFileSystem.js +72 -72
- package/lib/optimize/ChunkModuleIdRangePlugin.js +53 -53
- package/lib/optimize/ConcatenatedModule.js +17 -6
- package/lib/optimize/DedupePlugin.js +15 -15
- package/lib/optimize/FlagIncludedChunksPlugin.js +35 -35
- package/lib/optimize/LimitChunkCountPlugin.js +59 -59
- package/lib/optimize/MinChunkSizePlugin.js +65 -65
- package/lib/optimize/RemoveEmptyChunksPlugin.js +21 -21
- package/lib/optimize/UglifyJsPlugin.js +9 -9
- package/lib/performance/AssetsOverSizeLimitWarning.js +23 -23
- package/lib/performance/EntrypointsOverSizeLimitWarning.js +28 -28
- package/lib/performance/NoAsyncChunksWarning.js +20 -20
- package/lib/performance/SizeLimitsPlugin.js +102 -102
- package/lib/prepareOptions.js +29 -29
- package/lib/removeAndDo.js +15 -15
- package/lib/util/Semaphore.js +32 -32
- package/lib/util/identifier.js +38 -38
- package/lib/validateSchema.js +66 -66
- package/lib/web/WebEnvironmentPlugin.js +18 -18
- package/lib/webworker/WebWorkerChunkTemplatePlugin.js +29 -29
- package/lib/webworker/WebWorkerHotUpdateChunkTemplatePlugin.js +28 -28
- package/lib/webworker/WebWorkerMainTemplate.runtime.js +58 -58
- package/lib/webworker/WebWorkerMainTemplatePlugin.js +2 -2
- package/lib/webworker/WebWorkerTemplatePlugin.js +20 -20
- package/package.json +25 -16
- package/schemas/ajv.absolutePath.js +29 -29
- package/schemas/webpackOptionsSchema.json +405 -76
@@ -1,57 +1,57 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
"use strict";
|
6
|
-
|
7
|
-
const ConstDependency = require("./dependencies/ConstDependency");
|
8
|
-
|
9
|
-
const NullFactory = require("./NullFactory");
|
10
|
-
|
11
|
-
const jsonLoaderPath = require.resolve("json-loader");
|
12
|
-
const matchJson = /\.json$/i;
|
13
|
-
|
14
|
-
class CompatibilityPlugin {
|
15
|
-
|
16
|
-
apply(compiler) {
|
17
|
-
compiler.plugin("compilation", (compilation, params) => {
|
18
|
-
compilation.dependencyFactories.set(ConstDependency, new NullFactory());
|
19
|
-
compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template());
|
20
|
-
|
21
|
-
params.normalModuleFactory.plugin("parser", (parser, parserOptions) => {
|
22
|
-
|
23
|
-
if(typeof parserOptions.browserify !== "undefined" && !parserOptions.browserify)
|
24
|
-
return;
|
25
|
-
|
26
|
-
parser.plugin("call require", (expr) => {
|
27
|
-
// support for browserify style require delegator: "require(o, !0)"
|
28
|
-
if(expr.arguments.length !== 2) return;
|
29
|
-
const second = parser.evaluateExpression(expr.arguments[1]);
|
30
|
-
if(!second.isBoolean()) return;
|
31
|
-
if(second.asBool() !== true) return;
|
32
|
-
const dep = new ConstDependency("require", expr.callee.range);
|
33
|
-
dep.loc = expr.loc;
|
34
|
-
if(parser.state.current.dependencies.length > 1) {
|
35
|
-
const last = parser.state.current.dependencies[parser.state.current.dependencies.length - 1];
|
36
|
-
if(last.critical && last.request === "." && last.userRequest === "." && last.recursive)
|
37
|
-
parser.state.current.dependencies.pop();
|
38
|
-
}
|
39
|
-
parser.state.current.addDependency(dep);
|
40
|
-
return true;
|
41
|
-
});
|
42
|
-
});
|
43
|
-
|
44
|
-
params.normalModuleFactory.plugin("after-resolve", (data, done) => {
|
45
|
-
// if this is a json file and there are no loaders active, we use the json-loader in order to avoid parse errors
|
46
|
-
// @see https://github.com/webpack/webpack/issues/3363
|
47
|
-
if(matchJson.test(data.request) && data.loaders.length === 0) {
|
48
|
-
data.loaders.push({
|
49
|
-
loader: jsonLoaderPath
|
50
|
-
});
|
51
|
-
}
|
52
|
-
done(null, data);
|
53
|
-
});
|
54
|
-
});
|
55
|
-
}
|
56
|
-
}
|
57
|
-
module.exports = CompatibilityPlugin;
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
"use strict";
|
6
|
+
|
7
|
+
const ConstDependency = require("./dependencies/ConstDependency");
|
8
|
+
|
9
|
+
const NullFactory = require("./NullFactory");
|
10
|
+
|
11
|
+
const jsonLoaderPath = require.resolve("json-loader");
|
12
|
+
const matchJson = /\.json$/i;
|
13
|
+
|
14
|
+
class CompatibilityPlugin {
|
15
|
+
|
16
|
+
apply(compiler) {
|
17
|
+
compiler.plugin("compilation", (compilation, params) => {
|
18
|
+
compilation.dependencyFactories.set(ConstDependency, new NullFactory());
|
19
|
+
compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template());
|
20
|
+
|
21
|
+
params.normalModuleFactory.plugin("parser", (parser, parserOptions) => {
|
22
|
+
|
23
|
+
if(typeof parserOptions.browserify !== "undefined" && !parserOptions.browserify)
|
24
|
+
return;
|
25
|
+
|
26
|
+
parser.plugin("call require", (expr) => {
|
27
|
+
// support for browserify style require delegator: "require(o, !0)"
|
28
|
+
if(expr.arguments.length !== 2) return;
|
29
|
+
const second = parser.evaluateExpression(expr.arguments[1]);
|
30
|
+
if(!second.isBoolean()) return;
|
31
|
+
if(second.asBool() !== true) return;
|
32
|
+
const dep = new ConstDependency("require", expr.callee.range);
|
33
|
+
dep.loc = expr.loc;
|
34
|
+
if(parser.state.current.dependencies.length > 1) {
|
35
|
+
const last = parser.state.current.dependencies[parser.state.current.dependencies.length - 1];
|
36
|
+
if(last.critical && last.request === "." && last.userRequest === "." && last.recursive)
|
37
|
+
parser.state.current.dependencies.pop();
|
38
|
+
}
|
39
|
+
parser.state.current.addDependency(dep);
|
40
|
+
return true;
|
41
|
+
});
|
42
|
+
});
|
43
|
+
|
44
|
+
params.normalModuleFactory.plugin("after-resolve", (data, done) => {
|
45
|
+
// if this is a json file and there are no loaders active, we use the json-loader in order to avoid parse errors
|
46
|
+
// @see https://github.com/webpack/webpack/issues/3363
|
47
|
+
if(matchJson.test(data.request) && data.loaders.length === 0) {
|
48
|
+
data.loaders.push({
|
49
|
+
loader: jsonLoaderPath
|
50
|
+
});
|
51
|
+
}
|
52
|
+
done(null, data);
|
53
|
+
});
|
54
|
+
});
|
55
|
+
}
|
56
|
+
}
|
57
|
+
module.exports = CompatibilityPlugin;
|
package/lib/Compilation.js
CHANGED
@@ -34,7 +34,7 @@ function byId(a, b) {
|
|
34
34
|
|
35
35
|
function iterationBlockVariable(variables, fn) {
|
36
36
|
for(let indexVariable = 0; indexVariable < variables.length; indexVariable++) {
|
37
|
-
|
37
|
+
const varDep = variables[indexVariable].dependencies;
|
38
38
|
for(let indexVDep = 0; indexVDep < varDep.length; indexVDep++) {
|
39
39
|
fn(varDep[indexVDep]);
|
40
40
|
}
|
@@ -116,8 +116,8 @@ class Compilation extends Tapable {
|
|
116
116
|
cacheModule.disconnect();
|
117
117
|
this._modules[identifier] = cacheModule;
|
118
118
|
this.modules.push(cacheModule);
|
119
|
-
cacheModule.errors.forEach(err => this.errors.push(err)
|
120
|
-
cacheModule.warnings.forEach(err => this.warnings.push(err)
|
119
|
+
cacheModule.errors.forEach(err => this.errors.push(err));
|
120
|
+
cacheModule.warnings.forEach(err => this.warnings.push(err));
|
121
121
|
return cacheModule;
|
122
122
|
}
|
123
123
|
}
|
@@ -300,9 +300,7 @@ class Compilation extends Tapable {
|
|
300
300
|
iterationDependencies(dependencies);
|
301
301
|
|
302
302
|
if(_this.profile) {
|
303
|
-
|
304
|
-
module.profile = {};
|
305
|
-
}
|
303
|
+
module.profile = module.profile || {};
|
306
304
|
const time = Date.now() - start;
|
307
305
|
if(!module.profile.dependencies || time > module.profile.dependencies) {
|
308
306
|
module.profile.dependencies = time;
|
@@ -572,112 +570,111 @@ class Compilation extends Tapable {
|
|
572
570
|
}
|
573
571
|
|
574
572
|
seal(callback) {
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
self.preparedChunks.forEach(preparedChunk => {
|
573
|
+
this.applyPlugins0("seal");
|
574
|
+
this.nextFreeModuleIndex = 0;
|
575
|
+
this.nextFreeModuleIndex2 = 0;
|
576
|
+
this.preparedChunks.forEach(preparedChunk => {
|
580
577
|
const module = preparedChunk.module;
|
581
|
-
const chunk =
|
582
|
-
const entrypoint =
|
578
|
+
const chunk = this.addChunk(preparedChunk.name, module);
|
579
|
+
const entrypoint = this.entrypoints[chunk.name] = new Entrypoint(chunk.name);
|
583
580
|
entrypoint.unshiftChunk(chunk);
|
584
581
|
|
585
582
|
chunk.addModule(module);
|
586
583
|
module.addChunk(chunk);
|
587
584
|
chunk.entryModule = module;
|
588
|
-
|
589
|
-
|
585
|
+
this.assignIndex(module);
|
586
|
+
this.assignDepth(module);
|
590
587
|
});
|
591
|
-
|
592
|
-
|
593
|
-
|
588
|
+
this.processDependenciesBlocksForChunks(this.chunks.slice());
|
589
|
+
this.sortModules(this.modules);
|
590
|
+
this.applyPlugins0("optimize");
|
594
591
|
|
595
|
-
while(
|
596
|
-
|
597
|
-
|
598
|
-
|
592
|
+
while(this.applyPluginsBailResult1("optimize-modules-basic", this.modules) ||
|
593
|
+
this.applyPluginsBailResult1("optimize-modules", this.modules) ||
|
594
|
+
this.applyPluginsBailResult1("optimize-modules-advanced", this.modules)) { /* empty */ }
|
595
|
+
this.applyPlugins1("after-optimize-modules", this.modules);
|
599
596
|
|
600
|
-
while(
|
601
|
-
|
602
|
-
|
603
|
-
|
597
|
+
while(this.applyPluginsBailResult1("optimize-chunks-basic", this.chunks) ||
|
598
|
+
this.applyPluginsBailResult1("optimize-chunks", this.chunks) ||
|
599
|
+
this.applyPluginsBailResult1("optimize-chunks-advanced", this.chunks)) { /* empty */ }
|
600
|
+
this.applyPlugins1("after-optimize-chunks", this.chunks);
|
604
601
|
|
605
|
-
|
602
|
+
this.applyPluginsAsyncSeries("optimize-tree", this.chunks, this.modules, (err) => {
|
606
603
|
if(err) {
|
607
604
|
return callback(err);
|
608
605
|
}
|
609
606
|
|
610
|
-
|
607
|
+
this.applyPlugins2("after-optimize-tree", this.chunks, this.modules);
|
611
608
|
|
612
|
-
while(
|
613
|
-
|
614
|
-
|
615
|
-
|
609
|
+
while(this.applyPluginsBailResult("optimize-chunk-modules-basic", this.chunks, this.modules) ||
|
610
|
+
this.applyPluginsBailResult("optimize-chunk-modules", this.chunks, this.modules) ||
|
611
|
+
this.applyPluginsBailResult("optimize-chunk-modules-advanced", this.chunks, this.modules)) { /* empty */ }
|
612
|
+
this.applyPlugins2("after-optimize-chunk-modules", this.chunks, this.modules);
|
616
613
|
|
617
|
-
const shouldRecord =
|
614
|
+
const shouldRecord = this.applyPluginsBailResult("should-record") !== false;
|
618
615
|
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
616
|
+
this.applyPlugins2("revive-modules", this.modules, this.records);
|
617
|
+
this.applyPlugins1("optimize-module-order", this.modules);
|
618
|
+
this.applyPlugins1("advanced-optimize-module-order", this.modules);
|
619
|
+
this.applyPlugins1("before-module-ids", this.modules);
|
620
|
+
this.applyPlugins1("module-ids", this.modules);
|
621
|
+
this.applyModuleIds();
|
622
|
+
this.applyPlugins1("optimize-module-ids", this.modules);
|
623
|
+
this.applyPlugins1("after-optimize-module-ids", this.modules);
|
627
624
|
|
628
|
-
|
625
|
+
this.sortItemsWithModuleIds();
|
629
626
|
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
627
|
+
this.applyPlugins2("revive-chunks", this.chunks, this.records);
|
628
|
+
this.applyPlugins1("optimize-chunk-order", this.chunks);
|
629
|
+
this.applyPlugins1("before-chunk-ids", this.chunks);
|
630
|
+
this.applyChunkIds();
|
631
|
+
this.applyPlugins1("optimize-chunk-ids", this.chunks);
|
632
|
+
this.applyPlugins1("after-optimize-chunk-ids", this.chunks);
|
636
633
|
|
637
|
-
|
634
|
+
this.sortItemsWithChunkIds();
|
638
635
|
|
639
636
|
if(shouldRecord)
|
640
|
-
|
637
|
+
this.applyPlugins2("record-modules", this.modules, this.records);
|
641
638
|
if(shouldRecord)
|
642
|
-
|
639
|
+
this.applyPlugins2("record-chunks", this.chunks, this.records);
|
643
640
|
|
644
|
-
|
645
|
-
|
646
|
-
|
641
|
+
this.applyPlugins0("before-hash");
|
642
|
+
this.createHash();
|
643
|
+
this.applyPlugins0("after-hash");
|
647
644
|
|
648
645
|
if(shouldRecord)
|
649
|
-
|
646
|
+
this.applyPlugins1("record-hash", this.records);
|
650
647
|
|
651
|
-
|
652
|
-
|
653
|
-
if(
|
654
|
-
|
655
|
-
|
648
|
+
this.applyPlugins0("before-module-assets");
|
649
|
+
this.createModuleAssets();
|
650
|
+
if(this.applyPluginsBailResult("should-generate-chunk-assets") !== false) {
|
651
|
+
this.applyPlugins0("before-chunk-assets");
|
652
|
+
this.createChunkAssets();
|
656
653
|
}
|
657
|
-
|
658
|
-
|
654
|
+
this.applyPlugins1("additional-chunk-assets", this.chunks);
|
655
|
+
this.summarizeDependencies();
|
659
656
|
if(shouldRecord)
|
660
|
-
|
657
|
+
this.applyPlugins2("record", this, this.records);
|
661
658
|
|
662
|
-
|
659
|
+
this.applyPluginsAsync("additional-assets", err => {
|
663
660
|
if(err) {
|
664
661
|
return callback(err);
|
665
662
|
}
|
666
|
-
|
663
|
+
this.applyPluginsAsync("optimize-chunk-assets", this.chunks, err => {
|
667
664
|
if(err) {
|
668
665
|
return callback(err);
|
669
666
|
}
|
670
|
-
|
671
|
-
|
667
|
+
this.applyPlugins1("after-optimize-chunk-assets", this.chunks);
|
668
|
+
this.applyPluginsAsync("optimize-assets", this.assets, err => {
|
672
669
|
if(err) {
|
673
670
|
return callback(err);
|
674
671
|
}
|
675
|
-
|
676
|
-
if(
|
677
|
-
|
678
|
-
return
|
672
|
+
this.applyPlugins1("after-optimize-assets", this.assets);
|
673
|
+
if(this.applyPluginsBailResult("need-additional-seal")) {
|
674
|
+
this.unseal();
|
675
|
+
return this.seal(callback);
|
679
676
|
}
|
680
|
-
return
|
677
|
+
return this.applyPluginsAsync("after-seal", callback);
|
681
678
|
});
|
682
679
|
});
|
683
680
|
});
|
@@ -685,11 +682,7 @@ class Compilation extends Tapable {
|
|
685
682
|
}
|
686
683
|
|
687
684
|
sortModules(modules) {
|
688
|
-
modules.sort(
|
689
|
-
if(a.index < b.index) return -1;
|
690
|
-
if(a.index > b.index) return 1;
|
691
|
-
return 0;
|
692
|
-
});
|
685
|
+
modules.sort(byId);
|
693
686
|
}
|
694
687
|
|
695
688
|
reportDependencyErrorsAndWarnings(module, blocks) {
|
@@ -1097,9 +1090,9 @@ class Compilation extends Tapable {
|
|
1097
1090
|
}
|
1098
1091
|
|
1099
1092
|
applyModuleIds() {
|
1100
|
-
|
1093
|
+
const unusedIds = [];
|
1101
1094
|
let nextFreeModuleId = 0;
|
1102
|
-
|
1095
|
+
const usedIds = [];
|
1103
1096
|
// TODO consider Map when performance has improved https://gist.github.com/sokra/234c077e1299b7369461f1708519c392
|
1104
1097
|
const usedIdMap = Object.create(null);
|
1105
1098
|
if(this.usedModuleIds) {
|
@@ -1218,14 +1211,12 @@ class Compilation extends Tapable {
|
|
1218
1211
|
sortItemsWithChunkIds() {
|
1219
1212
|
this.chunks.sort(byId);
|
1220
1213
|
|
1221
|
-
|
1222
|
-
|
1223
|
-
modules[indexModule].sortItems(true);
|
1214
|
+
for(let indexModule = 0; indexModule < this.modules.length; indexModule++) {
|
1215
|
+
this.modules[indexModule].sortItems(true);
|
1224
1216
|
}
|
1225
1217
|
|
1226
|
-
|
1227
|
-
|
1228
|
-
chunks[indexChunk].sortItems();
|
1218
|
+
for(let indexChunk = 0; indexChunk < this.chunks.length; indexChunk++) {
|
1219
|
+
this.chunks[indexChunk].sortItems();
|
1229
1220
|
}
|
1230
1221
|
|
1231
1222
|
const byMessage = (a, b) => {
|
@@ -1253,18 +1244,16 @@ class Compilation extends Tapable {
|
|
1253
1244
|
this.contextDependencies = [];
|
1254
1245
|
this.missingDependencies = [];
|
1255
1246
|
|
1256
|
-
|
1257
|
-
|
1258
|
-
const child = children[indexChildren];
|
1247
|
+
for(let indexChildren = 0; indexChildren < this.children.length; indexChildren++) {
|
1248
|
+
const child = this.children[indexChildren];
|
1259
1249
|
|
1260
1250
|
this.fileDependencies = this.fileDependencies.concat(child.fileDependencies);
|
1261
1251
|
this.contextDependencies = this.contextDependencies.concat(child.contextDependencies);
|
1262
1252
|
this.missingDependencies = this.missingDependencies.concat(child.missingDependencies);
|
1263
1253
|
}
|
1264
1254
|
|
1265
|
-
|
1266
|
-
|
1267
|
-
const module = modules[indexModule];
|
1255
|
+
for(let indexModule = 0; indexModule < this.modules.length; indexModule++) {
|
1256
|
+
const module = this.modules[indexModule];
|
1268
1257
|
|
1269
1258
|
if(module.fileDependencies) {
|
1270
1259
|
const fileDependencies = module.fileDependencies;
|
@@ -1425,7 +1414,7 @@ class Compilation extends Tapable {
|
|
1425
1414
|
}
|
1426
1415
|
|
1427
1416
|
createChildCompiler(name, outputOptions, plugins) {
|
1428
|
-
|
1417
|
+
const idx = (this.childrenCounters[name] || 0);
|
1429
1418
|
this.childrenCounters[name] = idx + 1;
|
1430
1419
|
return this.compiler.createChildCompiler(this, name, idx, outputOptions, plugins);
|
1431
1420
|
}
|