webpack 2.3.3 → 2.5.1
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 +148 -133
- package/lib/APIPlugin.js +0 -6
- package/lib/AsyncDependenciesBlock.js +1 -1
- package/lib/AutomaticPrefetchPlugin.js +2 -2
- package/lib/BannerPlugin.js +30 -8
- package/lib/CachePlugin.js +2 -2
- package/lib/CaseSensitiveModulesWarning.js +6 -3
- package/lib/ChunkRenderError.js +3 -1
- package/lib/ChunkTemplate.js +2 -2
- package/lib/Compilation.js +17 -17
- package/lib/Compiler.js +30 -25
- package/lib/ContextModule.js +4 -3
- package/lib/ContextModuleFactory.js +5 -5
- package/lib/DelegatedModule.js +69 -63
- package/lib/DependenciesBlock.js +65 -59
- package/lib/Dependency.js +1 -0
- package/lib/EntryModuleNotFoundError.js +16 -10
- package/lib/ExtendedAPIPlugin.js +7 -2
- package/lib/ExternalModule.js +1 -1
- package/lib/ExternalModuleFactoryPlugin.js +26 -23
- package/lib/FlagDependencyUsagePlugin.js +63 -75
- package/lib/HotModuleReplacement.runtime.js +25 -27
- package/lib/HotModuleReplacementPlugin.js +3 -5
- package/lib/IgnorePlugin.js +48 -17
- package/lib/JsonpChunkTemplatePlugin.js +24 -24
- package/lib/JsonpMainTemplatePlugin.js +182 -182
- package/lib/LibManifestPlugin.js +51 -46
- package/lib/MainTemplate.js +17 -18
- package/lib/Module.js +158 -160
- package/lib/ModuleBuildError.js +4 -2
- package/lib/ModuleDependencyError.js +2 -1
- package/lib/ModuleDependencyWarning.js +2 -1
- package/lib/ModuleError.js +2 -2
- package/lib/ModuleFilenameHelpers.js +27 -27
- package/lib/ModuleNotFoundError.js +3 -1
- package/lib/ModuleParseError.js +6 -4
- package/lib/ModuleWarning.js +2 -2
- package/lib/MultiCompiler.js +3 -4
- package/lib/MultiStats.js +3 -3
- package/lib/MultiWatching.js +2 -2
- package/lib/NamedChunksPlugin.js +30 -0
- package/lib/NodeStuffPlugin.js +80 -79
- package/lib/NormalModule.js +7 -3
- package/lib/NormalModuleFactory.js +244 -240
- package/lib/Parser.js +1256 -1079
- package/lib/ProgressPlugin.js +2 -2
- package/lib/RawModule.js +1 -1
- package/lib/RecordIdsPlugin.js +5 -9
- package/lib/SetVarMainTemplatePlugin.js +1 -1
- package/lib/SourceMapDevToolPlugin.js +153 -157
- package/lib/Stats.js +34 -6
- package/lib/TemplatedPathPlugin.js +1 -0
- package/lib/UnsupportedFeatureWarning.js +2 -1
- package/lib/WebpackError.js +11 -0
- package/lib/WebpackOptionsApply.js +4 -4
- package/lib/WebpackOptionsValidationError.js +2 -3
- package/lib/dependencies/AMDDefineDependency.js +10 -6
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +8 -1
- package/lib/dependencies/AMDPlugin.js +3 -3
- package/lib/dependencies/ContextDependencyHelpers.js +19 -16
- package/lib/dependencies/CriticalDependencyWarning.js +4 -1
- package/lib/dependencies/DepBlockHelpers.js +3 -3
- package/lib/dependencies/HarmonyCompatibilityDependency.js +1 -1
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +3 -3
- package/lib/dependencies/ImportContextDependency.js +2 -1
- package/lib/dependencies/ImportDependenciesBlock.js +2 -2
- package/lib/dependencies/ImportParserPlugin.js +16 -2
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +11 -3
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +42 -13
- package/lib/dependencies/RequireEnsureDependency.js +9 -2
- package/lib/formatLocation.js +44 -27
- package/lib/optimize/AggressiveSplittingPlugin.js +10 -17
- package/lib/optimize/CommonsChunkPlugin.js +2 -2
- package/lib/performance/AssetsOverSizeLimitWarning.js +4 -1
- package/lib/performance/EntrypointsOverSizeLimitWarning.js +5 -1
- package/lib/performance/NoAsyncChunksWarning.js +5 -1
- package/lib/removeAndDo.js +6 -4
- package/lib/util/identifier.js +16 -0
- package/lib/webpack.js +2 -1
- package/package.json +7 -4
- package/schemas/webpackOptionsSchema.json +35 -0
package/lib/Module.js
CHANGED
@@ -2,189 +2,187 @@
|
|
2
2
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
3
|
Author Tobias Koppers @sokra
|
4
4
|
*/
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
function
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
this.lastId = -1;
|
17
|
-
this.id = null;
|
18
|
-
this.portableId = null;
|
19
|
-
this.index = null;
|
20
|
-
this.index2 = null;
|
21
|
-
this.depth = null;
|
22
|
-
this.used = null;
|
23
|
-
this.usedExports = null;
|
24
|
-
this.providedExports = null;
|
25
|
-
this.chunks = [];
|
26
|
-
this.warnings = [];
|
27
|
-
this.dependenciesWarnings = [];
|
28
|
-
this.errors = [];
|
29
|
-
this.dependenciesErrors = [];
|
30
|
-
this.strict = false;
|
31
|
-
this.meta = {};
|
5
|
+
"use strict";
|
6
|
+
|
7
|
+
const DependenciesBlock = require("./DependenciesBlock");
|
8
|
+
const ModuleReason = require("./ModuleReason");
|
9
|
+
const Template = require("./Template");
|
10
|
+
|
11
|
+
function addToSet(set, items) {
|
12
|
+
for(let item of items) {
|
13
|
+
if(set.indexOf(item) < 0)
|
14
|
+
set.push(item);
|
15
|
+
}
|
32
16
|
}
|
33
|
-
module.exports = Module;
|
34
17
|
|
35
|
-
|
36
|
-
|
18
|
+
function byId(a, b) {
|
19
|
+
return a.id - b.id;
|
20
|
+
}
|
37
21
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
22
|
+
let debugId = 1000;
|
23
|
+
|
24
|
+
class Module extends DependenciesBlock {
|
25
|
+
constructor() {
|
26
|
+
super();
|
27
|
+
this.context = null;
|
28
|
+
this.reasons = [];
|
29
|
+
this.debugId = debugId++;
|
30
|
+
this.lastId = -1;
|
31
|
+
this.id = null;
|
32
|
+
this.portableId = null;
|
33
|
+
this.index = null;
|
34
|
+
this.index2 = null;
|
35
|
+
this.depth = null;
|
36
|
+
this.used = null;
|
37
|
+
this.usedExports = null;
|
38
|
+
this.providedExports = null;
|
39
|
+
this.chunks = [];
|
40
|
+
this.warnings = [];
|
41
|
+
this.dependenciesWarnings = [];
|
42
|
+
this.errors = [];
|
43
|
+
this.dependenciesErrors = [];
|
44
|
+
this.strict = false;
|
45
|
+
this.meta = {};
|
45
46
|
}
|
46
|
-
});
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
};
|
61
|
-
|
62
|
-
Module.prototype.unseal = function() {
|
63
|
-
this.lastId = this.id;
|
64
|
-
this.id = null;
|
65
|
-
this.index = null;
|
66
|
-
this.index2 = null;
|
67
|
-
this.depth = null;
|
68
|
-
this.chunks.length = 0;
|
69
|
-
DependenciesBlock.prototype.unseal.call(this);
|
70
|
-
};
|
71
|
-
|
72
|
-
Module.prototype.addChunk = function(chunk) {
|
73
|
-
var idx = this.chunks.indexOf(chunk);
|
74
|
-
if(idx < 0)
|
75
|
-
this.chunks.push(chunk);
|
76
|
-
};
|
77
|
-
|
78
|
-
Module.prototype.removeChunk = function(chunk) {
|
79
|
-
var idx = this.chunks.indexOf(chunk);
|
80
|
-
if(idx >= 0) {
|
81
|
-
this.chunks.splice(idx, 1);
|
82
|
-
chunk.removeModule(this);
|
83
|
-
return true;
|
48
|
+
disconnect() {
|
49
|
+
this.reasons.length = 0;
|
50
|
+
this.lastId = this.id;
|
51
|
+
this.id = null;
|
52
|
+
this.index = null;
|
53
|
+
this.index2 = null;
|
54
|
+
this.depth = null;
|
55
|
+
this.used = null;
|
56
|
+
this.usedExports = null;
|
57
|
+
this.providedExports = null;
|
58
|
+
this.chunks.length = 0;
|
59
|
+
super.disconnect();
|
84
60
|
}
|
85
|
-
return false;
|
86
|
-
};
|
87
61
|
|
88
|
-
|
89
|
-
|
90
|
-
|
62
|
+
unseal() {
|
63
|
+
this.lastId = this.id;
|
64
|
+
this.id = null;
|
65
|
+
this.index = null;
|
66
|
+
this.index2 = null;
|
67
|
+
this.depth = null;
|
68
|
+
this.chunks.length = 0;
|
69
|
+
super.unseal();
|
70
|
+
}
|
91
71
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
72
|
+
addChunk(chunk) {
|
73
|
+
let idx = this.chunks.indexOf(chunk);
|
74
|
+
if(idx < 0)
|
75
|
+
this.chunks.push(chunk);
|
76
|
+
}
|
77
|
+
|
78
|
+
removeChunk(chunk) {
|
79
|
+
let idx = this.chunks.indexOf(chunk);
|
80
|
+
if(idx >= 0) {
|
81
|
+
this.chunks.splice(idx, 1);
|
82
|
+
chunk.removeModule(this);
|
97
83
|
return true;
|
98
84
|
}
|
85
|
+
return false;
|
99
86
|
}
|
100
|
-
return false;
|
101
|
-
};
|
102
87
|
|
103
|
-
|
104
|
-
|
105
|
-
var r = this.reasons[i];
|
106
|
-
if(r.chunks) {
|
107
|
-
if(r.chunks.indexOf(chunk) >= 0)
|
108
|
-
return true;
|
109
|
-
} else if(r.module.chunks.indexOf(chunk) >= 0)
|
110
|
-
return true;
|
88
|
+
addReason(module, dependency) {
|
89
|
+
this.reasons.push(new ModuleReason(module, dependency));
|
111
90
|
}
|
112
|
-
return false;
|
113
|
-
};
|
114
91
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
92
|
+
removeReason(module, dependency) {
|
93
|
+
for(let i = 0; i < this.reasons.length; i++) {
|
94
|
+
let r = this.reasons[i];
|
95
|
+
if(r.module === module && r.dependency === dependency) {
|
96
|
+
this.reasons.splice(i, 1);
|
97
|
+
return true;
|
98
|
+
}
|
99
|
+
}
|
100
|
+
return false;
|
101
|
+
}
|
121
102
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
103
|
+
hasReasonForChunk(chunk) {
|
104
|
+
for(let r of this.reasons) {
|
105
|
+
if(r.chunks) {
|
106
|
+
if(r.chunks.indexOf(chunk) >= 0)
|
107
|
+
return true;
|
108
|
+
} else if(r.module.chunks.indexOf(chunk) >= 0)
|
109
|
+
return true;
|
128
110
|
}
|
129
|
-
|
130
|
-
|
131
|
-
return arr;
|
132
|
-
}, []);
|
133
|
-
});
|
134
|
-
};
|
135
|
-
|
136
|
-
Module.prototype.isUsed = function(exportName) {
|
137
|
-
if(this.used === null) return exportName;
|
138
|
-
if(!exportName) return this.used ? true : false;
|
139
|
-
if(!this.used) return false;
|
140
|
-
if(!this.usedExports) return false;
|
141
|
-
if(this.usedExports === true) return exportName;
|
142
|
-
var idx = this.usedExports.indexOf(exportName);
|
143
|
-
if(idx < 0) return false;
|
144
|
-
if(this.isProvided(exportName))
|
145
|
-
return Template.numberToIdentifer(idx);
|
146
|
-
return exportName;
|
147
|
-
};
|
148
|
-
|
149
|
-
Module.prototype.isProvided = function(exportName) {
|
150
|
-
if(!Array.isArray(this.providedExports))
|
151
|
-
return null;
|
152
|
-
return this.providedExports.indexOf(exportName) >= 0;
|
153
|
-
};
|
154
|
-
|
155
|
-
Module.prototype.toString = function() {
|
156
|
-
return "Module[" + (this.id || this.debugId) + "]";
|
157
|
-
};
|
158
|
-
|
159
|
-
Module.prototype.needRebuild = function(fileTimestamps, contextTimestamps) {
|
160
|
-
return true;
|
161
|
-
};
|
162
|
-
|
163
|
-
Module.prototype.updateHash = function(hash) {
|
164
|
-
hash.update(this.id + "" + this.used);
|
165
|
-
hash.update(JSON.stringify(this.usedExports));
|
166
|
-
DependenciesBlock.prototype.updateHash.call(this, hash);
|
167
|
-
};
|
111
|
+
return false;
|
112
|
+
}
|
168
113
|
|
169
|
-
|
170
|
-
|
171
|
-
|
114
|
+
rewriteChunkInReasons(oldChunk, newChunks) {
|
115
|
+
this.reasons.forEach(r => {
|
116
|
+
if(!r.chunks) {
|
117
|
+
if(r.module.chunks.indexOf(oldChunk) < 0)
|
118
|
+
return;
|
119
|
+
r.chunks = r.module.chunks;
|
120
|
+
}
|
121
|
+
r.chunks = r.chunks.reduce((arr, c) => {
|
122
|
+
addToSet(arr, c !== oldChunk ? [c] : newChunks);
|
123
|
+
return arr;
|
124
|
+
}, []);
|
125
|
+
});
|
126
|
+
}
|
172
127
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
128
|
+
isUsed(exportName) {
|
129
|
+
if(this.used === null) return exportName;
|
130
|
+
if(!exportName) return !!this.used;
|
131
|
+
if(!this.used) return false;
|
132
|
+
if(!this.usedExports) return false;
|
133
|
+
if(this.usedExports === true) return exportName;
|
134
|
+
let idx = this.usedExports.indexOf(exportName);
|
135
|
+
if(idx < 0) return false;
|
136
|
+
if(this.isProvided(exportName))
|
137
|
+
return Template.numberToIdentifer(idx);
|
138
|
+
return exportName;
|
139
|
+
}
|
180
140
|
|
181
|
-
|
182
|
-
|
183
|
-
|
141
|
+
isProvided(exportName) {
|
142
|
+
if(!Array.isArray(this.providedExports))
|
143
|
+
return null;
|
144
|
+
return this.providedExports.indexOf(exportName) >= 0;
|
145
|
+
}
|
146
|
+
|
147
|
+
toString() {
|
148
|
+
return `Module[${this.id || this.debugId}]`;
|
149
|
+
}
|
150
|
+
|
151
|
+
needRebuild(fileTimestamps, contextTimestamps) {
|
152
|
+
return true;
|
153
|
+
}
|
154
|
+
|
155
|
+
updateHash(hash) {
|
156
|
+
hash.update(this.id + "" + this.used);
|
157
|
+
hash.update(JSON.stringify(this.usedExports));
|
158
|
+
super.updateHash(hash);
|
159
|
+
}
|
184
160
|
|
161
|
+
sortItems() {
|
162
|
+
super.sortItems();
|
163
|
+
this.chunks.sort(byId);
|
164
|
+
this.reasons.sort((a, b) => byId(a.module, b.module));
|
165
|
+
}
|
166
|
+
|
167
|
+
unbuild() {
|
168
|
+
this.disconnect();
|
169
|
+
}
|
170
|
+
}
|
171
|
+
|
172
|
+
Object.defineProperty(Module.prototype, "entry", {
|
173
|
+
configurable: false,
|
174
|
+
get() {
|
175
|
+
throw new Error("Module.entry was removed. Use Chunk.entryModule");
|
176
|
+
},
|
177
|
+
set() {
|
178
|
+
throw new Error("Module.entry was removed. Use Chunk.entryModule");
|
179
|
+
}
|
180
|
+
});
|
185
181
|
Module.prototype.identifier = null;
|
186
182
|
Module.prototype.readableIdentifier = null;
|
187
183
|
Module.prototype.build = null;
|
188
184
|
Module.prototype.source = null;
|
189
185
|
Module.prototype.size = null;
|
190
186
|
Module.prototype.nameForCondition = null;
|
187
|
+
|
188
|
+
module.exports = Module;
|
package/lib/ModuleBuildError.js
CHANGED
@@ -4,12 +4,13 @@
|
|
4
4
|
*/
|
5
5
|
"use strict";
|
6
6
|
|
7
|
+
const WebpackError = require("./WebpackError");
|
7
8
|
const cutOffLoaderExecution = require("./ErrorHelpers").cutOffLoaderExecution;
|
8
9
|
|
9
|
-
class ModuleBuildError extends
|
10
|
-
|
10
|
+
class ModuleBuildError extends WebpackError {
|
11
11
|
constructor(module, err) {
|
12
12
|
super();
|
13
|
+
|
13
14
|
this.name = "ModuleBuildError";
|
14
15
|
this.message = "Module build failed: ";
|
15
16
|
if(err !== null && typeof err === "object") {
|
@@ -33,6 +34,7 @@ class ModuleBuildError extends Error {
|
|
33
34
|
}
|
34
35
|
this.module = module;
|
35
36
|
this.error = err;
|
37
|
+
|
36
38
|
Error.captureStackTrace(this, this.constructor);
|
37
39
|
}
|
38
40
|
}
|
@@ -4,9 +4,10 @@
|
|
4
4
|
*/
|
5
5
|
"use strict";
|
6
6
|
|
7
|
+
const WebpackError = require("./WebpackError");
|
7
8
|
const formatLocation = require("./formatLocation");
|
8
9
|
|
9
|
-
module.exports = class ModuleDependencyError extends
|
10
|
+
module.exports = class ModuleDependencyError extends WebpackError {
|
10
11
|
constructor(module, err, loc) {
|
11
12
|
super();
|
12
13
|
|
@@ -4,9 +4,10 @@
|
|
4
4
|
*/
|
5
5
|
"use strict";
|
6
6
|
|
7
|
+
const WebpackError = require("./WebpackError");
|
7
8
|
const formatLocation = require("./formatLocation");
|
8
9
|
|
9
|
-
module.exports = class ModuleDependencyWarning extends
|
10
|
+
module.exports = class ModuleDependencyWarning extends WebpackError {
|
10
11
|
constructor(module, err, loc) {
|
11
12
|
super();
|
12
13
|
|
package/lib/ModuleError.js
CHANGED
@@ -4,10 +4,10 @@
|
|
4
4
|
*/
|
5
5
|
"use strict";
|
6
6
|
|
7
|
+
const WebpackError = require("./WebpackError");
|
7
8
|
const cleanUp = require("./ErrorHelpers").cleanUp;
|
8
9
|
|
9
|
-
class ModuleError extends
|
10
|
-
|
10
|
+
class ModuleError extends WebpackError {
|
11
11
|
constructor(module, err) {
|
12
12
|
super();
|
13
13
|
|
@@ -2,7 +2,9 @@
|
|
2
2
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
3
|
Author Tobias Koppers @sokra
|
4
4
|
*/
|
5
|
-
|
5
|
+
"use strict";
|
6
|
+
|
7
|
+
const ModuleFilenameHelpers = exports;
|
6
8
|
|
7
9
|
ModuleFilenameHelpers.ALL_LOADERS_RESOURCE = "[all-loaders][resource]";
|
8
10
|
ModuleFilenameHelpers.REGEXP_ALL_LOADERS_RESOURCE = /\[all-?loaders\]\[resource\]/gi;
|
@@ -26,17 +28,17 @@ ModuleFilenameHelpers.HASH = "[hash]";
|
|
26
28
|
ModuleFilenameHelpers.REGEXP_HASH = /\[hash\]/gi;
|
27
29
|
|
28
30
|
function getAfter(str, token) {
|
29
|
-
|
31
|
+
const idx = str.indexOf(token);
|
30
32
|
return idx < 0 ? "" : str.substr(idx);
|
31
33
|
}
|
32
34
|
|
33
35
|
function getBefore(str, token) {
|
34
|
-
|
36
|
+
const idx = str.lastIndexOf(token);
|
35
37
|
return idx < 0 ? "" : str.substr(0, idx);
|
36
38
|
}
|
37
39
|
|
38
40
|
function getHash(str) {
|
39
|
-
|
41
|
+
const hash = require("crypto").createHash("md5");
|
40
42
|
hash.update(str);
|
41
43
|
return hash.digest("hex").substr(0, 4);
|
42
44
|
}
|
@@ -47,12 +49,12 @@ function asRegExp(test) {
|
|
47
49
|
}
|
48
50
|
|
49
51
|
ModuleFilenameHelpers.createFilename = function createFilename(module, moduleFilenameTemplate, requestShortener) {
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
if(
|
52
|
+
let absoluteResourcePath;
|
53
|
+
let hash;
|
54
|
+
let identifier;
|
55
|
+
let moduleId;
|
56
|
+
let shortIdentifier;
|
57
|
+
if(module === undefined) module = "";
|
56
58
|
if(typeof module === "string") {
|
57
59
|
shortIdentifier = requestShortener.shorten(module);
|
58
60
|
identifier = shortIdentifier;
|
@@ -63,14 +65,14 @@ ModuleFilenameHelpers.createFilename = function createFilename(module, moduleFil
|
|
63
65
|
shortIdentifier = module.readableIdentifier(requestShortener);
|
64
66
|
identifier = requestShortener.shorten(module.identifier());
|
65
67
|
moduleId = module.id;
|
66
|
-
absoluteResourcePath = module.
|
68
|
+
absoluteResourcePath = module.identifier().split("!").pop();
|
67
69
|
hash = getHash(identifier);
|
68
70
|
}
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
71
|
+
const resource = shortIdentifier.split("!").pop();
|
72
|
+
const loaders = getBefore(shortIdentifier, "!");
|
73
|
+
const allLoaders = getBefore(identifier, "!");
|
74
|
+
const query = getAfter(resource, "?");
|
75
|
+
const resourcePath = resource.substr(0, resource.length - query.length);
|
74
76
|
if(typeof moduleFilenameTemplate === "function") {
|
75
77
|
return moduleFilenameTemplate({
|
76
78
|
identifier: identifier,
|
@@ -102,35 +104,33 @@ ModuleFilenameHelpers.createFooter = function createFooter(module, requestShorte
|
|
102
104
|
if(typeof module === "string") {
|
103
105
|
return [
|
104
106
|
"// WEBPACK FOOTER //",
|
105
|
-
|
107
|
+
`// ${requestShortener.shorten(module)}`
|
106
108
|
].join("\n");
|
107
109
|
} else {
|
108
110
|
return [
|
109
111
|
"//////////////////",
|
110
112
|
"// WEBPACK FOOTER",
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
return c.id;
|
115
|
-
}).join(" ")
|
113
|
+
`// ${module.readableIdentifier(requestShortener)}`,
|
114
|
+
`// module id = ${module.id}`,
|
115
|
+
`// module chunks = ${module.chunks.map(c => c.id).join(" ")}`
|
116
116
|
].join("\n");
|
117
117
|
}
|
118
118
|
};
|
119
119
|
|
120
120
|
ModuleFilenameHelpers.replaceDuplicates = function replaceDuplicates(array, fn, comparator) {
|
121
|
-
|
122
|
-
|
123
|
-
array.forEach(
|
121
|
+
const countMap = Object.create(null);
|
122
|
+
const posMap = Object.create(null);
|
123
|
+
array.forEach((item, idx) => {
|
124
124
|
countMap[item] = (countMap[item] || []);
|
125
125
|
countMap[item].push(idx);
|
126
126
|
posMap[item] = 0;
|
127
127
|
});
|
128
128
|
if(comparator) {
|
129
|
-
Object.keys(countMap).forEach(
|
129
|
+
Object.keys(countMap).forEach(item => {
|
130
130
|
countMap[item].sort(comparator);
|
131
131
|
});
|
132
132
|
}
|
133
|
-
return array.map(
|
133
|
+
return array.map((item, i) => {
|
134
134
|
if(countMap[item].length > 1) {
|
135
135
|
if(comparator && countMap[item][0] === i)
|
136
136
|
return item;
|
package/lib/ModuleParseError.js
CHANGED
@@ -4,9 +4,12 @@
|
|
4
4
|
*/
|
5
5
|
"use strict";
|
6
6
|
|
7
|
-
|
7
|
+
const WebpackError = require("./WebpackError");
|
8
|
+
|
9
|
+
class ModuleParseError extends WebpackError {
|
8
10
|
constructor(module, source, err) {
|
9
11
|
super();
|
12
|
+
|
10
13
|
this.name = "ModuleParseError";
|
11
14
|
this.message = "Module parse failed: " + module.request + " " + err.message;
|
12
15
|
this.message += "\nYou may need an appropriate loader to handle this file type.";
|
@@ -23,9 +26,8 @@ class ModuleParseError extends Error {
|
|
23
26
|
}
|
24
27
|
this.module = module;
|
25
28
|
this.error = err;
|
26
|
-
|
27
|
-
|
28
|
-
}
|
29
|
+
|
30
|
+
Error.captureStackTrace(this, this.constructor);
|
29
31
|
}
|
30
32
|
}
|
31
33
|
|
package/lib/ModuleWarning.js
CHANGED
@@ -4,10 +4,10 @@
|
|
4
4
|
*/
|
5
5
|
"use strict";
|
6
6
|
|
7
|
+
const WebpackError = require("./WebpackError");
|
7
8
|
const cleanUp = require("./ErrorHelpers").cleanUp;
|
8
9
|
|
9
|
-
class ModuleWarning extends
|
10
|
-
|
10
|
+
class ModuleWarning extends WebpackError {
|
11
11
|
constructor(module, warning) {
|
12
12
|
super();
|
13
13
|
|
package/lib/MultiCompiler.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
Author Tobias Koppers @sokra
|
4
4
|
*/
|
5
5
|
var Tapable = require("tapable");
|
6
|
-
var
|
6
|
+
var asyncLib = require("async");
|
7
7
|
var MultiWatching = require("./MultiWatching");
|
8
8
|
var MultiStats = require("./MultiStats");
|
9
9
|
|
@@ -100,7 +100,7 @@ function runWithDependencies(compilers, fn, callback) {
|
|
100
100
|
|
101
101
|
function runCompilers(callback) {
|
102
102
|
if(remainingCompilers.length === 0) return callback();
|
103
|
-
|
103
|
+
asyncLib.map(getReadyCompilers(), function(compiler, callback) {
|
104
104
|
fn(compiler, function(err) {
|
105
105
|
if(err) return callback(err);
|
106
106
|
fulfilledNames[compiler.name] = true;
|
@@ -119,11 +119,10 @@ MultiCompiler.prototype.watch = function(watchOptions, handler) {
|
|
119
119
|
var compilerStatus = this.compilers.map(function() {
|
120
120
|
return false;
|
121
121
|
});
|
122
|
-
|
123
122
|
runWithDependencies(this.compilers, function(compiler, callback) {
|
124
123
|
var compilerIdx = this.compilers.indexOf(compiler);
|
125
124
|
var firstRun = true;
|
126
|
-
var watching = compiler.watch(watchOptions, function(err, stats) {
|
125
|
+
var watching = compiler.watch(Array.isArray(watchOptions) ? watchOptions[compilerIdx] : watchOptions, function(err, stats) {
|
127
126
|
if(err)
|
128
127
|
handler(err);
|
129
128
|
if(stats) {
|
package/lib/MultiStats.js
CHANGED
@@ -11,7 +11,7 @@ const optionOrFallback = (optionValue, fallbackValue) => optionValue !== undefin
|
|
11
11
|
class MultiStats {
|
12
12
|
constructor(stats) {
|
13
13
|
this.stats = stats;
|
14
|
-
this.hash = stats.map(
|
14
|
+
this.hash = stats.map(stat => stat.hash).join("");
|
15
15
|
}
|
16
16
|
|
17
17
|
hasErrors() {
|
@@ -42,12 +42,12 @@ class MultiStats {
|
|
42
42
|
});
|
43
43
|
const obj = {
|
44
44
|
errors: jsons.reduce((arr, j) => {
|
45
|
-
return arr.concat(j.errors.map(
|
45
|
+
return arr.concat(j.errors.map(msg => {
|
46
46
|
return `(${j.name}) ${msg}`;
|
47
47
|
}));
|
48
48
|
}, []),
|
49
49
|
warnings: jsons.reduce((arr, j) => {
|
50
|
-
return arr.concat(j.warnings.map(
|
50
|
+
return arr.concat(j.warnings.map(msg => {
|
51
51
|
return `(${j.name}) ${msg}`;
|
52
52
|
}));
|
53
53
|
}, [])
|
package/lib/MultiWatching.js
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
*/
|
5
5
|
"use strict";
|
6
6
|
|
7
|
-
const
|
7
|
+
const asyncLib = require("async");
|
8
8
|
|
9
9
|
class MultiWatching {
|
10
10
|
constructor(watchings, compiler) {
|
@@ -19,7 +19,7 @@ class MultiWatching {
|
|
19
19
|
close(callback) {
|
20
20
|
if(callback === undefined) callback = () => { /*do nothing*/ };
|
21
21
|
|
22
|
-
|
22
|
+
asyncLib.forEach(this.watchings, (watching, finishedCallback) => {
|
23
23
|
watching.close(finishedCallback);
|
24
24
|
}, err => {
|
25
25
|
this.compiler.applyPlugins("watch-close");
|
@@ -0,0 +1,30 @@
|
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
"use strict";
|
6
|
+
|
7
|
+
class NamedChunksPlugin {
|
8
|
+
|
9
|
+
static defaultNameResolver(chunk) {
|
10
|
+
return chunk.name || null;
|
11
|
+
}
|
12
|
+
|
13
|
+
constructor(nameResolver) {
|
14
|
+
this.nameResolver = nameResolver || NamedChunksPlugin.defaultNameResolver;
|
15
|
+
}
|
16
|
+
|
17
|
+
apply(compiler) {
|
18
|
+
compiler.plugin("compilation", (compilation) => {
|
19
|
+
compilation.plugin("before-chunk-ids", (chunks) => {
|
20
|
+
chunks.forEach((chunk) => {
|
21
|
+
if(chunk.id === null) {
|
22
|
+
chunk.id = this.nameResolver(chunk);
|
23
|
+
}
|
24
|
+
});
|
25
|
+
});
|
26
|
+
});
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
module.exports = NamedChunksPlugin;
|