webpack 2.3.1 → 2.4.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 +139 -132
- package/lib/APIPlugin.js +0 -6
- package/lib/AsyncDependenciesBlock.js +1 -1
- package/lib/AutomaticPrefetchPlugin.js +2 -2
- 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 +3 -3
- package/lib/Compiler.js +1 -1
- package/lib/ContextModule.js +3 -2
- package/lib/ContextModuleFactory.js +5 -5
- package/lib/DelegatedModule.js +67 -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/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 +6 -2
- package/lib/NormalModuleFactory.js +244 -240
- package/lib/Parser.js +1256 -1079
- package/lib/ProgressPlugin.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 +32 -5
- package/lib/TemplatedPathPlugin.js +1 -0
- package/lib/UnsupportedFeatureWarning.js +2 -1
- package/lib/WebpackError.js +11 -0
- package/lib/WebpackOptionsApply.js +1 -1
- package/lib/WebpackOptionsValidationError.js +8 -4
- 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/HarmonyExportDependencyParserPlugin.js +2 -2
- 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/optimize/AggressiveSplittingPlugin.js +10 -17
- package/lib/optimize/CommonsChunkPlugin.js +1 -1
- 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 +4 -3
- package/schemas/ajv.absolutePath.js +1 -1
- package/schemas/webpackOptionsSchema.json +27 -0
package/lib/LibManifestPlugin.js
CHANGED
@@ -2,52 +2,57 @@
|
|
2
2
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
3
|
Author Tobias Koppers @sokra
|
4
4
|
*/
|
5
|
-
|
6
|
-
var async = require("async");
|
5
|
+
"use strict";
|
7
6
|
|
8
|
-
|
9
|
-
|
7
|
+
const path = require("path");
|
8
|
+
const asyncLib = require("async");
|
9
|
+
|
10
|
+
class LibManifestPlugin {
|
11
|
+
constructor(options) {
|
12
|
+
this.options = options;
|
13
|
+
}
|
14
|
+
|
15
|
+
apply(compiler) {
|
16
|
+
compiler.plugin("emit", (compilation, callback) => {
|
17
|
+
asyncLib.forEach(compilation.chunks, (chunk, callback) => {
|
18
|
+
if(!chunk.isInitial()) {
|
19
|
+
callback();
|
20
|
+
return;
|
21
|
+
}
|
22
|
+
const targetPath = compilation.getPath(this.options.path, {
|
23
|
+
hash: compilation.hash,
|
24
|
+
chunk
|
25
|
+
});
|
26
|
+
const name = this.options.name && compilation.getPath(this.options.name, {
|
27
|
+
hash: compilation.hash,
|
28
|
+
chunk
|
29
|
+
});
|
30
|
+
const manifest = {
|
31
|
+
name,
|
32
|
+
type: this.options.type,
|
33
|
+
content: chunk.modules.reduce((obj, module) => {
|
34
|
+
if(module.libIdent) {
|
35
|
+
const ident = module.libIdent({
|
36
|
+
context: this.options.context || compiler.options.context
|
37
|
+
});
|
38
|
+
if(ident) {
|
39
|
+
obj[ident] = {
|
40
|
+
id: module.id,
|
41
|
+
meta: module.meta,
|
42
|
+
exports: Array.isArray(module.providedExports) ? module.providedExports : undefined
|
43
|
+
};
|
44
|
+
}
|
45
|
+
}
|
46
|
+
return obj;
|
47
|
+
}, {})
|
48
|
+
};
|
49
|
+
const content = new Buffer(JSON.stringify(manifest, null, 2), "utf8"); //eslint-disable-line
|
50
|
+
compiler.outputFileSystem.mkdirp(path.dirname(targetPath), err => {
|
51
|
+
if(err) return callback(err);
|
52
|
+
compiler.outputFileSystem.writeFile(targetPath, content, callback);
|
53
|
+
});
|
54
|
+
}, callback);
|
55
|
+
});
|
56
|
+
}
|
10
57
|
}
|
11
58
|
module.exports = LibManifestPlugin;
|
12
|
-
LibManifestPlugin.prototype.apply = function(compiler) {
|
13
|
-
compiler.plugin("emit", function(compilation, callback) {
|
14
|
-
async.forEach(compilation.chunks, function(chunk, callback) {
|
15
|
-
if(!chunk.isInitial()) {
|
16
|
-
callback();
|
17
|
-
return;
|
18
|
-
}
|
19
|
-
var targetPath = compilation.getPath(this.options.path, {
|
20
|
-
hash: compilation.hash,
|
21
|
-
chunk: chunk
|
22
|
-
});
|
23
|
-
var name = this.options.name && compilation.getPath(this.options.name, {
|
24
|
-
hash: compilation.hash,
|
25
|
-
chunk: chunk
|
26
|
-
});
|
27
|
-
var manifest = {
|
28
|
-
name: name,
|
29
|
-
type: this.options.type,
|
30
|
-
content: chunk.modules.reduce(function(obj, module) {
|
31
|
-
if(module.libIdent) {
|
32
|
-
var ident = module.libIdent({
|
33
|
-
context: this.options.context || compiler.options.context
|
34
|
-
});
|
35
|
-
if(ident) {
|
36
|
-
obj[ident] = {
|
37
|
-
id: module.id,
|
38
|
-
meta: module.meta,
|
39
|
-
exports: Array.isArray(module.providedExports) ? module.providedExports : undefined
|
40
|
-
};
|
41
|
-
}
|
42
|
-
}
|
43
|
-
return obj;
|
44
|
-
}.bind(this), {})
|
45
|
-
};
|
46
|
-
var content = new Buffer(JSON.stringify(manifest, null, 2), "utf8"); //eslint-disable-line
|
47
|
-
compiler.outputFileSystem.mkdirp(path.dirname(targetPath), function(err) {
|
48
|
-
if(err) return callback(err);
|
49
|
-
compiler.outputFileSystem.writeFile(targetPath, content, callback);
|
50
|
-
});
|
51
|
-
}.bind(this), callback);
|
52
|
-
}.bind(this));
|
53
|
-
};
|
package/lib/MainTemplate.js
CHANGED
@@ -30,8 +30,7 @@ module.exports = class MainTemplate extends Template {
|
|
30
30
|
const buf = [];
|
31
31
|
if(chunk.entryModule) {
|
32
32
|
buf.push("// Load entry module and return exports");
|
33
|
-
buf.push(
|
34
|
-
"(" + this.requireFn + ".s = " + JSON.stringify(chunk.entryModule.id) + ");");
|
33
|
+
buf.push(`return ${this.renderRequireFunctionForModule(hash, chunk, JSON.stringify(chunk.entryModule.id))}(${this.requireFn}.s = ${JSON.stringify(chunk.entryModule.id)});`);
|
35
34
|
}
|
36
35
|
return this.asString(buf);
|
37
36
|
});
|
@@ -58,9 +57,9 @@ module.exports = class MainTemplate extends Template {
|
|
58
57
|
return this.asString([
|
59
58
|
source,
|
60
59
|
"// Check if module is in cache",
|
61
|
-
"if(installedModules[moduleId])",
|
60
|
+
"if(installedModules[moduleId]) {",
|
62
61
|
this.indent("return installedModules[moduleId].exports;"),
|
63
|
-
"",
|
62
|
+
"}",
|
64
63
|
"// Create a new module (and put it into the cache)",
|
65
64
|
"var module = installedModules[moduleId] = {",
|
66
65
|
this.indent(this.applyPluginsWaterfall("module-obj", "", chunk, hash, "moduleId")),
|
@@ -71,7 +70,7 @@ module.exports = class MainTemplate extends Template {
|
|
71
70
|
"var threw = true;",
|
72
71
|
"try {",
|
73
72
|
this.indent([
|
74
|
-
|
73
|
+
`modules[moduleId].call(module.exports, module, module.exports, ${this.renderRequireFunctionForModule(hash, chunk, "moduleId")});`,
|
75
74
|
"threw = false;"
|
76
75
|
]),
|
77
76
|
"} finally {",
|
@@ -81,7 +80,7 @@ module.exports = class MainTemplate extends Template {
|
|
81
80
|
"}"
|
82
81
|
] : [
|
83
82
|
"// Execute the module function",
|
84
|
-
|
83
|
+
`modules[moduleId].call(module.exports, module, module.exports, ${this.renderRequireFunctionForModule(hash, chunk, "moduleId")});`,
|
85
84
|
]),
|
86
85
|
"",
|
87
86
|
"// Flag the module as loaded",
|
@@ -103,27 +102,27 @@ module.exports = class MainTemplate extends Template {
|
|
103
102
|
if(chunk.chunks.length > 0) {
|
104
103
|
buf.push("// This file contains only the entry chunk.");
|
105
104
|
buf.push("// The chunk loading function for additional chunks");
|
106
|
-
buf.push(this.requireFn
|
105
|
+
buf.push(`${this.requireFn}.e = function requireEnsure(chunkId) {`);
|
107
106
|
buf.push(this.indent(this.applyPluginsWaterfall("require-ensure", "throw new Error('Not chunk loading available');", chunk, hash, "chunkId")));
|
108
107
|
buf.push("};");
|
109
108
|
}
|
110
109
|
buf.push("");
|
111
110
|
buf.push("// expose the modules object (__webpack_modules__)");
|
112
|
-
buf.push(this.requireFn
|
111
|
+
buf.push(`${this.requireFn}.m = modules;`);
|
113
112
|
|
114
113
|
buf.push("");
|
115
114
|
buf.push("// expose the module cache");
|
116
|
-
buf.push(this.requireFn
|
115
|
+
buf.push(`${this.requireFn}.c = installedModules;`);
|
117
116
|
|
118
117
|
buf.push("");
|
119
118
|
buf.push("// identity function for calling harmony imports with the correct context");
|
120
|
-
buf.push(this.requireFn
|
119
|
+
buf.push(`${this.requireFn}.i = function(value) { return value; };`);
|
121
120
|
|
122
121
|
buf.push("");
|
123
122
|
buf.push("// define getter function for harmony exports");
|
124
|
-
buf.push(this.requireFn
|
123
|
+
buf.push(`${this.requireFn}.d = function(exports, name, getter) {`);
|
125
124
|
buf.push(this.indent([
|
126
|
-
|
125
|
+
`if(!${this.requireFn}.o(exports, name)) {`,
|
127
126
|
this.indent([
|
128
127
|
"Object.defineProperty(exports, name, {",
|
129
128
|
this.indent([
|
@@ -146,21 +145,21 @@ module.exports = class MainTemplate extends Template {
|
|
146
145
|
"function getDefault() { return module['default']; } :",
|
147
146
|
"function getModuleExports() { return module; };"
|
148
147
|
]),
|
149
|
-
this.requireFn
|
148
|
+
`${this.requireFn}.d(getter, 'a', getter);`,
|
150
149
|
"return getter;"
|
151
150
|
]));
|
152
151
|
buf.push("};");
|
153
152
|
|
154
153
|
buf.push("");
|
155
154
|
buf.push("// Object.prototype.hasOwnProperty.call");
|
156
|
-
buf.push(this.requireFn
|
155
|
+
buf.push(`${this.requireFn}.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };`);
|
157
156
|
|
158
157
|
const publicPath = this.getPublicPath({
|
159
158
|
hash: hash
|
160
159
|
});
|
161
160
|
buf.push("");
|
162
161
|
buf.push("// __webpack_public_path__");
|
163
|
-
buf.push(this.requireFn
|
162
|
+
buf.push(`${this.requireFn}.p = ${JSON.stringify(publicPath)};`);
|
164
163
|
return this.asString(buf);
|
165
164
|
});
|
166
165
|
|
@@ -173,14 +172,14 @@ module.exports = class MainTemplate extends Template {
|
|
173
172
|
buf.push(this.applyPluginsWaterfall("local-vars", "", chunk, hash));
|
174
173
|
buf.push("");
|
175
174
|
buf.push("// The require function");
|
176
|
-
buf.push(
|
175
|
+
buf.push(`function ${this.requireFn}(moduleId) {`);
|
177
176
|
buf.push(this.indent(this.applyPluginsWaterfall("require", "", chunk, hash)));
|
178
177
|
buf.push("}");
|
179
178
|
buf.push("");
|
180
179
|
buf.push(this.asString(this.applyPluginsWaterfall("require-extensions", "", chunk, hash)));
|
181
180
|
buf.push("");
|
182
181
|
buf.push(this.asString(this.applyPluginsWaterfall("startup", "", chunk, hash)));
|
183
|
-
let source = this.applyPluginsWaterfall("render", new OriginalSource(this.prefix(buf, " \t") + "\n",
|
182
|
+
let source = this.applyPluginsWaterfall("render", new OriginalSource(this.prefix(buf, " \t") + "\n", `webpack/bootstrap ${hash}`), chunk, hash, moduleTemplate, dependencyTemplates);
|
184
183
|
if(chunk.hasEntryModule()) {
|
185
184
|
source = this.applyPluginsWaterfall("render-with-entry", source, chunk, hash);
|
186
185
|
}
|
@@ -194,7 +193,7 @@ module.exports = class MainTemplate extends Template {
|
|
194
193
|
}
|
195
194
|
|
196
195
|
renderAddModule(hash, chunk, varModuleId, varModule) {
|
197
|
-
return this.applyPluginsWaterfall("add-module",
|
196
|
+
return this.applyPluginsWaterfall("add-module", `modules[${varModuleId}] = ${varModule};`, chunk, hash, varModuleId, varModule);
|
198
197
|
}
|
199
198
|
|
200
199
|
renderCurrentHashCode(hash, length) {
|
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
|
|