webpack 5.80.0 → 5.82.0

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 (135) hide show
  1. package/bin/webpack.js +13 -2
  2. package/lib/AsyncDependenciesBlock.js +8 -0
  3. package/lib/CodeGenerationResults.js +2 -2
  4. package/lib/Compilation.js +4 -2
  5. package/lib/ContextModule.js +8 -0
  6. package/lib/CssModule.js +169 -0
  7. package/lib/DefinePlugin.js +81 -44
  8. package/lib/DelegatedModule.js +5 -0
  9. package/lib/DependenciesBlock.js +8 -0
  10. package/lib/Dependency.js +8 -0
  11. package/lib/DllModule.js +8 -0
  12. package/lib/ExportsInfo.js +3 -0
  13. package/lib/ExternalModule.js +8 -0
  14. package/lib/FileSystemInfo.js +8 -0
  15. package/lib/LoaderOptionsPlugin.js +12 -2
  16. package/lib/Module.js +8 -0
  17. package/lib/ModuleBuildError.js +9 -0
  18. package/lib/ModuleError.js +9 -0
  19. package/lib/ModuleFilenameHelpers.js +113 -4
  20. package/lib/ModuleParseError.js +9 -0
  21. package/lib/ModuleTypeConstants.js +21 -0
  22. package/lib/ModuleWarning.js +9 -0
  23. package/lib/NormalModule.js +8 -0
  24. package/lib/NormalModuleFactory.js +15 -3
  25. package/lib/RawModule.js +8 -0
  26. package/lib/WebpackError.js +8 -0
  27. package/lib/WebpackOptionsApply.js +33 -40
  28. package/lib/asset/RawDataUrlModule.js +8 -0
  29. package/lib/cache/MemoryWithGcCachePlugin.js +2 -0
  30. package/lib/cache/ResolverCachePlugin.js +3 -0
  31. package/lib/config/defaults.js +1 -0
  32. package/lib/config/normalization.js +1 -0
  33. package/lib/container/ContainerEntryModule.js +5 -0
  34. package/lib/container/ContainerExposedDependency.js +9 -0
  35. package/lib/container/FallbackDependency.js +6 -0
  36. package/lib/container/FallbackModule.js +5 -0
  37. package/lib/container/RemoteModule.js +5 -0
  38. package/lib/css/CssGenerator.js +4 -0
  39. package/lib/css/CssLoadingRuntimeModule.js +9 -2
  40. package/lib/css/CssModulesPlugin.js +201 -57
  41. package/lib/css/CssParser.js +270 -147
  42. package/lib/css/walkCssTokens.js +121 -65
  43. package/lib/debug/ProfilingPlugin.js +2 -0
  44. package/lib/dependencies/AMDDefineDependency.js +8 -0
  45. package/lib/dependencies/AMDRequireArrayDependency.js +8 -0
  46. package/lib/dependencies/AMDRequireContextDependency.js +9 -0
  47. package/lib/dependencies/AMDRequireDependency.js +8 -0
  48. package/lib/dependencies/CachedConstDependency.js +8 -0
  49. package/lib/dependencies/CommonJsDependencyHelpers.js +9 -0
  50. package/lib/dependencies/CommonJsExportRequireDependency.js +8 -0
  51. package/lib/dependencies/CommonJsExportsDependency.js +8 -0
  52. package/lib/dependencies/CommonJsExportsParserPlugin.js +65 -3
  53. package/lib/dependencies/CommonJsFullRequireDependency.js +8 -0
  54. package/lib/dependencies/CommonJsRequireContextDependency.js +9 -0
  55. package/lib/dependencies/CommonJsSelfReferenceDependency.js +8 -0
  56. package/lib/dependencies/ConstDependency.js +8 -0
  57. package/lib/dependencies/ContextDependency.js +8 -0
  58. package/lib/dependencies/ContextElementDependency.js +8 -0
  59. package/lib/dependencies/CreateScriptUrlDependency.js +8 -0
  60. package/lib/dependencies/CssExportDependency.js +8 -0
  61. package/lib/dependencies/CssImportDependency.js +52 -1
  62. package/lib/dependencies/CssLocalIdentifierDependency.js +8 -0
  63. package/lib/dependencies/CssSelfLocalIdentifierDependency.js +8 -0
  64. package/lib/dependencies/CssUrlDependency.js +8 -0
  65. package/lib/dependencies/DllEntryDependency.js +9 -0
  66. package/lib/dependencies/ExportsInfoDependency.js +5 -0
  67. package/lib/dependencies/HarmonyAcceptDependency.js +8 -0
  68. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +8 -0
  69. package/lib/dependencies/HarmonyExportExpressionDependency.js +8 -0
  70. package/lib/dependencies/HarmonyExportHeaderDependency.js +8 -0
  71. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +14 -0
  72. package/lib/dependencies/HarmonyExportSpecifierDependency.js +8 -0
  73. package/lib/dependencies/HarmonyImportDependency.js +8 -0
  74. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +1 -0
  75. package/lib/dependencies/HarmonyImportSpecifierDependency.js +8 -0
  76. package/lib/dependencies/ImportContextDependency.js +9 -0
  77. package/lib/dependencies/ImportDependency.js +8 -0
  78. package/lib/dependencies/JsonExportsDependency.js +8 -0
  79. package/lib/dependencies/LocalModuleDependency.js +8 -0
  80. package/lib/dependencies/ModuleDecoratorDependency.js +8 -0
  81. package/lib/dependencies/ModuleDependency.js +8 -0
  82. package/lib/dependencies/ProvidedDependency.js +8 -0
  83. package/lib/dependencies/PureExpressionDependency.js +8 -0
  84. package/lib/dependencies/RequireEnsureDependency.js +8 -0
  85. package/lib/dependencies/RequireHeaderDependency.js +5 -0
  86. package/lib/dependencies/RequireResolveContextDependency.js +9 -0
  87. package/lib/dependencies/RequireResolveHeaderDependency.js +5 -0
  88. package/lib/dependencies/RuntimeRequirementsDependency.js +8 -0
  89. package/lib/dependencies/StaticExportsDependency.js +8 -0
  90. package/lib/dependencies/URLDependency.js +8 -0
  91. package/lib/dependencies/UnsupportedDependency.js +8 -0
  92. package/lib/dependencies/WebAssemblyExportImportedDependency.js +8 -0
  93. package/lib/dependencies/WebAssemblyImportDependency.js +8 -0
  94. package/lib/dependencies/WorkerDependency.js +8 -0
  95. package/lib/index.js +1 -0
  96. package/lib/javascript/BasicEvaluatedExpression.js +108 -1
  97. package/lib/javascript/JavascriptParser.js +133 -12
  98. package/lib/json/JsonData.js +25 -0
  99. package/lib/json/JsonGenerator.js +15 -3
  100. package/lib/json/JsonModulesPlugin.js +1 -0
  101. package/lib/json/JsonParser.js +2 -1
  102. package/lib/library/ModuleLibraryPlugin.js +2 -1
  103. package/lib/optimize/RealContentHashPlugin.js +6 -0
  104. package/lib/runtime/AutoPublicPathRuntimeModule.js +6 -1
  105. package/lib/runtime/GetChunkFilenameRuntimeModule.js +4 -0
  106. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +22 -3
  107. package/lib/schemes/DataUriPlugin.js +4 -0
  108. package/lib/schemes/HttpUriPlugin.js +38 -0
  109. package/lib/serialization/ObjectMiddleware.js +2 -0
  110. package/lib/sharing/ConsumeSharedModule.js +8 -0
  111. package/lib/sharing/ConsumeSharedRuntimeModule.js +9 -3
  112. package/lib/sharing/ProvideSharedDependency.js +6 -0
  113. package/lib/sharing/ProvideSharedModule.js +5 -0
  114. package/lib/sharing/ShareRuntimeModule.js +7 -4
  115. package/lib/sharing/utils.js +293 -7
  116. package/lib/stats/DefaultStatsPrinterPlugin.js +25 -0
  117. package/lib/util/LazySet.js +10 -2
  118. package/lib/util/MapHelpers.js +19 -5
  119. package/lib/util/StackedCacheMap.js +6 -0
  120. package/lib/util/StringXor.js +51 -0
  121. package/lib/util/binarySearchBounds.js +49 -0
  122. package/lib/util/compileBooleanMatcher.js +31 -0
  123. package/lib/util/deprecation.js +8 -0
  124. package/lib/util/identifier.js +4 -0
  125. package/lib/util/internalSerializables.js +1 -0
  126. package/lib/util/numberHash.js +75 -21
  127. package/lib/util/propertyAccess.js +5 -0
  128. package/lib/util/semver.js +1 -1
  129. package/lib/wasm/EnableWasmLoadingPlugin.js +4 -0
  130. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +1 -0
  131. package/lib/wasm-async/AsyncWebAssemblyParser.js +1 -1
  132. package/package.json +4 -5
  133. package/schemas/WebpackOptions.check.js +1 -1
  134. package/schemas/WebpackOptions.json +33 -0
  135. package/types.d.ts +176 -48
