webpack 5.99.6 → 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 (219) hide show
  1. package/lib/AutomaticPrefetchPlugin.js +21 -22
  2. package/lib/BannerPlugin.js +31 -35
  3. package/lib/CleanPlugin.js +5 -3
  4. package/lib/Compilation.js +21 -15
  5. package/lib/Compiler.js +2 -1
  6. package/lib/ContextExclusionPlugin.js +4 -2
  7. package/lib/ContextModule.js +1 -1
  8. package/lib/ContextModuleFactory.js +1 -2
  9. package/lib/ContextReplacementPlugin.js +7 -4
  10. package/lib/DefinePlugin.js +2 -2
  11. package/lib/DelegatedModule.js +18 -8
  12. package/lib/DelegatedModuleFactoryPlugin.js +9 -7
  13. package/lib/DelegatedPlugin.js +4 -2
  14. package/lib/DllEntryPlugin.js +4 -2
  15. package/lib/DllPlugin.js +5 -3
  16. package/lib/DllReferencePlugin.js +56 -60
  17. package/lib/DynamicEntryPlugin.js +4 -2
  18. package/lib/EntryOptionPlugin.js +3 -1
  19. package/lib/EntryPlugin.js +4 -2
  20. package/lib/EnvironmentPlugin.js +4 -2
  21. package/lib/EvalDevToolModulePlugin.js +9 -7
  22. package/lib/EvalSourceMapDevToolPlugin.js +138 -139
  23. package/lib/ExportsInfo.js +35 -16
  24. package/lib/ExternalModule.js +6 -5
  25. package/lib/ExternalsPlugin.js +3 -1
  26. package/lib/FileSystemInfo.js +2 -2
  27. package/lib/FlagDependencyExportsPlugin.js +2 -1
  28. package/lib/IgnorePlugin.js +6 -4
  29. package/lib/IgnoreWarningsPlugin.js +4 -2
  30. package/lib/LibManifestPlugin.js +5 -6
  31. package/lib/LoaderOptionsPlugin.js +4 -2
  32. package/lib/LoaderTargetPlugin.js +4 -2
  33. package/lib/Module.js +19 -12
  34. package/lib/ModuleFilenameHelpers.js +8 -4
  35. package/lib/ModuleInfoHeaderPlugin.js +11 -12
  36. package/lib/MultiCompiler.js +5 -3
  37. package/lib/NoEmitOnErrorsPlugin.js +5 -3
  38. package/lib/NormalModule.js +13 -8
  39. package/lib/NormalModuleReplacementPlugin.js +33 -36
  40. package/lib/PlatformPlugin.js +3 -1
  41. package/lib/PrefetchPlugin.js +4 -2
  42. package/lib/ProgressPlugin.js +23 -26
  43. package/lib/RecordIdsPlugin.js +72 -102
  44. package/lib/RuntimePlugin.js +34 -32
  45. package/lib/SourceMapDevToolPlugin.js +9 -8
  46. package/lib/WarnCaseSensitiveModulesPlugin.js +36 -37
  47. package/lib/WarnNoModeSetPlugin.js +3 -1
  48. package/lib/WatchIgnorePlugin.js +3 -1
  49. package/lib/WebpackError.js +11 -3
  50. package/lib/WebpackOptionsApply.js +6 -7
  51. package/lib/asset/AssetGenerator.js +2 -2
  52. package/lib/async-modules/InferAsyncModulesPlugin.js +25 -26
  53. package/lib/cache/IdleFileCachePlugin.js +11 -12
  54. package/lib/cache/MemoryWithGcCachePlugin.js +7 -5
  55. package/lib/cache/ResolverCachePlugin.js +8 -6
  56. package/lib/cli.js +5 -1
  57. package/lib/config/defaults.js +10 -6
  58. package/lib/config/normalization.js +14 -8
  59. package/lib/container/ContainerReferencePlugin.js +24 -26
  60. package/lib/container/ModuleFederationPlugin.js +2 -1
  61. package/lib/css/CssGenerator.js +1 -1
  62. package/lib/css/CssModulesPlugin.js +8 -6
  63. package/lib/debug/ProfilingPlugin.js +18 -21
  64. package/lib/dependencies/CommonJsImportsParserPlugin.js +1 -1
  65. package/lib/dependencies/ContextElementDependency.js +1 -1
  66. package/lib/dependencies/CssLocalIdentifierDependency.js +2 -2
  67. package/lib/dependencies/HarmonyDetectionParserPlugin.js +9 -15
  68. package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +15 -15
  69. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +4 -2
  70. package/lib/dependencies/LoaderPlugin.js +5 -3
  71. package/lib/dependencies/RequireContextDependencyParserPlugin.js +46 -46
  72. package/lib/dependencies/RequireContextPlugin.js +2 -1
  73. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +94 -100
  74. package/lib/dependencies/WorkerPlugin.js +2 -2
  75. package/lib/esm/ModuleChunkLoadingPlugin.js +72 -73
  76. package/lib/hmr/HotModuleReplacement.runtime.js +0 -1
  77. package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +0 -2
  78. package/lib/hmr/LazyCompilationPlugin.js +17 -18
  79. package/lib/ids/ChunkModuleIdRangePlugin.js +6 -6
  80. package/lib/ids/DeterministicModuleIdsPlugin.js +47 -48
  81. package/lib/ids/HashedModuleIdsPlugin.js +4 -2
  82. package/lib/ids/NamedChunkIdsPlugin.js +4 -2
  83. package/lib/ids/NamedModuleIdsPlugin.js +4 -2
  84. package/lib/ids/NaturalChunkIdsPlugin.js +4 -2
  85. package/lib/ids/NaturalModuleIdsPlugin.js +4 -2
  86. package/lib/ids/OccurrenceChunkIdsPlugin.js +4 -2
  87. package/lib/ids/OccurrenceModuleIdsPlugin.js +4 -2
  88. package/lib/index.js +11 -0
  89. package/lib/javascript/JavascriptModulesPlugin.js +2 -2
  90. package/lib/javascript/JavascriptParser.js +634 -656
  91. package/lib/json/JsonModulesPlugin.js +4 -4
  92. package/lib/library/AbstractLibraryPlugin.js +1 -1
  93. package/lib/library/ModuleLibraryPlugin.js +60 -42
  94. package/lib/node/CommonJsChunkLoadingPlugin.js +69 -73
  95. package/lib/node/NodeEnvironmentPlugin.js +3 -1
  96. package/lib/node/nodeConsole.js +3 -2
  97. package/lib/optimize/AggressiveSplittingPlugin.js +224 -232
  98. package/lib/optimize/ConcatenatedModule.js +15 -16
  99. package/lib/optimize/FlagIncludedChunksPlugin.js +92 -97
  100. package/lib/optimize/LimitChunkCountPlugin.js +4 -2
  101. package/lib/optimize/MangleExportsPlugin.js +15 -16
  102. package/lib/optimize/MinChunkSizePlugin.js +4 -2
  103. package/lib/optimize/ModuleConcatenationPlugin.js +6 -4
  104. package/lib/optimize/RealContentHashPlugin.js +4 -2
  105. package/lib/optimize/RemoveEmptyChunksPlugin.js +5 -3
  106. package/lib/optimize/RemoveParentModulesPlugin.js +4 -2
  107. package/lib/optimize/RuntimeChunkPlugin.js +21 -23
  108. package/lib/optimize/SideEffectsFlagPlugin.js +9 -6
  109. package/lib/optimize/SplitChunksPlugin.js +9 -7
  110. package/lib/performance/SizeLimitsPlugin.js +3 -1
  111. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +61 -62
  112. package/lib/rules/BasicEffectRulePlugin.js +1 -2
  113. package/lib/rules/ObjectMatcherRulePlugin.js +2 -1
  114. package/lib/rules/RuleSetCompiler.js +19 -5
  115. package/lib/rules/UseEffectRulePlugin.js +4 -6
  116. package/lib/runtime/StartupChunkDependenciesPlugin.js +39 -42
  117. package/lib/schemes/DataUriPlugin.js +5 -3
  118. package/lib/schemes/FileUriPlugin.js +5 -3
  119. package/lib/schemes/HttpUriPlugin.js +186 -188
  120. package/lib/serialization/AggregateErrorSerializer.js +42 -0
  121. package/lib/serialization/ErrorObjectSerializer.js +7 -2
  122. package/lib/serialization/ObjectMiddleware.js +13 -0
  123. package/lib/sharing/ProvideSharedPlugin.js +6 -4
  124. package/lib/stats/DefaultStatsFactoryPlugin.js +89 -33
  125. package/lib/stats/DefaultStatsPresetPlugin.js +25 -20
  126. package/lib/stats/DefaultStatsPrinterPlugin.js +306 -341
  127. package/lib/util/concatenate.js +4 -2
  128. package/lib/util/createHash.js +3 -3
  129. package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +55 -57
  130. package/lib/web/JsonpChunkLoadingPlugin.js +73 -74
  131. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +77 -78
  132. package/package.json +35 -30
  133. package/schemas/WebpackOptions.check.d.ts +1 -1
  134. package/schemas/WebpackOptions.check.js +2 -2
  135. package/schemas/WebpackOptions.json +267 -26
  136. package/schemas/plugins/BannerPlugin.check.d.ts +1 -1
  137. package/schemas/plugins/BannerPlugin.check.js +1 -1
  138. package/schemas/plugins/DllPlugin.check.d.ts +1 -1
  139. package/schemas/plugins/DllPlugin.check.js +1 -1
  140. package/schemas/plugins/DllReferencePlugin.check.d.ts +1 -1
  141. package/schemas/plugins/DllReferencePlugin.check.js +1 -1
  142. package/schemas/plugins/HashedModuleIdsPlugin.check.d.ts +1 -1
  143. package/schemas/plugins/HashedModuleIdsPlugin.check.js +1 -1
  144. package/schemas/plugins/IgnorePlugin.check.d.ts +1 -1
  145. package/schemas/plugins/IgnorePlugin.check.js +1 -1
  146. package/schemas/plugins/LoaderOptionsPlugin.check.d.ts +1 -1
  147. package/schemas/plugins/LoaderOptionsPlugin.check.js +1 -1
  148. package/schemas/plugins/ProgressPlugin.check.d.ts +1 -1
  149. package/schemas/plugins/ProgressPlugin.check.js +1 -1
  150. package/schemas/plugins/SourceMapDevToolPlugin.check.d.ts +1 -1
  151. package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
  152. package/schemas/plugins/SourceMapDevToolPlugin.json +2 -2
  153. package/schemas/plugins/WatchIgnorePlugin.check.d.ts +1 -1
  154. package/schemas/plugins/WatchIgnorePlugin.check.js +1 -1
  155. package/schemas/plugins/asset/AssetGeneratorOptions.check.d.ts +1 -1
  156. package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
  157. package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.d.ts +1 -1
  158. package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.js +1 -1
  159. package/schemas/plugins/asset/AssetParserOptions.check.d.ts +1 -1
  160. package/schemas/plugins/asset/AssetParserOptions.check.js +1 -1
  161. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.d.ts +1 -1
  162. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
  163. package/schemas/plugins/container/ContainerPlugin.check.d.ts +1 -1
  164. package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
  165. package/schemas/plugins/container/ContainerReferencePlugin.check.d.ts +1 -1
  166. package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
  167. package/schemas/plugins/container/ExternalsType.check.d.ts +1 -1
  168. package/schemas/plugins/container/ExternalsType.check.js +1 -1
  169. package/schemas/plugins/container/ModuleFederationPlugin.check.d.ts +1 -1
  170. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  171. package/schemas/plugins/css/CssAutoGeneratorOptions.check.d.ts +1 -1
  172. package/schemas/plugins/css/CssAutoGeneratorOptions.check.js +1 -1
  173. package/schemas/plugins/css/CssAutoParserOptions.check.d.ts +1 -1
  174. package/schemas/plugins/css/CssAutoParserOptions.check.js +1 -1
  175. package/schemas/plugins/css/CssGeneratorOptions.check.d.ts +1 -1
  176. package/schemas/plugins/css/CssGeneratorOptions.check.js +1 -1
  177. package/schemas/plugins/css/CssGlobalGeneratorOptions.check.d.ts +1 -1
  178. package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +1 -1
  179. package/schemas/plugins/css/CssGlobalParserOptions.check.d.ts +1 -1
  180. package/schemas/plugins/css/CssGlobalParserOptions.check.js +1 -1
  181. package/schemas/plugins/css/CssModuleGeneratorOptions.check.d.ts +1 -1
  182. package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -1
  183. package/schemas/plugins/css/CssModuleParserOptions.check.d.ts +1 -1
  184. package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
  185. package/schemas/plugins/css/CssParserOptions.check.d.ts +1 -1
  186. package/schemas/plugins/css/CssParserOptions.check.js +1 -1
  187. package/schemas/plugins/debug/ProfilingPlugin.check.d.ts +1 -1
  188. package/schemas/plugins/debug/ProfilingPlugin.check.js +1 -1
  189. package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.d.ts +1 -1
  190. package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.js +1 -1
  191. package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.d.ts +1 -1
  192. package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.js +1 -1
  193. package/schemas/plugins/json/JsonModulesPluginGenerator.check.d.ts +7 -0
  194. package/schemas/plugins/{JsonModulesPluginGenerator.check.js → json/JsonModulesPluginGenerator.check.js} +1 -1
  195. package/schemas/plugins/json/JsonModulesPluginGenerator.json +3 -0
  196. package/schemas/plugins/json/JsonModulesPluginParser.check.d.ts +7 -0
  197. package/schemas/plugins/{JsonModulesPluginParser.check.js → json/JsonModulesPluginParser.check.js} +1 -1
  198. package/schemas/plugins/json/JsonModulesPluginParser.json +3 -0
  199. package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.d.ts +1 -1
  200. package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.js +1 -1
  201. package/schemas/plugins/optimize/LimitChunkCountPlugin.check.d.ts +1 -1
  202. package/schemas/plugins/optimize/LimitChunkCountPlugin.check.js +1 -1
  203. package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.d.ts +1 -1
  204. package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.js +1 -1
  205. package/schemas/plugins/optimize/MinChunkSizePlugin.check.d.ts +1 -1
  206. package/schemas/plugins/optimize/MinChunkSizePlugin.check.js +1 -1
  207. package/schemas/plugins/schemes/HttpUriPlugin.check.d.ts +1 -1
  208. package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
  209. package/schemas/plugins/sharing/ConsumeSharedPlugin.check.d.ts +1 -1
  210. package/schemas/plugins/sharing/ConsumeSharedPlugin.check.js +1 -1
  211. package/schemas/plugins/sharing/ProvideSharedPlugin.check.d.ts +1 -1
  212. package/schemas/plugins/sharing/ProvideSharedPlugin.check.js +1 -1
  213. package/schemas/plugins/sharing/SharePlugin.check.d.ts +1 -1
  214. package/schemas/plugins/sharing/SharePlugin.check.js +1 -1
  215. package/types.d.ts +587 -207
  216. package/schemas/plugins/JsonModulesPluginGenerator.check.d.ts +0 -7
  217. package/schemas/plugins/JsonModulesPluginGenerator.json +0 -11
  218. package/schemas/plugins/JsonModulesPluginParser.check.d.ts +0 -7
  219. package/schemas/plugins/JsonModulesPluginParser.json +0 -16
