webpack 5.81.0 → 5.82.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.

Potentially problematic release.


This version of webpack might be problematic. Click here for more details.

Files changed (62) hide show
  1. package/bin/webpack.js +13 -2
  2. package/lib/Compilation.js +4 -1
  3. package/lib/CssModule.js +39 -7
  4. package/lib/DependenciesBlock.js +8 -0
  5. package/lib/FileSystemInfo.js +1 -1
  6. package/lib/HotModuleReplacementPlugin.js +3 -2
  7. package/lib/Module.js +3 -2
  8. package/lib/ModuleTypeConstants.js +90 -0
  9. package/lib/NormalModule.js +2 -1
  10. package/lib/RuntimeModule.js +4 -3
  11. package/lib/Template.js +2 -1
  12. package/lib/WebpackOptionsApply.js +33 -40
  13. package/lib/asset/AssetGenerator.js +4 -3
  14. package/lib/asset/AssetModulesPlugin.js +21 -11
  15. package/lib/asset/RawDataUrlModule.js +2 -1
  16. package/lib/cache/MemoryWithGcCachePlugin.js +2 -0
  17. package/lib/config/defaults.js +4 -2
  18. package/lib/container/FallbackModule.js +2 -1
  19. package/lib/container/RemoteModule.js +2 -1
  20. package/lib/css/CssGenerator.js +4 -0
  21. package/lib/css/CssLoadingRuntimeModule.js +9 -2
  22. package/lib/css/CssModulesPlugin.js +149 -39
  23. package/lib/css/CssParser.js +443 -319
  24. package/lib/css/walkCssTokens.js +118 -27
  25. package/lib/debug/ProfilingPlugin.js +2 -0
  26. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +1 -0
  27. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +4 -2
  28. package/lib/hmr/LazyCompilationPlugin.js +13 -4
  29. package/lib/javascript/BasicEvaluatedExpression.js +108 -1
  30. package/lib/javascript/JavascriptModulesPlugin.js +3 -2
  31. package/lib/javascript/JavascriptParser.js +132 -11
  32. package/lib/json/JsonData.js +25 -0
  33. package/lib/json/JsonGenerator.js +15 -3
  34. package/lib/json/JsonModulesPlugin.js +1 -0
  35. package/lib/json/JsonParser.js +2 -1
  36. package/lib/library/ModuleLibraryPlugin.js +2 -1
  37. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +3 -1
  38. package/lib/runtime/GetChunkFilenameRuntimeModule.js +4 -0
  39. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +22 -3
  40. package/lib/schemes/DataUriPlugin.js +4 -0
  41. package/lib/schemes/HttpUriPlugin.js +38 -0
  42. package/lib/sharing/ConsumeSharedModule.js +5 -2
  43. package/lib/sharing/ProvideSharedModule.js +2 -1
  44. package/lib/sharing/utils.js +293 -7
  45. package/lib/stats/DefaultStatsFactoryPlugin.js +7 -4
  46. package/lib/stats/DefaultStatsPrinterPlugin.js +25 -0
  47. package/lib/util/StackedCacheMap.js +6 -0
  48. package/lib/util/StringXor.js +51 -0
  49. package/lib/util/compileBooleanMatcher.js +31 -0
  50. package/lib/util/createHash.js +4 -3
  51. package/lib/util/deprecation.js +8 -0
  52. package/lib/util/identifier.js +4 -0
  53. package/lib/util/numberHash.js +75 -21
  54. package/lib/util/propertyAccess.js +5 -0
  55. package/lib/wasm/EnableWasmLoadingPlugin.js +4 -0
  56. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +1 -0
  57. package/lib/wasm-async/AsyncWebAssemblyParser.js +1 -1
  58. package/lib/web/JsonpChunkLoadingRuntimeModule.js +8 -4
  59. package/package.json +3 -3
  60. package/schemas/WebpackOptions.check.js +1 -1
  61. package/schemas/WebpackOptions.json +25 -0
  62. package/types.d.ts +181 -39
@@ -76,6 +76,10 @@ const CC_HYPHEN_MINUS = "-".charCodeAt(0);
76
76
  const CC_LESS_THAN_SIGN = "<".charCodeAt(0);
