webpack 4.16.3 → 4.17.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 +0 -2
- package/hot/log.js +2 -0
- package/lib/Chunk.js +3 -3
- package/lib/CompatibilityPlugin.js +1 -1
- package/lib/Compilation.js +12 -2
- package/lib/ContextReplacementPlugin.js +6 -6
- package/lib/EnvironmentPlugin.js +1 -1
- package/lib/ExternalModuleFactoryPlugin.js +2 -2
- package/lib/HotModuleReplacement.runtime.js +2 -2
- package/lib/HotModuleReplacementPlugin.js +1 -5
- package/lib/IgnorePlugin.js +30 -11
- package/lib/JavascriptModulesPlugin.js +2 -0
- package/lib/LibraryTemplatePlugin.js +1 -1
- package/lib/MultiStats.js +2 -2
- package/lib/OptionsDefaulter.js +1 -2
- package/lib/RequireJsStuffPlugin.js +1 -4
- package/lib/Stats.js +2 -6
- package/lib/Template.js +44 -43
- package/lib/UmdMainTemplatePlugin.js +2 -2
- package/lib/UnsupportedFeatureWarning.js +8 -0
- package/lib/WatchIgnorePlugin.js +18 -18
- package/lib/debug/ProfilingPlugin.js +1 -1
- package/lib/dependencies/AMDPlugin.js +1 -2
- package/lib/dependencies/CommonJsPlugin.js +1 -4
- package/lib/dependencies/ContextDependencyHelpers.js +78 -43
- package/lib/dependencies/ContextDependencyTemplateAsId.js +1 -0
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +1 -0
- package/lib/dependencies/HarmonyModulesPlugin.js +1 -4
- package/lib/dependencies/ImportParserPlugin.js +7 -7
- package/lib/dependencies/ImportPlugin.js +1 -4
- package/lib/dependencies/RequireContextPlugin.js +1 -1
- package/lib/dependencies/RequireEnsurePlugin.js +1 -1
- package/lib/dependencies/RequireIncludePlugin.js +1 -1
- package/lib/dependencies/SystemPlugin.js +2 -5
- package/lib/node/NodeTargetPlugin.js +1 -0
- package/lib/optimize/ConcatenatedModule.js +27 -7
- package/lib/util/identifier.js +2 -2
- package/lib/wasm/WebAssemblyGenerator.js +9 -6
- package/package.json +5 -5
- package/schemas/plugins/IgnorePlugin.json +31 -0
package/README.md
CHANGED
@@ -58,8 +58,6 @@ yarn add webpack --dev
|
|
58
58
|
|
59
59
|
<h2 align="center">Introduction</h2>
|
60
60
|
|
61
|
-
> This README reflects webpack v2.x and v3.x. The webpack v1.x documentation has been deprecated and deleted.
|
62
|
-
|
63
61
|
webpack is a bundler for modules. The main purpose is to bundle JavaScript
|
64
62
|
files for usage in a browser, yet it is also capable of transforming, bundling,
|
65
63
|
or packaging just about any resource or asset.
|
package/hot/log.js
CHANGED
@@ -30,9 +30,11 @@ module.exports = function(level, msg) {
|
|
30
30
|
}
|
31
31
|
};
|
32
32
|
|
33
|
+
/* eslint-disable node/no-unsupported-features/node-builtins */
|
33
34
|
var group = console.group || dummy;
|
34
35
|
var groupCollapsed = console.groupCollapsed || dummy;
|
35
36
|
var groupEnd = console.groupEnd || dummy;
|
37
|
+
/* eslint-enable node/no-unsupported-features/node-builtins */
|
36
38
|
|
37
39
|
module.exports.group = logGroup(group);
|
38
40
|
|
package/lib/Chunk.js
CHANGED
@@ -313,17 +313,17 @@ class Chunk {
|
|
313
313
|
* @returns {-1|0|1} this is a comparitor function like sort and returns -1, 0, or 1 based on sort order
|
314
314
|
*/
|
315
315
|
compareTo(otherChunk) {
|
316
|
-
this._modules.sort();
|
317
|
-
otherChunk._modules.sort();
|
318
316
|
if (this._modules.size > otherChunk._modules.size) return -1;
|
319
317
|
if (this._modules.size < otherChunk._modules.size) return 1;
|
318
|
+
this._modules.sort();
|
319
|
+
otherChunk._modules.sort();
|
320
320
|
const a = this._modules[Symbol.iterator]();
|
321
321
|
const b = otherChunk._modules[Symbol.iterator]();
|
322
322
|
// eslint-disable-next-line no-constant-condition
|
323
323
|
while (true) {
|
324
324
|
const aItem = a.next();
|
325
|
-
const bItem = b.next();
|
326
325
|
if (aItem.done) return 0;
|
326
|
+
const bItem = b.next();
|
327
327
|
const aModuleIdentifier = aItem.value.identifier();
|
328
328
|
const bModuleIdentifier = bItem.value.identifier();
|
329
329
|
if (aModuleIdentifier < bModuleIdentifier) return -1;
|
@@ -30,7 +30,7 @@ class CompatibilityPlugin {
|
|
30
30
|
.for("javascript/auto")
|
31
31
|
.tap("CompatibilityPlugin", (parser, parserOptions) => {
|
32
32
|
if (
|
33
|
-
|
33
|
+
parserOptions.browserify !== undefined &&
|
34
34
|
!parserOptions.browserify
|
35
35
|
)
|
36
36
|
return;
|
package/lib/Compilation.js
CHANGED
@@ -1025,6 +1025,7 @@ class Compilation extends Tapable {
|
|
1025
1025
|
addEntry(context, entry, name, callback) {
|
1026
1026
|
const slot = {
|
1027
1027
|
name: name,
|
1028
|
+
// TODO webpack 5 remove `request`
|
1028
1029
|
request: null,
|
1029
1030
|
module: null
|
1030
1031
|
};
|
@@ -1033,7 +1034,14 @@ class Compilation extends Tapable {
|
|
1033
1034
|
slot.request = entry.request;
|
1034
1035
|
}
|
1035
1036
|
|
1036
|
-
|
1037
|
+
// TODO webpack 5: merge modules instead when multiple entry modules are supported
|
1038
|
+
const idx = this._preparedEntrypoints.findIndex(slot => slot.name === name);
|
1039
|
+
if (idx >= 0) {
|
1040
|
+
// Overwrite existing entrypoint
|
1041
|
+
this._preparedEntrypoints[idx] = slot;
|
1042
|
+
} else {
|
1043
|
+
this._preparedEntrypoints.push(slot);
|
1044
|
+
}
|
1037
1045
|
this._addModuleChain(
|
1038
1046
|
context,
|
1039
1047
|
entry,
|
@@ -1049,7 +1057,9 @@ class Compilation extends Tapable {
|
|
1049
1057
|
slot.module = module;
|
1050
1058
|
} else {
|
1051
1059
|
const idx = this._preparedEntrypoints.indexOf(slot);
|
1052
|
-
|
1060
|
+
if (idx >= 0) {
|
1061
|
+
this._preparedEntrypoints.splice(idx, 1);
|
1062
|
+
}
|
1053
1063
|
}
|
1054
1064
|
return callback(null, module);
|
1055
1065
|
}
|
@@ -60,13 +60,13 @@ class ContextReplacementPlugin {
|
|
60
60
|
cmf.hooks.beforeResolve.tap("ContextReplacementPlugin", result => {
|
61
61
|
if (!result) return;
|
62
62
|
if (resourceRegExp.test(result.request)) {
|
63
|
-
if (
|
63
|
+
if (newContentResource !== undefined) {
|
64
64
|
result.request = newContentResource;
|
65
65
|
}
|
66
|
-
if (
|
66
|
+
if (newContentRecursive !== undefined) {
|
67
67
|
result.recursive = newContentRecursive;
|
68
68
|
}
|
69
|
-
if (
|
69
|
+
if (newContentRegExp !== undefined) {
|
70
70
|
result.regExp = newContentRegExp;
|
71
71
|
}
|
72
72
|
if (typeof newContentCallback === "function") {
|
@@ -82,13 +82,13 @@ class ContextReplacementPlugin {
|
|
82
82
|
cmf.hooks.afterResolve.tap("ContextReplacementPlugin", result => {
|
83
83
|
if (!result) return;
|
84
84
|
if (resourceRegExp.test(result.resource)) {
|
85
|
-
if (
|
85
|
+
if (newContentResource !== undefined) {
|
86
86
|
result.resource = path.resolve(result.resource, newContentResource);
|
87
87
|
}
|
88
|
-
if (
|
88
|
+
if (newContentRecursive !== undefined) {
|
89
89
|
result.recursive = newContentRecursive;
|
90
90
|
}
|
91
|
-
if (
|
91
|
+
if (newContentRegExp !== undefined) {
|
92
92
|
result.regExp = newContentRegExp;
|
93
93
|
}
|
94
94
|
if (typeof newContentCreateContextMap === "function") {
|
package/lib/EnvironmentPlugin.js
CHANGED
@@ -27,7 +27,7 @@ class ExternalModuleFactoryPlugin {
|
|
27
27
|
}
|
28
28
|
if (value === false) return factory(data, callback);
|
29
29
|
if (value === true) value = dependency.request;
|
30
|
-
if (
|
30
|
+
if (type === undefined && /^[a-z0-9]+ /.test(value)) {
|
31
31
|
const idx = value.indexOf(" ");
|
32
32
|
type = value.substr(0, idx);
|
33
33
|
value = value.substr(idx + 1);
|
@@ -81,7 +81,7 @@ class ExternalModuleFactoryPlugin {
|
|
81
81
|
dependency.request,
|
82
82
|
(err, value, type) => {
|
83
83
|
if (err) return callback(err);
|
84
|
-
if (
|
84
|
+
if (value !== undefined) {
|
85
85
|
handleExternal(value, type, callback);
|
86
86
|
} else {
|
87
87
|
callback();
|
@@ -105,7 +105,7 @@ module.exports = function() {
|
|
105
105
|
// Module API
|
106
106
|
active: true,
|
107
107
|
accept: function(dep, callback) {
|
108
|
-
if (
|
108
|
+
if (dep === undefined) hot._selfAccepted = true;
|
109
109
|
else if (typeof dep === "function") hot._selfAccepted = dep;
|
110
110
|
else if (typeof dep === "object")
|
111
111
|
for (var i = 0; i < dep.length; i++)
|
@@ -113,7 +113,7 @@ module.exports = function() {
|
|
113
113
|
else hot._acceptedDependencies[dep] = callback || function() {};
|
114
114
|
},
|
115
115
|
decline: function(dep) {
|
116
|
-
if (
|
116
|
+
if (dep === undefined) hot._selfDeclined = true;
|
117
117
|
else if (typeof dep === "object")
|
118
118
|
for (var i = 0; i < dep.length; i++)
|
119
119
|
hot._declinedDependencies[dep[i]] = true;
|
@@ -285,11 +285,7 @@ module.exports = class HotModuleReplacementPlugin {
|
|
285
285
|
compilation.assets[filename] = source;
|
286
286
|
hotUpdateMainContent.c[chunkId] = true;
|
287
287
|
currentChunk.files.push(filename);
|
288
|
-
compilation.hooks.chunkAsset.call(
|
289
|
-
"HotModuleReplacementPlugin",
|
290
|
-
currentChunk,
|
291
|
-
filename
|
292
|
-
);
|
288
|
+
compilation.hooks.chunkAsset.call(currentChunk, filename);
|
293
289
|
}
|
294
290
|
} else {
|
295
291
|
hotUpdateMainContent.c[chunkId] = false;
|
package/lib/IgnorePlugin.js
CHANGED
@@ -4,18 +4,30 @@
|
|
4
4
|
*/
|
5
5
|
"use strict";
|
6
6
|
|
7
|
+
const validateOptions = require("schema-utils");
|
8
|
+
const schema = require("../schemas/plugins/IgnorePlugin.json");
|
9
|
+
|
7
10
|
/** @typedef {import("./Compiler")} Compiler */
|
8
11
|
|
9
12
|
class IgnorePlugin {
|
10
13
|
/**
|
11
|
-
* @param {
|
12
|
-
* @param {RegExp
|
14
|
+
* @param {object} options IgnorePlugin options
|
15
|
+
* @param {RegExp} options.resourceRegExp - A RegExp to test the request against
|
16
|
+
* @param {RegExp} options.contextRegExp - A RegExp to test the context (directory) against
|
17
|
+
* @param {function(string): boolean=} options.checkResource - A filter function for resource
|
18
|
+
* @param {function(string): boolean=} options.checkContext - A filter function for context
|
13
19
|
*/
|
14
|
-
constructor(
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
20
|
+
constructor(options) {
|
21
|
+
// TODO webpack 5 remove this compat-layer
|
22
|
+
if (arguments.length > 1 || options instanceof RegExp) {
|
23
|
+
options = {
|
24
|
+
resourceRegExp: arguments[0],
|
25
|
+
contextRegExp: arguments[1]
|
26
|
+
};
|
27
|
+
}
|
28
|
+
|
29
|
+
validateOptions(schema, options, "IgnorePlugin");
|
30
|
+
this.options = options;
|
19
31
|
|
20
32
|
/** @private @type {Function} */
|
21
33
|
this.checkIgnore = this.checkIgnore.bind(this);
|
@@ -27,10 +39,13 @@ class IgnorePlugin {
|
|
27
39
|
* and the resource given matches the regexp.
|
28
40
|
*/
|
29
41
|
checkResource(resource) {
|
30
|
-
if (
|
42
|
+
if (this.options.checkResource) {
|
43
|
+
return this.options.checkResource(resource);
|
44
|
+
}
|
45
|
+
if (!this.options.resourceRegExp) {
|
31
46
|
return false;
|
32
47
|
}
|
33
|
-
return this.resourceRegExp.test(resource);
|
48
|
+
return this.options.resourceRegExp.test(resource);
|
34
49
|
}
|
35
50
|
|
36
51
|
/**
|
@@ -39,10 +54,14 @@ class IgnorePlugin {
|
|
39
54
|
* or if context matches the given regexp.
|
40
55
|
*/
|
41
56
|
checkContext(context) {
|
42
|
-
if (
|
57
|
+
if (this.options.checkContext) {
|
58
|
+
return this.options.checkContext(context);
|
59
|
+
}
|
60
|
+
|
61
|
+
if (!this.options.contextRegExp) {
|
43
62
|
return true;
|
44
63
|
}
|
45
|
-
return this.contextRegExp.test(context);
|
64
|
+
return this.options.contextRegExp.test(context);
|
46
65
|
}
|
47
66
|
|
48
67
|
/**
|
@@ -135,6 +135,8 @@ class JavascriptModulesPlugin {
|
|
135
135
|
const template = chunk.hasRuntime()
|
136
136
|
? compilation.mainTemplate
|
137
137
|
: compilation.chunkTemplate;
|
138
|
+
hash.update(`${chunk.id} `);
|
139
|
+
hash.update(chunk.ids ? chunk.ids.join(",") : "");
|
138
140
|
template.updateHashForChunk(hash, chunk);
|
139
141
|
for (const m of chunk.modulesIterable) {
|
140
142
|
if (typeof m.source === "function") {
|
@@ -30,7 +30,7 @@ const accessorAccess = (base, accessor, joinWith = "; ") => {
|
|
30
30
|
? base + accessorToObjectAccess(accessors.slice(0, idx + 1))
|
31
31
|
: accessors[0] + accessorToObjectAccess(accessors.slice(1, idx + 1));
|
32
32
|
if (idx === accessors.length - 1) return a;
|
33
|
-
if (idx === 0 &&
|
33
|
+
if (idx === 0 && base === undefined) {
|
34
34
|
return `${a} = typeof ${a} === "object" ? ${a} : {}`;
|
35
35
|
}
|
36
36
|
return `${a} = ${a} || {}`;
|
package/lib/MultiStats.js
CHANGED
@@ -40,11 +40,11 @@ class MultiStats {
|
|
40
40
|
return obj;
|
41
41
|
});
|
42
42
|
const showVersion =
|
43
|
-
|
43
|
+
options.version === undefined
|
44
44
|
? jsons.every(j => j.version)
|
45
45
|
: options.version !== false;
|
46
46
|
const showHash =
|
47
|
-
|
47
|
+
options.hash === undefined
|
48
48
|
? jsons.every(j => j.hash)
|
49
49
|
: options.hash !== false;
|
50
50
|
if (showVersion) {
|
package/lib/OptionsDefaulter.js
CHANGED
@@ -16,8 +16,7 @@ const getProperty = (obj, name) => {
|
|
16
16
|
const setProperty = (obj, name, value) => {
|
17
17
|
name = name.split(".");
|
18
18
|
for (let i = 0; i < name.length - 1; i++) {
|
19
|
-
if (typeof obj[name[i]] !== "object" &&
|
20
|
-
return;
|
19
|
+
if (typeof obj[name[i]] !== "object" && obj[name[i]] !== undefined) return;
|
21
20
|
if (Array.isArray(obj[name[i]])) return;
|
22
21
|
if (!obj[name[i]]) obj[name[i]] = {};
|
23
22
|
obj = obj[name[i]];
|
@@ -19,10 +19,7 @@ module.exports = class RequireJsStuffPlugin {
|
|
19
19
|
new ConstDependency.Template()
|
20
20
|
);
|
21
21
|
const handler = (parser, parserOptions) => {
|
22
|
-
if (
|
23
|
-
typeof parserOptions.requireJs !== "undefined" &&
|
24
|
-
!parserOptions.requireJs
|
25
|
-
)
|
22
|
+
if (parserOptions.requireJs !== undefined && !parserOptions.requireJs)
|
26
23
|
return;
|
27
24
|
|
28
25
|
parser.hooks.call
|
package/lib/Stats.js
CHANGED
@@ -13,7 +13,7 @@ const compareLocations = require("./compareLocations");
|
|
13
13
|
const optionsOrFallback = (...args) => {
|
14
14
|
let optionValues = [];
|
15
15
|
optionValues.push(...args);
|
16
|
-
return optionValues.find(optionValue =>
|
16
|
+
return optionValues.find(optionValue => optionValue !== undefined);
|
17
17
|
};
|
18
18
|
|
19
19
|
const compareId = (a, b) => {
|
@@ -105,11 +105,7 @@ class Stats {
|
|
105
105
|
}
|
106
106
|
|
107
107
|
const optionOrLocalFallback = (v, def) =>
|
108
|
-
|
109
|
-
? v
|
110
|
-
: typeof options.all !== "undefined"
|
111
|
-
? options.all
|
112
|
-
: def;
|
108
|
+
v !== undefined ? v : options.all !== undefined ? options.all : def;
|
113
109
|
|
114
110
|
const testAgainstGivenOption = item => {
|
115
111
|
if (typeof item === "string") {
|
package/lib/Template.js
CHANGED
@@ -27,7 +27,7 @@ const MATCH_PADDED_HYPHENS_REPLACE_REGEX = /^-|-$/g;
|
|
27
27
|
/**
|
28
28
|
* @typedef {Object} HasId
|
29
29
|
* @property {number | string} id
|
30
|
-
|
30
|
+
*/
|
31
31
|
|
32
32
|
/**
|
33
33
|
* @typedef {function(Module, number): boolean} ModuleFilterPredicate
|
@@ -39,8 +39,8 @@ const MATCH_PADDED_HYPHENS_REPLACE_REGEX = /^-|-$/g;
|
|
39
39
|
* @returns {-1|0|1} the sort value
|
40
40
|
*/
|
41
41
|
const stringifyIdSortPredicate = (a, b) => {
|
42
|
-
|
43
|
-
|
42
|
+
const aId = a.id + "";
|
43
|
+
const bId = b.id + "";
|
44
44
|
if (aId < bId) return -1;
|
45
45
|
if (aId > bId) return 1;
|
46
46
|
return 0;
|
@@ -59,6 +59,7 @@ class Template {
|
|
59
59
|
.replace(INDENT_MULTILINE_REGEX, "")
|
60
60
|
.replace(LINE_SEPARATOR_REGEX, "\n");
|
61
61
|
}
|
62
|
+
|
62
63
|
/**
|
63
64
|
* @param {string} str the string converted to identifier
|
64
65
|
* @returns {string} created identifier
|
@@ -128,31 +129,28 @@ class Template {
|
|
128
129
|
|
129
130
|
/**
|
130
131
|
*
|
131
|
-
* @param {string | string[]}
|
132
|
+
* @param {string | string[]} s string to convert to identity
|
132
133
|
* @returns {string} converted identity
|
133
134
|
*/
|
134
|
-
static indent(
|
135
|
-
if (Array.isArray(
|
136
|
-
return
|
135
|
+
static indent(s) {
|
136
|
+
if (Array.isArray(s)) {
|
137
|
+
return s.map(Template.indent).join("\n");
|
137
138
|
} else {
|
138
|
-
str =
|
139
|
+
const str = s.trimRight();
|
139
140
|
if (!str) return "";
|
140
|
-
|
141
|
+
const ind = str[0] === "\n" ? "" : "\t";
|
141
142
|
return ind + str.replace(/\n([^\n])/g, "\n\t$1");
|
142
143
|
}
|
143
144
|
}
|
144
145
|
|
145
146
|
/**
|
146
147
|
*
|
147
|
-
* @param {string|string[]}
|
148
|
+
* @param {string|string[]} s string to create prefix for
|
148
149
|
* @param {string} prefix prefix to compose
|
149
150
|
* @returns {string} returns new prefix string
|
150
151
|
*/
|
151
|
-
static prefix(
|
152
|
-
|
153
|
-
str = str.join("\n");
|
154
|
-
}
|
155
|
-
str = str.trim();
|
152
|
+
static prefix(s, prefix) {
|
153
|
+
const str = Template.asString(s).trim();
|
156
154
|
if (!str) return "";
|
157
155
|
const ind = str[0] === "\n" ? "" : prefix;
|
158
156
|
return ind + str.replace(/\n([^\n])/g, "\n" + prefix + "$1");
|
@@ -181,8 +179,8 @@ class Template {
|
|
181
179
|
* or false if not every module has a number based id
|
182
180
|
*/
|
183
181
|
static getModulesArrayBounds(modules) {
|
184
|
-
|
185
|
-
|
182
|
+
let maxId = -Infinity;
|
183
|
+
let minId = Infinity;
|
186
184
|
for (const module of modules) {
|
187
185
|
if (typeof module.id !== "number") return false;
|
188
186
|
if (maxId < module.id) maxId = /** @type {number} */ (module.id);
|
@@ -192,15 +190,11 @@ class Template {
|
|
192
190
|
// add minId x ',' instead of 'Array(minId).concat(…)'
|
193
191
|
minId = 0;
|
194
192
|
}
|
195
|
-
|
196
|
-
.map(module =>
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
.reduce((a, b) => {
|
201
|
-
return a + b;
|
202
|
-
}, -1);
|
203
|
-
var arrayOverhead = minId === 0 ? maxId : 16 + ("" + minId).length + maxId;
|
193
|
+
const objectOverhead = modules
|
194
|
+
.map(module => (module.id + "").length + 2)
|
195
|
+
.reduce((a, b) => a + b, -1);
|
196
|
+
const arrayOverhead =
|
197
|
+
minId === 0 ? maxId : 16 + ("" + minId).length + maxId;
|
204
198
|
return arrayOverhead < objectOverhead ? [minId, maxId] : false;
|
205
199
|
}
|
206
200
|
|
@@ -217,13 +211,13 @@ class Template {
|
|
217
211
|
filterFn,
|
218
212
|
moduleTemplate,
|
219
213
|
dependencyTemplates,
|
220
|
-
prefix
|
214
|
+
prefix = ""
|
221
215
|
) {
|
222
|
-
|
223
|
-
var source = new ConcatSource();
|
216
|
+
const source = new ConcatSource();
|
224
217
|
const modules = chunk.getModules().filter(filterFn);
|
218
|
+
let removedModules;
|
225
219
|
if (chunk instanceof HotUpdateChunk) {
|
226
|
-
|
220
|
+
removedModules = chunk.removedModules;
|
227
221
|
}
|
228
222
|
if (
|
229
223
|
modules.length === 0 &&
|
@@ -233,7 +227,7 @@ class Template {
|
|
233
227
|
return source;
|
234
228
|
}
|
235
229
|
/** @type {{id: string|number, source: Source|string}[]} */
|
236
|
-
|
230
|
+
const allModules = modules.map(module => {
|
237
231
|
return {
|
238
232
|
id: module.id,
|
239
233
|
source: moduleTemplate.render(module, dependencyTemplates, {
|
@@ -249,38 +243,45 @@ class Template {
|
|
249
243
|
});
|
250
244
|
}
|
251
245
|
}
|
252
|
-
|
253
|
-
|
246
|
+
const bounds = Template.getModulesArrayBounds(allModules);
|
254
247
|
if (bounds) {
|
255
248
|
// Render a spare array
|
256
|
-
|
257
|
-
|
258
|
-
if (minId !== 0)
|
249
|
+
const minId = bounds[0];
|
250
|
+
const maxId = bounds[1];
|
251
|
+
if (minId !== 0) {
|
252
|
+
source.add(`Array(${minId}).concat(`);
|
253
|
+
}
|
259
254
|
source.add("[\n");
|
260
255
|
const modules = new Map();
|
261
256
|
for (const module of allModules) {
|
262
257
|
modules.set(module.id, module);
|
263
258
|
}
|
264
|
-
for (
|
265
|
-
|
266
|
-
if (idx !== minId)
|
267
|
-
|
259
|
+
for (let idx = minId; idx <= maxId; idx++) {
|
260
|
+
const module = modules.get(idx);
|
261
|
+
if (idx !== minId) {
|
262
|
+
source.add(",\n");
|
263
|
+
}
|
264
|
+
source.add(`/* ${idx} */`);
|
268
265
|
if (module) {
|
269
266
|
source.add("\n");
|
270
267
|
source.add(module.source);
|
271
268
|
}
|
272
269
|
}
|
273
270
|
source.add("\n" + prefix + "]");
|
274
|
-
if (minId !== 0)
|
271
|
+
if (minId !== 0) {
|
272
|
+
source.add(")");
|
273
|
+
}
|
275
274
|
} else {
|
276
275
|
// Render an object
|
277
276
|
source.add("{\n");
|
278
277
|
allModules.sort(stringifyIdSortPredicate).forEach((module, idx) => {
|
279
|
-
if (idx !== 0)
|
278
|
+
if (idx !== 0) {
|
279
|
+
source.add(",\n");
|
280
|
+
}
|
280
281
|
source.add(`\n/***/ ${JSON.stringify(module.id)}:\n`);
|
281
282
|
source.add(module.source);
|
282
283
|
});
|
283
|
-
source.add(
|
284
|
+
source.add(`\n\n${prefix}}`);
|
284
285
|
}
|
285
286
|
return source;
|
286
287
|
}
|
@@ -31,7 +31,7 @@ const accessorAccess = (base, accessor, joinWith = ", ") => {
|
|
31
31
|
? base + accessorToObjectAccess(accessors.slice(0, idx + 1))
|
32
32
|
: accessors[0] + accessorToObjectAccess(accessors.slice(1, idx + 1));
|
33
33
|
if (idx === accessors.length - 1) return a;
|
34
|
-
if (idx === 0 &&
|
34
|
+
if (idx === 0 && base === undefined)
|
35
35
|
return `${a} = typeof ${a} === "object" ? ${a} : {}`;
|
36
36
|
return `${a} = ${a} || {}`;
|
37
37
|
})
|
@@ -147,7 +147,7 @@ class UmdMainTemplatePlugin {
|
|
147
147
|
if (typeof request === "object") {
|
148
148
|
request = request[type];
|
149
149
|
}
|
150
|
-
if (
|
150
|
+
if (request === undefined) {
|
151
151
|
throw new Error(
|
152
152
|
"Missing external configuration for type:" + type
|
153
153
|
);
|
@@ -6,7 +6,15 @@
|
|
6
6
|
|
7
7
|
const WebpackError = require("./WebpackError");
|
8
8
|
|
9
|
+
/** @typedef {import("./Module")} Module */
|
10
|
+
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
|
11
|
+
|
9
12
|
class UnsupportedFeatureWarning extends WebpackError {
|
13
|
+
/**
|
14
|
+
* @param {Module} module module relevant to warning
|
15
|
+
* @param {string} message description of warning
|
16
|
+
* @param {DependencyLocation} loc location start and end positions of the module
|
17
|
+
*/
|
10
18
|
constructor(module, message, loc) {
|
11
19
|
super(message);
|
12
20
|
|
package/lib/WatchIgnorePlugin.js
CHANGED
@@ -7,24 +7,6 @@
|
|
7
7
|
const validateOptions = require("schema-utils");
|
8
8
|
const schema = require("../schemas/plugins/WatchIgnorePlugin.json");
|
9
9
|
|
10
|
-
class WatchIgnorePlugin {
|
11
|
-
constructor(paths) {
|
12
|
-
validateOptions(schema, paths, "Watch Ignore Plugin");
|
13
|
-
this.paths = paths;
|
14
|
-
}
|
15
|
-
|
16
|
-
apply(compiler) {
|
17
|
-
compiler.hooks.afterEnvironment.tap("WatchIgnorePlugin", () => {
|
18
|
-
compiler.watchFileSystem = new IgnoringWatchFileSystem(
|
19
|
-
compiler.watchFileSystem,
|
20
|
-
this.paths
|
21
|
-
);
|
22
|
-
});
|
23
|
-
}
|
24
|
-
}
|
25
|
-
|
26
|
-
module.exports = WatchIgnorePlugin;
|
27
|
-
|
28
10
|
class IgnoringWatchFileSystem {
|
29
11
|
constructor(wfs, paths) {
|
30
12
|
this.wfs = wfs;
|
@@ -98,3 +80,21 @@ class IgnoringWatchFileSystem {
|
|
98
80
|
};
|
99
81
|
}
|
100
82
|
}
|
83
|
+
|
84
|
+
class WatchIgnorePlugin {
|
85
|
+
constructor(paths) {
|
86
|
+
validateOptions(schema, paths, "Watch Ignore Plugin");
|
87
|
+
this.paths = paths;
|
88
|
+
}
|
89
|
+
|
90
|
+
apply(compiler) {
|
91
|
+
compiler.hooks.afterEnvironment.tap("WatchIgnorePlugin", () => {
|
92
|
+
compiler.watchFileSystem = new IgnoringWatchFileSystem(
|
93
|
+
compiler.watchFileSystem,
|
94
|
+
this.paths
|
95
|
+
);
|
96
|
+
});
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
module.exports = WatchIgnorePlugin;
|
@@ -5,7 +5,7 @@ const schema = require("../../schemas/plugins/debug/ProfilingPlugin.json");
|
|
5
5
|
let inspector = undefined;
|
6
6
|
|
7
7
|
try {
|
8
|
-
// eslint-disable-next-line node/no-
|
8
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
9
9
|
inspector = require("inspector");
|
10
10
|
} catch (e) {
|
11
11
|
console.log("Unable to CPU profile in < node 8.0");
|
@@ -98,8 +98,7 @@ class AMDPlugin {
|
|
98
98
|
);
|
99
99
|
|
100
100
|
const handler = (parser, parserOptions) => {
|
101
|
-
if (
|
102
|
-
return;
|
101
|
+
if (parserOptions.amd !== undefined && !parserOptions.amd) return;
|
103
102
|
|
104
103
|
const setExpressionToModule = (outerExpr, module) => {
|
105
104
|
parser.hooks.expression.for(outerExpr).tap("AMDPlugin", expr => {
|
@@ -83,10 +83,7 @@ class CommonJsPlugin {
|
|
83
83
|
);
|
84
84
|
|
85
85
|
const handler = (parser, parserOptions) => {
|
86
|
-
if (
|
87
|
-
typeof parserOptions.commonjs !== "undefined" &&
|
88
|
-
!parserOptions.commonjs
|
89
|
-
)
|
86
|
+
if (parserOptions.commonjs !== undefined && !parserOptions.commonjs)
|
90
87
|
return;
|
91
88
|
|
92
89
|
const requireExpressions = [
|
@@ -15,6 +15,32 @@ const quotemeta = str => {
|
|
15
15
|
return str.replace(/[-[\]\\/{}()*+?.^$|]/g, "\\$&");
|
16
16
|
};
|
17
17
|
|
18
|
+
const splitContextFromPrefix = prefix => {
|
19
|
+
const idx = prefix.lastIndexOf("/");
|
20
|
+
let context = ".";
|
21
|
+
if (idx >= 0) {
|
22
|
+
context = prefix.substr(0, idx);
|
23
|
+
prefix = `.${prefix.substr(idx)}`;
|
24
|
+
}
|
25
|
+
return {
|
26
|
+
context,
|
27
|
+
prefix
|
28
|
+
};
|
29
|
+
};
|
30
|
+
|
31
|
+
const splitQueryFromPostfix = postfix => {
|
32
|
+
const idx = postfix.indexOf("?");
|
33
|
+
let query = "";
|
34
|
+
if (idx >= 0) {
|
35
|
+
query = postfix.substr(idx);
|
36
|
+
postfix = postfix.substr(0, idx);
|
37
|
+
}
|
38
|
+
return {
|
39
|
+
postfix,
|
40
|
+
query
|
41
|
+
};
|
42
|
+
};
|
43
|
+
|
18
44
|
ContextDependencyHelpers.create = (
|
19
45
|
Dep,
|
20
46
|
range,
|
@@ -23,38 +49,30 @@ ContextDependencyHelpers.create = (
|
|
23
49
|
options,
|
24
50
|
contextOptions
|
25
51
|
) => {
|
26
|
-
let dep;
|
27
|
-
let prefix;
|
28
|
-
let postfix;
|
29
|
-
let prefixRange;
|
30
|
-
let valueRange;
|
31
|
-
let idx;
|
32
|
-
let context;
|
33
|
-
let regExp;
|
34
52
|
if (param.isTemplateString()) {
|
35
|
-
|
36
|
-
|
53
|
+
let prefixRaw = param.quasis[0].string;
|
54
|
+
let postfixRaw =
|
37
55
|
param.quasis.length > 1
|
38
56
|
? param.quasis[param.quasis.length - 1].string
|
39
57
|
: "";
|
40
|
-
prefixRange = [param.quasis[0].range[0], param.quasis[0].range[1]];
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
}
|
58
|
+
const prefixRange = [param.quasis[0].range[0], param.quasis[0].range[1]];
|
59
|
+
const postfixRange =
|
60
|
+
param.quasis.length > 1
|
61
|
+
? param.quasis[param.quasis.length - 1].range
|
62
|
+
: "";
|
63
|
+
const valueRange = param.range;
|
64
|
+
const { context, prefix } = splitContextFromPrefix(prefixRaw);
|
65
|
+
const { postfix, query } = splitQueryFromPostfix(postfixRaw);
|
48
66
|
// If there are more than two quasis, maybe the generated RegExp can be more precise?
|
49
|
-
regExp = new RegExp(
|
67
|
+
const regExp = new RegExp(
|
50
68
|
`^${quotemeta(prefix)}${options.wrappedContextRegExp.source}${quotemeta(
|
51
69
|
postfix
|
52
70
|
)}$`
|
53
71
|
);
|
54
|
-
dep = new Dep(
|
72
|
+
const dep = new Dep(
|
55
73
|
Object.assign(
|
56
74
|
{
|
57
|
-
request: context,
|
75
|
+
request: context + query,
|
58
76
|
recursive: options.wrappedContextRecursive,
|
59
77
|
regExp,
|
60
78
|
mode: "sync"
|
@@ -65,12 +83,20 @@ ContextDependencyHelpers.create = (
|
|
65
83
|
valueRange
|
66
84
|
);
|
67
85
|
dep.loc = expr.loc;
|
68
|
-
|
69
|
-
|
86
|
+
const replaces = [];
|
87
|
+
if (prefixRange && prefix !== prefixRaw) {
|
88
|
+
replaces.push({
|
70
89
|
range: prefixRange,
|
71
90
|
value: prefix
|
72
|
-
}
|
73
|
-
|
91
|
+
});
|
92
|
+
}
|
93
|
+
if (postfixRange && postfix !== postfixRaw) {
|
94
|
+
replaces.push({
|
95
|
+
range: postfixRange,
|
96
|
+
value: postfix
|
97
|
+
});
|
98
|
+
}
|
99
|
+
dep.replaces = replaces;
|
74
100
|
dep.critical =
|
75
101
|
options.wrappedContextCritical &&
|
76
102
|
"a part of the request of a dependency is an expression";
|
@@ -80,30 +106,26 @@ ContextDependencyHelpers.create = (
|
|
80
106
|
((param.prefix && param.prefix.isString()) ||
|
81
107
|
(param.postfix && param.postfix.isString()))
|
82
108
|
) {
|
83
|
-
|
84
|
-
|
109
|
+
let prefixRaw =
|
110
|
+
param.prefix && param.prefix.isString() ? param.prefix.string : "";
|
111
|
+
let postfixRaw =
|
85
112
|
param.postfix && param.postfix.isString() ? param.postfix.string : "";
|
86
|
-
prefixRange =
|
113
|
+
const prefixRange =
|
87
114
|
param.prefix && param.prefix.isString() ? param.prefix.range : null;
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
if (idx >= 0) {
|
95
|
-
context = prefix.substr(0, idx);
|
96
|
-
prefix = `.${prefix.substr(idx)}`;
|
97
|
-
}
|
98
|
-
regExp = new RegExp(
|
115
|
+
const postfixRange =
|
116
|
+
param.postfix && param.postfix.isString() ? param.postfix.range : null;
|
117
|
+
const valueRange = param.range;
|
118
|
+
const { context, prefix } = splitContextFromPrefix(prefixRaw);
|
119
|
+
const { postfix, query } = splitQueryFromPostfix(postfixRaw);
|
120
|
+
const regExp = new RegExp(
|
99
121
|
`^${quotemeta(prefix)}${options.wrappedContextRegExp.source}${quotemeta(
|
100
122
|
postfix
|
101
123
|
)}$`
|
102
124
|
);
|
103
|
-
dep = new Dep(
|
125
|
+
const dep = new Dep(
|
104
126
|
Object.assign(
|
105
127
|
{
|
106
|
-
request: context,
|
128
|
+
request: context + query,
|
107
129
|
recursive: options.wrappedContextRecursive,
|
108
130
|
regExp,
|
109
131
|
mode: "sync"
|
@@ -114,13 +136,26 @@ ContextDependencyHelpers.create = (
|
|
114
136
|
valueRange
|
115
137
|
);
|
116
138
|
dep.loc = expr.loc;
|
117
|
-
|
139
|
+
const replaces = [];
|
140
|
+
if (prefixRange && prefix !== prefixRaw) {
|
141
|
+
replaces.push({
|
142
|
+
range: prefixRange,
|
143
|
+
value: JSON.stringify(prefix)
|
144
|
+
});
|
145
|
+
}
|
146
|
+
if (postfixRange && postfix !== postfixRaw) {
|
147
|
+
replaces.push({
|
148
|
+
range: postfixRange,
|
149
|
+
value: JSON.stringify(postfix)
|
150
|
+
});
|
151
|
+
}
|
152
|
+
dep.replaces = replaces;
|
118
153
|
dep.critical =
|
119
154
|
options.wrappedContextCritical &&
|
120
155
|
"a part of the request of a dependency is an expression";
|
121
156
|
return dep;
|
122
157
|
} else {
|
123
|
-
dep = new Dep(
|
158
|
+
const dep = new Dep(
|
124
159
|
Object.assign(
|
125
160
|
{
|
126
161
|
request: options.exprContextRequest,
|
@@ -121,10 +121,7 @@ class HarmonyModulesPlugin {
|
|
121
121
|
);
|
122
122
|
|
123
123
|
const handler = (parser, parserOptions) => {
|
124
|
-
if (
|
125
|
-
typeof parserOptions.harmony !== "undefined" &&
|
126
|
-
!parserOptions.harmony
|
127
|
-
)
|
124
|
+
if (parserOptions.harmony !== undefined && !parserOptions.harmony)
|
128
125
|
return;
|
129
126
|
|
130
127
|
new HarmonyDetectionParserPlugin().apply(parser);
|
@@ -54,7 +54,7 @@ class ImportParserPlugin {
|
|
54
54
|
}
|
55
55
|
|
56
56
|
if (importOptions) {
|
57
|
-
if (
|
57
|
+
if (importOptions.webpackIgnore !== undefined) {
|
58
58
|
if (typeof importOptions.webpackIgnore !== "boolean") {
|
59
59
|
parser.state.module.warnings.push(
|
60
60
|
new UnsupportedFeatureWarning(
|
@@ -72,7 +72,7 @@ class ImportParserPlugin {
|
|
72
72
|
}
|
73
73
|
}
|
74
74
|
}
|
75
|
-
if (
|
75
|
+
if (importOptions.webpackChunkName !== undefined) {
|
76
76
|
if (typeof importOptions.webpackChunkName !== "string") {
|
77
77
|
parser.state.module.warnings.push(
|
78
78
|
new UnsupportedFeatureWarning(
|
@@ -87,7 +87,7 @@ class ImportParserPlugin {
|
|
87
87
|
chunkName = importOptions.webpackChunkName;
|
88
88
|
}
|
89
89
|
}
|
90
|
-
if (
|
90
|
+
if (importOptions.webpackMode !== undefined) {
|
91
91
|
if (typeof importOptions.webpackMode !== "string") {
|
92
92
|
parser.state.module.warnings.push(
|
93
93
|
new UnsupportedFeatureWarning(
|
@@ -102,7 +102,7 @@ class ImportParserPlugin {
|
|
102
102
|
mode = importOptions.webpackMode;
|
103
103
|
}
|
104
104
|
}
|
105
|
-
if (
|
105
|
+
if (importOptions.webpackPrefetch !== undefined) {
|
106
106
|
if (importOptions.webpackPrefetch === true) {
|
107
107
|
groupOptions.prefetchOrder = 0;
|
108
108
|
} else if (typeof importOptions.webpackPrefetch === "number") {
|
@@ -119,7 +119,7 @@ class ImportParserPlugin {
|
|
119
119
|
);
|
120
120
|
}
|
121
121
|
}
|
122
|
-
if (
|
122
|
+
if (importOptions.webpackPreload !== undefined) {
|
123
123
|
if (importOptions.webpackPreload === true) {
|
124
124
|
groupOptions.preloadOrder = 0;
|
125
125
|
} else if (typeof importOptions.webpackPreload === "number") {
|
@@ -136,7 +136,7 @@ class ImportParserPlugin {
|
|
136
136
|
);
|
137
137
|
}
|
138
138
|
}
|
139
|
-
if (
|
139
|
+
if (importOptions.webpackInclude !== undefined) {
|
140
140
|
if (
|
141
141
|
!importOptions.webpackInclude ||
|
142
142
|
importOptions.webpackInclude.constructor.name !== "RegExp"
|
@@ -154,7 +154,7 @@ class ImportParserPlugin {
|
|
154
154
|
include = new RegExp(importOptions.webpackInclude);
|
155
155
|
}
|
156
156
|
}
|
157
|
-
if (
|
157
|
+
if (importOptions.webpackExclude !== undefined) {
|
158
158
|
if (
|
159
159
|
!importOptions.webpackExclude ||
|
160
160
|
importOptions.webpackExclude.constructor.name !== "RegExp"
|
@@ -57,10 +57,7 @@ class ImportPlugin {
|
|
57
57
|
);
|
58
58
|
|
59
59
|
const handler = (parser, parserOptions) => {
|
60
|
-
if (
|
61
|
-
typeof parserOptions.import !== "undefined" &&
|
62
|
-
!parserOptions.import
|
63
|
-
)
|
60
|
+
if (parserOptions.import !== undefined && !parserOptions.import)
|
64
61
|
return;
|
65
62
|
|
66
63
|
new ImportParserPlugin(options).apply(parser);
|
@@ -17,13 +17,10 @@ class SystemPlugin {
|
|
17
17
|
"SystemPlugin",
|
18
18
|
(compilation, { normalModuleFactory }) => {
|
19
19
|
const handler = (parser, parserOptions) => {
|
20
|
-
if (
|
21
|
-
typeof parserOptions.system !== "undefined" &&
|
22
|
-
!parserOptions.system
|
23
|
-
)
|
20
|
+
if (parserOptions.system !== undefined && !parserOptions.system)
|
24
21
|
return;
|
25
22
|
|
26
|
-
const shouldWarn =
|
23
|
+
const shouldWarn = parserOptions.system === undefined;
|
27
24
|
|
28
25
|
const setNotSupported = name => {
|
29
26
|
parser.hooks.evaluateTypeof
|
@@ -136,6 +136,9 @@ const getFinalName = (
|
|
136
136
|
} else if (!info.module.isUsed(exportName)) {
|
137
137
|
return "/* unused export */ undefined";
|
138
138
|
}
|
139
|
+
if (info.globalExports.has(directExport)) {
|
140
|
+
return directExport;
|
141
|
+
}
|
139
142
|
const name = info.internalNames.get(directExport);
|
140
143
|
if (!name) {
|
141
144
|
throw new Error(
|
@@ -267,7 +270,7 @@ const getPathInAst = (ast, node) => {
|
|
267
270
|
if (Array.isArray(ast)) {
|
268
271
|
for (i = 0; i < ast.length; i++) {
|
269
272
|
const enterResult = enterNode(ast[i]);
|
270
|
-
if (
|
273
|
+
if (enterResult !== undefined) return enterResult;
|
271
274
|
}
|
272
275
|
} else if (ast && typeof ast === "object") {
|
273
276
|
const keys = Object.keys(ast);
|
@@ -275,10 +278,10 @@ const getPathInAst = (ast, node) => {
|
|
275
278
|
const value = ast[keys[i]];
|
276
279
|
if (Array.isArray(value)) {
|
277
280
|
const pathResult = getPathInAst(value, node);
|
278
|
-
if (
|
281
|
+
if (pathResult !== undefined) return pathResult;
|
279
282
|
} else if (value && typeof value === "object") {
|
280
283
|
const enterResult = enterNode(value);
|
281
|
-
if (
|
284
|
+
if (enterResult !== undefined) return enterResult;
|
282
285
|
}
|
283
286
|
}
|
284
287
|
}
|
@@ -562,6 +565,7 @@ class ConcatenatedModule extends Module {
|
|
562
565
|
globalScope: undefined,
|
563
566
|
moduleScope: undefined,
|
564
567
|
internalNames: new Map(),
|
568
|
+
globalExports: new Set(),
|
565
569
|
exportMap: exportMap,
|
566
570
|
reexportMap: reexportMap,
|
567
571
|
hasNamespaceObject: false,
|
@@ -941,6 +945,19 @@ class ConcatenatedModule extends Module {
|
|
941
945
|
}
|
942
946
|
}
|
943
947
|
}
|
948
|
+
|
949
|
+
// add exported globals
|
950
|
+
if (info.type === "concatenated") {
|
951
|
+
const variables = new Set();
|
952
|
+
for (const variable of info.moduleScope.variables) {
|
953
|
+
variables.add(variable.name);
|
954
|
+
}
|
955
|
+
for (const [, variable] of info.exportMap) {
|
956
|
+
if (!variables.has(variable)) {
|
957
|
+
info.globalExports.add(variable);
|
958
|
+
}
|
959
|
+
}
|
960
|
+
}
|
944
961
|
}
|
945
962
|
|
946
963
|
// generate names for symbols
|
@@ -1430,8 +1447,9 @@ class HarmonyExportImportedSpecifierDependencyConcatenatedTemplate {
|
|
1430
1447
|
if (!used) {
|
1431
1448
|
source.insert(
|
1432
1449
|
-1,
|
1433
|
-
`/* unused concated harmony import ${
|
1450
|
+
`/* unused concated harmony import ${def.name} */\n`
|
1434
1451
|
);
|
1452
|
+
continue;
|
1435
1453
|
}
|
1436
1454
|
let finalName;
|
1437
1455
|
const strictFlag = dep.originModule.buildMeta.strictHarmonyModule
|
@@ -1448,9 +1466,11 @@ class HarmonyExportImportedSpecifierDependencyConcatenatedTemplate {
|
|
1448
1466
|
}_${exportData}${strictFlag}__`;
|
1449
1467
|
}
|
1450
1468
|
const exportsName = this.rootModule.exportsArgument;
|
1451
|
-
const content =
|
1452
|
-
|
1453
|
-
|
1469
|
+
const content =
|
1470
|
+
`/* concated harmony reexport ${def.name} */` +
|
1471
|
+
`__webpack_require__.d(${exportsName}, ` +
|
1472
|
+
`${JSON.stringify(used)}, ` +
|
1473
|
+
`function() { return ${finalName}; });\n`;
|
1454
1474
|
source.insert(-1, content);
|
1455
1475
|
}
|
1456
1476
|
} else {
|
package/lib/util/identifier.js
CHANGED
@@ -60,13 +60,13 @@ exports.makePathsRelative = (context, identifier, cache) => {
|
|
60
60
|
|
61
61
|
let cachedResult;
|
62
62
|
let contextCache = relativePaths.get(context);
|
63
|
-
if (
|
63
|
+
if (contextCache === undefined) {
|
64
64
|
relativePaths.set(context, (contextCache = new Map()));
|
65
65
|
} else {
|
66
66
|
cachedResult = contextCache.get(identifier);
|
67
67
|
}
|
68
68
|
|
69
|
-
if (
|
69
|
+
if (cachedResult !== undefined) {
|
70
70
|
return cachedResult;
|
71
71
|
} else {
|
72
72
|
const relativePath = _makePathsRelative(context, identifier);
|
@@ -47,9 +47,12 @@ const preprocess = ab => {
|
|
47
47
|
* @returns {Function} composed transform
|
48
48
|
*/
|
49
49
|
const compose = (...fns) => {
|
50
|
-
return fns.reduce(
|
51
|
-
|
52
|
-
|
50
|
+
return fns.reduce(
|
51
|
+
(prevFn, nextFn) => {
|
52
|
+
return value => nextFn(prevFn(value));
|
53
|
+
},
|
54
|
+
value => value
|
55
|
+
);
|
53
56
|
};
|
54
57
|
|
55
58
|
// TODO replace with @callback
|
@@ -111,7 +114,7 @@ const getCountImportedFunc = ast => {
|
|
111
114
|
const getNextTypeIndex = ast => {
|
112
115
|
const typeSectionMetadata = t.getSectionMetadata(ast, "type");
|
113
116
|
|
114
|
-
if (
|
117
|
+
if (typeSectionMetadata === undefined) {
|
115
118
|
return t.indexLiteral(0);
|
116
119
|
}
|
117
120
|
|
@@ -132,7 +135,7 @@ const getNextTypeIndex = ast => {
|
|
132
135
|
const getNextFuncIndex = (ast, countImportedFunc) => {
|
133
136
|
const funcSectionMetadata = t.getSectionMetadata(ast, "func");
|
134
137
|
|
135
|
-
if (
|
138
|
+
if (funcSectionMetadata === undefined) {
|
136
139
|
return t.indexLiteral(0 + countImportedFunc);
|
137
140
|
}
|
138
141
|
|
@@ -268,7 +271,7 @@ const rewriteImports = ({ ast, usedDependencyMap }) => bin => {
|
|
268
271
|
path.node.module + ":" + path.node.name
|
269
272
|
);
|
270
273
|
|
271
|
-
if (
|
274
|
+
if (result !== undefined) {
|
272
275
|
path.node.module = result.module;
|
273
276
|
path.node.name = result.name;
|
274
277
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "4.
|
3
|
+
"version": "4.17.1",
|
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
|
"license": "MIT",
|
@@ -43,10 +43,10 @@
|
|
43
43
|
"coveralls": "^2.11.2",
|
44
44
|
"css-loader": "^0.28.3",
|
45
45
|
"es6-promise-polyfill": "^1.1.1",
|
46
|
-
"eslint": "^5.
|
46
|
+
"eslint": "^5.2.0",
|
47
47
|
"eslint-config-prettier": "^2.9.0",
|
48
|
-
"eslint-plugin-jest": "^21.
|
49
|
-
"eslint-plugin-node": "^
|
48
|
+
"eslint-plugin-jest": "^21.18.0",
|
49
|
+
"eslint-plugin-node": "^7.0.1",
|
50
50
|
"eslint-plugin-prettier": "^2.6.2",
|
51
51
|
"express": "~4.13.1",
|
52
52
|
"file-loader": "^1.1.6",
|
@@ -63,7 +63,7 @@
|
|
63
63
|
"less-loader": "^4.0.3",
|
64
64
|
"lint-staged": "^7.2.0",
|
65
65
|
"lodash": "^4.17.4",
|
66
|
-
"prettier": "^1.
|
66
|
+
"prettier": "^1.14.0",
|
67
67
|
"pug": "^2.0.3",
|
68
68
|
"pug-loader": "^2.4.0",
|
69
69
|
"raw-loader": "~0.5.0",
|
@@ -0,0 +1,31 @@
|
|
1
|
+
{
|
2
|
+
"type": "object",
|
3
|
+
"oneOf": [
|
4
|
+
{
|
5
|
+
"additionalProperties": false,
|
6
|
+
"properties": {
|
7
|
+
"resourceRegExp": {
|
8
|
+
"description": "A RegExp to test the request against",
|
9
|
+
"instanceof": "RegExp"
|
10
|
+
},
|
11
|
+
"contextRegExp": {
|
12
|
+
"description": "A RegExp to test the context (directory) against",
|
13
|
+
"instanceof": "RegExp"
|
14
|
+
}
|
15
|
+
}
|
16
|
+
},
|
17
|
+
{
|
18
|
+
"additionalProperties": false,
|
19
|
+
"properties": {
|
20
|
+
"checkResource": {
|
21
|
+
"description": "A filter function for resource",
|
22
|
+
"instanceof": "Function"
|
23
|
+
},
|
24
|
+
"checkContext": {
|
25
|
+
"description": "A filter function for context",
|
26
|
+
"instanceof": "Function"
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
]
|
31
|
+
}
|