webpack 4.20.2 → 4.23.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.
Files changed (50) hide show
  1. package/LICENSE +20 -20
  2. package/SECURITY.md +9 -9
  3. package/buildin/amd-define.js +3 -3
  4. package/buildin/amd-options.js +2 -2
  5. package/buildin/global.js +20 -20
  6. package/buildin/module.js +22 -22
  7. package/buildin/system.js +7 -7
  8. package/declarations/WebpackOptions.d.ts +1388 -0
  9. package/declarations/plugins/BannerPlugin.d.ts +51 -0
  10. package/declarations/plugins/DllPlugin.d.ts +28 -0
  11. package/declarations/plugins/DllReferencePlugin.d.ts +126 -0
  12. package/declarations/plugins/HashedModuleIdsPlugin.d.ts +24 -0
  13. package/declarations/plugins/IgnorePlugin.d.ts +27 -0
  14. package/declarations/plugins/LoaderOptionsPlugin.d.ts +27 -0
  15. package/declarations/plugins/SourceMapDevToolPlugin.d.ts +94 -0
  16. package/declarations/plugins/WatchIgnorePlugin.d.ts +10 -0
  17. package/declarations/plugins/debug/ProfilingPlugin.d.ts +12 -0
  18. package/declarations/plugins/optimize/AggressiveSplittingPlugin.d.ts +24 -0
  19. package/declarations/plugins/optimize/LimitChunkCountPlugin.d.ts +16 -0
  20. package/declarations/plugins/optimize/MinChunkSizePlugin.d.ts +12 -0
  21. package/declarations/plugins/optimize/OccurrenceOrderChunkIdsPlugin.d.ts +12 -0
  22. package/declarations/plugins/optimize/OccurrenceOrderModuleIdsPlugin.d.ts +12 -0
  23. package/hot/emitter.js +2 -2
  24. package/lib/AmdMainTemplatePlugin.js +22 -5
  25. package/lib/BasicEvaluatedExpression.js +211 -211
  26. package/lib/Chunk.js +33 -14
  27. package/lib/Compilation.js +99 -52
  28. package/lib/Compiler.js +6 -1
  29. package/lib/ConstPlugin.js +85 -0
  30. package/lib/Entrypoint.js +10 -0
  31. package/lib/ExternalModule.js +3 -2
  32. package/lib/LibraryTemplatePlugin.js +11 -8
  33. package/lib/MainTemplate.js +13 -0
  34. package/lib/Parser.js +9 -1
  35. package/lib/Stats.js +44 -45
  36. package/lib/WatchIgnorePlugin.js +4 -3
  37. package/lib/Watching.js +4 -3
  38. package/lib/dependencies/WebAssemblyExportImportedDependency.js +3 -1
  39. package/lib/node/NodeWatchFileSystem.js +16 -6
  40. package/lib/optimize/LimitChunkCountPlugin.js +11 -5
  41. package/lib/optimize/OccurrenceModuleOrderPlugin.js +5 -1
  42. package/lib/wasm/WasmFinalizeExportsPlugin.js +2 -0
  43. package/lib/wasm/WebAssemblyJavascriptGenerator.js +9 -4
  44. package/lib/wasm/WebAssemblyParser.js +2 -1
  45. package/lib/web/JsonpMainTemplate.runtime.js +1 -1
  46. package/lib/web/JsonpMainTemplatePlugin.js +1 -3
  47. package/package.json +14 -12
  48. package/schemas/WebpackOptions.json +1 -0
  49. package/schemas/ajv.absolutePath.js +55 -55
  50. package/schemas/plugins/DllReferencePlugin.json +1 -0
@@ -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;
package/lib/Chunk.js CHANGED
@@ -182,12 +182,13 @@ class Chunk {
182
182
  */
183
183
  hasRuntime() {
184
184
  for (const chunkGroup of this._groups) {
185
- // We only need to check the first one
186
- return (
185
+ if (
187
186
  chunkGroup.isInitial() &&
188
187
  chunkGroup instanceof Entrypoint &&
189
188
  chunkGroup.getRuntimeChunk() === this
190
- );
189
+ ) {
190
+ return true;
191
+ }
191
192
  }
192
193
  return false;
193
194
  }
@@ -313,6 +314,10 @@ class Chunk {
313
314
  * @returns {-1|0|1} this is a comparitor function like sort and returns -1, 0, or 1 based on sort order
314
315
  */
315
316
  compareTo(otherChunk) {
317
+ if (this.name && !otherChunk.name) return -1;
318
+ if (!this.name && otherChunk.name) return 1;
319
+ if (this.name < otherChunk.name) return -1;
320
+ if (this.name > otherChunk.name) return 1;
316
321
  if (this._modules.size > otherChunk._modules.size) return -1;
317
322
  if (this._modules.size < otherChunk._modules.size) return 1;
318
323
  this._modules.sort();
@@ -384,29 +389,43 @@ class Chunk {
384
389
  return false;
385
390
  }
386
391
 
392
+ // Pick a new name for the integrated chunk
393
+ if (this.name && otherChunk.name) {
394
+ if (this.hasEntryModule() === otherChunk.hasEntryModule()) {
395
+ // When both chunks have entry modules or none have one, use
396
+ // shortest name
397
+ if (this.name.length !== otherChunk.name.length) {
398
+ this.name =
399
+ this.name.length < otherChunk.name.length
400
+ ? this.name
401
+ : otherChunk.name;
402
+ } else {
403
+ this.name = this.name < otherChunk.name ? this.name : otherChunk.name;
404
+ }
405
+ } else if (otherChunk.hasEntryModule()) {
406
+ // Pick the name of the chunk with the entry module
407
+ this.name = otherChunk.name;
408
+ }
409
+ } else if (otherChunk.name) {
410
+ this.name = otherChunk.name;
411
+ }
412
+
387
413
  // Array.from is used here to create a clone, because moveModule modifies otherChunk._modules
388
414
  for (const module of Array.from(otherChunk._modules)) {
389
415
  otherChunk.moveModule(module, this);
390
416
  }
391
417
  otherChunk._modules.clear();
392
418
 
419
+ if (otherChunk.entryModule) {
420
+ this.entryModule = otherChunk.entryModule;
421
+ }
422
+
393
423
  for (const chunkGroup of otherChunk._groups) {
394
424
  chunkGroup.replaceChunk(otherChunk, this);
395
425
  this.addGroup(chunkGroup);
396
426
  }
397
427
  otherChunk._groups.clear();
398
428
 
399
- if (this.name && otherChunk.name) {
400
- if (this.name.length !== otherChunk.name.length) {
401
- this.name =
402
- this.name.length < otherChunk.name.length
403
- ? this.name
404
- : otherChunk.name;
405
- } else {
406
- this.name = this.name < otherChunk.name ? this.name : otherChunk.name;
407
- }
408
- }
409
-
410
429
  return true;
411
430
  }
412
431