77
77
  const CC_GREATER_THAN_SIGN = ">".charCodeAt(0);
78
78
 
79
+ /**
80
+ * @param {number} cc char code
81
+ * @returns {boolean} true, if cc is a newline
82
+ */
79
83
  const _isNewLine = cc => {
80
84
  return (
81
85
  cc === CC_LINE_FEED || cc === CC_CARRIAGE_RETURN || cc === CC_FORM_FEED
@@ -84,6 +88,7 @@ const _isNewLine = cc => {
84
88
 
85
89
  /** @type {CharHandler} */
86
90
  const consumeSpace = (input, pos, callbacks) => {
91
+ /** @type {number} */
87
92
  let cc;
88
93
  do {
89
94
  pos++;
@@ -92,17 +97,41 @@ const consumeSpace = (input, pos, callbacks) => {
92
97
  return pos;
93
98
  };
94
99
 
95
- const _isWhiteSpace = cc => {
100
+ /**
101
+ * @param {number} cc char code
102
+ * @returns {boolean} true, if cc is a newline
103
+ */
104
+ const _isNewline = cc => {
96
105
  return (
97
- cc === CC_LINE_FEED ||
98
- cc === CC_CARRIAGE_RETURN ||
99
- cc === CC_FORM_FEED ||
100
- cc === CC_TAB ||
101
- cc === CC_SPACE
106
+ cc === CC_LINE_FEED || cc === CC_CARRIAGE_RETURN || cc === CC_FORM_FEED
102
107
  );
103
108
  };
104
109
 
105
- const _isIdentStartCodePoint = cc => {
110
+ /**
111
+ * @param {number} cc char code
112
+ * @returns {boolean} true, if cc is a space (U+0009 CHARACTER TABULATION or U+0020 SPACE)
113
+ */
114
+ const _isSpace = cc => {
115
+ return cc === CC_TAB || cc === CC_SPACE;
116
+ };
117
+
118
+ /**
119
+ * @param {number} cc char code
120
+ * @returns {boolean} true, if cc is a whitespace
121
+ */
122
+ const _isWhiteSpace = cc => {
123
+ return _isNewline(cc) || _isSpace(cc);
124
+ };
125
+
126
+ /**
127
+ * ident-start code point
128
+ *
129
+ * A letter, a non-ASCII code point, or U+005F LOW LINE (_).
130
+ *
131
+ * @param {number} cc char code
132
+ * @returns {boolean} true, if cc is a start code point of an identifier
133
+ */
134
+ const isIdentStartCodePoint = cc => {
106
135
  return (
107
136
  (cc >= CC_LOWER_A && cc <= CC_LOWER_Z) ||
108
137
  (cc >= CC_UPPER_A && cc <= CC_UPPER_Z) ||
@@ -145,21 +174,27 @@ const consumeComments = (input, pos, callbacks) => {
145
174
  };
146
175
 
147
176
  /** @type {function(number): CharHandler} */
148
- const consumeString = end => (input, pos, callbacks) => {
177
+ const consumeString = quote_cc => (input, pos, callbacks) => {
149
178
  const start = pos;
150
- pos = _consumeString(input, pos, end);
179
+ pos = _consumeString(input, pos, quote_cc);
151
180
  if (callbacks.string !== undefined) {
152
181
  pos = callbacks.string(input, start, pos);
153
182
  }
154
183
  return pos;
155
184
  };
156
185
 
157
- const _consumeString = (input, pos, end) => {
186
+ /**
187
+ * @param {string} input input
188
+ * @param {number} pos position
189
+ * @param {number} quote_cc quote char code
190
+ * @returns {number} new position
191
+ */
192
+ const _consumeString = (input, pos, quote_cc) => {
158
193
  pos++;
159
194
  for (;;) {
160
195
  if (pos === input.length) return pos;
161
196
  const cc = input.charCodeAt(pos);
162
- if (cc === end) return pos + 1;
197
+ if (cc === quote_cc) return pos + 1;
163
198
  if (_isNewLine(cc)) {
164
199
  // bad string
165
200
  return pos;
@@ -176,6 +211,10 @@ const _consumeString = (input, pos, end) => {
176
211
  }
177
212
  };
178
213
 
214
+ /**
215
+ * @param {number} cc char code
216
+ * @returns {boolean} is identifier start code
217
+ */
179
218
  const _isIdentifierStartCode = cc => {
180
219
  return (
181
220
  cc === CC_LOW_LINE ||
@@ -185,16 +224,30 @@ const _isIdentifierStartCode = cc => {
185
224
  );
186
225
  };
187
226
 
227
+ /**
228
+ * @param {number} first first code point
229
+ * @param {number} second second code point
230
+ * @returns {boolean} true if two code points are a valid escape
231
+ */
188
232
  const _isTwoCodePointsAreValidEscape = (first, second) => {
189
233
  if (first !== CC_REVERSE_SOLIDUS) return false;
190
234
  if (_isNewLine(second)) return false;
191
235
  return true;
192
236
  };
193
237
 
238
+ /**
239
+ * @param {number} cc char code
240
+ * @returns {boolean} is digit
241
+ */
194
242
  const _isDigit = cc => {
195
243
  return cc >= CC_0 && cc <= CC_9;
196
244
  };
197
245
 
246
+ /**
247
+ * @param {string} input input
248
+ * @param {number} pos position
249
+ * @returns {boolean} true, if input at pos starts an identifier
250
+ */
198
251
  const _startsIdentifier = (input, pos) => {
199
252
  const cc = input.charCodeAt(pos);
200
253
  if (cc === CC_HYPHEN_MINUS) {
@@ -220,7 +273,7 @@ const consumeNumberSign = (input, pos, callbacks) => {
220
273
  pos++;
221
274
  if (pos === input.length) return pos;
222
275
  if (callbacks.isSelector(input, pos) && _startsIdentifier(input, pos)) {
223
- pos = _consumeIdentifier(input, pos);
276
+ pos = _consumeIdentifier(input, pos, callbacks);
224
277
  if (callbacks.id !== undefined) {
225
278
  return callbacks.id(input, start, pos);
226
279
  }
@@ -244,7 +297,7 @@ const consumeMinus = (input, pos, callbacks) => {
244
297
  if (cc === CC_GREATER_THAN_SIGN) {
245
298
  return pos + 1;
246
299
  } else {
247
- pos = _consumeIdentifier(input, pos);
300
+ pos = _consumeIdentifier(input, pos, callbacks);
248
301
  if (callbacks.identifier !== undefined) {
249
302
  return callbacks.identifier(input, start, pos);
250
303
  }
@@ -253,7 +306,7 @@ const consumeMinus = (input, pos, callbacks) => {
253
306
  if (pos + 1 === input.length) return pos;
254
307
  const cc = input.charCodeAt(pos + 1);
255
308
  if (_isNewLine(cc)) return pos;
256
- pos = _consumeIdentifier(input, pos);
309
+ pos = _consumeIdentifier(input, pos, callbacks);
257
310
  if (callbacks.identifier !== undefined) {
258
311
  return callbacks.identifier(input, start, pos);
259
312
  }
@@ -272,16 +325,17 @@ const consumeDot = (input, pos, callbacks) => {
272
325
  if (_isDigit(cc)) return consumeNumericToken(input, pos - 2, callbacks);
273
326
  if (!callbacks.isSelector(input, pos) || !_startsIdentifier(input, pos))
274
327
  return pos;
275
- pos = _consumeIdentifier(input, pos);
328
+ pos = _consumeIdentifier(input, pos, callbacks);
276
329
  if (callbacks.class !== undefined) return callbacks.class(input, start, pos);
277
330
  return pos;
278
331
  };
279
332
 
280
333
  /** @type {CharHandler} */
281
334
  const consumeNumericToken = (input, pos, callbacks) => {
282
- pos = _consumeNumber(input, pos);
335
+ pos = _consumeNumber(input, pos, callbacks);
283
336
  if (pos === input.length) return pos;
284
- if (_startsIdentifier(input, pos)) return _consumeIdentifier(input, pos);
337
+ if (_startsIdentifier(input, pos))
338
+ return _consumeIdentifier(input, pos, callbacks);
285
339
  const cc = input.charCodeAt(pos);
286
340
  if (cc === CC_PERCENTAGE) return pos + 1;
287
341
  return pos;
@@ -290,12 +344,8 @@ const consumeNumericToken = (input, pos, callbacks) => {
290
344
  /** @type {CharHandler} */
291
345
  const consumeOtherIdentifier = (input, pos, callbacks) => {
292
346
  const start = pos;
293
- pos = _consumeIdentifier(input, pos);
294
- if (
295
- pos !== input.length &&
296
- !callbacks.isSelector(input, pos) &&
297
- input.charCodeAt(pos) === CC_LEFT_PARENTHESIS
298
- ) {
347
+ pos = _consumeIdentifier(input, pos, callbacks);
348
+ if (pos !== input.length && input.charCodeAt(pos) === CC_LEFT_PARENTHESIS) {
299
349
  pos++;
300
350
  if (callbacks.function !== undefined) {
301
351
  return callbacks.function(input, start, pos);
@@ -311,7 +361,7 @@ const consumeOtherIdentifier = (input, pos, callbacks) => {
311
361
  /** @type {CharHandler} */
312
362
  const consumePotentialUrl = (input, pos, callbacks) => {
313
363
  const start = pos;
314
- pos = _consumeIdentifier(input, pos);
364
+ pos = _consumeIdentifier(input, pos, callbacks);
315
365
  const nextPos = pos + 1;
316
366
  if (
317
367
  pos === start + 3 &&
@@ -331,6 +381,7 @@ const consumePotentialUrl = (input, pos, callbacks) => {
331
381
  return nextPos;
332
382
  } else {
333
383
  const contentStart = pos;
384
+ /** @type {number} */
334
385
  let contentEnd;
335
386
  for (;;) {
336
387
  if (cc === CC_REVERSE_SOLIDUS) {
@@ -380,7 +431,7 @@ const consumePotentialPseudo = (input, pos, callbacks) => {
380
431
  pos++;
381
432
  if (!callbacks.isSelector(input, pos) || !_startsIdentifier(input, pos))
382
433
  return pos;
383
- pos = _consumeIdentifier(input, pos);
434
+ pos = _consumeIdentifier(input, pos, callbacks);
384
435
  let cc = input.charCodeAt(pos);
385
436
  if (cc === CC_LEFT_PARENTHESIS) {
386
437
  pos++;
@@ -449,6 +500,7 @@ const consumeComma = (input, pos, callbacks) => {
449
500
  return pos;
450
501
  };
451
502
 
503
+ /** @type {CharHandler} */
452
504
  const _consumeIdentifier = (input, pos) => {
453
505
  for (;;) {
454
506
  const cc = input.charCodeAt(pos);
@@ -468,6 +520,7 @@ const _consumeIdentifier = (input, pos) => {
468
520
  }
469
521
  };
470
522
 
523
+ /** @type {CharHandler} */
471
524
  const _consumeNumber = (input, pos) => {
472
525
  pos++;
473
526
  if (pos === input.length) return pos;
@@ -526,12 +579,13 @@ const consumeLessThan = (input, pos, callbacks) => {
526
579
  return pos + 1;
527
580
  };
528
581
 
582
+ /** @type {CharHandler} */
529
583
  const consumeAt = (input, pos, callbacks) => {
530
584
  const start = pos;
531
585
  pos++;
532
586
  if (pos === input.length) return pos;
533
587
  if (_startsIdentifier(input, pos)) {
534
- pos = _consumeIdentifier(input, pos);
588
+ pos = _consumeIdentifier(input, pos, callbacks);
535
589
  if (callbacks.atKeyword !== undefined) {
536
590
  pos = callbacks.atKeyword(input, start, pos);
537
591
  }
@@ -629,7 +683,7 @@ const CHAR_MAP = Array.from({ length: 0x80 }, (_, cc) => {
629
683
  // digit
630
684
  if (_isDigit(cc)) return consumeNumericToken;
631
685
  // ident-start code point
632
- if (_isIdentStartCodePoint(cc)) {
686
+ if (isIdentStartCodePoint(cc)) {
633
687
  return consumeOtherIdentifier;
634
688
  }
635
689
  // EOF, but we don't have it
@@ -661,6 +715,8 @@ module.exports = (input, callbacks) => {
661
715
  }
662
716
  };
663
717
 
718
+ module.exports.isIdentStartCodePoint = isIdentStartCodePoint;
719
+
664
720
  /**
665
721
  * @param {string} input input
666
722
  * @param {number} pos position
@@ -678,6 +734,19 @@ module.exports.eatComments = (input, pos) => {
678
734
  return pos;
679
735
  };
680
736
 
737
+ /**
738
+ * @param {string} input input
739
+ * @param {number} pos position
740
+ * @returns {number} position after whitespace
741
+ */
742
+ module.exports.eatWhitespace = (input, pos) => {
743
+ while (_isWhiteSpace(input.charCodeAt(pos))) {
744
+ pos++;
745
+ }
746
+
747
+ return pos;
748
+ };
749
+
681
750
  /**
682
751
  * @param {string} input input
683
752
  * @param {number} pos position
@@ -697,3 +766,25 @@ module.exports.eatWhitespaceAndComments = (input, pos) => {
697
766
 
698
767
  return pos;
699
768
  };
769
+
770
+ /**
771
+ * @param {string} input input
772
+ * @param {number} pos position
773
+ * @returns {number} position after whitespace
774
+ */
775
+ module.exports.eatWhiteLine = (input, pos) => {
776
+ for (;;) {
777
+ const cc = input.charCodeAt(pos);
778
+ if (_isSpace(cc)) {
779
+ pos++;
780
+ continue;
781
+ }
782
+ if (_isNewLine(cc)) pos++;
783
+ // For `\r\n`
784
+ if (cc === CC_CARRIAGE_RETURN && input.charCodeAt(pos + 1) === CC_LINE_FEED)
785
+ pos++;
786
+ break;
787
+ }
788
+
789
+ return pos;
790
+ };
@@ -100,6 +100,8 @@ class Profiler {
100
100
  return this.sendCommand("Profiler.stop").then(({ profile }) => {
101
101
  const hrtime = process.hrtime();
102
102
  const endTime = hrtime[0] * 1000000 + Math.round(hrtime[1] / 1000);
103
+ // Avoid coverage problems due indirect changes
104
+ /* istanbul ignore next */
103
105
  if (profile.startTime < this._startTime || profile.endTime > endTime) {
104
106
  // In some cases timestamps mismatch and we need to adjust them
105
107
  // Both process.hrtime and the inspector timestamps claim to be relative
@@ -159,6 +159,7 @@ module.exports = class HarmonyImportDependencyParserPlugin {
159
159
 
160
160
  const rootInfo = rightPart.rootInfo;
161
161
  if (
162
+ typeof rootInfo === "string" ||
162
163
  !rootInfo ||
163
164
  !rootInfo.tagInfo ||
164
165
  rootInfo.tagInfo.tag !== harmonySpecifierTag
@@ -127,7 +127,7 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
127
127
  "",
128
128
  "// object to store loaded and loading chunks",
129
129
  "// undefined = chunk not loaded, null = chunk preloaded/prefetched",
130
- "// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded",
130
+ "// [resolve, Promise] = chunk loading, 0 = chunk loaded",
131
131
  `var installedChunks = ${
132
132
  stateExpression ? `${stateExpression} = ${stateExpression} || ` : ""
133
133
  }{`,
@@ -210,7 +210,9 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
210
210
  )})])`,
211
211
  `promises.push(installedChunkData[1] = promise);`
212
212
  ]),
213
- "} else installedChunks[chunkId] = 0;"
213
+ hasJsMatcher === true
214
+ ? "}"
215
+ : "} else installedChunks[chunkId] = 0;"
214
216
  ]),
215
217
  "}"
216
218
  ]),
@@ -10,6 +10,9 @@ const AsyncDependenciesBlock = require("../AsyncDependenciesBlock");
10
10
  const Dependency = require("../Dependency");
11
11
  const Module = require("../Module");
12
12
  const ModuleFactory = require("../ModuleFactory");
13
+ const {
14
+ WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY
15
+ } = require("../ModuleTypeConstants");
13
16
  const RuntimeGlobals = require("../RuntimeGlobals");
14
17
  const Template = require("../Template");
15
18
  const CommonJsRequireDependency = require("../dependencies/CommonJsRequireDependency");
@@ -95,7 +98,11 @@ registerNotSerializable(LazyCompilationDependency);
95
98
 
96
99
  class LazyCompilationProxyModule extends Module {
97
100
  constructor(context, originalModule, request, client, data, active) {
98
- super("lazy-compilation-proxy", context, originalModule.layer);
101
+ super(
102
+ WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY,
103
+ context,
104
+ originalModule.layer
105
+ );
99
106
  this.originalModule = originalModule;
100
107
  this.request = request;
101
108
  this.client = client;
@@ -107,7 +114,7 @@ class LazyCompilationProxyModule extends Module {
107
114
  * @returns {string} a unique identifier of the module
108
115
  */
109
116
  identifier() {
110
- return `lazy-compilation-proxy|${this.originalModule.identifier()}`;
117
+ return `${WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY}|${this.originalModule.identifier()}`;
111
118
  }
112
119
 
113
120
  /**
@@ -115,7 +122,7 @@ class LazyCompilationProxyModule extends Module {
115
122
  * @returns {string} a user readable identifier of the module
116
123
  */
117
124
  readableIdentifier(requestShortener) {
118
- return `lazy-compilation-proxy ${this.originalModule.readableIdentifier(
125
+ return `${WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY} ${this.originalModule.readableIdentifier(
119
126
  requestShortener
120
127
  )}`;
121
128
  }
@@ -142,7 +149,9 @@ class LazyCompilationProxyModule extends Module {
142
149
  * @returns {string | null} an identifier for library inclusion
143
150
  */
144
151
  libIdent(options) {
145
- return `${this.originalModule.libIdent(options)}!lazy-compilation-proxy`;
152
+ return `${this.originalModule.libIdent(
153
+ options
154
+ )}!${WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY}`;
146
155
  }
147
156
 
148
157
  /**
@@ -60,10 +60,11 @@ class BasicEvaluatedExpression {
60
60
  this.prefix = undefined;
61
61
  /** @type {BasicEvaluatedExpression | undefined} */
62
62
  this.postfix = undefined;
63
+ /** @type {BasicEvaluatedExpression[]} */
63
64
  this.wrappedInnerExpressions = undefined;
64
65
  /** @type {string | VariableInfoInterface | undefined} */
65
66
  this.identifier = undefined;
66
- /** @type {VariableInfoInterface} */
67
+ /** @type {string | VariableInfoInterface} */
67
68
  this.rootInfo = undefined;
68
69
  /** @type {() => string[]} */
69
70
  this.getMembers = undefined;
@@ -222,6 +223,10 @@ class BasicEvaluatedExpression {
222
223
  return this.sideEffects;
223
224
  }
224
225
 
226
+ /**
227
+ * Creates a boolean representation of this evaluated expression.
228
+ * @returns {boolean | undefined} true: truthy, false: falsy, undefined: unknown
229
+ */
225
230
  asBool() {
226
231
  if (this.truthy) return true;
227
232
  if (this.falsy || this.nullish) return false;
@@ -247,6 +252,10 @@ class BasicEvaluatedExpression {
247
252
  return undefined;
248
253
  }
249
254
 
255
+ /**
256
+ * Creates a nullish coalescing representation of this evaluated expression.
257
+ * @returns {boolean | undefined} true: nullish, false: not nullish, undefined: unknown
258
+ */
250
259
  asNullish() {
251
260
  const nullish = this.isNullish();
252
261
 
@@ -267,6 +276,10 @@ class BasicEvaluatedExpression {
267
276
  return undefined;
268
277
  }
269
278
 
279
+ /**
280
+ * Creates a string representation of this evaluated expression.
281
+ * @returns {string | undefined} the string representation or undefined if not possible
282
+ */
270
283
  asString() {
271
284
  if (this.isBoolean()) return `${this.bool}`;
272
285
  if (this.isNull()) return "null";
@@ -316,6 +329,11 @@ class BasicEvaluatedExpression {
316
329
  return this;
317
330
  }
318
331
 
332
+ /**
333
+ * Set's the value of this expression to a number
334
+ * @param {number} number number to set
335
+ * @returns {this} this
336
+ */
319
337
  setNumber(number) {
320
338
  this.type = TypeNumber;
321
339
  this.number = number;
@@ -323,6 +341,11 @@ class BasicEvaluatedExpression {
323
341
  return this;
324
342
  }
325
343
 
344
+ /**
345
+ * Set's the value of this expression to a BigInt
346
+ * @param {bigint} bigint bigint to set
347
+ * @returns {this} this
348
+ */
326
349
  setBigInt(bigint) {
327
350
  this.type = TypeBigInt;
328
351
  this.bigint = bigint;
@@ -330,6 +353,11 @@ class BasicEvaluatedExpression {
330
353
  return this;
331
354
  }
332
355
 
356
+ /**
357
+ * Set's the value of this expression to a boolean
358
+ * @param {boolean} bool boolean to set
359
+ * @returns {this} this
360
+ */
333
361
  setBoolean(bool) {
334
362
  this.type = TypeBoolean;
335
363
  this.bool = bool;
@@ -337,6 +365,11 @@ class BasicEvaluatedExpression {
337
365
  return this;
338
366
  }
339
367
 
368
+ /**
369
+ * Set's the value of this expression to a regular expression
370
+ * @param {RegExp} regExp regular expression to set
371
+ * @returns {this} this
372
+ */
340
373
  setRegExp(regExp) {
341
374
  this.type = TypeRegExp;
342
375
  this.regExp = regExp;
@@ -344,6 +377,15 @@ class BasicEvaluatedExpression {
344
377
  return this;
345
378
  }
346
379
 
380
+ /**
381
+ * Set's the value of this expression to a particular identifier and its members.
382
+ *
383
+ * @param {string | VariableInfoInterface} identifier identifier to set
384
+ * @param {string | VariableInfoInterface} rootInfo root info
385
+ * @param {() => string[]} getMembers members
386
+ * @param {() => boolean[]=} getMembersOptionals optional members
387
+ * @returns {this} this
388
+ */
347
389
  setIdentifier(identifier, rootInfo, getMembers, getMembersOptionals) {
348
390
  this.type = TypeIdentifier;
349
391
  this.identifier = identifier;
@@ -354,6 +396,14 @@ class BasicEvaluatedExpression {
354
396
  return this;
355
397
  }
356
398
 
399
+ /**
400
+ * Wraps an array of expressions with a prefix and postfix expression.
401
+ *
402
+ * @param {BasicEvaluatedExpression | null} prefix Expression to be added before the innerExpressions
403
+ * @param {BasicEvaluatedExpression} postfix Expression to be added after the innerExpressions
404
+ * @param {BasicEvaluatedExpression[]} innerExpressions Expressions to be wrapped
405
+ * @returns {this} this
406
+ */
357
407
  setWrapped(prefix, postfix, innerExpressions) {
358
408
  this.type = TypeWrapped;
359
409
  this.prefix = prefix;
@@ -363,6 +413,12 @@ class BasicEvaluatedExpression {
363
413
  return this;
364
414
  }
365
415
 
416
+ /**
417
+ * Stores the options of a conditional expression.
418
+ *
419
+ * @param {BasicEvaluatedExpression[]} options optional (consequent/alternate) expressions to be set
420
+ * @returns {this} this
421
+ */
366
422
  setOptions(options) {
367
423
  this.type = TypeConditional;
368
424
  this.options = options;
@@ -370,6 +426,12 @@ class BasicEvaluatedExpression {
370
426
  return this;
371
427
  }
372
428
 
429
+ /**
430
+ * Adds options to a conditional expression.
431
+ *
432
+ * @param {BasicEvaluatedExpression[]} options optional (consequent/alternate) expressions to be added
433
+ * @returns {this} this
434
+ */
373
435
  addOptions(options) {
374
436
  if (!this.options) {
375
437
  this.type = TypeConditional;
@@ -382,6 +444,12 @@ class BasicEvaluatedExpression {
382
444
  return this;
383
445
  }
384
446
 
447
+ /**
448
+ * Set's the value of this expression to an array of expressions.
449
+ *
450
+ * @param {BasicEvaluatedExpression[]} items expressions to set
451
+ * @returns {this} this
452
+ */
385
453
  setItems(items) {
386
454
  this.type = TypeArray;
387
455
  this.items = items;
@@ -389,6 +457,12 @@ class BasicEvaluatedExpression {
389
457
  return this;
390
458
  }
391
459
 
460
+ /**
461
+ * Set's the value of this expression to an array of strings.
462
+ *
463
+ * @param {string[]} array array to set
464
+ * @returns {this} this
465
+ */
392
466
  setArray(array) {
393
467
  this.type = TypeConstArray;
394
468
  this.array = array;
@@ -396,6 +470,15 @@ class BasicEvaluatedExpression {
396
470
  return this;
397
471
  }
398
472
 
473
+ /**
474
+ * Set's the value of this expression to a processed/unprocessed template string. Used
475
+ * for evaluating TemplateLiteral expressions in the JavaScript Parser.
476
+ *
477
+ * @param {BasicEvaluatedExpression[]} quasis template string quasis
478
+ * @param {BasicEvaluatedExpression[]} parts template string parts
479
+ * @param {"cooked" | "raw"} kind template string kind
480
+ * @returns {this} this
481
+ */
399
482
  setTemplateString(quasis, parts, kind) {
400
483
  this.type = TypeTemplateString;
401
484
  this.quasis = quasis;
@@ -418,6 +501,12 @@ class BasicEvaluatedExpression {
418
501
  return this;
419
502
  }
420
503
 
504
+ /**
505
+ * Set's the value of the expression to nullish.
506
+ *
507
+ * @param {boolean} value true, if the expression is nullish
508
+ * @returns {this} this
509
+ */
421
510
  setNullish(value) {
422
511
  this.nullish = value;
423
512
 
@@ -426,16 +515,34 @@ class BasicEvaluatedExpression {
426
515
  return this;
427
516
  }
428
517
 
518
+ /**
519
+ * Set's the range for the expression.
520
+ *
521
+ * @param {[number, number]} range range to set
522
+ * @returns {this} this
523
+ */
429
524
  setRange(range) {
430
525
  this.range = range;
431
526
  return this;
432
527
  }
433
528
 
529
+ /**
530
+ * Set whether or not the expression has side effects.
531
+ *
532
+ * @param {boolean} sideEffects true, if the expression has side effects
533
+ * @returns {this} this
534
+ */
434
535
  setSideEffects(sideEffects = true) {
435
536
  this.sideEffects = sideEffects;
436
537
  return this;
437
538
  }
438
539
 
540
+ /**
541
+ * Set the expression node for the expression.
542
+ *
543
+ * @param {EsTreeNode} expression expression
544
+ * @returns {this} this
545
+ */
439
546
  setExpression(expression) {
440
547
  this.expression = expression;
441
548
  return this;
@@ -21,7 +21,8 @@ const InitFragment = require("../InitFragment");
21
21
  const {
22
22
  JAVASCRIPT_MODULE_TYPE_AUTO,
23
23
  JAVASCRIPT_MODULE_TYPE_DYNAMIC,
24
- JAVASCRIPT_MODULE_TYPE_ESM
24
+ JAVASCRIPT_MODULE_TYPE_ESM,
25
+ WEBPACK_MODULE_TYPE_RUNTIME
25
26
  } = require("../ModuleTypeConstants");
26
27
  const RuntimeGlobals = require("../RuntimeGlobals");
27
28
  const Template = require("../Template");
@@ -394,7 +395,7 @@ class JavascriptModulesPlugin {
394
395
  }
395
396
  const runtimeModules = chunkGraph.getChunkModulesIterableBySourceType(
396
397
  chunk,
397
- "runtime"
398
+ WEBPACK_MODULE_TYPE_RUNTIME
398
399
  );
399
400
  if (runtimeModules) {
400
401
  const xor = new StringXor();