@@ -7,7 +7,7 @@
7
7
 
8
8
  /**
9
9
  * @typedef {Object} CssTokenCallbacks
10
- * @property {function(string, number): boolean} isSelector
10
+ * @property {function(string, number): boolean=} isSelector
11
11
  * @property {function(string, number, number, number, number): number=} url
12
12
  * @property {function(string, number, number): number=} string
13
13
  * @property {function(string, number, number): number=} leftParenthesis
@@ -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,16 +97,36 @@ 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
 
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
+ * @param {number} cc char code
128
+ * @returns {boolean} true, if cc is a start code point of an identifier
129
+ */
105
130
  const _isIdentStartCodePoint = cc => {
106
131
  return (
107
132
  (cc >= CC_LOWER_A && cc <= CC_LOWER_Z) ||
@@ -145,21 +170,27 @@ const consumeComments = (input, pos, callbacks) => {
145
170
  };
146
171
 
147
172
  /** @type {function(number): CharHandler} */
148
- const consumeString = end => (input, pos, callbacks) => {
173
+ const consumeString = quote_cc => (input, pos, callbacks) => {
149
174
  const start = pos;
150
- pos = _consumeString(input, pos, end);
175
+ pos = _consumeString(input, pos, quote_cc);
151
176
  if (callbacks.string !== undefined) {
152
177
  pos = callbacks.string(input, start, pos);
153
178
  }
154
179
  return pos;
155
180
  };
156
181
 
157
- const _consumeString = (input, pos, end) => {
182
+ /**
183
+ * @param {string} input input
184
+ * @param {number} pos position
185
+ * @param {number} quote_cc quote char code
186
+ * @returns {number} new position
187
+ */
188
+ const _consumeString = (input, pos, quote_cc) => {
158
189
  pos++;
159
190
  for (;;) {
160
191
  if (pos === input.length) return pos;
161
192
  const cc = input.charCodeAt(pos);
162
- if (cc === end) return pos + 1;
193
+ if (cc === quote_cc) return pos + 1;
163
194
  if (_isNewLine(cc)) {
164
195
  // bad string
165
196
  return pos;
@@ -176,6 +207,10 @@ const _consumeString = (input, pos, end) => {
176
207
  }
177
208
  };
178
209
 
210
+ /**
211
+ * @param {number} cc char code
212
+ * @returns {boolean} is identifier start code
213
+ */
179
214
  const _isIdentifierStartCode = cc => {
180
215
  return (
181
216
  cc === CC_LOW_LINE ||
@@ -185,16 +220,30 @@ const _isIdentifierStartCode = cc => {
185
220
  );
186
221
  };
187
222
 
223
+ /**
224
+ * @param {number} first first code point
225
+ * @param {number} second second code point
226
+ * @returns {boolean} true if two code points are a valid escape
227
+ */
188
228
  const _isTwoCodePointsAreValidEscape = (first, second) => {
189
229
  if (first !== CC_REVERSE_SOLIDUS) return false;
190
230
  if (_isNewLine(second)) return false;
191
231
  return true;
192
232
  };
193
233
 
234
+ /**
235
+ * @param {number} cc char code
236
+ * @returns {boolean} is digit
237
+ */
194
238
  const _isDigit = cc => {
195
239
  return cc >= CC_0 && cc <= CC_9;
196
240
  };
197
241
 
242
+ /**
243
+ * @param {string} input input
244
+ * @param {number} pos position
245
+ * @returns {boolean} true, if input at pos starts an identifier
246
+ */
198
247
  const _startsIdentifier = (input, pos) => {
199
248
  const cc = input.charCodeAt(pos);
200
249
  if (cc === CC_HYPHEN_MINUS) {
@@ -220,7 +269,7 @@ const consumeNumberSign = (input, pos, callbacks) => {
220
269
  pos++;
221
270
  if (pos === input.length) return pos;
222
271
  if (callbacks.isSelector(input, pos) && _startsIdentifier(input, pos)) {
223
- pos = _consumeIdentifier(input, pos);
272
+ pos = _consumeIdentifier(input, pos, callbacks);
224
273
  if (callbacks.id !== undefined) {
225
274
  return callbacks.id(input, start, pos);
226
275
  }
@@ -244,7 +293,7 @@ const consumeMinus = (input, pos, callbacks) => {
244
293
  if (cc === CC_GREATER_THAN_SIGN) {
245
294
  return pos + 1;
246
295
  } else {
247
- pos = _consumeIdentifier(input, pos);
296
+ pos = _consumeIdentifier(input, pos, callbacks);
248
297
  if (callbacks.identifier !== undefined) {
249
298
  return callbacks.identifier(input, start, pos);
250
299
  }
@@ -253,7 +302,7 @@ const consumeMinus = (input, pos, callbacks) => {
253
302
  if (pos + 1 === input.length) return pos;
254
303
  const cc = input.charCodeAt(pos + 1);
255
304
  if (_isNewLine(cc)) return pos;
256
- pos = _consumeIdentifier(input, pos);
305
+ pos = _consumeIdentifier(input, pos, callbacks);
257
306
  if (callbacks.identifier !== undefined) {
258
307
  return callbacks.identifier(input, start, pos);
259
308
  }
@@ -272,16 +321,17 @@ const consumeDot = (input, pos, callbacks) => {
272
321
  if (_isDigit(cc)) return consumeNumericToken(input, pos - 2, callbacks);
273
322
  if (!callbacks.isSelector(input, pos) || !_startsIdentifier(input, pos))
274
323
  return pos;
275
- pos = _consumeIdentifier(input, pos);
324
+ pos = _consumeIdentifier(input, pos, callbacks);
276
325
  if (callbacks.class !== undefined) return callbacks.class(input, start, pos);
277
326
  return pos;
278
327
  };
279
328
 
280
329
  /** @type {CharHandler} */
281
330
  const consumeNumericToken = (input, pos, callbacks) => {
282
- pos = _consumeNumber(input, pos);
331
+ pos = _consumeNumber(input, pos, callbacks);
283
332
  if (pos === input.length) return pos;
284
- if (_startsIdentifier(input, pos)) return _consumeIdentifier(input, pos);
333
+ if (_startsIdentifier(input, pos))
334
+ return _consumeIdentifier(input, pos, callbacks);
285
335
  const cc = input.charCodeAt(pos);
286
336
  if (cc === CC_PERCENTAGE) return pos + 1;
287
337
  return pos;
@@ -290,7 +340,7 @@ const consumeNumericToken = (input, pos, callbacks) => {
290
340
  /** @type {CharHandler} */
291
341
  const consumeOtherIdentifier = (input, pos, callbacks) => {
292
342
  const start = pos;
293
- pos = _consumeIdentifier(input, pos);
343
+ pos = _consumeIdentifier(input, pos, callbacks);
294
344
  if (
295
345
  pos !== input.length &&
296
346
  !callbacks.isSelector(input, 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
  }
@@ -661,59 +715,61 @@ module.exports = (input, callbacks) => {
661
715
  }
662
716
  };
663
717
 
718
+ /**
719
+ * @param {string} input input
720
+ * @param {number} pos position
721
+ * @returns {number} position after comments
722
+ */
664
723
  module.exports.eatComments = (input, pos) => {
665
- loop: for (;;) {
666
- const cc = input.charCodeAt(pos);
667
- if (cc === CC_SOLIDUS) {
668
- if (pos === input.length) return pos;
669
- let cc = input.charCodeAt(pos + 1);
670
- if (cc !== CC_ASTERISK) return pos;
671
- pos++;
672
- for (;;) {
673
- pos++;
674
- if (pos === input.length) return pos;
675
- cc = input.charCodeAt(pos);
676
- while (cc === CC_ASTERISK) {
677
- pos++;
678
- if (pos === input.length) return pos;
679
- cc = input.charCodeAt(pos);
680
- if (cc === CC_SOLIDUS) {
681
- pos++;
682
- continue loop;
683
- }
684
- }
685
- }
724
+ for (;;) {
725
+ let originalPos = pos;
726
+ pos = consumeComments(input, pos, {});
727
+ if (originalPos === pos) {
728
+ break;
686
729
  }
687
- return pos;
688
730
  }
731
+
732
+ return pos;
689
733
  };
690
734
 
735
+ /**
736
+ * @param {string} input input
737
+ * @param {number} pos position
738
+ * @returns {number} position after whitespace and comments
739
+ */
691
740
  module.exports.eatWhitespaceAndComments = (input, pos) => {
692
- loop: for (;;) {
693
- const cc = input.charCodeAt(pos);
694
- if (cc === CC_SOLIDUS) {
695
- if (pos === input.length) return pos;
696
- let cc = input.charCodeAt(pos + 1);
697
- if (cc !== CC_ASTERISK) return pos;
741
+ for (;;) {
742
+ let originalPos = pos;
743
+ pos = consumeComments(input, pos, {});
744
+ while (_isWhiteSpace(input.charCodeAt(pos))) {
698
745
  pos++;
699
- for (;;) {
700
- pos++;
701
- if (pos === input.length) return pos;
702
- cc = input.charCodeAt(pos);
703
- while (cc === CC_ASTERISK) {
704
- pos++;
705
- if (pos === input.length) return pos;
706
- cc = input.charCodeAt(pos);
707
- if (cc === CC_SOLIDUS) {
708
- pos++;
709
- continue loop;
710
- }
711
- }
712
- }
713
- } else if (_isWhiteSpace(cc)) {
746
+ }
747
+ if (originalPos === pos) {
748
+ break;
749
+ }
750
+ }
751
+
752
+ return pos;
753
+ };
754
+
755
+ /**
756
+ * @param {string} input input
757
+ * @param {number} pos position
758
+ * @returns {number} position after whitespace
759
+ */
760
+ module.exports.eatWhiteLine = (input, pos) => {
761
+ for (;;) {
762
+ const cc = input.charCodeAt(pos);
763
+ if (_isSpace(cc)) {
714
764
  pos++;
715
765
  continue;
716
766
  }
717
- return pos;
767
+ if (_isNewLine(cc)) pos++;
768
+ // For `\r\n`
769
+ if (cc === CC_CARRIAGE_RETURN && input.charCodeAt(pos + 1) === CC_LINE_FEED)
770
+ pos++;
771
+ break;
718
772
  }
773
+
774
+ return pos;
719
775
  };
@@ -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
@@ -12,6 +12,8 @@ const NullDependency = require("./NullDependency");
12
12
  /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
13
13
  /** @typedef {import("../Dependency")} Dependency */
14
14
  /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
15
+ /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
16
+ /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
15
17
 
16
18
  /** @type {Record<string, { definition: string, content: string, requests: string[] }>} */
17
19
  const DEFINITIONS = {
@@ -119,6 +121,9 @@ class AMDDefineDependency extends NullDependency {
119
121
  return "amd define";
120
122
  }
121
123
 
124
+ /**
125
+ * @param {ObjectSerializerContext} context context
126
+ */
122
127
  serialize(context) {
123
128
  const { write } = context;
124
129
  write(this.range);
@@ -130,6 +135,9 @@ class AMDDefineDependency extends NullDependency {
130
135
  super.serialize(context);
131
136
  }
132
137
 
138
+ /**
139
+ * @param {ObjectDeserializerContext} context context
140
+ */
133
141
  deserialize(context) {
134
142
  const { read } = context;
135
143
  this.range = read();
@@ -12,6 +12,8 @@ const NullDependency = require("./NullDependency");
12
12
  /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
13
13
  /** @typedef {import("../Dependency")} Dependency */
14
14
  /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
15
+ /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
16
+ /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
15
17
 
16
18
  class AMDRequireArrayDependency extends NullDependency {
17
19
  constructor(depsArray, range) {
@@ -29,6 +31,9 @@ class AMDRequireArrayDependency extends NullDependency {
29
31
  return "amd";
30
32
  }
31
33
 
34
+ /**
35
+ * @param {ObjectSerializerContext} context context
36
+ */
32
37
  serialize(context) {
33
38
  const { write } = context;
34
39
 
@@ -38,6 +43,9 @@ class AMDRequireArrayDependency extends NullDependency {
38
43
  super.serialize(context);
39
44
  }
40
45
 
46
+ /**
47
+ * @param {ObjectDeserializerContext} context context
48
+ */
41
49
  deserialize(context) {
42
50
  const { read } = context;
43
51
 
@@ -8,6 +8,9 @@
8
8
  const makeSerializable = require("../util/makeSerializable");
9
9
  const ContextDependency = require("./ContextDependency");
10
10
 
11
+ /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
12
+ /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
13
+
11
14
  class AMDRequireContextDependency extends ContextDependency {
12
15
  constructor(options, range, valueRange) {
13
16
  super(options);
@@ -24,6 +27,9 @@ class AMDRequireContextDependency extends ContextDependency {
24
27
  return "amd";
25
28
  }
26
29
 
30
+ /**
31
+ * @param {ObjectSerializerContext} context context
32
+ */
27
33
  serialize(context) {
28
34
  const { write } = context;
29
35
 
@@ -33,6 +39,9 @@ class AMDRequireContextDependency extends ContextDependency {
33
39
  super.serialize(context);
34
40
  }
35
41
 
42
+ /**
43
+ * @param {ObjectDeserializerContext} context context
44
+ */
36
45
  deserialize(context) {
37
46
  const { read } = context;
38
47
 
@@ -13,6 +13,8 @@ const NullDependency = require("./NullDependency");
13
13
  /** @typedef {import("../AsyncDependenciesBlock")} AsyncDependenciesBlock */
14
14
  /** @typedef {import("../Dependency")} Dependency */
15
15
  /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
16
+ /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
17
+ /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
16
18
 
17
19
  class AMDRequireDependency extends NullDependency {
18
20
  constructor(outerRange, arrayRange, functionRange, errorCallbackRange) {
@@ -30,6 +32,9 @@ class AMDRequireDependency extends NullDependency {
30
32
  return "amd";
31
33
  }
32
34
 
35
+ /**
36
+ * @param {ObjectSerializerContext} context context
37
+ */
33
38
  serialize(context) {
34
39
  const { write } = context;
35
40
 
@@ -43,6 +48,9 @@ class AMDRequireDependency extends NullDependency {
43
48
  super.serialize(context);
44
49
  }
45
50
 
51
+ /**
52
+ * @param {ObjectDeserializerContext} context context
53
+ */
46
54
  deserialize(context) {
47
55
  const { read } = context;
48
56
 
@@ -18,6 +18,8 @@ const NullDependency = require("./NullDependency");
18
18
  /** @typedef {import("../DependencyTemplates")} DependencyTemplates */
19
19
  /** @typedef {import("../ModuleGraph")} ModuleGraph */
20
20
  /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
21
+ /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
22
+ /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
21
23
  /** @typedef {import("../util/Hash")} Hash */
22
24
 
23
25
  class CachedConstDependency extends NullDependency {
@@ -42,6 +44,9 @@ class CachedConstDependency extends NullDependency {
42
44
  hash.update(this._hashUpdate);
43
45
  }
44
46
 
47
+ /**
48
+ * @param {ObjectSerializerContext} context context
49
+ */
45
50
  serialize(context) {
46
51
  const { write } = context;
47
52
 
@@ -52,6 +57,9 @@ class CachedConstDependency extends NullDependency {
52
57
  super.serialize(context);
53
58
  }
54
59
 
60
+ /**
61
+ * @param {ObjectDeserializerContext} context context
62
+ */
55
63
  deserialize(context) {
56
64
  const { read } = context;
57
65
 
@@ -7,6 +7,15 @@
7
7
 
8
8
  const RuntimeGlobals = require("../RuntimeGlobals");
9
9
 
10
+ /** @typedef {import("../Module")} Module */
11
+ /** @typedef {"exports" | "module.exports" | "this" | "Object.defineProperty(exports)" | "Object.defineProperty(module.exports)" | "Object.defineProperty(this)"} CommonJSDependencyBaseKeywords */
12
+
13
+ /**
14
+ * @param {CommonJSDependencyBaseKeywords} depBase commonjs dependency base
15
+ * @param {Module} module module
16
+ * @param {Set<string>} runtimeRequirements runtime requirements
17
+ * @returns {[string, string]} type and base
18
+ */
10
19
  exports.handleDependencyBase = (depBase, module, runtimeRequirements) => {
11
20
  let base = undefined;
12
21
  let type;
@@ -22,6 +22,8 @@ const processExportInfo = require("./processExportInfo");
22
22
  /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
23
23
  /** @typedef {import("../Module")} Module */
24
24
  /** @typedef {import("../ModuleGraph")} ModuleGraph */
25
+ /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
26
+ /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
25
27
  /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
26
28
 
27
29
  const idsSymbol = Symbol("CommonJsExportRequireDependency.ids");
@@ -270,6 +272,9 @@ class CommonJsExportRequireDependency extends ModuleDependency {
270
272
  return { exports, checked };
271
273
  }
272
274
 
275
+ /**
276
+ * @param {ObjectSerializerContext} context context
277
+ */
273
278
  serialize(context) {
274
279
  const { write } = context;
275
280
  write(this.asiSafe);
@@ -282,6 +287,9 @@ class CommonJsExportRequireDependency extends ModuleDependency {
282
287
  super.serialize(context);
283
288
  }
284
289
 
290
+ /**
291
+ * @param {ObjectDeserializerContext} context context
292
+ */
285
293
  deserialize(context) {
286
294
  const { read } = context;
287
295
  this.asiSafe = read();
@@ -16,6 +16,8 @@ const NullDependency = require("./NullDependency");
16
16
  /** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */
17
17
  /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
18
18
  /** @typedef {import("../ModuleGraph")} ModuleGraph */
19
+ /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
20
+ /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
19
21
 
20
22
  const EMPTY_OBJECT = {};
21
23
 
@@ -53,6 +55,9 @@ class CommonJsExportsDependency extends NullDependency {
53
55
  };
54
56
  }
55
57
 
58
+ /**
59
+ * @param {ObjectSerializerContext} context context
60
+ */
56
61
  serialize(context) {
57
62
  const { write } = context;
58
63
  write(this.range);
@@ -62,6 +67,9 @@ class CommonJsExportsDependency extends NullDependency {
62
67
  super.serialize(context);
63
68
  }
64
69
 
70
+ /**
71
+ * @param {ObjectDeserializerContext} context context
72
+ */
65
73
  deserialize(context) {
66
74
  const { read } = context;
67
75
  this.range = read();