webpack 5.90.2 → 5.91.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 (182) hide show
  1. package/README.md +5 -5
  2. package/bin/webpack.js +5 -1
  3. package/lib/APIPlugin.js +8 -4
  4. package/lib/AutomaticPrefetchPlugin.js +1 -1
  5. package/lib/BannerPlugin.js +3 -1
  6. package/lib/Cache.js +7 -1
  7. package/lib/CacheFacade.js +3 -3
  8. package/lib/ChunkGraph.js +32 -18
  9. package/lib/ChunkGroup.js +14 -14
  10. package/lib/CleanPlugin.js +7 -5
  11. package/lib/Compilation.js +263 -94
  12. package/lib/Compiler.js +199 -83
  13. package/lib/ConditionalInitFragment.js +4 -5
  14. package/lib/ContextModule.js +4 -1
  15. package/lib/ContextModuleFactory.js +4 -2
  16. package/lib/ContextReplacementPlugin.js +3 -2
  17. package/lib/CssModule.js +0 -3
  18. package/lib/DefinePlugin.js +4 -2
  19. package/lib/DelegatedModule.js +2 -1
  20. package/lib/Dependency.js +4 -2
  21. package/lib/DependencyTemplate.js +7 -2
  22. package/lib/DllModule.js +3 -1
  23. package/lib/DllReferencePlugin.js +6 -2
  24. package/lib/EntryOptionPlugin.js +4 -1
  25. package/lib/EntryPlugin.js +6 -1
  26. package/lib/Entrypoint.js +1 -1
  27. package/lib/ExportsInfo.js +1 -4
  28. package/lib/ExternalModule.js +120 -25
  29. package/lib/ExternalModuleFactoryPlugin.js +37 -2
  30. package/lib/FileSystemInfo.js +1 -1
  31. package/lib/Generator.js +2 -1
  32. package/lib/HookWebpackError.js +2 -2
  33. package/lib/InitFragment.js +5 -3
  34. package/lib/LibManifestPlugin.js +15 -7
  35. package/lib/Module.js +54 -5
  36. package/lib/ModuleFilenameHelpers.js +1 -1
  37. package/lib/ModuleGraph.js +56 -27
  38. package/lib/ModuleGraphConnection.js +2 -1
  39. package/lib/MultiCompiler.js +61 -17
  40. package/lib/NodeStuffPlugin.js +14 -3
  41. package/lib/NormalModule.js +239 -86
  42. package/lib/NormalModuleFactory.js +163 -32
  43. package/lib/NormalModuleReplacementPlugin.js +5 -1
  44. package/lib/ProvidePlugin.js +3 -1
  45. package/lib/RawModule.js +4 -2
  46. package/lib/ResolverFactory.js +5 -1
  47. package/lib/RuntimeModule.js +6 -5
  48. package/lib/RuntimePlugin.js +1 -0
  49. package/lib/RuntimeTemplate.js +102 -34
  50. package/lib/SourceMapDevToolPlugin.js +4 -1
  51. package/lib/Stats.js +12 -5
  52. package/lib/TemplatedPathPlugin.js +32 -6
  53. package/lib/Watching.js +67 -60
  54. package/lib/WebpackError.js +6 -6
  55. package/lib/WebpackOptionsApply.js +18 -5
  56. package/lib/asset/RawDataUrlModule.js +5 -2
  57. package/lib/async-modules/AwaitDependenciesInitFragment.js +2 -2
  58. package/lib/buildChunkGraph.js +220 -392
  59. package/lib/cache/IdleFileCachePlugin.js +8 -3
  60. package/lib/cache/MemoryCachePlugin.js +1 -1
  61. package/lib/cache/MemoryWithGcCachePlugin.js +6 -2
  62. package/lib/cache/PackFileCacheStrategy.js +49 -16
  63. package/lib/cache/ResolverCachePlugin.js +14 -6
  64. package/lib/cache/getLazyHashedEtag.js +1 -1
  65. package/lib/config/defaults.js +24 -1
  66. package/lib/config/normalization.js +3 -1
  67. package/lib/container/ContainerEntryDependency.js +2 -1
  68. package/lib/container/ContainerEntryModule.js +5 -2
  69. package/lib/container/ContainerPlugin.js +14 -10
  70. package/lib/container/FallbackModule.js +3 -2
  71. package/lib/container/RemoteModule.js +2 -1
  72. package/lib/container/RemoteRuntimeModule.js +12 -3
  73. package/lib/css/CssExportsGenerator.js +34 -17
  74. package/lib/css/CssGenerator.js +20 -2
  75. package/lib/css/CssLoadingRuntimeModule.js +212 -96
  76. package/lib/css/CssModulesPlugin.js +47 -13
  77. package/lib/debug/ProfilingPlugin.js +27 -2
  78. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +9 -5
  79. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +4 -1
  80. package/lib/dependencies/CommonJsDependencyHelpers.js +2 -1
  81. package/lib/dependencies/CommonJsExportRequireDependency.js +33 -18
  82. package/lib/dependencies/CommonJsExportsDependency.js +13 -5
  83. package/lib/dependencies/CommonJsExportsParserPlugin.js +20 -15
  84. package/lib/dependencies/CommonJsImportsParserPlugin.js +1 -2
  85. package/lib/dependencies/ContextDependencyHelpers.js +49 -29
  86. package/lib/dependencies/ContextElementDependency.js +8 -1
  87. package/lib/dependencies/CssLocalIdentifierDependency.js +63 -8
  88. package/lib/dependencies/CssUrlDependency.js +5 -3
  89. package/lib/dependencies/ExportsInfoDependency.js +4 -3
  90. package/lib/dependencies/ExternalModuleInitFragment.js +5 -3
  91. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +4 -4
  92. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +43 -23
  93. package/lib/dependencies/HarmonyExportHeaderDependency.js +1 -1
  94. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +73 -32
  95. package/lib/dependencies/HarmonyExportInitFragment.js +10 -2
  96. package/lib/dependencies/HarmonyImportDependency.js +28 -12
  97. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +44 -16
  98. package/lib/dependencies/HarmonyImportSideEffectDependency.js +7 -6
  99. package/lib/dependencies/HarmonyImportSpecifierDependency.js +21 -10
  100. package/lib/dependencies/ImportDependency.js +9 -2
  101. package/lib/dependencies/ImportEagerDependency.js +4 -2
  102. package/lib/dependencies/ImportMetaContextDependency.js +7 -0
  103. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +25 -14
  104. package/lib/dependencies/ImportParserPlugin.js +12 -4
  105. package/lib/dependencies/ImportWeakDependency.js +4 -2
  106. package/lib/dependencies/LoaderDependency.js +2 -1
  107. package/lib/dependencies/LoaderImportDependency.js +2 -1
  108. package/lib/dependencies/ModuleDependency.js +4 -5
  109. package/lib/dependencies/PureExpressionDependency.js +4 -1
  110. package/lib/dependencies/RequireContextPlugin.js +1 -1
  111. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +26 -14
  112. package/lib/dependencies/RequireEnsureDependency.js +1 -1
  113. package/lib/dependencies/URLDependency.js +7 -4
  114. package/lib/dependencies/WorkerDependency.js +1 -1
  115. package/lib/dependencies/WorkerPlugin.js +6 -5
  116. package/lib/dependencies/getFunctionExpression.js +3 -1
  117. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +2 -1
  118. package/lib/hmr/LazyCompilationPlugin.js +2 -1
  119. package/lib/javascript/BasicEvaluatedExpression.js +2 -2
  120. package/lib/javascript/ChunkHelpers.js +2 -2
  121. package/lib/javascript/JavascriptParser.js +169 -57
  122. package/lib/javascript/JavascriptParserHelpers.js +1 -1
  123. package/lib/javascript/StartupHelpers.js +22 -5
  124. package/lib/logging/Logger.js +27 -2
  125. package/lib/logging/createConsoleLogger.js +11 -7
  126. package/lib/node/NodeEnvironmentPlugin.js +13 -7
  127. package/lib/node/NodeWatchFileSystem.js +37 -26
  128. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -1
  129. package/lib/node/RequireChunkLoadingRuntimeModule.js +2 -1
  130. package/lib/node/nodeConsole.js +24 -1
  131. package/lib/optimize/AggressiveSplittingPlugin.js +1 -0
  132. package/lib/optimize/ConcatenatedModule.js +140 -55
  133. package/lib/optimize/EnsureChunkConditionsPlugin.js +1 -1
  134. package/lib/optimize/InnerGraph.js +7 -2
  135. package/lib/optimize/InnerGraphPlugin.js +36 -13
  136. package/lib/optimize/ModuleConcatenationPlugin.js +12 -2
  137. package/lib/optimize/RemoveParentModulesPlugin.js +1 -0
  138. package/lib/optimize/RuntimeChunkPlugin.js +6 -1
  139. package/lib/optimize/SideEffectsFlagPlugin.js +46 -15
  140. package/lib/optimize/SplitChunksPlugin.js +2 -2
  141. package/lib/performance/SizeLimitsPlugin.js +11 -0
  142. package/lib/rules/ObjectMatcherRulePlugin.js +4 -0
  143. package/lib/runtime/EnsureChunkRuntimeModule.js +2 -1
  144. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +2 -1
  145. package/lib/serialization/FileMiddleware.js +1 -0
  146. package/lib/serialization/ObjectMiddleware.js +2 -0
  147. package/lib/serialization/Serializer.js +19 -0
  148. package/lib/sharing/ConsumeSharedModule.js +3 -2
  149. package/lib/sharing/ConsumeSharedPlugin.js +17 -3
  150. package/lib/sharing/ConsumeSharedRuntimeModule.js +9 -2
  151. package/lib/sharing/ProvideSharedModule.js +2 -1
  152. package/lib/sharing/ProvideSharedPlugin.js +12 -5
  153. package/lib/sharing/resolveMatchedConfigs.js +2 -2
  154. package/lib/sharing/utils.js +13 -6
  155. package/lib/util/StackedCacheMap.js +26 -0
  156. package/lib/util/WeakTupleMap.js +57 -13
  157. package/lib/util/cleverMerge.js +24 -11
  158. package/lib/util/comparators.js +34 -14
  159. package/lib/util/conventions.js +129 -0
  160. package/lib/util/fs.js +379 -65
  161. package/lib/util/hash/BatchedHash.js +3 -0
  162. package/lib/util/hash/xxhash64.js +2 -2
  163. package/lib/util/memoize.js +2 -0
  164. package/lib/util/runtime.js +1 -1
  165. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +4 -2
  166. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +15 -6
  167. package/lib/wasm-sync/WebAssemblyGenerator.js +27 -6
  168. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +2 -1
  169. package/lib/wasm-sync/WebAssemblyParser.js +7 -4
  170. package/lib/web/JsonpChunkLoadingRuntimeModule.js +2 -1
  171. package/lib/webpack.js +11 -5
  172. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +2 -1
  173. package/package.json +25 -26
  174. package/schemas/WebpackOptions.check.js +1 -1
  175. package/schemas/WebpackOptions.json +69 -8
  176. package/schemas/plugins/BannerPlugin.check.js +1 -1
  177. package/schemas/plugins/BannerPlugin.json +5 -1
  178. package/schemas/plugins/css/CssAutoGeneratorOptions.check.js +1 -1
  179. package/schemas/plugins/css/CssGeneratorOptions.check.js +1 -1
  180. package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +1 -1
  181. package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -1
  182. package/types.d.ts +1772 -673
