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
@@ -1,21 +1,21 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
var ModuleParserHelpers = exports;
|
6
|
-
|
7
|
-
ModuleParserHelpers.addParsedVariable = function(parser, name, expression) {
|
8
|
-
if(!parser.state.current.addVariable) return false;
|
9
|
-
var deps = [];
|
10
|
-
parser.parse(expression, {
|
11
|
-
current: {
|
12
|
-
addDependency: function(dep) {
|
13
|
-
dep.userRequest = name;
|
14
|
-
deps.push(dep);
|
15
|
-
}
|
16
|
-
},
|
17
|
-
module: parser.state.module
|
18
|
-
});
|
19
|
-
parser.state.current.addVariable(name, expression, deps);
|
20
|
-
return true;
|
21
|
-
};
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
var ModuleParserHelpers = exports;
|
6
|
+
|
7
|
+
ModuleParserHelpers.addParsedVariable = function(parser, name, expression) {
|
8
|
+
if(!parser.state.current.addVariable) return false;
|
9
|
+
var deps = [];
|
10
|
+
parser.parse(expression, {
|
11
|
+
current: {
|
12
|
+
addDependency: function(dep) {
|
13
|
+
dep.userRequest = name;
|
14
|
+
deps.push(dep);
|
15
|
+
}
|
16
|
+
},
|
17
|
+
module: parser.state.module
|
18
|
+
});
|
19
|
+
parser.state.current.addVariable(name, expression, deps);
|
20
|
+
return true;
|
21
|
+
};
|
package/lib/ModuleReason.js
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
function ModuleReason(module, dependency) {
|
6
|
-
this.module = module;
|
7
|
-
this.dependency = dependency;
|
8
|
-
}
|
9
|
-
module.exports = ModuleReason;
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
function ModuleReason(module, dependency) {
|
6
|
+
this.module = module;
|
7
|
+
this.dependency = dependency;
|
8
|
+
}
|
9
|
+
module.exports = ModuleReason;
|
package/lib/ModuleTemplate.js
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
var Template = require("./Template");
|
6
|
-
|
7
|
-
function ModuleTemplate(outputOptions) {
|
8
|
-
Template.call(this, outputOptions);
|
9
|
-
}
|
10
|
-
module.exports = ModuleTemplate;
|
11
|
-
|
12
|
-
ModuleTemplate.prototype = Object.create(Template.prototype);
|
13
|
-
ModuleTemplate.prototype.render = function(module, dependencyTemplates, chunk) {
|
14
|
-
var moduleSource = module.source(dependencyTemplates, this.outputOptions, this.requestShortener);
|
15
|
-
moduleSource = this.applyPluginsWaterfall("module", moduleSource, module, chunk, dependencyTemplates);
|
16
|
-
moduleSource = this.applyPluginsWaterfall("render", moduleSource, module, chunk, dependencyTemplates);
|
17
|
-
return this.applyPluginsWaterfall("package", moduleSource, module, chunk, dependencyTemplates);
|
18
|
-
};
|
19
|
-
|
20
|
-
ModuleTemplate.prototype.updateHash = function(hash) {
|
21
|
-
hash.update("1");
|
22
|
-
this.applyPlugins("hash", hash);
|
23
|
-
};
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
var Template = require("./Template");
|
6
|
+
|
7
|
+
function ModuleTemplate(outputOptions) {
|
8
|
+
Template.call(this, outputOptions);
|
9
|
+
}
|
10
|
+
module.exports = ModuleTemplate;
|
11
|
+
|
12
|
+
ModuleTemplate.prototype = Object.create(Template.prototype);
|
13
|
+
ModuleTemplate.prototype.render = function(module, dependencyTemplates, chunk) {
|
14
|
+
var moduleSource = module.source(dependencyTemplates, this.outputOptions, this.requestShortener);
|
15
|
+
moduleSource = this.applyPluginsWaterfall("module", moduleSource, module, chunk, dependencyTemplates);
|
16
|
+
moduleSource = this.applyPluginsWaterfall("render", moduleSource, module, chunk, dependencyTemplates);
|
17
|
+
return this.applyPluginsWaterfall("package", moduleSource, module, chunk, dependencyTemplates);
|
18
|
+
};
|
19
|
+
|
20
|
+
ModuleTemplate.prototype.updateHash = function(hash) {
|
21
|
+
hash.update("1");
|
22
|
+
this.applyPlugins("hash", hash);
|
23
|
+
};
|
@@ -1,17 +1,17 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
function MovedToPluginWarningPlugin(optionName, pluginName) {
|
6
|
-
this.optionName = optionName;
|
7
|
-
this.pluginName = pluginName;
|
8
|
-
}
|
9
|
-
module.exports = MovedToPluginWarningPlugin;
|
10
|
-
|
11
|
-
MovedToPluginWarningPlugin.prototype.apply = function(compiler) {
|
12
|
-
var optionName = this.optionName;
|
13
|
-
var pluginName = this.pluginName;
|
14
|
-
compiler.plugin("compilation", function(compilation) {
|
15
|
-
compilation.warnings.push(new Error("webpack options:\nDEPRECATED option '" + optionName + "' will be moved to the " + pluginName + ". Use this instead.\nFor more info about the usage of the " + pluginName + " see https://webpack.github.io/docs/list-of-plugins.html"));
|
16
|
-
});
|
17
|
-
};
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
function MovedToPluginWarningPlugin(optionName, pluginName) {
|
6
|
+
this.optionName = optionName;
|
7
|
+
this.pluginName = pluginName;
|
8
|
+
}
|
9
|
+
module.exports = MovedToPluginWarningPlugin;
|
10
|
+
|
11
|
+
MovedToPluginWarningPlugin.prototype.apply = function(compiler) {
|
12
|
+
var optionName = this.optionName;
|
13
|
+
var pluginName = this.pluginName;
|
14
|
+
compiler.plugin("compilation", function(compilation) {
|
15
|
+
compilation.warnings.push(new Error("webpack options:\nDEPRECATED option '" + optionName + "' will be moved to the " + pluginName + ". Use this instead.\nFor more info about the usage of the " + pluginName + " see https://webpack.github.io/docs/list-of-plugins.html"));
|
16
|
+
});
|
17
|
+
};
|
package/lib/MultiCompiler.js
CHANGED
@@ -1,166 +1,166 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
var Tapable = require("tapable");
|
6
|
-
var async = require("async");
|
7
|
-
var Stats = require("./Stats");
|
8
|
-
|
9
|
-
function MultiWatching(watchings) {
|
10
|
-
this.watchings = watchings;
|
11
|
-
}
|
12
|
-
|
13
|
-
MultiWatching.prototype.invalidate = function() {
|
14
|
-
this.watchings.forEach(function(watching) {
|
15
|
-
watching.invalidate();
|
16
|
-
});
|
17
|
-
};
|
18
|
-
|
19
|
-
MultiWatching.prototype.close = function(callback) {
|
20
|
-
async.forEach(this.watchings, function(watching, callback) {
|
21
|
-
watching.close(callback);
|
22
|
-
}, callback);
|
23
|
-
};
|
24
|
-
|
25
|
-
function MultiCompiler(compilers) {
|
26
|
-
Tapable.call(this);
|
27
|
-
if(!Array.isArray(compilers)) {
|
28
|
-
compilers = Object.keys(compilers).map(function(name) {
|
29
|
-
compilers[name].name = name;
|
30
|
-
return compilers[name];
|
31
|
-
});
|
32
|
-
}
|
33
|
-
this.compilers = compilers;
|
34
|
-
|
35
|
-
function delegateProperty(name) {
|
36
|
-
Object.defineProperty(this, name, {
|
37
|
-
configurable: false,
|
38
|
-
get: function() {
|
39
|
-
throw new Error("Cannot read " + name + " of a MultiCompiler");
|
40
|
-
},
|
41
|
-
set: function(value) {
|
42
|
-
this.compilers.forEach(function(compiler) {
|
43
|
-
compiler[name] = value;
|
44
|
-
});
|
45
|
-
}.bind(this)
|
46
|
-
});
|
47
|
-
}
|
48
|
-
delegateProperty.call(this, "outputFileSystem");
|
49
|
-
delegateProperty.call(this, "inputFileSystem");
|
50
|
-
|
51
|
-
Object.defineProperty(this, "outputPath", {
|
52
|
-
configurable: false,
|
53
|
-
get: function() {
|
54
|
-
var commonPath = compilers[0].outputPath;
|
55
|
-
for(var i = 1; i < compilers.length; i++) {
|
56
|
-
while(compilers[i].outputPath.indexOf(commonPath) !== 0 && /[\/\\]/.test(commonPath)) {
|
57
|
-
commonPath = commonPath.replace(/[\/\\][^\/\\]*$/, "");
|
58
|
-
}
|
59
|
-
}
|
60
|
-
if(!commonPath && compilers[0].outputPath[0] === "/") return "/";
|
61
|
-
return commonPath;
|
62
|
-
}
|
63
|
-
});
|
64
|
-
|
65
|
-
var doneCompilers = 0;
|
66
|
-
var compilerStats = [];
|
67
|
-
this.compilers.forEach(function(compiler, idx) {
|
68
|
-
var compilerDone = false;
|
69
|
-
compiler.plugin("done", function(stats) {
|
70
|
-
if(!compilerDone) {
|
71
|
-
compilerDone = true;
|
72
|
-
doneCompilers++;
|
73
|
-
}
|
74
|
-
compilerStats[idx] = stats;
|
75
|
-
if(doneCompilers === this.compilers.length) {
|
76
|
-
this.applyPlugins("done", new MultiStats(compilerStats));
|
77
|
-
}
|
78
|
-
}.bind(this));
|
79
|
-
compiler.plugin("invalid", function() {
|
80
|
-
if(compilerDone) {
|
81
|
-
compilerDone = false;
|
82
|
-
doneCompilers--;
|
83
|
-
}
|
84
|
-
this.applyPlugins("invalid");
|
85
|
-
}.bind(this));
|
86
|
-
}, this);
|
87
|
-
}
|
88
|
-
module.exports = MultiCompiler;
|
89
|
-
|
90
|
-
MultiCompiler.prototype = Object.create(Tapable.prototype);
|
91
|
-
MultiCompiler.prototype.constructor = MultiCompiler;
|
92
|
-
|
93
|
-
MultiCompiler.prototype.watch = function(watchDelay, handler) {
|
94
|
-
var watchings = this.compilers.map(function(compiler) {
|
95
|
-
return compiler.watch(watchDelay, handler);
|
96
|
-
});
|
97
|
-
return new MultiWatching(watchings);
|
98
|
-
};
|
99
|
-
|
100
|
-
MultiCompiler.prototype.run = function(callback) {
|
101
|
-
async.map(this.compilers, function(compiler, callback) {
|
102
|
-
compiler.run(callback);
|
103
|
-
}, function(err, stats) {
|
104
|
-
if(err) return callback(err);
|
105
|
-
callback(null, new MultiStats(stats));
|
106
|
-
});
|
107
|
-
};
|
108
|
-
|
109
|
-
MultiCompiler.prototype.purgeInputFileSystem = function() {
|
110
|
-
this.compilers.forEach(function(compiler) {
|
111
|
-
if(compiler.inputFileSystem && compiler.inputFileSystem.purge)
|
112
|
-
compiler.inputFileSystem.purge();
|
113
|
-
});
|
114
|
-
};
|
115
|
-
|
116
|
-
function MultiStats(stats) {
|
117
|
-
this.stats = stats;
|
118
|
-
this.hash = stats.map(function(stat) {
|
119
|
-
return stat.hash;
|
120
|
-
}).join("");
|
121
|
-
}
|
122
|
-
|
123
|
-
MultiStats.prototype.hasErrors = function() {
|
124
|
-
return this.stats.map(function(stat) {
|
125
|
-
return stat.hasErrors();
|
126
|
-
}).reduce(function(a, b) {
|
127
|
-
return a || b;
|
128
|
-
}, false);
|
129
|
-
};
|
130
|
-
|
131
|
-
MultiStats.prototype.hasWarnings = function() {
|
132
|
-
return this.stats.map(function(stat) {
|
133
|
-
return stat.hasWarnings();
|
134
|
-
}).reduce(function(a, b) {
|
135
|
-
return a || b;
|
136
|
-
}, false);
|
137
|
-
};
|
138
|
-
|
139
|
-
MultiStats.prototype.toJson = function(options, forToString) {
|
140
|
-
var jsons = this.stats.map(function(stat) {
|
141
|
-
var obj = stat.toJson(options, forToString);
|
142
|
-
obj.name = stat.compilation && stat.compilation.name;
|
143
|
-
return obj;
|
144
|
-
});
|
145
|
-
var obj = {
|
146
|
-
errors: jsons.reduce(function(arr, j) {
|
147
|
-
return arr.concat(j.errors.map(function(msg) {
|
148
|
-
return "(" + j.name + ") " + msg;
|
149
|
-
}));
|
150
|
-
}, []),
|
151
|
-
warnings: jsons.reduce(function(arr, j) {
|
152
|
-
return arr.concat(j.warnings.map(function(msg) {
|
153
|
-
return "(" + j.name + ") " + msg;
|
154
|
-
}));
|
155
|
-
}, [])
|
156
|
-
};
|
157
|
-
if(!options || options.version !== false)
|
158
|
-
obj.version = require("../package.json").version;
|
159
|
-
if(!options || options.hash !== false)
|
160
|
-
obj.hash = this.hash;
|
161
|
-
if(!options || options.children !== false)
|
162
|
-
obj.children = jsons;
|
163
|
-
return obj;
|
164
|
-
};
|
165
|
-
|
166
|
-
MultiStats.prototype.toString = Stats.prototype.toString;
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
var Tapable = require("tapable");
|
6
|
+
var async = require("async");
|
7
|
+
var Stats = require("./Stats");
|
8
|
+
|
9
|
+
function MultiWatching(watchings) {
|
10
|
+
this.watchings = watchings;
|
11
|
+
}
|
12
|
+
|
13
|
+
MultiWatching.prototype.invalidate = function() {
|
14
|
+
this.watchings.forEach(function(watching) {
|
15
|
+
watching.invalidate();
|
16
|
+
});
|
17
|
+
};
|
18
|
+
|
19
|
+
MultiWatching.prototype.close = function(callback) {
|
20
|
+
async.forEach(this.watchings, function(watching, callback) {
|
21
|
+
watching.close(callback);
|
22
|
+
}, callback);
|
23
|
+
};
|
24
|
+
|
25
|
+
function MultiCompiler(compilers) {
|
26
|
+
Tapable.call(this);
|
27
|
+
if(!Array.isArray(compilers)) {
|
28
|
+
compilers = Object.keys(compilers).map(function(name) {
|
29
|
+
compilers[name].name = name;
|
30
|
+
return compilers[name];
|
31
|
+
});
|
32
|
+
}
|
33
|
+
this.compilers = compilers;
|
34
|
+
|
35
|
+
function delegateProperty(name) {
|
36
|
+
Object.defineProperty(this, name, {
|
37
|
+
configurable: false,
|
38
|
+
get: function() {
|
39
|
+
throw new Error("Cannot read " + name + " of a MultiCompiler");
|
40
|
+
},
|
41
|
+
set: function(value) {
|
42
|
+
this.compilers.forEach(function(compiler) {
|
43
|
+
compiler[name] = value;
|
44
|
+
});
|
45
|
+
}.bind(this)
|
46
|
+
});
|
47
|
+
}
|
48
|
+
delegateProperty.call(this, "outputFileSystem");
|
49
|
+
delegateProperty.call(this, "inputFileSystem");
|
50
|
+
|
51
|
+
Object.defineProperty(this, "outputPath", {
|
52
|
+
configurable: false,
|
53
|
+
get: function() {
|
54
|
+
var commonPath = compilers[0].outputPath;
|
55
|
+
for(var i = 1; i < compilers.length; i++) {
|
56
|
+
while(compilers[i].outputPath.indexOf(commonPath) !== 0 && /[\/\\]/.test(commonPath)) {
|
57
|
+
commonPath = commonPath.replace(/[\/\\][^\/\\]*$/, "");
|
58
|
+
}
|
59
|
+
}
|
60
|
+
if(!commonPath && compilers[0].outputPath[0] === "/") return "/";
|
61
|
+
return commonPath;
|
62
|
+
}
|
63
|
+
});
|
64
|
+
|
65
|
+
var doneCompilers = 0;
|
66
|
+
var compilerStats = [];
|
67
|
+
this.compilers.forEach(function(compiler, idx) {
|
68
|
+
var compilerDone = false;
|
69
|
+
compiler.plugin("done", function(stats) {
|
70
|
+
if(!compilerDone) {
|
71
|
+
compilerDone = true;
|
72
|
+
doneCompilers++;
|
73
|
+
}
|
74
|
+
compilerStats[idx] = stats;
|
75
|
+
if(doneCompilers === this.compilers.length) {
|
76
|
+
this.applyPlugins("done", new MultiStats(compilerStats));
|
77
|
+
}
|
78
|
+
}.bind(this));
|
79
|
+
compiler.plugin("invalid", function() {
|
80
|
+
if(compilerDone) {
|
81
|
+
compilerDone = false;
|
82
|
+
doneCompilers--;
|
83
|
+
}
|
84
|
+
this.applyPlugins("invalid");
|
85
|
+
}.bind(this));
|
86
|
+
}, this);
|
87
|
+
}
|
88
|
+
module.exports = MultiCompiler;
|
89
|
+
|
90
|
+
MultiCompiler.prototype = Object.create(Tapable.prototype);
|
91
|
+
MultiCompiler.prototype.constructor = MultiCompiler;
|
92
|
+
|
93
|
+
MultiCompiler.prototype.watch = function(watchDelay, handler) {
|
94
|
+
var watchings = this.compilers.map(function(compiler) {
|
95
|
+
return compiler.watch(watchDelay, handler);
|
96
|
+
});
|
97
|
+
return new MultiWatching(watchings);
|
98
|
+
};
|
99
|
+
|
100
|
+
MultiCompiler.prototype.run = function(callback) {
|
101
|
+
async.map(this.compilers, function(compiler, callback) {
|
102
|
+
compiler.run(callback);
|
103
|
+
}, function(err, stats) {
|
104
|
+
if(err) return callback(err);
|
105
|
+
callback(null, new MultiStats(stats));
|
106
|
+
});
|
107
|
+
};
|
108
|
+
|
109
|
+
MultiCompiler.prototype.purgeInputFileSystem = function() {
|
110
|
+
this.compilers.forEach(function(compiler) {
|
111
|
+
if(compiler.inputFileSystem && compiler.inputFileSystem.purge)
|
112
|
+
compiler.inputFileSystem.purge();
|
113
|
+
});
|
114
|
+
};
|
115
|
+
|
116
|
+
function MultiStats(stats) {
|
117
|
+
this.stats = stats;
|
118
|
+
this.hash = stats.map(function(stat) {
|
119
|
+
return stat.hash;
|
120
|
+
}).join("");
|
121
|
+
}
|
122
|
+
|
123
|
+
MultiStats.prototype.hasErrors = function() {
|
124
|
+
return this.stats.map(function(stat) {
|
125
|
+
return stat.hasErrors();
|
126
|
+
}).reduce(function(a, b) {
|
127
|
+
return a || b;
|
128
|
+
}, false);
|
129
|
+
};
|
130
|
+
|
131
|
+
MultiStats.prototype.hasWarnings = function() {
|
132
|
+
return this.stats.map(function(stat) {
|
133
|
+
return stat.hasWarnings();
|
134
|
+
}).reduce(function(a, b) {
|
135
|
+
return a || b;
|
136
|
+
}, false);
|
137
|
+
};
|
138
|
+
|
139
|
+
MultiStats.prototype.toJson = function(options, forToString) {
|
140
|
+
var jsons = this.stats.map(function(stat) {
|
141
|
+
var obj = stat.toJson(options, forToString);
|
142
|
+
obj.name = stat.compilation && stat.compilation.name;
|
143
|
+
return obj;
|
144
|
+
});
|
145
|
+
var obj = {
|
146
|
+
errors: jsons.reduce(function(arr, j) {
|
147
|
+
return arr.concat(j.errors.map(function(msg) {
|
148
|
+
return "(" + j.name + ") " + msg;
|
149
|
+
}));
|
150
|
+
}, []),
|
151
|
+
warnings: jsons.reduce(function(arr, j) {
|
152
|
+
return arr.concat(j.warnings.map(function(msg) {
|
153
|
+
return "(" + j.name + ") " + msg;
|
154
|
+
}));
|
155
|
+
}, [])
|
156
|
+
};
|
157
|
+
if(!options || options.version !== false)
|
158
|
+
obj.version = require("../package.json").version;
|
159
|
+
if(!options || options.hash !== false)
|
160
|
+
obj.hash = this.hash;
|
161
|
+
if(!options || options.children !== false)
|
162
|
+
obj.children = jsons;
|
163
|
+
return obj;
|
164
|
+
};
|
165
|
+
|
166
|
+
MultiStats.prototype.toString = Stats.prototype.toString;
|
package/lib/MultiEntryPlugin.js
CHANGED
@@ -1,31 +1,31 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
var MultiEntryDependency = require("./dependencies/MultiEntryDependency");
|
6
|
-
var SingleEntryDependency = require("./dependencies/SingleEntryDependency");
|
7
|
-
var MultiModuleFactory = require("./MultiModuleFactory");
|
8
|
-
|
9
|
-
function MultiEntryPlugin(context, entries, name) {
|
10
|
-
this.context = context;
|
11
|
-
this.entries = entries;
|
12
|
-
this.name = name;
|
13
|
-
}
|
14
|
-
module.exports = MultiEntryPlugin;
|
15
|
-
MultiEntryPlugin.prototype.apply = function(compiler) {
|
16
|
-
compiler.plugin("compilation", function(compilation, params) {
|
17
|
-
var multiModuleFactory = new MultiModuleFactory();
|
18
|
-
var normalModuleFactory = params.normalModuleFactory;
|
19
|
-
|
20
|
-
compilation.dependencyFactories.set(MultiEntryDependency, multiModuleFactory);
|
21
|
-
|
22
|
-
compilation.dependencyFactories.set(SingleEntryDependency, normalModuleFactory);
|
23
|
-
});
|
24
|
-
compiler.plugin("make", function(compilation, callback) {
|
25
|
-
compilation.addEntry(this.context, new MultiEntryDependency(this.entries.map(function(e, idx) {
|
26
|
-
var dep = new SingleEntryDependency(e);
|
27
|
-
dep.loc = this.name + ":" + (100000 + idx);
|
28
|
-
return dep;
|
29
|
-
}, this), this.name), this.name, callback);
|
30
|
-
}.bind(this));
|
31
|
-
};
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
var MultiEntryDependency = require("./dependencies/MultiEntryDependency");
|
6
|
+
var SingleEntryDependency = require("./dependencies/SingleEntryDependency");
|
7
|
+
var MultiModuleFactory = require("./MultiModuleFactory");
|
8
|
+
|
9
|
+
function MultiEntryPlugin(context, entries, name) {
|
10
|
+
this.context = context;
|
11
|
+
this.entries = entries;
|
12
|
+
this.name = name;
|
13
|
+
}
|
14
|
+
module.exports = MultiEntryPlugin;
|
15
|
+
MultiEntryPlugin.prototype.apply = function(compiler) {
|
16
|
+
compiler.plugin("compilation", function(compilation, params) {
|
17
|
+
var multiModuleFactory = new MultiModuleFactory();
|
18
|
+
var normalModuleFactory = params.normalModuleFactory;
|
19
|
+
|
20
|
+
compilation.dependencyFactories.set(MultiEntryDependency, multiModuleFactory);
|
21
|
+
|
22
|
+
compilation.dependencyFactories.set(SingleEntryDependency, normalModuleFactory);
|
23
|
+
});
|
24
|
+
compiler.plugin("make", function(compilation, callback) {
|
25
|
+
compilation.addEntry(this.context, new MultiEntryDependency(this.entries.map(function(e, idx) {
|
26
|
+
var dep = new SingleEntryDependency(e);
|
27
|
+
dep.loc = this.name + ":" + (100000 + idx);
|
28
|
+
return dep;
|
29
|
+
}, this), this.name), this.name, callback);
|
30
|
+
}.bind(this));
|
31
|
+
};
|