webpack 5.99.7 → 5.99.8

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 (132) hide show
  1. package/lib/Compilation.js +12 -7
  2. package/lib/ContextModule.js +1 -1
  3. package/lib/ContextModuleFactory.js +1 -2
  4. package/lib/ContextReplacementPlugin.js +2 -1
  5. package/lib/DefinePlugin.js +2 -2
  6. package/lib/DelegatedModule.js +18 -8
  7. package/lib/DelegatedModuleFactoryPlugin.js +9 -7
  8. package/lib/EvalSourceMapDevToolPlugin.js +1 -1
  9. package/lib/ExportsInfo.js +35 -16
  10. package/lib/ExternalModule.js +6 -5
  11. package/lib/FileSystemInfo.js +2 -2
  12. package/lib/LibManifestPlugin.js +2 -2
  13. package/lib/ModuleFilenameHelpers.js +8 -4
  14. package/lib/NormalModule.js +8 -7
  15. package/lib/SourceMapDevToolPlugin.js +2 -3
  16. package/lib/WebpackOptionsApply.js +1 -4
  17. package/lib/asset/AssetGenerator.js +2 -2
  18. package/lib/config/defaults.js +10 -6
  19. package/lib/config/normalization.js +5 -5
  20. package/lib/css/CssModulesPlugin.js +2 -2
  21. package/lib/debug/ProfilingPlugin.js +18 -21
  22. package/lib/dependencies/CommonJsImportsParserPlugin.js +1 -1
  23. package/lib/dependencies/ContextElementDependency.js +1 -1
  24. package/lib/dependencies/CssLocalIdentifierDependency.js +2 -2
  25. package/lib/dependencies/RequireContextPlugin.js +2 -1
  26. package/lib/dependencies/WorkerPlugin.js +2 -2
  27. package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +0 -1
  28. package/lib/index.js +11 -0
  29. package/lib/javascript/JavascriptModulesPlugin.js +2 -2
  30. package/lib/json/JsonModulesPlugin.js +4 -4
  31. package/lib/library/AbstractLibraryPlugin.js +1 -1
  32. package/lib/node/nodeConsole.js +3 -2
  33. package/lib/optimize/AggressiveSplittingPlugin.js +1 -1
  34. package/lib/optimize/ConcatenatedModule.js +3 -1
  35. package/lib/optimize/ModuleConcatenationPlugin.js +2 -2
  36. package/lib/optimize/RuntimeChunkPlugin.js +5 -6
  37. package/lib/optimize/SideEffectsFlagPlugin.js +9 -6
  38. package/lib/optimize/SplitChunksPlugin.js +2 -2
  39. package/lib/rules/BasicEffectRulePlugin.js +1 -2
  40. package/lib/rules/ObjectMatcherRulePlugin.js +2 -1
  41. package/lib/rules/RuleSetCompiler.js +19 -5
  42. package/lib/rules/UseEffectRulePlugin.js +4 -6
  43. package/lib/schemes/HttpUriPlugin.js +154 -149
  44. package/lib/util/createHash.js +3 -3
  45. package/package.json +33 -29
  46. package/schemas/WebpackOptions.check.d.ts +1 -1
  47. package/schemas/WebpackOptions.check.js +2 -2
  48. package/schemas/WebpackOptions.json +243 -24
  49. package/schemas/plugins/BannerPlugin.check.d.ts +1 -1
  50. package/schemas/plugins/BannerPlugin.check.js +1 -1
  51. package/schemas/plugins/DllPlugin.check.d.ts +1 -1
  52. package/schemas/plugins/DllPlugin.check.js +1 -1
  53. package/schemas/plugins/DllReferencePlugin.check.d.ts +1 -1
  54. package/schemas/plugins/DllReferencePlugin.check.js +1 -1
  55. package/schemas/plugins/HashedModuleIdsPlugin.check.d.ts +1 -1
  56. package/schemas/plugins/HashedModuleIdsPlugin.check.js +1 -1
  57. package/schemas/plugins/IgnorePlugin.check.d.ts +1 -1
  58. package/schemas/plugins/IgnorePlugin.check.js +1 -1
  59. package/schemas/plugins/LoaderOptionsPlugin.check.d.ts +1 -1
  60. package/schemas/plugins/LoaderOptionsPlugin.check.js +1 -1
  61. package/schemas/plugins/ProgressPlugin.check.d.ts +1 -1
  62. package/schemas/plugins/ProgressPlugin.check.js +1 -1
  63. package/schemas/plugins/SourceMapDevToolPlugin.check.d.ts +1 -1
  64. package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
  65. package/schemas/plugins/SourceMapDevToolPlugin.json +2 -2
  66. package/schemas/plugins/WatchIgnorePlugin.check.d.ts +1 -1
  67. package/schemas/plugins/WatchIgnorePlugin.check.js +1 -1
  68. package/schemas/plugins/asset/AssetGeneratorOptions.check.d.ts +1 -1
  69. package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
  70. package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.d.ts +1 -1
  71. package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.js +1 -1
  72. package/schemas/plugins/asset/AssetParserOptions.check.d.ts +1 -1
  73. package/schemas/plugins/asset/AssetParserOptions.check.js +1 -1
  74. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.d.ts +1 -1
  75. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
  76. package/schemas/plugins/container/ContainerPlugin.check.d.ts +1 -1
  77. package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
  78. package/schemas/plugins/container/ContainerReferencePlugin.check.d.ts +1 -1
  79. package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
  80. package/schemas/plugins/container/ExternalsType.check.d.ts +1 -1
  81. package/schemas/plugins/container/ExternalsType.check.js +1 -1
  82. package/schemas/plugins/container/ModuleFederationPlugin.check.d.ts +1 -1
  83. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  84. package/schemas/plugins/css/CssAutoGeneratorOptions.check.d.ts +1 -1
  85. package/schemas/plugins/css/CssAutoGeneratorOptions.check.js +1 -1
  86. package/schemas/plugins/css/CssAutoParserOptions.check.d.ts +1 -1
  87. package/schemas/plugins/css/CssAutoParserOptions.check.js +1 -1
  88. package/schemas/plugins/css/CssGeneratorOptions.check.d.ts +1 -1
  89. package/schemas/plugins/css/CssGeneratorOptions.check.js +1 -1
  90. package/schemas/plugins/css/CssGlobalGeneratorOptions.check.d.ts +1 -1
  91. package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +1 -1
  92. package/schemas/plugins/css/CssGlobalParserOptions.check.d.ts +1 -1
  93. package/schemas/plugins/css/CssGlobalParserOptions.check.js +1 -1
  94. package/schemas/plugins/css/CssModuleGeneratorOptions.check.d.ts +1 -1
  95. package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -1
  96. package/schemas/plugins/css/CssModuleParserOptions.check.d.ts +1 -1
  97. package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
  98. package/schemas/plugins/css/CssParserOptions.check.d.ts +1 -1
  99. package/schemas/plugins/css/CssParserOptions.check.js +1 -1
  100. package/schemas/plugins/debug/ProfilingPlugin.check.d.ts +1 -1
  101. package/schemas/plugins/debug/ProfilingPlugin.check.js +1 -1
  102. package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.d.ts +1 -1
  103. package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.js +1 -1
  104. package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.d.ts +1 -1
  105. package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.js +1 -1
  106. package/schemas/plugins/json/JsonModulesPluginGenerator.check.d.ts +7 -0
  107. package/schemas/plugins/{JsonModulesPluginGenerator.check.js → json/JsonModulesPluginGenerator.check.js} +1 -1
  108. package/schemas/plugins/json/JsonModulesPluginGenerator.json +3 -0
  109. package/schemas/plugins/json/JsonModulesPluginParser.check.d.ts +7 -0
  110. package/schemas/plugins/{JsonModulesPluginParser.check.js → json/JsonModulesPluginParser.check.js} +1 -1
  111. package/schemas/plugins/json/JsonModulesPluginParser.json +3 -0
  112. package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.d.ts +1 -1
  113. package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.js +1 -1
  114. package/schemas/plugins/optimize/LimitChunkCountPlugin.check.d.ts +1 -1
  115. package/schemas/plugins/optimize/LimitChunkCountPlugin.check.js +1 -1
  116. package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.d.ts +1 -1
  117. package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.js +1 -1
  118. package/schemas/plugins/optimize/MinChunkSizePlugin.check.d.ts +1 -1
  119. package/schemas/plugins/optimize/MinChunkSizePlugin.check.js +1 -1
  120. package/schemas/plugins/schemes/HttpUriPlugin.check.d.ts +1 -1
  121. package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
  122. package/schemas/plugins/sharing/ConsumeSharedPlugin.check.d.ts +1 -1
  123. package/schemas/plugins/sharing/ConsumeSharedPlugin.check.js +1 -1
  124. package/schemas/plugins/sharing/ProvideSharedPlugin.check.d.ts +1 -1
  125. package/schemas/plugins/sharing/ProvideSharedPlugin.check.js +1 -1
  126. package/schemas/plugins/sharing/SharePlugin.check.d.ts +1 -1
  127. package/schemas/plugins/sharing/SharePlugin.check.js +1 -1
  128. package/types.d.ts +437 -150
  129. package/schemas/plugins/JsonModulesPluginGenerator.check.d.ts +0 -7
  130. package/schemas/plugins/JsonModulesPluginGenerator.json +0 -11
  131. package/schemas/plugins/JsonModulesPluginParser.check.d.ts +0 -7
  132. package/schemas/plugins/JsonModulesPluginParser.json +0 -16