@@ -95,19 +95,32 @@ class WebpackLogger {
95
95
  this[LOG_SYMBOL](LogType.groupEnd, args);
96
96
  }
97
97
 
98
+ /**
99
+ * @param {string=} label label
100
+ */
98
101
  profile(label) {
99
102
  this[LOG_SYMBOL](LogType.profile, [label]);
100
103
  }
101
104
 
105
+ /**
106
+ * @param {string=} label label
107
+ */
102
108
  profileEnd(label) {
103
109
  this[LOG_SYMBOL](LogType.profileEnd, [label]);
104
110
  }
105
111
 
112
+ /**
113
+ * @param {string} label label
114
+ */
106
115
  time(label) {
116
+ /** @type {Map<string | undefined, [number, number]>} */
107
117
  this[TIMERS_SYMBOL] = this[TIMERS_SYMBOL] || new Map();
108
118
  this[TIMERS_SYMBOL].set(label, process.hrtime());
109
119
  }
110
120
 
121
+ /**
122
+ * @param {string=} label label
123
+ */
111
124
  timeLog(label) {
112
125
  const prev = this[TIMERS_SYMBOL] && this[TIMERS_SYMBOL].get(label);
113
126
  if (!prev) {
@@ -117,16 +130,23 @@ class WebpackLogger {
117
130
  this[LOG_SYMBOL](LogType.time, [label, ...time]);
118
131
  }
119
132
 
133
+ /**
134
+ * @param {string=} label label
135
+ */
120
136
  timeEnd(label) {
121
137
  const prev = this[TIMERS_SYMBOL] && this[TIMERS_SYMBOL].get(label);
122
138
  if (!prev) {
123
139
  throw new Error(`No such label '${label}' for WebpackLogger.timeEnd()`);
124
140
  }
125
141
  const time = process.hrtime(prev);
126
- this[TIMERS_SYMBOL].delete(label);
142
+ /** @type {Map<string | undefined, [number, number]>} */
143
+ (this[TIMERS_SYMBOL]).delete(label);
127
144
  this[LOG_SYMBOL](LogType.time, [label, ...time]);
128
145
  }
129
146
 
147
+ /**
148
+ * @param {string=} label label
149
+ */
130
150
  timeAggregate(label) {
131
151
  const prev = this[TIMERS_SYMBOL] && this[TIMERS_SYMBOL].get(label);
132
152
  if (!prev) {
@@ -135,7 +155,9 @@ class WebpackLogger {
135
155
  );
136
156
  }
137
157
  const time = process.hrtime(prev);
138
- this[TIMERS_SYMBOL].delete(label);
158
+ /** @type {Map<string | undefined, [number, number]>} */
159
+ (this[TIMERS_SYMBOL]).delete(label);
160
+ /** @type {Map<string | undefined, [number, number]>} */
139
161
  this[TIMERS_AGGREGATES_SYMBOL] =
140
162
  this[TIMERS_AGGREGATES_SYMBOL] || new Map();
141
163
  const current = this[TIMERS_AGGREGATES_SYMBOL].get(label);
@@ -151,6 +173,9 @@ class WebpackLogger {
151
173
  this[TIMERS_AGGREGATES_SYMBOL].set(label, time);
152
174
  }
153
175
 
176
+ /**
177
+ * @param {string=} label label
178
+ */
154
179
  timeAggregateEnd(label) {
155
180
  if (this[TIMERS_AGGREGATES_SYMBOL] === undefined) return;
156
181
  const time = this[TIMERS_AGGREGATES_SYMBOL].get(label);
@@ -12,6 +12,7 @@ const { LogType } = require("./Logger");
12
12
  /** @typedef {import("./Logger").LogTypeEnum} LogTypeEnum */
13
13
 
14
14
  /** @typedef {function(string): boolean} FilterFunction */
15
+ /** @typedef {function(string, LogTypeEnum, any[]): void} LoggingFunction */
15
16
 
16
17
  /**
17
18
  * @typedef {Object} LoggerConsole
@@ -40,7 +41,7 @@ const { LogType } = require("./Logger");
40
41
 
41
42
  /**
42
43
  * @param {FilterItemTypes} item an input item
43
- * @returns {FilterFunction} filter function
44
+ * @returns {FilterFunction | undefined} filter function
44
45
  */
45
46
  const filterToFunction = item => {
46
47
  if (typeof item === "string") {
@@ -76,15 +77,18 @@ const LogLevel = {
76
77
 
77
78
  /**
78
79
  * @param {LoggerOptions} options options object
79
- * @returns {function(string, LogTypeEnum, any[]): void} logging function
80
+ * @returns {LoggingFunction} logging function
80
81
  */
81
82
  module.exports = ({ level = "info", debug = false, console }) => {
82
83
  const debugFilters =
83
- typeof debug === "boolean"
84
- ? [() => debug]
85
- : /** @type {FilterItemTypes[]} */ ([])
86
- .concat(debug)
87
- .map(filterToFunction);
84
+ /** @type {FilterFunction[]} */
85
+ (
86
+ typeof debug === "boolean"
87
+ ? [() => debug]
88
+ : /** @type {FilterItemTypes[]} */ ([])
89
+ .concat(debug)
90
+ .map(filterToFunction)
91
+ );
88
92
  /** @type {number} */
89
93
  const loglevel = LogLevel[`${level}`] || 0;
90
94
 
@@ -5,7 +5,7 @@
5
5
 
6
6
  "use strict";
7
7
 
8
- const CachedInputFileSystem = require("enhanced-resolve/lib/CachedInputFileSystem");
8
+ const CachedInputFileSystem = require("enhanced-resolve").CachedInputFileSystem;
9
9
  const fs = require("graceful-fs");
10
10
  const createConsoleLogger = require("../logging/createConsoleLogger");
11
11
  const NodeWatchFileSystem = require("./NodeWatchFileSystem");
@@ -13,6 +13,7 @@ const nodeConsole = require("./nodeConsole");
13
13
 
14
14
  /** @typedef {import("../../declarations/WebpackOptions").InfrastructureLogging} InfrastructureLogging */
15
15
  /** @typedef {import("../Compiler")} Compiler */
16
+ /** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
16
17
 
17
18
  class NodeEnvironmentPlugin {
18
19
  /**
@@ -38,18 +39,23 @@ class NodeEnvironmentPlugin {
38
39
  nodeConsole({
39
40
  colors: infrastructureLogging.colors,
40
41
  appendOnly: infrastructureLogging.appendOnly,
41
- stream: infrastructureLogging.stream
42
+ stream:
43
+ /** @type {NodeJS.WritableStream} */
44
+ (infrastructureLogging.stream)
42
45
  })
43
46
  });
44
47
  compiler.inputFileSystem = new CachedInputFileSystem(fs, 60000);
45
- const inputFileSystem = compiler.inputFileSystem;
48
+ const inputFileSystem =
49
+ /** @type {InputFileSystem} */
50
+ (compiler.inputFileSystem);
46
51
  compiler.outputFileSystem = fs;
47
52
  compiler.intermediateFileSystem = fs;
48
- compiler.watchFileSystem = new NodeWatchFileSystem(
49
- compiler.inputFileSystem
50
- );
53
+ compiler.watchFileSystem = new NodeWatchFileSystem(inputFileSystem);
51
54
  compiler.hooks.beforeRun.tap("NodeEnvironmentPlugin", compiler => {
52
- if (compiler.inputFileSystem === inputFileSystem) {
55
+ if (
56
+ compiler.inputFileSystem === inputFileSystem &&
57
+ inputFileSystem.purge
58
+ ) {
53
59
  compiler.fsStartTime = Date.now();
54
60
  inputFileSystem.purge();
55
61
  }
@@ -10,11 +10,15 @@ const Watchpack = require("watchpack");
10
10
 
11
11
  /** @typedef {import("../../declarations/WebpackOptions").WatchOptions} WatchOptions */
12
12
  /** @typedef {import("../FileSystemInfo").FileSystemInfoEntry} FileSystemInfoEntry */
13
+ /** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
13
14
  /** @typedef {import("../util/fs").WatchFileSystem} WatchFileSystem */
14
15
  /** @typedef {import("../util/fs").WatchMethod} WatchMethod */
15
16
  /** @typedef {import("../util/fs").Watcher} Watcher */
16
17
 
17
18
  class NodeWatchFileSystem {
19
+ /**
20
+ * @param {InputFileSystem} inputFileSystem input filesystem
21
+ */
18
22
  constructor(inputFileSystem) {
19
23
  this.inputFileSystem = inputFileSystem;
20
24
  this.watcherOptions = {
@@ -26,10 +30,10 @@ class NodeWatchFileSystem {
26
30
  /**
27
31
  * @param {Iterable<string>} files watched files
28
32
  * @param {Iterable<string>} directories watched directories
29
- * @param {Iterable<string>} missing watched exitance entries
33
+ * @param {Iterable<string>} missing watched existence entries
30
34
  * @param {number} startTime timestamp of start time
31
35
  * @param {WatchOptions} options options object
32
- * @param {function((Error | null)=, Map<string, FileSystemInfoEntry>, Map<string, FileSystemInfoEntry>, Set<string>, Set<string>): void} callback aggregated callback
36
+ * @param {function(Error | null, Map<string, FileSystemInfoEntry>, Map<string, FileSystemInfoEntry>, Set<string>, Set<string>): void} callback aggregated callback
33
37
  * @param {function(string, number): void} callbackUndelayed callback when the first change was detected
34
38
  * @returns {Watcher} a watcher
35
39
  */
@@ -81,28 +85,35 @@ class NodeWatchFileSystem {
81
85
  }
82
86
  return { fileTimeInfoEntries, contextTimeInfoEntries };
83
87
  };
84
- this.watcher.once("aggregated", (changes, removals) => {
85
- // pause emitting events (avoids clearing aggregated changes and removals on timeout)
86
- this.watcher.pause();
88
+ this.watcher.once(
89
+ "aggregated",
90
+ /**
91
+ * @param {Set<string>} changes changes
92
+ * @param {Set<string>} removals removals
93
+ */
94
+ (changes, removals) => {
95
+ // pause emitting events (avoids clearing aggregated changes and removals on timeout)
96
+ this.watcher.pause();
87
97
 
88
- if (this.inputFileSystem && this.inputFileSystem.purge) {
89
98
  const fs = this.inputFileSystem;
90
- for (const item of changes) {
91
- fs.purge(item);
92
- }
93
- for (const item of removals) {
94
- fs.purge(item);
99
+ if (fs && fs.purge) {
100
+ for (const item of changes) {
101
+ fs.purge(item);
102
+ }
103
+ for (const item of removals) {
104
+ fs.purge(item);
105
+ }
95
106
  }
107
+ const { fileTimeInfoEntries, contextTimeInfoEntries } = fetchTimeInfo();
108
+ callback(
109
+ null,
110
+ fileTimeInfoEntries,
111
+ contextTimeInfoEntries,
112
+ changes,
113
+ removals
114
+ );
96
115
  }
97
- const { fileTimeInfoEntries, contextTimeInfoEntries } = fetchTimeInfo();
98
- callback(
99
- null,
100
- fileTimeInfoEntries,
101
- contextTimeInfoEntries,
102
- changes,
103
- removals
104
- );
105
- });
116
+ );
106
117
 
107
118
  this.watcher.watch({ files, directories, missing, startTime });
108
119
 
@@ -124,8 +135,8 @@ class NodeWatchFileSystem {
124
135
  getAggregatedRemovals: util.deprecate(
125
136
  () => {
126
137
  const items = this.watcher && this.watcher.aggregatedRemovals;
127
- if (items && this.inputFileSystem && this.inputFileSystem.purge) {
128
- const fs = this.inputFileSystem;
138
+ const fs = this.inputFileSystem;
139
+ if (items && fs && fs.purge) {
129
140
  for (const item of items) {
130
141
  fs.purge(item);
131
142
  }
@@ -138,8 +149,8 @@ class NodeWatchFileSystem {
138
149
  getAggregatedChanges: util.deprecate(
139
150
  () => {
140
151
  const items = this.watcher && this.watcher.aggregatedChanges;
141
- if (items && this.inputFileSystem && this.inputFileSystem.purge) {
142
- const fs = this.inputFileSystem;
152
+ const fs = this.inputFileSystem;
153
+ if (items && fs && fs.purge) {
143
154
  for (const item of items) {
144
155
  fs.purge(item);
145
156
  }
@@ -166,8 +177,8 @@ class NodeWatchFileSystem {
166
177
  getInfo: () => {
167
178
  const removals = this.watcher && this.watcher.aggregatedRemovals;
168
179
  const changes = this.watcher && this.watcher.aggregatedChanges;
169
- if (this.inputFileSystem && this.inputFileSystem.purge) {
170
- const fs = this.inputFileSystem;
180
+ const fs = this.inputFileSystem;
181
+ if (fs && fs.purge) {
171
182
  if (removals) {
172
183
  for (const item of removals) {
173
184
  fs.purge(item);
@@ -18,10 +18,11 @@ const { getUndoPath } = require("../util/identifier");
18
18
  /** @typedef {import("../Chunk")} Chunk */
19
19
  /** @typedef {import("../ChunkGraph")} ChunkGraph */
20
20
  /** @typedef {import("../Compilation")} Compilation */
21
+ /** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
21
22
 
22
23
  class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
23
24
  /**
24
- * @param {ReadonlySet<string>} runtimeRequirements runtime requirements
25
+ * @param {ReadOnlyRuntimeRequirements} runtimeRequirements runtime requirements
25
26
  */
26
27
  constructor(runtimeRequirements) {
27
28
  super("readFile chunk loading", RuntimeModule.STAGE_ATTACH);
@@ -18,10 +18,11 @@ const { getUndoPath } = require("../util/identifier");
18
18
  /** @typedef {import("../Chunk")} Chunk */
19
19
  /** @typedef {import("../ChunkGraph")} ChunkGraph */
20
20
  /** @typedef {import("../Compilation")} Compilation */
21
+ /** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
21
22
 
22
23
  class RequireChunkLoadingRuntimeModule extends RuntimeModule {
23
24
  /**
24
- * @param {ReadonlySet<string>} runtimeRequirements runtime requirements
25
+ * @param {ReadOnlyRuntimeRequirements} runtimeRequirements runtime requirements
25
26
  */
26
27
  constructor(runtimeRequirements) {
27
28
  super("require chunk loading", RuntimeModule.STAGE_ATTACH);
@@ -8,12 +8,29 @@
8
8
  const util = require("util");
9
9
  const truncateArgs = require("../logging/truncateArgs");
10
10
 
11
+ /** @typedef {import("../logging/createConsoleLogger").LoggerConsole} LoggerConsole */
12
+
13
+ /**
14
+ * @param {Object} options options
15
+ * @param {boolean=} options.colors colors
16
+ * @param {boolean=} options.appendOnly append only
17
+ * @param {NodeJS.WritableStream} options.stream stream
18
+ * @returns {LoggerConsole} logger function
19
+ */
11
20
  module.exports = ({ colors, appendOnly, stream }) => {
21
+ /** @type {string[] | undefined} */
12
22
  let currentStatusMessage = undefined;
13
23
  let hasStatusMessage = false;
14
24
  let currentIndent = "";
15
25
  let currentCollapsed = 0;
16
26
 
27
+ /**
28
+ * @param {string} str string
29
+ * @param {string} prefix prefix
30
+ * @param {string} colorPrefix color prefix
31
+ * @param {string} colorSuffix color suffix
32
+ * @returns {string} indented string
33
+ */
17
34
  const indent = (str, prefix, colorPrefix, colorSuffix) => {
18
35
  if (str === "") return str;
19
36
  prefix = currentIndent + prefix;
@@ -38,7 +55,7 @@ module.exports = ({ colors, appendOnly, stream }) => {
38
55
 
39
56
  const writeStatusMessage = () => {
40
57
  if (!currentStatusMessage) return;
41
- const l = stream.columns || 40;
58
+ const l = /** @type {TODO} */ (stream).columns || 40;
42
59
  const args = truncateArgs(currentStatusMessage, l - 1);
43
60
  const str = args.join(" ");
44
61
  const coloredStr = `\u001b[1m${str}\u001b[39m\u001b[22m`;
@@ -46,6 +63,12 @@ module.exports = ({ colors, appendOnly, stream }) => {
46
63
  hasStatusMessage = true;
47
64
  };
48
65
 
66
+ /**
67
+ * @param {string} prefix prefix
68
+ * @param {string} colorPrefix color prefix
69
+ * @param {string} colorSuffix color suffix
70
+ * @returns {(function(...any[]): void)} function to write with colors
71
+ */
49
72
  const writeColored = (prefix, colorPrefix, colorSuffix) => {
50
73
  return (...args) => {
51
74
  if (currentCollapsed > 0) return;
@@ -100,6 +100,7 @@ class AggressiveSplittingPlugin {
100
100
  let newSplits;
101
101
  /** @type {Set<Chunk>} */
102
102
  let fromAggressiveSplittingSet;
103
+ /** @type {Map<Chunk, TODO>} */
103
104
  let chunkSplitDataMap;
104
105
  compilation.hooks.optimize.tap("AggressiveSplittingPlugin", () => {
105
106
  newSplits = [];