webpack 3.5.2 → 3.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +567 -567
- package/bin/config-yargs.js +1 -1
- package/bin/convert-argv.js +4 -4
- package/lib/Compilation.js +178 -144
- package/lib/Compiler.js +17 -17
- package/lib/ContextModuleFactory.js +6 -6
- package/lib/HotModuleReplacement.runtime.js +602 -594
- package/lib/Module.js +250 -248
- package/lib/NormalModule.js +556 -555
- package/lib/OptionsDefaulter.js +73 -71
- package/lib/Parser.js +10 -10
- package/lib/SourceMapDevToolPlugin.js +209 -207
- package/lib/Template.js +176 -166
- package/lib/UmdMainTemplatePlugin.js +6 -6
- package/lib/WebpackOptionsDefaulter.js +129 -115
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +285 -286
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +124 -121
- package/lib/dependencies/HarmonyModulesHelpers.js +85 -85
- package/lib/optimize/ConcatenatedModule.js +814 -807
- package/lib/optimize/EnsureChunkConditionsPlugin.js +1 -0
- package/lib/optimize/ModuleConcatenationPlugin.js +9 -0
- package/lib/util/Semaphore.js +32 -0
- package/lib/webpack.js +119 -118
- package/package.json +1 -1
- package/schemas/webpackOptionsSchema.json +5 -0
@@ -5,6 +5,8 @@
|
|
5
5
|
"use strict";
|
6
6
|
|
7
7
|
const HarmonyImportDependency = require("../dependencies/HarmonyImportDependency");
|
8
|
+
const ModuleHotAcceptDependency = require("../dependencies/ModuleHotAcceptDependency");
|
9
|
+
const ModuleHotDeclineDependency = require("../dependencies/ModuleHotDeclineDependency");
|
8
10
|
const ConcatenatedModule = require("./ConcatenatedModule");
|
9
11
|
const HarmonyExportImportedSpecifierDependency = require("../dependencies/HarmonyExportImportedSpecifierDependency");
|
10
12
|
const HarmonyCompatibilityDependency = require("../dependencies/HarmonyCompatibilityDependency");
|
@@ -67,6 +69,12 @@ class ModuleConcatenationPlugin {
|
|
67
69
|
continue;
|
68
70
|
}
|
69
71
|
|
72
|
+
// Hot Module Replacement need it's own module to work correctly
|
73
|
+
if(module.dependencies.some(dep => dep instanceof ModuleHotAcceptDependency || dep instanceof ModuleHotDeclineDependency)) {
|
74
|
+
setBailoutReason(module, "Module uses Hot Module Replacement");
|
75
|
+
continue;
|
76
|
+
}
|
77
|
+
|
70
78
|
relevantModules.push(module);
|
71
79
|
|
72
80
|
// Module must not be the entry points
|
@@ -155,6 +163,7 @@ class ModuleConcatenationPlugin {
|
|
155
163
|
}
|
156
164
|
chunks.forEach(chunk => {
|
157
165
|
chunk.addModule(newModule);
|
166
|
+
newModule.addChunk(chunk);
|
158
167
|
if(chunk.entryModule === concatConfiguration.rootModule)
|
159
168
|
chunk.entryModule = newModule;
|
160
169
|
});
|
@@ -0,0 +1,32 @@
|
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
"use strict";
|
6
|
+
|
7
|
+
class Semaphore {
|
8
|
+
constructor(available) {
|
9
|
+
this.available = available;
|
10
|
+
this.waiters = [];
|
11
|
+
}
|
12
|
+
|
13
|
+
acquire(callback) {
|
14
|
+
if(this.available > 0) {
|
15
|
+
this.available--;
|
16
|
+
callback();
|
17
|
+
} else {
|
18
|
+
this.waiters.push(callback);
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
release() {
|
23
|
+
if(this.waiters.length > 0) {
|
24
|
+
const callback = this.waiters.pop();
|
25
|
+
process.nextTick(callback);
|
26
|
+
} else {
|
27
|
+
this.available++;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
module.exports = Semaphore;
|
package/lib/webpack.js
CHANGED
@@ -1,118 +1,119 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
"use strict";
|
6
|
-
|
7
|
-
const Compiler = require("./Compiler");
|
8
|
-
const MultiCompiler = require("./MultiCompiler");
|
9
|
-
const NodeEnvironmentPlugin = require("./node/NodeEnvironmentPlugin");
|
10
|
-
const WebpackOptionsApply = require("./WebpackOptionsApply");
|
11
|
-
const WebpackOptionsDefaulter = require("./WebpackOptionsDefaulter");
|
12
|
-
const validateSchema = require("./validateSchema");
|
13
|
-
const WebpackOptionsValidationError = require("./WebpackOptionsValidationError");
|
14
|
-
const webpackOptionsSchema = require("../schemas/webpackOptionsSchema.json");
|
15
|
-
|
16
|
-
function webpack(options, callback) {
|
17
|
-
const webpackOptionsValidationErrors = validateSchema(webpackOptionsSchema, options);
|
18
|
-
if(webpackOptionsValidationErrors.length) {
|
19
|
-
throw new WebpackOptionsValidationError(webpackOptionsValidationErrors);
|
20
|
-
}
|
21
|
-
let compiler;
|
22
|
-
if(Array.isArray(options)) {
|
23
|
-
compiler = new MultiCompiler(options.map(options => webpack(options)));
|
24
|
-
} else if(typeof options === "object") {
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
compiler
|
29
|
-
compiler.
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
compiler.applyPlugins("
|
36
|
-
compiler.
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
if(
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
webpack.
|
54
|
-
webpack.
|
55
|
-
webpack.
|
56
|
-
webpack.
|
57
|
-
webpack.
|
58
|
-
webpack.
|
59
|
-
webpack.
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
}
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
"
|
74
|
-
"
|
75
|
-
"
|
76
|
-
"
|
77
|
-
"
|
78
|
-
"
|
79
|
-
"
|
80
|
-
"
|
81
|
-
"
|
82
|
-
"
|
83
|
-
"
|
84
|
-
"
|
85
|
-
"
|
86
|
-
"
|
87
|
-
"
|
88
|
-
"
|
89
|
-
"
|
90
|
-
"
|
91
|
-
"
|
92
|
-
"
|
93
|
-
"
|
94
|
-
"
|
95
|
-
"
|
96
|
-
"
|
97
|
-
"
|
98
|
-
"
|
99
|
-
"
|
100
|
-
"
|
101
|
-
"
|
102
|
-
"
|
103
|
-
"
|
104
|
-
"
|
105
|
-
"
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
"
|
110
|
-
"
|
111
|
-
"
|
112
|
-
"
|
113
|
-
"
|
114
|
-
"
|
115
|
-
"
|
116
|
-
"
|
117
|
-
"
|
118
|
-
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
"use strict";
|
6
|
+
|
7
|
+
const Compiler = require("./Compiler");
|
8
|
+
const MultiCompiler = require("./MultiCompiler");
|
9
|
+
const NodeEnvironmentPlugin = require("./node/NodeEnvironmentPlugin");
|
10
|
+
const WebpackOptionsApply = require("./WebpackOptionsApply");
|
11
|
+
const WebpackOptionsDefaulter = require("./WebpackOptionsDefaulter");
|
12
|
+
const validateSchema = require("./validateSchema");
|
13
|
+
const WebpackOptionsValidationError = require("./WebpackOptionsValidationError");
|
14
|
+
const webpackOptionsSchema = require("../schemas/webpackOptionsSchema.json");
|
15
|
+
|
16
|
+
function webpack(options, callback) {
|
17
|
+
const webpackOptionsValidationErrors = validateSchema(webpackOptionsSchema, options);
|
18
|
+
if(webpackOptionsValidationErrors.length) {
|
19
|
+
throw new WebpackOptionsValidationError(webpackOptionsValidationErrors);
|
20
|
+
}
|
21
|
+
let compiler;
|
22
|
+
if(Array.isArray(options)) {
|
23
|
+
compiler = new MultiCompiler(options.map(options => webpack(options)));
|
24
|
+
} else if(typeof options === "object") {
|
25
|
+
// TODO webpack 4: process returns options
|
26
|
+
new WebpackOptionsDefaulter().process(options);
|
27
|
+
|
28
|
+
compiler = new Compiler();
|
29
|
+
compiler.context = options.context;
|
30
|
+
compiler.options = options;
|
31
|
+
new NodeEnvironmentPlugin().apply(compiler);
|
32
|
+
if(options.plugins && Array.isArray(options.plugins)) {
|
33
|
+
compiler.apply.apply(compiler, options.plugins);
|
34
|
+
}
|
35
|
+
compiler.applyPlugins("environment");
|
36
|
+
compiler.applyPlugins("after-environment");
|
37
|
+
compiler.options = new WebpackOptionsApply().process(options, compiler);
|
38
|
+
} else {
|
39
|
+
throw new Error("Invalid argument: options");
|
40
|
+
}
|
41
|
+
if(callback) {
|
42
|
+
if(typeof callback !== "function") throw new Error("Invalid argument: callback");
|
43
|
+
if(options.watch === true || (Array.isArray(options) && options.some(o => o.watch))) {
|
44
|
+
const watchOptions = Array.isArray(options) ? options.map(o => o.watchOptions || {}) : (options.watchOptions || {});
|
45
|
+
return compiler.watch(watchOptions, callback);
|
46
|
+
}
|
47
|
+
compiler.run(callback);
|
48
|
+
}
|
49
|
+
return compiler;
|
50
|
+
}
|
51
|
+
exports = module.exports = webpack;
|
52
|
+
|
53
|
+
webpack.WebpackOptionsDefaulter = WebpackOptionsDefaulter;
|
54
|
+
webpack.WebpackOptionsApply = WebpackOptionsApply;
|
55
|
+
webpack.Compiler = Compiler;
|
56
|
+
webpack.MultiCompiler = MultiCompiler;
|
57
|
+
webpack.NodeEnvironmentPlugin = NodeEnvironmentPlugin;
|
58
|
+
webpack.validate = validateSchema.bind(this, webpackOptionsSchema);
|
59
|
+
webpack.validateSchema = validateSchema;
|
60
|
+
webpack.WebpackOptionsValidationError = WebpackOptionsValidationError;
|
61
|
+
|
62
|
+
function exportPlugins(obj, mappings) {
|
63
|
+
Object.keys(mappings).forEach(name => {
|
64
|
+
Object.defineProperty(obj, name, {
|
65
|
+
configurable: false,
|
66
|
+
enumerable: true,
|
67
|
+
get: mappings[name]
|
68
|
+
});
|
69
|
+
});
|
70
|
+
}
|
71
|
+
|
72
|
+
exportPlugins(exports, {
|
73
|
+
"DefinePlugin": () => require("./DefinePlugin"),
|
74
|
+
"NormalModuleReplacementPlugin": () => require("./NormalModuleReplacementPlugin"),
|
75
|
+
"ContextReplacementPlugin": () => require("./ContextReplacementPlugin"),
|
76
|
+
"IgnorePlugin": () => require("./IgnorePlugin"),
|
77
|
+
"WatchIgnorePlugin": () => require("./WatchIgnorePlugin"),
|
78
|
+
"BannerPlugin": () => require("./BannerPlugin"),
|
79
|
+
"PrefetchPlugin": () => require("./PrefetchPlugin"),
|
80
|
+
"AutomaticPrefetchPlugin": () => require("./AutomaticPrefetchPlugin"),
|
81
|
+
"ProvidePlugin": () => require("./ProvidePlugin"),
|
82
|
+
"HotModuleReplacementPlugin": () => require("./HotModuleReplacementPlugin"),
|
83
|
+
"SourceMapDevToolPlugin": () => require("./SourceMapDevToolPlugin"),
|
84
|
+
"EvalSourceMapDevToolPlugin": () => require("./EvalSourceMapDevToolPlugin"),
|
85
|
+
"EvalDevToolModulePlugin": () => require("./EvalDevToolModulePlugin"),
|
86
|
+
"CachePlugin": () => require("./CachePlugin"),
|
87
|
+
"ExtendedAPIPlugin": () => require("./ExtendedAPIPlugin"),
|
88
|
+
"ExternalsPlugin": () => require("./ExternalsPlugin"),
|
89
|
+
"JsonpTemplatePlugin": () => require("./JsonpTemplatePlugin"),
|
90
|
+
"LibraryTemplatePlugin": () => require("./LibraryTemplatePlugin"),
|
91
|
+
"LoaderTargetPlugin": () => require("./LoaderTargetPlugin"),
|
92
|
+
"MemoryOutputFileSystem": () => require("./MemoryOutputFileSystem"),
|
93
|
+
"ProgressPlugin": () => require("./ProgressPlugin"),
|
94
|
+
"SetVarMainTemplatePlugin": () => require("./SetVarMainTemplatePlugin"),
|
95
|
+
"UmdMainTemplatePlugin": () => require("./UmdMainTemplatePlugin"),
|
96
|
+
"NoErrorsPlugin": () => require("./NoErrorsPlugin"),
|
97
|
+
"NoEmitOnErrorsPlugin": () => require("./NoEmitOnErrorsPlugin"),
|
98
|
+
"NewWatchingPlugin": () => require("./NewWatchingPlugin"),
|
99
|
+
"EnvironmentPlugin": () => require("./EnvironmentPlugin"),
|
100
|
+
"DllPlugin": () => require("./DllPlugin"),
|
101
|
+
"DllReferencePlugin": () => require("./DllReferencePlugin"),
|
102
|
+
"LoaderOptionsPlugin": () => require("./LoaderOptionsPlugin"),
|
103
|
+
"NamedModulesPlugin": () => require("./NamedModulesPlugin"),
|
104
|
+
"NamedChunksPlugin": () => require("./NamedChunksPlugin"),
|
105
|
+
"HashedModuleIdsPlugin": () => require("./HashedModuleIdsPlugin"),
|
106
|
+
"ModuleFilenameHelpers": () => require("./ModuleFilenameHelpers")
|
107
|
+
});
|
108
|
+
exportPlugins(exports.optimize = {}, {
|
109
|
+
"AggressiveMergingPlugin": () => require("./optimize/AggressiveMergingPlugin"),
|
110
|
+
"AggressiveSplittingPlugin": () => require("./optimize/AggressiveSplittingPlugin"),
|
111
|
+
"CommonsChunkPlugin": () => require("./optimize/CommonsChunkPlugin"),
|
112
|
+
"ChunkModuleIdRangePlugin": () => require("./optimize/ChunkModuleIdRangePlugin"),
|
113
|
+
"DedupePlugin": () => require("./optimize/DedupePlugin"),
|
114
|
+
"LimitChunkCountPlugin": () => require("./optimize/LimitChunkCountPlugin"),
|
115
|
+
"MinChunkSizePlugin": () => require("./optimize/MinChunkSizePlugin"),
|
116
|
+
"ModuleConcatenationPlugin": () => require("./optimize/ModuleConcatenationPlugin"),
|
117
|
+
"OccurrenceOrderPlugin": () => require("./optimize/OccurrenceOrderPlugin"),
|
118
|
+
"UglifyJsPlugin": () => require("./optimize/UglifyJsPlugin")
|
119
|
+
});
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "3.5.
|
3
|
+
"version": "3.5.6",
|
4
4
|
"author": "Tobias Koppers @sokra",
|
5
5
|
"description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
|
6
6
|
"dependencies": {
|
@@ -900,6 +900,11 @@
|
|
900
900
|
"output": {
|
901
901
|
"$ref": "#/definitions/output"
|
902
902
|
},
|
903
|
+
"parallelism": {
|
904
|
+
"description": "The number of parallel processed modules in the compilation.",
|
905
|
+
"minimum": 1,
|
906
|
+
"type": "number"
|
907
|
+
},
|
903
908
|
"performance": {
|
904
909
|
"description": "Configuration for web performance recommendations.",
|
905
910
|
"anyOf": [
|