@@ -15,83 +15,82 @@ const ChunkPreloadTriggerRuntimeModule = require("./ChunkPreloadTriggerRuntimeMo
15
15
  /** @typedef {import("../ChunkGroup").RawChunkGroupOptions} RawChunkGroupOptions */
16
16
  /** @typedef {import("../Compiler")} Compiler */
17
17
 
18
+ const PLUGIN_NAME = "ChunkPrefetchPreloadPlugin";
19
+
18
20
  class ChunkPrefetchPreloadPlugin {
19
21
  /**
20
22
  * @param {Compiler} compiler the compiler
21
23
  * @returns {void}
22
24
  */
23
25
  apply(compiler) {
24
- compiler.hooks.compilation.tap(
25
- "ChunkPrefetchPreloadPlugin",
26
- compilation => {
27
- compilation.hooks.additionalChunkRuntimeRequirements.tap(
28
- "ChunkPrefetchPreloadPlugin",
29
- (chunk, set, { chunkGraph }) => {
30
- if (chunkGraph.getNumberOfEntryModules(chunk) === 0) return;
31
- const startupChildChunks = chunk.getChildrenOfTypeInOrder(
32
- chunkGraph,
33
- "prefetchOrder"
26
+ compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
27
+ compilation.hooks.additionalChunkRuntimeRequirements.tap(
28
+ PLUGIN_NAME,
29
+ (chunk, set, { chunkGraph }) => {
30
+ if (chunkGraph.getNumberOfEntryModules(chunk) === 0) return;
31
+ const startupChildChunks = chunk.getChildrenOfTypeInOrder(
32
+ chunkGraph,
33
+ "prefetchOrder"
34
+ );
35
+ if (startupChildChunks) {
36
+ set.add(RuntimeGlobals.prefetchChunk);
37
+ set.add(RuntimeGlobals.onChunksLoaded);
38
+ set.add(RuntimeGlobals.exports);
39
+ compilation.addRuntimeModule(
40
+ chunk,
41
+ new ChunkPrefetchStartupRuntimeModule(startupChildChunks)
34
42
  );
35
- if (startupChildChunks) {
36
- set.add(RuntimeGlobals.prefetchChunk);
37
- set.add(RuntimeGlobals.onChunksLoaded);
38
- set.add(RuntimeGlobals.exports);
39
- compilation.addRuntimeModule(
40
- chunk,
41
- new ChunkPrefetchStartupRuntimeModule(startupChildChunks)
42
- );
43
- }
44
43
  }
45
- );
46
- compilation.hooks.additionalTreeRuntimeRequirements.tap(
47
- "ChunkPrefetchPreloadPlugin",
48
- (chunk, set, { chunkGraph }) => {
49
- const chunkMap = chunk.getChildIdsByOrdersMap(chunkGraph);
44
+ }
45
+ );
46
+ compilation.hooks.additionalTreeRuntimeRequirements.tap(
47
+ PLUGIN_NAME,
48
+ (chunk, set, { chunkGraph }) => {
49
+ const chunkMap = chunk.getChildIdsByOrdersMap(chunkGraph);
50
50
 
51
- if (chunkMap.prefetch) {
52
- set.add(RuntimeGlobals.prefetchChunk);
53
- compilation.addRuntimeModule(
54
- chunk,
55
- new ChunkPrefetchTriggerRuntimeModule(chunkMap.prefetch)
56
- );
57
- }
58
- if (chunkMap.preload) {
59
- set.add(RuntimeGlobals.preloadChunk);
60
- compilation.addRuntimeModule(
61
- chunk,
62
- new ChunkPreloadTriggerRuntimeModule(chunkMap.preload)
63
- );
64
- }
65
- }
66
- );
67
- compilation.hooks.runtimeRequirementInTree
68
- .for(RuntimeGlobals.prefetchChunk)
69
- .tap("ChunkPrefetchPreloadPlugin", (chunk, set) => {
51
+ if (chunkMap.prefetch) {
52
+ set.add(RuntimeGlobals.prefetchChunk);
70
53
  compilation.addRuntimeModule(
71
54
  chunk,
72
- new ChunkPrefetchFunctionRuntimeModule(
73
- "prefetch",
74
- RuntimeGlobals.prefetchChunk,
75
- RuntimeGlobals.prefetchChunkHandlers
76
- )
55
+ new ChunkPrefetchTriggerRuntimeModule(chunkMap.prefetch)
77
56
  );
78
- set.add(RuntimeGlobals.prefetchChunkHandlers);
79
- });
80
- compilation.hooks.runtimeRequirementInTree
81
- .for(RuntimeGlobals.preloadChunk)
82
- .tap("ChunkPrefetchPreloadPlugin", (chunk, set) => {
57
+ }
58
+ if (chunkMap.preload) {
59
+ set.add(RuntimeGlobals.preloadChunk);
83
60
  compilation.addRuntimeModule(
84
61
  chunk,
85
- new ChunkPrefetchFunctionRuntimeModule(
86
- "preload",
87
- RuntimeGlobals.preloadChunk,
88
- RuntimeGlobals.preloadChunkHandlers
89
- )
62
+ new ChunkPreloadTriggerRuntimeModule(chunkMap.preload)
90
63
  );
91
- set.add(RuntimeGlobals.preloadChunkHandlers);
92
- });
93
- }
94
- );
64
+ }
65
+ }
66
+ );
67
+ compilation.hooks.runtimeRequirementInTree
68
+ .for(RuntimeGlobals.prefetchChunk)
69
+ .tap(PLUGIN_NAME, (chunk, set) => {
70
+ compilation.addRuntimeModule(
71
+ chunk,
72
+ new ChunkPrefetchFunctionRuntimeModule(
73
+ "prefetch",
74
+ RuntimeGlobals.prefetchChunk,
75
+ RuntimeGlobals.prefetchChunkHandlers
76
+ )
77
+ );
78
+ set.add(RuntimeGlobals.prefetchChunkHandlers);
79
+ });
80
+ compilation.hooks.runtimeRequirementInTree
81
+ .for(RuntimeGlobals.preloadChunk)
82
+ .tap(PLUGIN_NAME, (chunk, set) => {
83
+ compilation.addRuntimeModule(
84
+ chunk,
85
+ new ChunkPrefetchFunctionRuntimeModule(
86
+ "preload",
87
+ RuntimeGlobals.preloadChunk,
88
+ RuntimeGlobals.preloadChunkHandlers
89
+ )
90
+ );
91
+ set.add(RuntimeGlobals.preloadChunkHandlers);
92
+ });
93
+ });
95
94
  }
96
95
  }
97
96
 
@@ -37,8 +37,7 @@ class BasicEffectRulePlugin {
37
37
  if (unhandledProperties.has(this.ruleProperty)) {
38
38
  unhandledProperties.delete(this.ruleProperty);
39
39
 
40
- const value =
41
- rule[/** @type {keyof RuleSetRule} */ (this.ruleProperty)];
40
+ const value = rule[this.ruleProperty];
42
41
 
43
42
  result.effects.push({
44
43
  type: this.effectType,
@@ -8,6 +8,7 @@
8
8
  /** @typedef {import("../../declarations/WebpackOptions").RuleSetConditionOrConditions} RuleSetConditionOrConditions */
9
9
  /** @typedef {import("../../declarations/WebpackOptions").RuleSetRule} RuleSetRule */
10
10
  /** @typedef {import("./RuleSetCompiler")} RuleSetCompiler */
11
+ /** @typedef {import("./RuleSetCompiler").EffectData} EffectData */
11
12
  /** @typedef {import("./RuleSetCompiler").RuleCondition} RuleCondition */
12
13
  /** @typedef {import("./RuleSetCompiler").RuleConditionFunction} RuleConditionFunction */
13
14
 
@@ -22,7 +23,7 @@
22
23
  class ObjectMatcherRulePlugin {
23
24
  /**
24
25
  * @param {ObjectMatcherRuleKeys} ruleProperty the rule property
25
- * @param {string=} dataProperty the data property
26
+ * @param {keyof EffectData=} dataProperty the data property
26
27
  * @param {RuleConditionFunction=} additionalConditionFunction need to check
27
28
  */
28
29
  constructor(ruleProperty, dataProperty, additionalConditionFunction) {
@@ -13,7 +13,9 @@ const { SyncHook } = require("tapable");
13
13
 
14
14
  /** @typedef {(Falsy | RuleSetRule)[]} RuleSetRules */
15
15
 
16
- /** @typedef {(value: string | EffectData) => boolean} RuleConditionFunction */
16
+ /**
17
+ * @typedef {(value: EffectData[keyof EffectData]) => boolean} RuleConditionFunction
18
+ */
17
19
 
18
20
  /**
19
21
  * @typedef {object} RuleCondition
@@ -29,7 +31,19 @@ const { SyncHook } = require("tapable");
29
31
  */
30
32
 
31
33
  /**
32
- * @typedef {Record<string, TODO>} EffectData
34
+ * @typedef {object} EffectData
35
+ * @property {string=} resource
36
+ * @property {string=} realResource
37
+ * @property {string=} resourceQuery
38
+ * @property {string=} resourceFragment
39
+ * @property {string=} scheme
40
+ * @property {ImportAttributes=} assertions
41
+ * @property {string=} mimetype
42
+ * @property {string} dependency
43
+ * @property {Record<string, EXPECTED_ANY>} descriptionData
44
+ * @property {string=} compiler
45
+ * @property {string} issuer
46
+ * @property {string} issuerLayer
33
47
  */
34
48
 
35
49
  /**
@@ -102,7 +116,7 @@ class RuleSetCompiler {
102
116
  for (const condition of rule.conditions) {
103
117
  const p = condition.property;
104
118
  if (Array.isArray(p)) {
105
- /** @type {EffectData | string | undefined} */
119
+ /** @type {EffectData | EffectData[keyof EffectData] | undefined} */
106
120
  let current = data;
107
121
  for (const subProperty of p) {
108
122
  if (
@@ -110,7 +124,7 @@ class RuleSetCompiler {
110
124
  typeof current === "object" &&
111
125
  Object.prototype.hasOwnProperty.call(current, subProperty)
112
126
  ) {
113
- current = current[subProperty];
127
+ current = current[/** @type {keyof EffectData} */ (subProperty)];
114
128
  } else {
115
129
  current = undefined;
116
130
  break;
@@ -121,7 +135,7 @@ class RuleSetCompiler {
121
135
  continue;
122
136
  }
123
137
  } else if (p in data) {
124
- const value = data[p];
138
+ const value = data[/** @type {keyof EffectData} */ (p)];
125
139
  if (value !== undefined) {
126
140
  if (!condition.fn(value)) return false;
127
141
  continue;
@@ -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)) {
@@ -18,6 +18,8 @@ const StartupEntrypointRuntimeModule = require("./StartupEntrypointRuntimeModule
18
18
  * @property {boolean=} asyncChunkLoading
19
19
  */
20
20
 
21
+ const PLUGIN_NAME = "StartupChunkDependenciesPlugin";
22
+
21
23
  class StartupChunkDependenciesPlugin {
22
24
  /**
23
25
  * @param {Options} options options
@@ -36,53 +38,48 @@ class StartupChunkDependenciesPlugin {
36
38
  * @returns {void}
37
39
  */
38
40
  apply(compiler) {
39
- compiler.hooks.thisCompilation.tap(
40
- "StartupChunkDependenciesPlugin",
41
- compilation => {
42
- const globalChunkLoading = compilation.outputOptions.chunkLoading;
43
- /**
44
- * @param {Chunk} chunk chunk to check
45
- * @returns {boolean} true, when the plugin is enabled for the chunk
46
- */
47
- const isEnabledForChunk = chunk => {
48
- const options = chunk.getEntryOptions();
49
- const chunkLoading =
50
- options && options.chunkLoading !== undefined
51
- ? options.chunkLoading
52
- : globalChunkLoading;
53
- return chunkLoading === this.chunkLoading;
54
- };
55
- compilation.hooks.additionalTreeRuntimeRequirements.tap(
56
- "StartupChunkDependenciesPlugin",
57
- (chunk, set, { chunkGraph }) => {
58
- if (!isEnabledForChunk(chunk)) return;
59
- if (chunkGraph.hasChunkEntryDependentChunks(chunk)) {
60
- set.add(RuntimeGlobals.startup);
61
- set.add(RuntimeGlobals.ensureChunk);
62
- set.add(RuntimeGlobals.ensureChunkIncludeEntries);
63
- compilation.addRuntimeModule(
64
- chunk,
65
- new StartupChunkDependenciesRuntimeModule(
66
- this.asyncChunkLoading
67
- )
68
- );
69
- }
70
- }
71
- );
72
- compilation.hooks.runtimeRequirementInTree
73
- .for(RuntimeGlobals.startupEntrypoint)
74
- .tap("StartupChunkDependenciesPlugin", (chunk, set) => {
75
- if (!isEnabledForChunk(chunk)) return;
76
- set.add(RuntimeGlobals.require);
41
+ compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
42
+ const globalChunkLoading = compilation.outputOptions.chunkLoading;
43
+ /**
44
+ * @param {Chunk} chunk chunk to check
45
+ * @returns {boolean} true, when the plugin is enabled for the chunk
46
+ */
47
+ const isEnabledForChunk = chunk => {
48
+ const options = chunk.getEntryOptions();
49
+ const chunkLoading =
50
+ options && options.chunkLoading !== undefined
51
+ ? options.chunkLoading
52
+ : globalChunkLoading;
53
+ return chunkLoading === this.chunkLoading;
54
+ };
55
+ compilation.hooks.additionalTreeRuntimeRequirements.tap(
56
+ PLUGIN_NAME,
57
+ (chunk, set, { chunkGraph }) => {
58
+ if (!isEnabledForChunk(chunk)) return;
59
+ if (chunkGraph.hasChunkEntryDependentChunks(chunk)) {
60
+ set.add(RuntimeGlobals.startup);
77
61
  set.add(RuntimeGlobals.ensureChunk);
78
62
  set.add(RuntimeGlobals.ensureChunkIncludeEntries);
79
63
  compilation.addRuntimeModule(
80
64
  chunk,
81
- new StartupEntrypointRuntimeModule(this.asyncChunkLoading)
65
+ new StartupChunkDependenciesRuntimeModule(this.asyncChunkLoading)
82
66
  );
83
- });
84
- }
85
- );
67
+ }
68
+ }
69
+ );
70
+ compilation.hooks.runtimeRequirementInTree
71
+ .for(RuntimeGlobals.startupEntrypoint)
72
+ .tap(PLUGIN_NAME, (chunk, set) => {
73
+ if (!isEnabledForChunk(chunk)) return;
74
+ set.add(RuntimeGlobals.require);
75
+ set.add(RuntimeGlobals.ensureChunk);
76
+ set.add(RuntimeGlobals.ensureChunkIncludeEntries);
77
+ compilation.addRuntimeModule(
78
+ chunk,
79
+ new StartupEntrypointRuntimeModule(this.asyncChunkLoading)
80
+ );
81
+ });
82
+ });
86
83
  }
87
84
  }
88
85
 
@@ -37,6 +37,8 @@ const decodeDataURI = uri => {
37
37
  }
38
38
  };
39
39
 
40
+ const PLUGIN_NAME = "DataUriPlugin";
41
+
40
42
  class DataUriPlugin {
41
43
  /**
42
44
  * Apply the plugin
@@ -45,11 +47,11 @@ class DataUriPlugin {
45
47
  */
46
48
  apply(compiler) {
47
49
  compiler.hooks.compilation.tap(
48
- "DataUriPlugin",
50
+ PLUGIN_NAME,
49
51
  (compilation, { normalModuleFactory }) => {
50
52
  normalModuleFactory.hooks.resolveForScheme
51
53
  .for("data")
52
- .tap("DataUriPlugin", resourceData => {
54
+ .tap(PLUGIN_NAME, resourceData => {
53
55
  const match = URIRegEx.exec(resourceData.resource);
54
56
  if (match) {
55
57
  resourceData.data.mimetype = match[1] || "";
@@ -60,7 +62,7 @@ class DataUriPlugin {
60
62
  });
61
63
  NormalModule.getCompilationHooks(compilation)
62
64
  .readResourceForScheme.for("data")
63
- .tap("DataUriPlugin", resource => decodeDataURI(resource));
65
+ .tap(PLUGIN_NAME, resource => decodeDataURI(resource));
64
66
  }
65
67
  );
66
68
  }
@@ -10,6 +10,8 @@ const { NormalModule } = require("..");
10
10
 
11
11
  /** @typedef {import("../Compiler")} Compiler */
12
12
 
13
+ const PLUGIN_NAME = "FileUriPlugin";
14
+
13
15
  class FileUriPlugin {
14
16
  /**
15
17
  * Apply the plugin
@@ -18,11 +20,11 @@ class FileUriPlugin {
18
20
  */
19
21
  apply(compiler) {
20
22
  compiler.hooks.compilation.tap(
21
- "FileUriPlugin",
23
+ PLUGIN_NAME,
22
24
  (compilation, { normalModuleFactory }) => {
23
25
  normalModuleFactory.hooks.resolveForScheme
24
26
  .for("file")
25
- .tap("FileUriPlugin", resourceData => {
27
+ .tap(PLUGIN_NAME, resourceData => {
26
28
  const url = new URL(resourceData.resource);
27
29
  const path = fileURLToPath(url);
28
30
  const query = url.search;
@@ -36,7 +38,7 @@ class FileUriPlugin {
36
38
  const hooks = NormalModule.getCompilationHooks(compilation);
37
39
  hooks.readResource
38
40
  .for(undefined)
39
- .tapAsync("FileUriPlugin", (loaderContext, callback) => {
41
+ .tapAsync(PLUGIN_NAME, (loaderContext, callback) => {
40
42
  const { resourcePath } = loaderContext;
41
43
  loaderContext.addDependency(resourcePath);
42
44
  loaderContext.fs.readFile(resourcePath, callback);