webpack 4.16.3 → 4.16.4

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.
@@ -1,211 +1,211 @@
1
- /*
2
- MIT License http://www.opensource.org/licenses/mit-license.php
3
- Author Tobias Koppers @sokra
4
- */
5
-
6
- "use strict";
7
-
8
- const TypeUnknown = 0;
9
- const TypeNull = 1;
10
- const TypeString = 2;
11
- const TypeNumber = 3;
12
- const TypeBoolean = 4;
13
- const TypeRegExp = 5;
14
- const TypeConditional = 6;
15
- const TypeArray = 7;
16
- const TypeConstArray = 8;
17
- const TypeIdentifier = 9;
18
- const TypeWrapped = 10;
19
- const TypeTemplateString = 11;
20
-
21
- class BasicEvaluatedExpression {
22
- constructor() {
23
- this.type = TypeUnknown;
24
- this.range = null;
25
- this.falsy = false;
26
- this.truthy = false;
27
- this.bool = null;
28
- this.number = null;
29
- this.regExp = null;
30
- this.string = null;
31
- this.quasis = null;
32
- this.array = null;
33
- this.items = null;
34
- this.options = null;
35
- this.prefix = null;
36
- this.postfix = null;
37
- }
38
-
39
- isNull() {
40
- return this.type === TypeNull;
41
- }
42
-
43
- isString() {
44
- return this.type === TypeString;
45
- }
46
-
47
- isNumber() {
48
- return this.type === TypeNumber;
49
- }
50
-
51
- isBoolean() {
52
- return this.type === TypeBoolean;
53
- }
54
-
55
- isRegExp() {
56
- return this.type === TypeRegExp;
57
- }
58
-
59
- isConditional() {
60
- return this.type === TypeConditional;
61
- }
62
-
63
- isArray() {
64
- return this.type === TypeArray;
65
- }
66
-
67
- isConstArray() {
68
- return this.type === TypeConstArray;
69
- }
70
-
71
- isIdentifier() {
72
- return this.type === TypeIdentifier;
73
- }
74
-
75
- isWrapped() {
76
- return this.type === TypeWrapped;
77
- }
78
-
79
- isTemplateString() {
80
- return this.type === TypeTemplateString;
81
- }
82
-
83
- isTruthy() {
84
- return this.truthy;
85
- }
86
-
87
- isFalsy() {
88
- return this.falsy;
89
- }
90
-
91
- asBool() {
92
- if (this.truthy) return true;
93
- if (this.falsy) return false;
94
- if (this.isBoolean()) return this.bool;
95
- if (this.isNull()) return false;
96
- if (this.isString()) return this.string !== "";
97
- if (this.isNumber()) return this.number !== 0;
98
- if (this.isRegExp()) return true;
99
- if (this.isArray()) return true;
100
- if (this.isConstArray()) return true;
101
- if (this.isWrapped()) {
102
- return (this.prefix && this.prefix.asBool()) ||
103
- (this.postfix && this.postfix.asBool())
104
- ? true
105
- : undefined;
106
- }
107
- if (this.isTemplateString()) {
108
- for (const quasi of this.quasis) {
109
- if (quasi.asBool()) return true;
110
- }
111
- // can't tell if string will be empty without executing
112
- }
113
- return undefined;
114
- }
115
-
116
- setString(string) {
117
- this.type = TypeString;
118
- this.string = string;
119
- return this;
120
- }
121
-
122
- setNull() {
123
- this.type = TypeNull;
124
- return this;
125
- }
126
-
127
- setNumber(number) {
128
- this.type = TypeNumber;
129
- this.number = number;
130
- return this;
131
- }
132
-
133
- setBoolean(bool) {
134
- this.type = TypeBoolean;
135
- this.bool = bool;
136
- return this;
137
- }
138
-
139
- setRegExp(regExp) {
140
- this.type = TypeRegExp;
141
- this.regExp = regExp;
142
- return this;
143
- }
144
-
145
- setIdentifier(identifier) {
146
- this.type = TypeIdentifier;
147
- this.identifier = identifier;
148
- return this;
149
- }
150
-
151
- setWrapped(prefix, postfix) {
152
- this.type = TypeWrapped;
153
- this.prefix = prefix;
154
- this.postfix = postfix;
155
- return this;
156
- }
157
-
158
- setOptions(options) {
159
- this.type = TypeConditional;
160
- this.options = options;
161
- return this;
162
- }
163
-
164
- addOptions(options) {
165
- if (!this.options) {
166
- this.type = TypeConditional;
167
- this.options = [];
168
- }
169
- for (const item of options) {
170
- this.options.push(item);
171
- }
172
- return this;
173
- }
174
-
175
- setItems(items) {
176
- this.type = TypeArray;
177
- this.items = items;
178
- return this;
179
- }
180
-
181
- setArray(array) {
182
- this.type = TypeConstArray;
183
- this.array = array;
184
- return this;
185
- }
186
-
187
- setTemplateString(quasis) {
188
- this.type = TypeTemplateString;
189
- this.quasis = quasis;
190
- return this;
191
- }
192
-
193
- setTruthy() {
194
- this.falsy = false;
195
- this.truthy = true;
196
- return this;
197
- }
198
-
199
- setFalsy() {
200
- this.falsy = true;
201
- this.truthy = false;
202
- return this;
203
- }
204
-
205
- setRange(range) {
206
- this.range = range;
207
- return this;
208
- }
209
- }
210
-
211
- module.exports = BasicEvaluatedExpression;
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Tobias Koppers @sokra
4
+ */
5
+
6
+ "use strict";
7
+
8
+ const TypeUnknown = 0;
9
+ const TypeNull = 1;
10
+ const TypeString = 2;
11
+ const TypeNumber = 3;
12
+ const TypeBoolean = 4;
13
+ const TypeRegExp = 5;
14
+ const TypeConditional = 6;
15
+ const TypeArray = 7;
16
+ const TypeConstArray = 8;
17
+ const TypeIdentifier = 9;
18
+ const TypeWrapped = 10;
19
+ const TypeTemplateString = 11;
20
+
21
+ class BasicEvaluatedExpression {
22
+ constructor() {
23
+ this.type = TypeUnknown;
24
+ this.range = null;
25
+ this.falsy = false;
26
+ this.truthy = false;
27
+ this.bool = null;
28
+ this.number = null;
29
+ this.regExp = null;
30
+ this.string = null;
31
+ this.quasis = null;
32
+ this.array = null;
33
+ this.items = null;
34
+ this.options = null;
35
+ this.prefix = null;
36
+ this.postfix = null;
37
+ }
38
+
39
+ isNull() {
40
+ return this.type === TypeNull;
41
+ }
42
+
43
+ isString() {
44
+ return this.type === TypeString;
45
+ }
46
+
47
+ isNumber() {
48
+ return this.type === TypeNumber;
49
+ }
50
+
51
+ isBoolean() {
52
+ return this.type === TypeBoolean;
53
+ }
54
+
55
+ isRegExp() {
56
+ return this.type === TypeRegExp;
57
+ }
58
+
59
+ isConditional() {
60
+ return this.type === TypeConditional;
61
+ }
62
+
63
+ isArray() {
64
+ return this.type === TypeArray;
65
+ }
66
+
67
+ isConstArray() {
68
+ return this.type === TypeConstArray;
69
+ }
70
+
71
+ isIdentifier() {
72
+ return this.type === TypeIdentifier;
73
+ }
74
+
75
+ isWrapped() {
76
+ return this.type === TypeWrapped;
77
+ }
78
+
79
+ isTemplateString() {
80
+ return this.type === TypeTemplateString;
81
+ }
82
+
83
+ isTruthy() {
84
+ return this.truthy;
85
+ }
86
+
87
+ isFalsy() {
88
+ return this.falsy;
89
+ }
90
+
91
+ asBool() {
92
+ if (this.truthy) return true;
93
+ if (this.falsy) return false;
94
+ if (this.isBoolean()) return this.bool;
95
+ if (this.isNull()) return false;
96
+ if (this.isString()) return this.string !== "";
97
+ if (this.isNumber()) return this.number !== 0;
98
+ if (this.isRegExp()) return true;
99
+ if (this.isArray()) return true;
100
+ if (this.isConstArray()) return true;
101
+ if (this.isWrapped()) {
102
+ return (this.prefix && this.prefix.asBool()) ||
103
+ (this.postfix && this.postfix.asBool())
104
+ ? true
105
+ : undefined;
106
+ }
107
+ if (this.isTemplateString()) {
108
+ for (const quasi of this.quasis) {
109
+ if (quasi.asBool()) return true;
110
+ }
111
+ // can't tell if string will be empty without executing
112
+ }
113
+ return undefined;
114
+ }
115
+
116
+ setString(string) {
117
+ this.type = TypeString;
118
+ this.string = string;
119
+ return this;
120
+ }
121
+
122
+ setNull() {
123
+ this.type = TypeNull;
124
+ return this;
125
+ }
126
+
127
+ setNumber(number) {
128
+ this.type = TypeNumber;
129
+ this.number = number;
130
+ return this;
131
+ }
132
+
133
+ setBoolean(bool) {
134
+ this.type = TypeBoolean;
135
+ this.bool = bool;
136
+ return this;
137
+ }
138
+
139
+ setRegExp(regExp) {
140
+ this.type = TypeRegExp;
141
+ this.regExp = regExp;
142
+ return this;
143
+ }
144
+
145
+ setIdentifier(identifier) {
146
+ this.type = TypeIdentifier;
147
+ this.identifier = identifier;
148
+ return this;
149
+ }
150
+
151
+ setWrapped(prefix, postfix) {
152
+ this.type = TypeWrapped;
153
+ this.prefix = prefix;
154
+ this.postfix = postfix;
155
+ return this;
156
+ }
157
+
158
+ setOptions(options) {
159
+ this.type = TypeConditional;
160
+ this.options = options;
161
+ return this;
162
+ }
163
+
164
+ addOptions(options) {
165
+ if (!this.options) {
166
+ this.type = TypeConditional;
167
+ this.options = [];
168
+ }
169
+ for (const item of options) {
170
+ this.options.push(item);
171
+ }
172
+ return this;
173
+ }
174
+
175
+ setItems(items) {
176
+ this.type = TypeArray;
177
+ this.items = items;
178
+ return this;
179
+ }
180
+
181
+ setArray(array) {
182
+ this.type = TypeConstArray;
183
+ this.array = array;
184
+ return this;
185
+ }
186
+
187
+ setTemplateString(quasis) {
188
+ this.type = TypeTemplateString;
189
+ this.quasis = quasis;
190
+ return this;
191
+ }
192
+
193
+ setTruthy() {
194
+ this.falsy = false;
195
+ this.truthy = true;
196
+ return this;
197
+ }
198
+
199
+ setFalsy() {
200
+ this.falsy = true;
201
+ this.truthy = false;
202
+ return this;
203
+ }
204
+
205
+ setRange(range) {
206
+ this.range = range;
207
+ return this;
208
+ }
209
+ }
210
+
211
+ module.exports = BasicEvaluatedExpression;
@@ -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/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
- var aId = a.id + "";
43
- var bId = b.id + "";
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[]} str string to convert to identity
132
+ * @param {string | string[]} s string to convert to identity
132
133
  * @returns {string} converted identity