@@ -15,6 +15,7 @@ const util = require("util");
15
15
  /** @typedef {import("../../declarations/WebpackOptions").RuleSetUseItem} RuleSetUseItem */
16
16
  /** @typedef {import("./RuleSetCompiler")} RuleSetCompiler */
17
17
  /** @typedef {import("./RuleSetCompiler").Effect} Effect */
18
+ /** @typedef {import("./RuleSetCompiler").EffectData} EffectData */
18
19
 
19
20
  class UseEffectRulePlugin {
20
21
  /**
@@ -55,7 +56,7 @@ class UseEffectRulePlugin {
55
56
  * @param {string} path options path
56
57
  * @param {string} defaultIdent default ident when none is provided
57
58
  * @param {RuleSetUseItem} item user provided use value
58
- * @returns {Effect | ((value: TODO) => Effect[])} effect
59
+ * @returns {(Effect | ((effectData: EffectData) => Effect[]))} effect
59
60
  */
60
61
  const useToEffect = (path, defaultIdent, item) => {
61
62
  if (typeof item === "function") {
@@ -139,7 +140,7 @@ class UseEffectRulePlugin {
139
140
  /**
140
141
  * @param {string} path current path
141
142
  * @param {RuleSetUse} items user provided use value
142
- * @returns {(Effect | ((value: TODO) => Effect[]))[]} effects
143
+ * @returns {(Effect | ((effectData: EffectData) => Effect[]))[]} effects
143
144
  */
144
145
  const useToEffects = (path, items) => {
145
146
  if (Array.isArray(items)) {
@@ -160,10 +161,7 @@ class UseEffectRulePlugin {
160
161
 
161
162
  if (typeof use === "function") {
162
163
  result.effects.push(data =>
163
- useToEffectsWithoutIdent(
164
- `${path}.use`,
165
- use(/** @type {TODO} */ (data))
166
- )
164
+ useToEffectsWithoutIdent(`${path}.use`, use(data))
167
165
  );
168
166
  } else {
169
167
  for (const effect of useToEffects(`${path}.use`, use)) {
@@ -16,6 +16,7 @@ const { mkdirp, dirname, join } = require("../util/fs");
16
16
  const memoize = require("../util/memoize");
17
17
 
18
18
  /** @typedef {import("http").IncomingMessage} IncomingMessage */
19
+ /** @typedef {import("http").OutgoingHttpHeaders} OutgoingHttpHeaders */
19
20
  /** @typedef {import("http").RequestOptions} RequestOptions */
20
21
  /** @typedef {import("net").Socket} Socket */
21
22
  /** @typedef {import("stream").Readable} Readable */
@@ -147,7 +148,7 @@ const parseKeyValuePairs = str => {
147
148
  /**
148
149
  * @param {string | undefined} cacheControl Cache-Control header
149
150
  * @param {number} requestTime timestamp of request
150
- * @returns {{storeCache: boolean, storeLock: boolean, validUntil: number}} Logic for storing in cache and lockfile cache
151
+ * @returns {{ storeCache: boolean, storeLock: boolean, validUntil: number }} Logic for storing in cache and lockfile cache
151
152
  */
152
153
  const parseCacheControl = (cacheControl, requestTime) => {
153
154
  // When false resource is not stored in cache
@@ -190,7 +191,7 @@ const areLockfileEntriesEqual = (a, b) =>
190
191
 
191
192
  /**
192
193
  * @param {LockfileEntry} entry lockfile entry
193
- * @returns {`resolved: ${string}, integrity: ${string}, contentType: ${*}`} stringified entry
194
+ * @returns {`resolved: ${string}, integrity: ${string}, contentType: ${string}`} stringified entry
194
195
  */
195
196
  const entryToString = entry =>
196
197
  `resolved: ${entry.resolved}, integrity: ${entry.integrity}, contentType: ${entry.contentType}`;
@@ -636,11 +637,14 @@ class HttpUriPlugin {
636
637
  const resolveContent = (url, integrity, callback) => {
637
638
  /**
638
639
  * @param {Error | null} err error
639
- * @param {TODO} result result result
640
+ * @param {FetchResult=} _result fetch result
640
641
  * @returns {void}
641
642
  */
642
- const handleResult = (err, result) => {
643
+ const handleResult = (err, _result) => {
643
644
  if (err) return callback(err);
645
+
646
+ const result = /** @type {FetchResult} */ (_result);
647
+
644
648
  if ("location" in result) {
645
649
  return resolveContent(
646
650
  result.location,
@@ -657,6 +661,7 @@ class HttpUriPlugin {
657
661
  }
658
662
  );
659
663
  }
664
+
660
665
  if (
661
666
  !result.fresh &&
662
667
  integrity &&
@@ -665,12 +670,14 @@ class HttpUriPlugin {
665
670
  ) {
666
671
  return fetchContent.force(url, handleResult);
667
672
  }
673
+
668
674
  return callback(null, {
669
675
  entry: result.entry,
670
676
  content: result.content,
671
677
  storeLock: result.storeLock
672
678
  });
673
679
  };
680
+
674
681
  fetchContent(url, handleResult);
675
682
  };
676
683
 
@@ -682,164 +689,162 @@ class HttpUriPlugin {
682
689
  */
683
690
  const fetchContentRaw = (url, cachedResult, callback) => {
684
691
  const requestTime = Date.now();
685
- fetch(
686
- new URL(url),
687
- {
688
- headers: {
689
- "accept-encoding": "gzip, deflate, br",
690
- "user-agent": "webpack",
691
- "if-none-match": /** @type {TODO} */ (
692
- cachedResult ? cachedResult.etag || null : null
693
- )
694
- }
695
- },
696
- res => {
697
- const etag = res.headers.etag;
698
- const location = res.headers.location;
699
- const cacheControl = res.headers["cache-control"];
700
- const { storeLock, storeCache, validUntil } = parseCacheControl(
701
- cacheControl,
702
- requestTime
703
- );
704
- /**
705
- * @param {Partial<Pick<FetchResultMeta, "fresh">> & (Pick<RedirectFetchResult, "location"> | Pick<ContentFetchResult, "content" | "entry">)} partialResult result
706
- * @returns {void}
707
- */
708
- const finishWith = partialResult => {
709
- if ("location" in partialResult) {
710
- logger.debug(
711
- `GET ${url} [${res.statusCode}] -> ${partialResult.location}`
712
- );
713
- } else {
714
- logger.debug(
715
- `GET ${url} [${res.statusCode}] ${Math.ceil(
716
- partialResult.content.length / 1024
717
- )} kB${!storeLock ? " no-cache" : ""}`
718
- );
719
- }
720
- const result = {
721
- ...partialResult,
722
- fresh: true,
723
- storeLock,
724
- storeCache,
725
- validUntil,
726
- etag
727
- };
728
- if (!storeCache) {
729
- logger.log(
730
- `${url} can't be stored in cache, due to Cache-Control header: ${cacheControl}`
731
- );
732
- return callback(null, result);
733
- }
734
- cache.store(
735
- url,
736
- null,
737
- {
738
- ...result,
739
- fresh: false
740
- },
741
- err => {
742
- if (err) {
743
- logger.warn(
744
- `${url} can't be stored in cache: ${err.message}`
745
- );
746
- logger.debug(err.stack);
747
- }
748
- callback(null, result);
749
- }
692
+ /** @type {OutgoingHttpHeaders} */
693
+ const headers = {
694
+ "accept-encoding": "gzip, deflate, br",
695
+ "user-agent": "webpack"
696
+ };
697
+
698
+ if (cachedResult && cachedResult.etag) {
699
+ headers["if-none-match"] = cachedResult.etag;
700
+ }
701
+
702
+ fetch(new URL(url), { headers }, res => {
703
+ const etag = res.headers.etag;
704
+ const location = res.headers.location;
705
+ const cacheControl = res.headers["cache-control"];
706
+ const { storeLock, storeCache, validUntil } = parseCacheControl(
707
+ cacheControl,
708
+ requestTime
709
+ );
710
+ /**
711
+ * @param {Partial<Pick<FetchResultMeta, "fresh">> & (Pick<RedirectFetchResult, "location"> | Pick<ContentFetchResult, "content" | "entry">)} partialResult result
712
+ * @returns {void}
713
+ */
714
+ const finishWith = partialResult => {
715
+ if ("location" in partialResult) {
716
+ logger.debug(
717
+ `GET ${url} [${res.statusCode}] -> ${partialResult.location}`
718
+ );
719
+ } else {
720
+ logger.debug(
721
+ `GET ${url} [${res.statusCode}] ${Math.ceil(
722
+ partialResult.content.length / 1024
723
+ )} kB${!storeLock ? " no-cache" : ""}`
750
724
  );
725
+ }
726
+ const result = {
727
+ ...partialResult,
728
+ fresh: true,
729
+ storeLock,
730
+ storeCache,
731
+ validUntil,
732
+ etag
751
733
  };
752
- if (res.statusCode === 304) {
753
- const result = /** @type {FetchResult} */ (cachedResult);
754
- if (
755
- result.validUntil < validUntil ||
756
- result.storeLock !== storeLock ||
757
- result.storeCache !== storeCache ||
758
- result.etag !== etag
759
- ) {
760
- return finishWith(result);
761
- }
762
- logger.debug(`GET ${url} [${res.statusCode}] (unchanged)`);
763
- return callback(null, { ...result, fresh: true });
734
+ if (!storeCache) {
735
+ logger.log(
736
+ `${url} can't be stored in cache, due to Cache-Control header: ${cacheControl}`
737
+ );
738
+ return callback(null, result);
764
739
  }
740
+ cache.store(
741
+ url,
742
+ null,
743
+ {
744
+ ...result,
745
+ fresh: false
746
+ },
747
+ err => {
748
+ if (err) {
749
+ logger.warn(
750
+ `${url} can't be stored in cache: ${err.message}`
751
+ );
752
+ logger.debug(err.stack);
753
+ }
754
+ callback(null, result);
755
+ }
756
+ );
757
+ };
758
+ if (res.statusCode === 304) {
759
+ const result = /** @type {FetchResult} */ (cachedResult);
765
760
  if (
766
- location &&
767
- res.statusCode &&
768
- res.statusCode >= 301 &&
769
- res.statusCode <= 308
761
+ result.validUntil < validUntil ||
762
+ result.storeLock !== storeLock ||
763
+ result.storeCache !== storeCache ||
764
+ result.etag !== etag
770
765
  ) {
771
- const result = {
772
- location: new URL(location, url).href
773
- };
774
- if (
775
- !cachedResult ||
776
- !("location" in cachedResult) ||
777
- cachedResult.location !== result.location ||
778
- cachedResult.validUntil < validUntil ||
779
- cachedResult.storeLock !== storeLock ||
780
- cachedResult.storeCache !== storeCache ||
781
- cachedResult.etag !== etag
782
- ) {
783
- return finishWith(result);
784
- }
785
- logger.debug(`GET ${url} [${res.statusCode}] (unchanged)`);
786
- return callback(null, {
787
- ...result,
788
- fresh: true,
789
- storeLock,
790
- storeCache,
791
- validUntil,
792
- etag
793
- });
766
+ return finishWith(result);
794
767
  }
795
- const contentType = res.headers["content-type"] || "";
796
- /** @type {Buffer[]} */
797
- const bufferArr = [];
798
-
799
- const contentEncoding = res.headers["content-encoding"];
800
- /** @type {Readable} */
801
- let stream = res;
802
- if (contentEncoding === "gzip") {
803
- stream = stream.pipe(createGunzip());
804
- } else if (contentEncoding === "br") {
805
- stream = stream.pipe(createBrotliDecompress());
806
- } else if (contentEncoding === "deflate") {
807
- stream = stream.pipe(createInflate());
768
+ logger.debug(`GET ${url} [${res.statusCode}] (unchanged)`);
769
+ return callback(null, { ...result, fresh: true });
770
+ }
771
+ if (
772
+ location &&
773
+ res.statusCode &&
774
+ res.statusCode >= 301 &&
775
+ res.statusCode <= 308
776
+ ) {
777
+ const result = {
778
+ location: new URL(location, url).href
779
+ };
780
+ if (
781
+ !cachedResult ||
782
+ !("location" in cachedResult) ||
783
+ cachedResult.location !== result.location ||
784
+ cachedResult.validUntil < validUntil ||
785
+ cachedResult.storeLock !== storeLock ||
786
+ cachedResult.storeCache !== storeCache ||
787
+ cachedResult.etag !== etag
788
+ ) {
789
+ return finishWith(result);
808
790
  }
809
-
810
- stream.on("data", chunk => {
811
- bufferArr.push(chunk);
791
+ logger.debug(`GET ${url} [${res.statusCode}] (unchanged)`);
792
+ return callback(null, {
793
+ ...result,
794
+ fresh: true,
795
+ storeLock,
796
+ storeCache,
797
+ validUntil,
798
+ etag
812
799
  });
800
+ }
801
+ const contentType = res.headers["content-type"] || "";
802
+ /** @type {Buffer[]} */
803
+ const bufferArr = [];
813
804
 
814
- stream.on("end", () => {
815
- if (!res.complete) {
816
- logger.log(`GET ${url} [${res.statusCode}] (terminated)`);
817
- return callback(new Error(`${url} request was terminated`));
818
- }
805
+ const contentEncoding = res.headers["content-encoding"];
806
+ /** @type {Readable} */
807
+ let stream = res;
808
+ if (contentEncoding === "gzip") {
809
+ stream = stream.pipe(createGunzip());
810
+ } else if (contentEncoding === "br") {
811
+ stream = stream.pipe(createBrotliDecompress());
812
+ } else if (contentEncoding === "deflate") {
813
+ stream = stream.pipe(createInflate());
814
+ }
819
815
 
820
- const content = Buffer.concat(bufferArr);
816
+ stream.on("data", chunk => {
817
+ bufferArr.push(chunk);
818
+ });
821
819
 
822
- if (res.statusCode !== 200) {
823
- logger.log(`GET ${url} [${res.statusCode}]`);
824
- return callback(
825
- new Error(
826
- `${url} request status code = ${
827
- res.statusCode
828
- }\n${content.toString("utf-8")}`
829
- )
830
- );
831
- }
820
+ stream.on("end", () => {
821
+ if (!res.complete) {
822
+ logger.log(`GET ${url} [${res.statusCode}] (terminated)`);
823
+ return callback(new Error(`${url} request was terminated`));
824
+ }
832
825
 
833
- const integrity = computeIntegrity(content);
834
- const entry = { resolved: url, integrity, contentType };
826
+ const content = Buffer.concat(bufferArr);
835
827
 
836
- finishWith({
837
- entry,
838
- content
839
- });
828
+ if (res.statusCode !== 200) {
829
+ logger.log(`GET ${url} [${res.statusCode}]`);
830
+ return callback(
831
+ new Error(
832
+ `${url} request status code = ${
833
+ res.statusCode
834
+ }\n${content.toString("utf-8")}`
835
+ )
836
+ );
837
+ }
838
+
839
+ const integrity = computeIntegrity(content);
840
+ const entry = { resolved: url, integrity, contentType };
841
+
842
+ finishWith({
843
+ entry,
844
+ content
840
845
  });
841
- }
842
- ).on("error", err => {
846
+ });
847
+ }).on("error", err => {
843
848
  logger.log(`GET ${url} (error)`);
844
849
  err.message += `\nwhile fetching ${url}`;
845
850
  callback(err);
@@ -849,7 +854,7 @@ class HttpUriPlugin {
849
854
  const fetchContent = cachedWithKey(
850
855
  /**
851
856
  * @param {string} url URL
852
- * @param {(err: Error | null, result?: { validUntil: number, etag?: string, entry: LockfileEntry, content: Buffer, fresh: boolean } | { validUntil: number, etag?: string, location: string, fresh: boolean }) => void} callback callback
857
+ * @param {(err: Error | null, result?: FetchResult) => void} callback callback
853
858
  * @returns {void}
854
859
  */
855
860
  (url, callback) => {
@@ -7,6 +7,8 @@
7
7
 
8
8
  const Hash = require("./Hash");
9
9
 
10
+ /** @typedef {import("../../declarations/WebpackOptions").HashFunction} HashFunction */
11
+
10
12
  const BULK_SIZE = 2000;
11
13
 
12
14
  // We are using an object instead of a Map as this will stay static during the runtime
@@ -141,11 +143,9 @@ let createMd4;
141
143
  /** @type {typeof import("./hash/BatchedHash") | undefined} */
142
144
  let BatchedHash;
143
145
 
144
- /** @typedef {string | typeof Hash} Algorithm */
145
-
146
146
  /**
147
147
  * Creates a hash by name or function
148
- * @param {Algorithm} algorithm the algorithm name or a constructor creating a hash
148
+ * @param {HashFunction} algorithm the algorithm name or a constructor creating a hash
149
149
  * @returns {Hash} the hash
150
150
  */
151
151
  module.exports = algorithm => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.99.7",
3
+ "version": "5.99.8",
4
4
  "author": "Tobias Koppers @sokra",
5
5
  "description": "Packs ECMAScript/CommonJs/AMD modules for the browser. Allows you to split your codebase into multiple bundles, which can be loaded on demand. Supports loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
6
6
  "license": "MIT",
@@ -36,14 +36,16 @@
36
36
  }
37
37
  },
38
38
  "devDependencies": {
39
- "@babel/core": "^7.26.8",
40
- "@babel/preset-react": "^7.25.7",
39
+ "@babel/core": "^7.27.1",
40
+ "@babel/preset-react": "^7.27.1",
41
+ "@codspeed/benchmark.js-plugin": "^4.0.1",
41
42
  "@eslint/js": "^9.21.0",
42
43
  "@stylistic/eslint-plugin": "^4.2.0",
43
44
  "@types/glob-to-regexp": "^0.4.4",
44
45
  "@types/jest": "^29.5.11",
45
46
  "@types/mime-types": "^2.1.4",
46
- "@types/node": "^22.13.10",
47
+ "@types/node": "^22.15.11",
48
+ "@types/xxhashjs": "^0.2.4",
47
49
  "assemblyscript": "^0.27.34",
48
50
  "babel-loader": "^10.0.0",
49
51
  "benchmark": "^2.1.4",
@@ -62,7 +64,7 @@
62
64
  "eslint-plugin-jsdoc": "^50.6.3",
63
65
  "eslint-plugin-n": "^17.16.2",
64
66
  "eslint-plugin-prettier": "^5.1.3",
65
- "eslint-plugin-unicorn": "^58.0.0",
67
+ "eslint-plugin-unicorn": "^59.0.0",
66
68
  "file-loader": "^6.0.0",
67
69
  "fork-ts-checker-webpack-plugin": "^9.0.2",
68
70
  "globals": "^16.0.0",
@@ -85,6 +87,7 @@
85
87
  "memfs": "^4.14.0",
86
88
  "mini-css-extract-plugin": "^2.9.0",
87
89
  "mini-svg-data-uri": "^1.2.3",
90
+ "node-gyp": "^11.2.0",
88
91
  "nyc": "^17.1.0",
89
92
  "open-cli": "^8.0.0",
90
93
  "prettier": "^3.5.1",
@@ -101,8 +104,9 @@
101
104
  "strip-ansi": "^6.0.0",
102
105
  "style-loader": "^4.0.0",
103
106
  "terser": "^5.38.1",
107
+ "three": "^0.176.0",
104
108
  "toml": "^3.0.0",
105
- "tooling": "webpack/tooling#v1.23.7",
109
+ "tooling": "webpack/tooling#v1.23.8",
106
110
  "ts-loader": "^9.5.1",
107
111
  "typescript": "^5.8.2",
108
112
  "url-loader": "^4.1.0",
@@ -141,34 +145,34 @@
141
145
  "types.d.ts"
142
146
  ],
143
147
  "scripts": {
148
+ "prepare": "husky",
144
149
  "setup": "node ./setup/setup.js",
145
- "jest": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --logHeapUsage",
150
+ "prelint": "yarn setup",
151
+ "lint": "yarn lint:code && yarn lint:special && yarn lint:types && yarn lint:types-test && yarn lint:types-module-test && yarn lint:yarn && yarn fmt:check && yarn lint:spellcheck",
152
+ "lint:code": "node node_modules/eslint/bin/eslint.js --cache .",
153
+ "lint:special": "node node_modules/tooling/lockfile-lint && node node_modules/tooling/schemas-lint && node node_modules/tooling/inherit-types && node node_modules/tooling/format-schemas && node tooling/generate-runtime-code.js && node tooling/generate-wasm-code.js && node node_modules/tooling/format-file-header && node node_modules/tooling/compile-to-definitions && node node_modules/tooling/precompile-schemas && node node_modules/tooling/generate-types --no-template-literals",
154
+ "lint:types": "tsc",
155
+ "lint:types-test": "tsc -p tsconfig.types.test.json",
156
+ "lint:types-module-test": "tsc -p tsconfig.module.test.json",
157
+ "lint:yarn": "yarn-deduplicate --fail --list -s highest yarn.lock",
158
+ "lint:spellcheck": "cspell --cache --no-must-find-files --quiet \"**/*.*\"",
159
+ "report:types": "rimraf coverage && yarn cover:types && yarn cover:report && open-cli coverage/lcov-report/index.html",
160
+ "validate:types": "tsc -p tsconfig.validation.json",
161
+ "fmt": "yarn fmt:base --log-level warn --write",
162
+ "fmt:check": "yarn fmt:base --check",
163
+ "fmt:base": "node node_modules/prettier/bin/prettier.cjs --cache --ignore-unknown .",
164
+ "fix": "yarn fix:code && fix:yarn && fix:special && yarn fmt",
165
+ "fix:code": "yarn lint:code --fix",
166
+ "fix:yarn": "yarn-deduplicate -s highest yarn.lock",
167
+ "fix:special": "node node_modules/tooling/inherit-types --write && node node_modules/tooling/format-schemas --write && node tooling/generate-runtime-code.js --write && node tooling/generate-wasm-code.js --write && node node_modules/tooling/format-file-header --write && node node_modules/tooling/compile-to-definitions --write && node node_modules/tooling/precompile-schemas --write && node node_modules/tooling/generate-types --no-template-literals --write",
168
+ "build:examples": "cd examples && node buildAll.js",
169
+ "benchmark": "node --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation --hash-seed=1 --random-seed=1 --no-opt --predictable --predictable-gc-schedule --interpreted-frames-native-stack --allow-natives-syntax --expose-gc --no-concurrent-sweeping ./test/BenchmarkTestCases.benchmark.mjs",
170
+ "pretest": "yarn lint",
146
171
  "test": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --logHeapUsage",
147
- "test:update-snapshots": "yarn jest -u",
172
+ "test:update-snapshots": "yarn test -u",
148
173
  "test:integration": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --logHeapUsage --testMatch \"<rootDir>/test/*.{basictest,longtest,test}.js\"",
149
174
  "test:basic": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --logHeapUsage --testMatch \"<rootDir>/test/*.basictest.js\"",
150
175
  "test:unit": "node --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.unittest.js\"",
151
- "build:examples": "cd examples && node buildAll.js",
152
- "type-report": "rimraf coverage && yarn cover:types && yarn cover:report && open-cli coverage/lcov-report/index.html",
153
- "pretest": "yarn lint",
154
- "prelint": "yarn setup",
155
- "lint": "yarn code-lint && yarn special-lint && yarn type-lint && yarn typings-test && yarn module-typings-test && yarn yarn-lint && yarn pretty-lint && yarn spellcheck",
156
- "code-lint": "node node_modules/eslint/bin/eslint.js --cache .",
157
- "type-lint": "tsc",
158
- "type-validate": "tsc -p tsconfig.validation.json",
159
- "typings-test": "tsc -p tsconfig.types.test.json",
160
- "module-typings-test": "tsc -p tsconfig.module.test.json",
161
- "spellcheck": "cspell --cache --no-must-find-files --quiet \"**/*.*\"",
162
- "special-lint": "node node_modules/tooling/lockfile-lint && node node_modules/tooling/schemas-lint && node node_modules/tooling/inherit-types && node node_modules/tooling/format-schemas && node tooling/generate-runtime-code.js && node tooling/generate-wasm-code.js && node node_modules/tooling/format-file-header && node node_modules/tooling/compile-to-definitions && node node_modules/tooling/precompile-schemas && node node_modules/tooling/generate-types --no-template-literals",
163
- "special-lint-fix": "node node_modules/tooling/inherit-types --write && node node_modules/tooling/format-schemas --write && node tooling/generate-runtime-code.js --write && node tooling/generate-wasm-code.js --write && node node_modules/tooling/format-file-header --write && node node_modules/tooling/compile-to-definitions --write && node node_modules/tooling/precompile-schemas --write && node node_modules/tooling/generate-types --no-template-literals --write",
164
- "fix": "yarn code-lint --fix && yarn special-lint-fix && yarn pretty-lint-fix",
165
- "prepare": "husky",
166
- "pretty-lint-base": "node node_modules/prettier/bin/prettier.cjs --cache --ignore-unknown .",
167
- "pretty-lint-fix": "yarn pretty-lint-base --log-level warn --write",
168
- "pretty-lint": "yarn pretty-lint-base --check",
169
- "yarn-lint": "yarn-deduplicate --fail --list -s highest yarn.lock",
170
- "yarn-lint-fix": "yarn-deduplicate -s highest yarn.lock",
171
- "benchmark": "node --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.benchmark.mjs\" --runInBand",
172
176
  "cover": "yarn cover:all && yarn cover:report",
173
177
  "cover:clean": "rimraf .nyc_output coverage",
174
178
  "cover:all": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules node_modules/jest-cli/bin/jest --logHeapUsage --coverage",
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * This file was automatically generated.
3
3
  * DO NOT MODIFY BY HAND.
4
- * Run `yarn special-lint-fix` to update
4
+ * Run `yarn fix:special` to update
5
5
  */
6
6
  declare const check: (options: import("../declarations/WebpackOptions").WebpackOptions) => boolean;
7
7
  export = check;