133
134
  */
134
- static indent(str) {
135
- if (Array.isArray(str)) {
136
- return str.map(Template.indent).join("\n");
135
+ static indent(s) {
136
+ if (Array.isArray(s)) {
137
+ return s.map(Template.indent).join("\n");
137
138
  } else {
138
- str = str.trimRight();
139
+ const str = s.trimRight();
139
140
  if (!str) return "";
140
- var ind = str[0] === "\n" ? "" : "\t";
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[]} str string to create prefix for
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(str, prefix) {
152
- if (Array.isArray(str)) {
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
- var maxId = -Infinity;
185
- var minId = Infinity;
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
- var objectOverhead = modules
196
- .map(module => {
197
- var idLength = (module.id + "").length;
198
- return idLength + 2;
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
- if (!prefix) prefix = "";
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
- var removedModules = chunk.removedModules;
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
- var allModules = modules.map(module => {
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
- var bounds = Template.getModulesArrayBounds(allModules);
253
-
246
+ const bounds = Template.getModulesArrayBounds(allModules);
254
247
  if (bounds) {
255
248
  // Render a spare array
256
- var minId = bounds[0];
257
- var maxId = bounds[1];
258
- if (minId !== 0) source.add("Array(" + minId + ").concat(");
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 (var idx = minId; idx <= maxId; idx++) {
265
- var module = modules.get(idx);
266
- if (idx !== minId) source.add(",\n");
267
- source.add("/* " + idx + " */");
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) source.add(")");
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) source.add(",\n");
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("\n\n" + prefix + "}");
284
+ source.add(`\n\n${prefix}}`);
284
285
  }
285
286
  return source;
286
287
  }
@@ -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-missing-require
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");
@@ -7,6 +7,7 @@
7
7
  const ExternalsPlugin = require("../ExternalsPlugin");
8
8
 
9
9
  const builtins =
10
+ // eslint-disable-next-line node/no-unsupported-features/node-builtins
10
11
  require("module").builtinModules || Object.keys(process.binding("natives"));
11
12
 
12
13
  class NodeTargetPlugin {