webpack 5.100.2 → 5.101.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (309) hide show
  1. package/README.md +12 -10
  2. package/bin/webpack.js +7 -7
  3. package/lib/APIPlugin.js +12 -14
  4. package/lib/AutomaticPrefetchPlugin.js +2 -2
  5. package/lib/BannerPlugin.js +4 -4
  6. package/lib/Cache.js +1 -1
  7. package/lib/CacheFacade.js +7 -7
  8. package/lib/CaseSensitiveModulesWarning.js +2 -2
  9. package/lib/Chunk.js +3 -3
  10. package/lib/ChunkGraph.js +63 -18
  11. package/lib/ChunkGroup.js +4 -4
  12. package/lib/CleanPlugin.js +19 -53
  13. package/lib/CodeGenerationResults.js +3 -3
  14. package/lib/CompatibilityPlugin.js +6 -6
  15. package/lib/Compilation.js +168 -116
  16. package/lib/Compiler.js +37 -37
  17. package/lib/ConcatenationScope.js +39 -1
  18. package/lib/ConstPlugin.js +11 -11
  19. package/lib/ContextExclusionPlugin.js +3 -3
  20. package/lib/ContextModule.js +12 -11
  21. package/lib/ContextModuleFactory.js +11 -11
  22. package/lib/ContextReplacementPlugin.js +5 -5
  23. package/lib/DefinePlugin.js +24 -22
  24. package/lib/DelegatedModuleFactoryPlugin.js +1 -1
  25. package/lib/Dependency.js +2 -1
  26. package/lib/DllEntryPlugin.js +1 -1
  27. package/lib/DllReferencePlugin.js +1 -1
  28. package/lib/DynamicEntryPlugin.js +3 -3
  29. package/lib/EntryPlugin.js +1 -1
  30. package/lib/EnvironmentPlugin.js +1 -1
  31. package/lib/ErrorHelpers.js +2 -2
  32. package/lib/EvalDevToolModulePlugin.js +2 -2
  33. package/lib/EvalSourceMapDevToolPlugin.js +5 -5
  34. package/lib/ExportsInfo.js +9 -9
  35. package/lib/ExportsInfoApiPlugin.js +2 -2
  36. package/lib/ExternalModule.js +163 -48
  37. package/lib/ExternalModuleFactoryPlugin.js +2 -2
  38. package/lib/ExternalsPlugin.js +45 -0
  39. package/lib/FileSystemInfo.js +64 -61
  40. package/lib/FlagAllModulesAsUsedPlugin.js +2 -2
  41. package/lib/FlagDependencyExportsPlugin.js +7 -7
  42. package/lib/FlagDependencyUsagePlugin.js +4 -4
  43. package/lib/FlagEntryExportAsUsedPlugin.js +1 -1
  44. package/lib/HotModuleReplacementPlugin.js +27 -27
  45. package/lib/IgnorePlugin.js +3 -3
  46. package/lib/IgnoreWarningsPlugin.js +4 -4
  47. package/lib/InitFragment.js +6 -0
  48. package/lib/InvalidDependenciesModuleWarning.js +1 -1
  49. package/lib/JavascriptMetaInfoPlugin.js +1 -1
  50. package/lib/LibManifestPlugin.js +2 -2
  51. package/lib/LoaderOptionsPlugin.js +1 -1
  52. package/lib/LoaderTargetPlugin.js +2 -2
  53. package/lib/MainTemplate.js +1 -1
  54. package/lib/Module.js +3 -2
  55. package/lib/ModuleFilenameHelpers.js +3 -3
  56. package/lib/ModuleGraph.js +23 -38
  57. package/lib/ModuleInfoHeaderPlugin.js +3 -3
  58. package/lib/ModuleParseError.js +5 -3
  59. package/lib/ModuleTemplate.js +3 -2
  60. package/lib/MultiCompiler.js +29 -24
  61. package/lib/MultiStats.js +18 -13
  62. package/lib/MultiWatching.js +1 -1
  63. package/lib/NoEmitOnErrorsPlugin.js +2 -2
  64. package/lib/NodeStuffPlugin.js +27 -15
  65. package/lib/NormalModule.js +23 -23
  66. package/lib/NormalModuleFactory.js +23 -21
  67. package/lib/NormalModuleReplacementPlugin.js +3 -3
  68. package/lib/PrefetchPlugin.js +1 -1
  69. package/lib/ProgressPlugin.js +11 -11
  70. package/lib/ProvidePlugin.js +2 -2
  71. package/lib/RecordIdsPlugin.js +3 -3
  72. package/lib/ResolverFactory.js +3 -3
  73. package/lib/RuntimeGlobals.js +20 -0
  74. package/lib/RuntimePlugin.js +16 -16
  75. package/lib/RuntimeTemplate.js +35 -26
  76. package/lib/SizeFormatHelpers.js +1 -1
  77. package/lib/SourceMapDevToolModuleOptionsPlugin.js +4 -4
  78. package/lib/SourceMapDevToolPlugin.js +9 -9
  79. package/lib/Stats.js +2 -2
  80. package/lib/Template.js +1 -1
  81. package/lib/TemplatedPathPlugin.js +2 -2
  82. package/lib/UseStrictPlugin.js +1 -1
  83. package/lib/WarnCaseSensitiveModulesPlugin.js +1 -1
  84. package/lib/WarnDeprecatedOptionPlugin.js +1 -1
  85. package/lib/WarnNoModeSetPlugin.js +1 -1
  86. package/lib/WatchIgnorePlugin.js +2 -2
  87. package/lib/Watching.js +12 -14
  88. package/lib/WebpackIsIncludedPlugin.js +2 -2
  89. package/lib/WebpackOptionsApply.js +3 -3
  90. package/lib/asset/AssetGenerator.js +1 -1
  91. package/lib/asset/AssetModulesPlugin.js +6 -6
  92. package/lib/async-modules/AsyncModuleHelpers.js +1 -1
  93. package/lib/async-modules/AwaitDependenciesInitFragment.js +36 -24
  94. package/lib/async-modules/InferAsyncModulesPlugin.js +3 -3
  95. package/lib/buildChunkGraph.js +5 -5
  96. package/lib/cache/AddBuildDependenciesPlugin.js +1 -1
  97. package/lib/cache/IdleFileCachePlugin.js +5 -5
  98. package/lib/cache/PackFileCacheStrategy.js +20 -20
  99. package/lib/cache/ResolverCachePlugin.js +4 -4
  100. package/lib/cli.js +196 -14
  101. package/lib/config/browserslistTargetHandler.js +6 -6
  102. package/lib/config/defaults.js +23 -14
  103. package/lib/config/normalization.js +41 -38
  104. package/lib/config/target.js +4 -4
  105. package/lib/container/ContainerEntryModule.js +3 -3
  106. package/lib/container/ContainerPlugin.js +3 -3
  107. package/lib/container/ContainerReferencePlugin.js +3 -3
  108. package/lib/container/FallbackModule.js +1 -1
  109. package/lib/container/HoistContainerReferencesPlugin.js +7 -7
  110. package/lib/container/options.js +4 -4
  111. package/lib/css/CssGenerator.js +5 -3
  112. package/lib/css/CssLoadingRuntimeModule.js +1 -1
  113. package/lib/css/CssModulesPlugin.js +25 -22
  114. package/lib/css/CssParser.js +5 -5
  115. package/lib/css/walkCssTokens.js +9 -9
  116. package/lib/debug/ProfilingPlugin.js +5 -5
  117. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +4 -4
  118. package/lib/dependencies/AMDPlugin.js +3 -3
  119. package/lib/dependencies/AMDRequireArrayDependency.js +1 -1
  120. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +3 -3
  121. package/lib/dependencies/CommonJsExportRequireDependency.js +2 -2
  122. package/lib/dependencies/CommonJsExportsParserPlugin.js +12 -10
  123. package/lib/dependencies/CommonJsImportsParserPlugin.js +21 -19
  124. package/lib/dependencies/CommonJsPlugin.js +2 -2
  125. package/lib/dependencies/ContextDependency.js +1 -1
  126. package/lib/dependencies/ContextDependencyHelpers.js +3 -3
  127. package/lib/dependencies/CssIcssExportDependency.js +2 -2
  128. package/lib/dependencies/CssLocalIdentifierDependency.js +2 -2
  129. package/lib/dependencies/CssUrlDependency.js +4 -4
  130. package/lib/dependencies/DynamicExports.js +5 -5
  131. package/lib/dependencies/HarmonyAcceptDependency.js +91 -5
  132. package/lib/dependencies/HarmonyDetectionParserPlugin.js +2 -2
  133. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +17 -13
  134. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +7 -8
  135. package/lib/dependencies/HarmonyExportInitFragment.js +1 -1
  136. package/lib/dependencies/HarmonyExports.js +1 -1
  137. package/lib/dependencies/HarmonyImportDependency.js +28 -9
  138. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +56 -48
  139. package/lib/dependencies/HarmonyImportSideEffectDependency.js +4 -5
  140. package/lib/dependencies/HarmonyImportSpecifierDependency.js +3 -4
  141. package/lib/dependencies/HarmonyModulesPlugin.js +2 -8
  142. package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +1 -1
  143. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +4 -4
  144. package/lib/dependencies/ImportMetaPlugin.js +7 -7
  145. package/lib/dependencies/ImportParserPlugin.js +4 -4
  146. package/lib/dependencies/JsonExportsDependency.js +7 -2
  147. package/lib/dependencies/LoaderPlugin.js +4 -4
  148. package/lib/dependencies/ModuleDependency.js +2 -1
  149. package/lib/dependencies/ProvidedDependency.js +2 -2
  150. package/lib/dependencies/PureExpressionDependency.js +1 -1
  151. package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
  152. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +1 -1
  153. package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +3 -3
  154. package/lib/dependencies/SystemPlugin.js +3 -3
  155. package/lib/dependencies/WorkerPlugin.js +5 -5
  156. package/lib/dependencies/getFunctionExpression.js +1 -1
  157. package/lib/esm/ExportWebpackRequireRuntimeModule.js +8 -1
  158. package/lib/esm/ModuleChunkFormatPlugin.js +35 -69
  159. package/lib/esm/ModuleChunkLoadingPlugin.js +3 -6
  160. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +15 -11
  161. package/lib/formatLocation.js +2 -2
  162. package/lib/hmr/HotModuleReplacement.runtime.js +39 -27
  163. package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +43 -32
  164. package/lib/hmr/JavascriptHotModuleReplacementHelper.js +1 -1
  165. package/lib/hmr/LazyCompilationPlugin.js +6 -6
  166. package/lib/hmr/lazyCompilationBackend.js +6 -6
  167. package/lib/ids/ChunkModuleIdRangePlugin.js +4 -4
  168. package/lib/ids/DeterministicChunkIdsPlugin.js +5 -4
  169. package/lib/ids/DeterministicModuleIdsPlugin.js +2 -2
  170. package/lib/ids/HashedModuleIdsPlugin.js +1 -1
  171. package/lib/ids/IdHelpers.js +9 -9
  172. package/lib/ids/NamedChunkIdsPlugin.js +5 -5
  173. package/lib/ids/NamedModuleIdsPlugin.js +2 -2
  174. package/lib/ids/NaturalChunkIdsPlugin.js +2 -2
  175. package/lib/ids/NaturalModuleIdsPlugin.js +1 -1
  176. package/lib/ids/OccurrenceChunkIdsPlugin.js +2 -2
  177. package/lib/ids/OccurrenceModuleIdsPlugin.js +4 -4
  178. package/lib/ids/SyncModuleIdsPlugin.js +4 -4
  179. package/lib/index.js +18 -6
  180. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +1 -1
  181. package/lib/javascript/BasicEvaluatedExpression.js +3 -3
  182. package/lib/javascript/ChunkFormatHelpers.js +70 -0
  183. package/lib/javascript/CommonJsChunkFormatPlugin.js +10 -21
  184. package/lib/javascript/EnableChunkLoadingPlugin.js +1 -1
  185. package/lib/javascript/JavascriptGenerator.js +1 -1
  186. package/lib/javascript/JavascriptModulesPlugin.js +108 -54
  187. package/lib/javascript/JavascriptParser.js +80 -78
  188. package/lib/javascript/JavascriptParserHelpers.js +3 -3
  189. package/lib/javascript/StartupHelpers.js +2 -2
  190. package/lib/json/JsonGenerator.js +2 -2
  191. package/lib/json/JsonModulesPlugin.js +2 -2
  192. package/lib/library/AbstractLibraryPlugin.js +30 -3
  193. package/lib/library/AmdLibraryPlugin.js +3 -3
  194. package/lib/library/AssignLibraryPlugin.js +2 -2
  195. package/lib/library/EnableLibraryPlugin.js +2 -2
  196. package/lib/library/ModuleLibraryPlugin.js +49 -31
  197. package/lib/library/SystemLibraryPlugin.js +6 -4
  198. package/lib/library/UmdLibraryPlugin.js +14 -14
  199. package/lib/logging/createConsoleLogger.js +4 -4
  200. package/lib/logging/runtime.js +3 -3
  201. package/lib/logging/truncateArgs.js +4 -4
  202. package/lib/node/CommonJsChunkLoadingPlugin.js +2 -2
  203. package/lib/node/NodeEnvironmentPlugin.js +1 -1
  204. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +16 -14
  205. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +7 -7
  206. package/lib/node/ReadFileCompileWasmPlugin.js +7 -7
  207. package/lib/node/RequireChunkLoadingRuntimeModule.js +13 -6
  208. package/lib/node/nodeConsole.js +2 -2
  209. package/lib/optimize/AggressiveMergingPlugin.js +2 -2
  210. package/lib/optimize/AggressiveSplittingPlugin.js +10 -10
  211. package/lib/optimize/ConcatenatedModule.js +186 -77
  212. package/lib/optimize/EnsureChunkConditionsPlugin.js +2 -2
  213. package/lib/optimize/FlagIncludedChunksPlugin.js +2 -2
  214. package/lib/optimize/InnerGraph.js +5 -5
  215. package/lib/optimize/InnerGraphPlugin.js +14 -12
  216. package/lib/optimize/LimitChunkCountPlugin.js +5 -5
  217. package/lib/optimize/MangleExportsPlugin.js +5 -5
  218. package/lib/optimize/MergeDuplicateChunksPlugin.js +2 -2
  219. package/lib/optimize/MinChunkSizePlugin.js +3 -3
  220. package/lib/optimize/ModuleConcatenationPlugin.js +45 -38
  221. package/lib/optimize/RealContentHashPlugin.js +23 -23
  222. package/lib/optimize/RemoveEmptyChunksPlugin.js +2 -2
  223. package/lib/optimize/RemoveParentModulesPlugin.js +3 -3
  224. package/lib/optimize/RuntimeChunkPlugin.js +2 -2
  225. package/lib/optimize/SideEffectsFlagPlugin.js +5 -5
  226. package/lib/optimize/SplitChunksPlugin.js +20 -20
  227. package/lib/performance/AssetsOverSizeLimitWarning.js +1 -1
  228. package/lib/performance/EntrypointsOverSizeLimitWarning.js +2 -2
  229. package/lib/performance/SizeLimitsPlugin.js +4 -4
  230. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +1 -1
  231. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +3 -3
  232. package/lib/rules/BasicMatcherRulePlugin.js +1 -1
  233. package/lib/rules/RuleSetCompiler.js +10 -10
  234. package/lib/rules/UseEffectRulePlugin.js +2 -2
  235. package/lib/runtime/GetChunkFilenameRuntimeModule.js +19 -15
  236. package/lib/runtime/GetMainFilenameRuntimeModule.js +1 -1
  237. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -1
  238. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +1 -1
  239. package/lib/runtime/StartupChunkDependenciesPlugin.js +2 -2
  240. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +3 -3
  241. package/lib/schemes/DataUriPlugin.js +3 -3
  242. package/lib/schemes/FileUriPlugin.js +1 -1
  243. package/lib/schemes/HttpUriPlugin.js +40 -36
  244. package/lib/schemes/VirtualUrlPlugin.js +1 -1
  245. package/lib/serialization/BinaryMiddleware.js +11 -11
  246. package/lib/serialization/FileMiddleware.js +18 -17
  247. package/lib/serialization/ObjectMiddleware.js +8 -8
  248. package/lib/serialization/Serializer.js +2 -2
  249. package/lib/serialization/SerializerMiddleware.js +2 -2
  250. package/lib/sharing/ConsumeSharedPlugin.js +4 -4
  251. package/lib/sharing/ProvideSharedPlugin.js +4 -4
  252. package/lib/sharing/SharePlugin.js +1 -1
  253. package/lib/sharing/resolveMatchedConfigs.js +1 -1
  254. package/lib/stats/DefaultStatsFactoryPlugin.js +85 -80
  255. package/lib/stats/DefaultStatsPresetPlugin.js +15 -15
  256. package/lib/stats/DefaultStatsPrinterPlugin.js +87 -87
  257. package/lib/stats/StatsFactory.js +7 -7
  258. package/lib/stats/StatsPrinter.js +9 -9
  259. package/lib/url/URLParserPlugin.js +5 -5
  260. package/lib/util/AsyncQueue.js +4 -4
  261. package/lib/util/IterableHelpers.js +2 -2
  262. package/lib/util/LazyBucketSortedSet.js +3 -3
  263. package/lib/util/SetHelpers.js +2 -2
  264. package/lib/util/StackedCacheMap.js +1 -1
  265. package/lib/util/StackedMap.js +1 -1
  266. package/lib/util/TupleSet.js +1 -1
  267. package/lib/util/WeakTupleMap.js +1 -1
  268. package/lib/util/cleverMerge.js +8 -8
  269. package/lib/util/comparators.js +10 -10
  270. package/lib/util/compileBooleanMatcher.js +20 -20
  271. package/lib/util/concatenate.js +3 -3
  272. package/lib/util/conventions.js +4 -4
  273. package/lib/util/create-schema-validation.js +1 -1
  274. package/lib/util/createHash.js +1 -1
  275. package/lib/util/deprecation.js +4 -4
  276. package/lib/util/deterministicGrouping.js +7 -7
  277. package/lib/util/findGraphRoots.js +1 -1
  278. package/lib/util/fs.js +4 -4
  279. package/lib/util/identifier.js +14 -14
  280. package/lib/util/magicComment.js +5 -1
  281. package/lib/util/memoize.js +1 -1
  282. package/lib/util/processAsyncTree.js +2 -2
  283. package/lib/util/propertyName.js +1 -1
  284. package/lib/util/removeBOM.js +1 -1
  285. package/lib/util/runtime.js +6 -6
  286. package/lib/util/semver.js +16 -16
  287. package/lib/util/serialization.js +5 -5
  288. package/lib/util/smartGrouping.js +1 -1
  289. package/lib/validateSchema.js +2 -2
  290. package/lib/wasm/EnableWasmLoadingPlugin.js +1 -1
  291. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +1 -1
  292. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +1 -1
  293. package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +4 -4
  294. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +13 -9
  295. package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +2 -2
  296. package/lib/wasm-sync/WebAssemblyGenerator.js +16 -17
  297. package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +4 -2
  298. package/lib/wasm-sync/WebAssemblyParser.js +2 -2
  299. package/lib/web/FetchCompileAsyncWasmPlugin.js +4 -4
  300. package/lib/web/FetchCompileWasmPlugin.js +4 -4
  301. package/lib/web/JsonpChunkLoadingPlugin.js +2 -2
  302. package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -1
  303. package/lib/webpack.js +17 -12
  304. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +2 -2
  305. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
  306. package/package.json +16 -16
  307. package/schemas/WebpackOptions.check.js +1 -1
  308. package/schemas/WebpackOptions.json +4 -0
  309. package/types.d.ts +275 -64
package/lib/index.js CHANGED
@@ -49,14 +49,21 @@ const memoize = require("./util/memoize");
49
49
  /** @typedef {import("./Compiler").AssetEmittedInfo} AssetEmittedInfo */
50
50
  /** @typedef {import("./Entrypoint")} Entrypoint */
51
51
  /** @typedef {import("./MultiCompiler").MultiCompilerOptions} MultiCompilerOptions */
52
+ /** @typedef {import("./MultiCompiler").MultiWebpackOptions} MultiConfiguration */
52
53
  /** @typedef {import("./MultiStats")} MultiStats */
54
+ /** @typedef {import("./MultiStats").MultiStatsOptions} MultiStatsOptions */
53
55
  /** @typedef {import("./NormalModuleFactory").ResolveData} ResolveData */
54
56
  /** @typedef {import("./Parser").ParserState} ParserState */
55
57
  /** @typedef {import("./ResolverFactory").ResolvePluginInstance} ResolvePluginInstance */
56
58
  /** @typedef {import("./ResolverFactory").Resolver} Resolver */
59
+ /** @typedef {import("./Template").RenderManifestEntry} RenderManifestEntry */
60
+ /** @typedef {import("./Template").RenderManifestOptions} RenderManifestOptions */
61
+ /** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */
57
62
  /** @typedef {import("./Watching")} Watching */
58
63
  /** @typedef {import("./cli").Argument} Argument */
59
64
  /** @typedef {import("./cli").Problem} Problem */
65
+ /** @typedef {import("./cli").Colors} Colors */
66
+ /** @typedef {import("./cli").ColorsOptions} ColorsOptions */
60
67
  /** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsAsset} StatsAsset */
61
68
  /** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsChunk} StatsChunk */
62
69
  /** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsChunkGroup} StatsChunkGroup */
@@ -71,6 +78,8 @@ const memoize = require("./util/memoize");
71
78
  /** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsModuleTraceDependency} StatsModuleTraceDependency */
72
79
  /** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsModuleTraceItem} StatsModuleTraceItem */
73
80
  /** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsProfile} StatsProfile */
81
+ /** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
82
+ /** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
74
83
  /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
75
84
  /** @typedef {import("./util/fs").OutputFileSystem} OutputFileSystem */
76
85
 
@@ -79,7 +88,7 @@ const memoize = require("./util/memoize");
79
88
  * @param {() => T} factory factory function
80
89
  * @returns {T} function
81
90
  */
82
- const lazyFunction = factory => {
91
+ const lazyFunction = (factory) => {
83
92
  const fac = memoize(factory);
84
93
  const f = /** @type {unknown} */ (
85
94
  /**
@@ -132,25 +141,25 @@ module.exports = mergeExports(fn, {
132
141
  return require("./webpack");
133
142
  },
134
143
  /**
135
- * @returns {(configuration: Configuration | Configuration[]) => void} validate fn
144
+ * @returns {(configuration: Configuration | MultiConfiguration) => void} validate fn
136
145
  */
137
146
  get validate() {
138
147
  const webpackOptionsSchemaCheck =
139
- /** @type {(configuration: Configuration | Configuration[]) => boolean} */
148
+ /** @type {(configuration: Configuration | MultiConfiguration) => boolean} */
140
149
  (require("../schemas/WebpackOptions.check"));
141
150
 
142
151
  const getRealValidate = memoize(
143
152
  /**
144
- * @returns {(configuration: Configuration | Configuration[]) => void} validate fn
153
+ * @returns {(configuration: Configuration | MultiConfiguration) => void} validate fn
145
154
  */
146
155
  () => {
147
156
  const validateSchema = require("./validateSchema");
148
157
  const webpackOptionsSchema = require("../schemas/WebpackOptions.json");
149
158
 
150
- return options => validateSchema(webpackOptionsSchema, options);
159
+ return (options) => validateSchema(webpackOptionsSchema, options);
151
160
  }
152
161
  );
153
- return options => {
162
+ return (options) => {
154
163
  if (!webpackOptionsSchemaCheck(options)) {
155
164
  getRealValidate()(options);
156
165
  }
@@ -284,6 +293,9 @@ module.exports = mergeExports(fn, {
284
293
  get Module() {
285
294
  return require("./Module");
286
295
  },
296
+ get ModuleFactory() {
297
+ return require("./ModuleFactory");
298
+ },
287
299
  get ModuleFilenameHelpers() {
288
300
  return require("./ModuleFilenameHelpers");
289
301
  },
@@ -27,7 +27,7 @@ class ArrayPushCallbackChunkFormatPlugin {
27
27
  * @returns {void}
28
28
  */
29
29
  apply(compiler) {
30
- compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
30
+ compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
31
31
  compilation.hooks.additionalChunkRuntimeRequirements.tap(
32
32
  PLUGIN_NAME,
33
33
  (chunk, set, { chunkGraph }) => {
@@ -463,7 +463,7 @@ class BasicEvaluatedExpression {
463
463
  setItems(items) {
464
464
  this.type = TypeArray;
465
465
  this.items = items;
466
- this.sideEffects = items.some(i => i.couldHaveSideEffects());
466
+ this.sideEffects = items.some((i) => i.couldHaveSideEffects());
467
467
  return this;
468
468
  }
469
469
 
@@ -492,7 +492,7 @@ class BasicEvaluatedExpression {
492
492
  this.quasis = quasis;
493
493
  this.parts = parts;
494
494
  this.templateStringKind = kind;
495
- this.sideEffects = parts.some(p => p.sideEffects);
495
+ this.sideEffects = parts.some((p) => p.sideEffects);
496
496
  return this;
497
497
  }
498
498
 
@@ -557,7 +557,7 @@ class BasicEvaluatedExpression {
557
557
  * @param {string} flags regexp flags
558
558
  * @returns {boolean} is valid flags
559
559
  */
560
- BasicEvaluatedExpression.isValidRegExpFlags = flags => {
560
+ BasicEvaluatedExpression.isValidRegExpFlags = (flags) => {
561
561
  const len = flags.length;
562
562
 
563
563
  if (len === 0) return true;
@@ -0,0 +1,70 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Natsu @xiaoxiaojx
4
+ */
5
+
6
+ "use strict";
7
+
8
+ const { updateHashForEntryStartup } = require("./StartupHelpers");
9
+
10
+ /** @typedef {import("../ChunkGraph")} ChunkGraph */
11
+ /** @typedef {import("../Module")} Module */
12
+ /** @typedef {import("../Chunk")} Chunk */
13
+ /** @typedef {import("../Entrypoint")} Entrypoint */
14
+ /** @typedef {import("../util/Hash")} Hash */
15
+ /** @typedef {import("../Compilation").ChunkHashContext} ChunkHashContext */
16
+
17
+ /**
18
+ * Gets information about a chunk including its entries and runtime chunk
19
+ * @param {Chunk} chunk The chunk to get information for
20
+ * @param {ChunkGraph} chunkGraph The chunk graph containing the chunk
21
+ * @returns {{entries: Array<[Module, Entrypoint | undefined]>, runtimeChunk: Chunk|null}} Object containing chunk entries and runtime chunk
22
+ */
23
+ function getChunkInfo(chunk, chunkGraph) {
24
+ const entries = [
25
+ ...chunkGraph.getChunkEntryModulesWithChunkGroupIterable(chunk)
26
+ ];
27
+ const runtimeChunk =
28
+ entries.length > 0
29
+ ? /** @type {Entrypoint[][]} */
30
+ (entries)[0][1].getRuntimeChunk()
31
+ : null;
32
+
33
+ return {
34
+ entries,
35
+ runtimeChunk
36
+ };
37
+ }
38
+
39
+ /**
40
+ * Creates a chunk hash handler
41
+ * @param {string} name The name of the chunk
42
+ * @returns {(chunk: Chunk, hash: Hash, { chunkGraph }: ChunkHashContext) => void} The chunk hash handler
43
+ */
44
+ function createChunkHashHandler(name) {
45
+ /**
46
+ * @param {Chunk} chunk The chunk to get information for
47
+ * @param {Hash} hash The hash to update
48
+ * @param {ChunkHashContext} chunkHashContext The chunk hash context
49
+ * @returns {void}
50
+ */
51
+ return (chunk, hash, { chunkGraph }) => {
52
+ if (chunk.hasRuntime()) return;
53
+ const { entries, runtimeChunk } = getChunkInfo(chunk, chunkGraph);
54
+ hash.update(name);
55
+ hash.update("1");
56
+ if (runtimeChunk && runtimeChunk.hash) {
57
+ // https://github.com/webpack/webpack/issues/19439
58
+ // Any change to runtimeChunk should trigger a hash update,
59
+ // we shouldn't depend on or inspect its internal implementation.
60
+ // import __webpack_require__ from "./runtime-main.e9400aee33633a3973bd.js";
61
+ hash.update(runtimeChunk.hash);
62
+ }
63
+ updateHashForEntryStartup(hash, chunkGraph, entries, chunk);
64
+ };
65
+ }
66
+
67
+ module.exports = {
68
+ createChunkHashHandler,
69
+ getChunkInfo
70
+ };
@@ -9,14 +9,15 @@ const { ConcatSource, RawSource } = require("webpack-sources");
9
9
  const RuntimeGlobals = require("../RuntimeGlobals");
10
10
  const Template = require("../Template");
11
11
  const { getUndoPath } = require("../util/identifier");
12
+ const {
13
+ createChunkHashHandler,
14
+ getChunkInfo
15
+ } = require("./ChunkFormatHelpers");
12
16
  const {
13
17
  getChunkFilenameTemplate,
14
18
  getCompilationHooks
15
19
  } = require("./JavascriptModulesPlugin");
16
- const {
17
- generateEntryStartup,
18
- updateHashForEntryStartup
19
- } = require("./StartupHelpers");
20
+ const { generateEntryStartup } = require("./StartupHelpers");
20
21
 
21
22
  /** @typedef {import("../Chunk")} Chunk */
22
23
  /** @typedef {import("../Compiler")} Compiler */
@@ -31,7 +32,7 @@ class CommonJsChunkFormatPlugin {
31
32
  * @returns {void}
32
33
  */
33
34
  apply(compiler) {
34
- compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
35
+ compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
35
36
  compilation.hooks.additionalChunkRuntimeRequirements.tap(
36
37
  PLUGIN_NAME,
37
38
  (chunk, set, { chunkGraph }) => {
@@ -59,13 +60,8 @@ class CommonJsChunkFormatPlugin {
59
60
  Template.renderChunkRuntimeModules(runtimeModules, renderContext)
60
61
  );
61
62
  }
62
- const entries = [
63
- ...chunkGraph.getChunkEntryModulesWithChunkGroupIterable(chunk)
64
- ];
65
- if (entries.length > 0) {
66
- const runtimeChunk =
67
- /** @type {Entrypoint} */
68
- (entries[0][1]).getRuntimeChunk();
63
+ const { entries, runtimeChunk } = getChunkInfo(chunk, chunkGraph);
64
+ if (runtimeChunk) {
69
65
  const currentOutputName = compilation
70
66
  .getPath(
71
67
  getChunkFilenameTemplate(chunk, compilation.outputOptions),
@@ -144,15 +140,8 @@ class CommonJsChunkFormatPlugin {
144
140
  }
145
141
  return source;
146
142
  });
147
- hooks.chunkHash.tap(PLUGIN_NAME, (chunk, hash, { chunkGraph }) => {
148
- if (chunk.hasRuntime()) return;
149
- hash.update(PLUGIN_NAME);
150
- hash.update("1");
151
- const entries = [
152
- ...chunkGraph.getChunkEntryModulesWithChunkGroupIterable(chunk)
153
- ];
154
- updateHashForEntryStartup(hash, chunkGraph, entries, chunk);
155
- });
143
+
144
+ hooks.chunkHash.tap(PLUGIN_NAME, createChunkHashHandler(PLUGIN_NAME));
156
145
  });
157
146
  }
158
147
  }
@@ -15,7 +15,7 @@ const enabledTypes = new WeakMap();
15
15
  * @param {Compiler} compiler compiler
16
16
  * @returns {Set<ChunkLoadingType>} enabled types
17
17
  */
18
- const getEnabledTypes = compiler => {
18
+ const getEnabledTypes = (compiler) => {
19
19
  let set = enabledTypes.get(compiler);
20
20
  if (set === undefined) {
21
21
  set = new Set();
@@ -88,7 +88,7 @@ class JavascriptGenerator extends Generator {
88
88
  module.buildMeta.exportsType !== "namespace" ||
89
89
  module.presentationalDependencies === undefined ||
90
90
  !module.presentationalDependencies.some(
91
- d => d instanceof HarmonyCompatibilityDependency
91
+ (d) => d instanceof HarmonyCompatibilityDependency
92
92
  )
93
93
  ) {
94
94
  return "Module is not an ECMAScript module";
@@ -173,20 +173,45 @@ const printGeneratedCodeForStack = (module, code) => {
173
173
  * @property {string} hash hash to be used for render call
174
174
  */
175
175
 
176
- /** @typedef {RenderContext & { inlined: boolean }} StartupRenderContext */
176
+ /**
177
+ * @typedef {object} StartupRenderContext
178
+ * @property {Chunk} chunk the chunk
179
+ * @property {DependencyTemplates} dependencyTemplates the dependency templates
180
+ * @property {RuntimeTemplate} runtimeTemplate the runtime template
181
+ * @property {ModuleGraph} moduleGraph the module graph
182
+ * @property {ChunkGraph} chunkGraph the chunk graph
183
+ * @property {CodeGenerationResults} codeGenerationResults results of code generation
184
+ * @property {boolean | undefined} strictMode rendering in strict context
185
+ * @property {boolean } inlined inlined
186
+ * @property {boolean=} inlinedInIIFE the inlined entry module is wrapped in an IIFE
187
+ */
188
+
189
+ /**
190
+ * @typedef {object} ModuleRenderContext
191
+ * @property {Chunk} chunk the chunk
192
+ * @property {DependencyTemplates} dependencyTemplates the dependency templates
193
+ * @property {RuntimeTemplate} runtimeTemplate the runtime template
194
+ * @property {ModuleGraph} moduleGraph the module graph
195
+ * @property {ChunkGraph} chunkGraph the chunk graph
196
+ * @property {CodeGenerationResults} codeGenerationResults results of code generation
197
+ * @property {InitFragment<ChunkRenderContext>[]} chunkInitFragments init fragments for the chunk
198
+ * @property {boolean | undefined} strictMode rendering in strict context
199
+ * @property {boolean} factory true: renders as factory method, false: pure module content
200
+ * @property {boolean=} inlinedInIIFE the inlined entry module is wrapped in an IIFE, existing only when `factory` is set to false
201
+ */
177
202
 
178
203
  /**
179
204
  * @typedef {object} CompilationHooks
180
- * @property {SyncWaterfallHook<[Source, Module, ChunkRenderContext]>} renderModuleContent
181
- * @property {SyncWaterfallHook<[Source, Module, ChunkRenderContext]>} renderModuleContainer
182
- * @property {SyncWaterfallHook<[Source, Module, ChunkRenderContext]>} renderModulePackage
205
+ * @property {SyncWaterfallHook<[Source, Module, ModuleRenderContext]>} renderModuleContent
206
+ * @property {SyncWaterfallHook<[Source, Module, ModuleRenderContext]>} renderModuleContainer
207
+ * @property {SyncWaterfallHook<[Source, Module, ModuleRenderContext]>} renderModulePackage
183
208
  * @property {SyncWaterfallHook<[Source, RenderContext]>} renderChunk
184
209
  * @property {SyncWaterfallHook<[Source, RenderContext]>} renderMain
185
210
  * @property {SyncWaterfallHook<[Source, RenderContext]>} renderContent
186
211
  * @property {SyncWaterfallHook<[Source, RenderContext]>} render
187
212
  * @property {SyncWaterfallHook<[Source, Module, StartupRenderContext]>} renderStartup
188
213
  * @property {SyncWaterfallHook<[string, RenderBootstrapContext]>} renderRequire
189
- * @property {SyncBailHook<[Module, RenderBootstrapContext], string | void>} inlineInRuntimeBailout
214
+ * @property {SyncBailHook<[Module, Partial<RenderBootstrapContext>], string | void>} inlineInRuntimeBailout
190
215
  * @property {SyncBailHook<[Module, RenderContext], string | void>} embedInRuntimeBailout
191
216
  * @property {SyncBailHook<[RenderContext], string | void>} strictRuntimeBailout
192
217
  * @property {SyncHook<[Chunk, Hash, ChunkHashContext]>} chunkHash
@@ -217,17 +242,17 @@ class JavascriptModulesPlugin {
217
242
  renderModuleContent: new SyncWaterfallHook([
218
243
  "source",
219
244
  "module",
220
- "renderContext"
245
+ "moduleRenderContext"
221
246
  ]),
222
247
  renderModuleContainer: new SyncWaterfallHook([
223
248
  "source",
224
249
  "module",
225
- "renderContext"
250
+ "moduleRenderContext"
226
251
  ]),
227
252
  renderModulePackage: new SyncWaterfallHook([
228
253
  "source",
229
254
  "module",
230
- "renderContext"
255
+ "moduleRenderContext"
231
256
  ]),
232
257
  render: new SyncWaterfallHook(["source", "renderContext"]),
233
258
  renderContent: new SyncWaterfallHook(["source", "renderContext"]),
@@ -274,7 +299,7 @@ class JavascriptModulesPlugin {
274
299
  ]) {
275
300
  normalModuleFactory.hooks.createParser
276
301
  .for(type)
277
- .tap(PLUGIN_NAME, _options => {
302
+ .tap(PLUGIN_NAME, (_options) => {
278
303
  switch (type) {
279
304
  case JAVASCRIPT_MODULE_TYPE_AUTO: {
280
305
  return new JavascriptParser("auto");
@@ -417,7 +442,7 @@ class JavascriptModulesPlugin {
417
442
  );
418
443
  }
419
444
  });
420
- compilation.hooks.contentHash.tap(PLUGIN_NAME, chunk => {
445
+ compilation.hooks.contentHash.tap(PLUGIN_NAME, (chunk) => {
421
446
  const {
422
447
  chunkGraph,
423
448
  codeGenerationResults,
@@ -575,18 +600,18 @@ class JavascriptModulesPlugin {
575
600
 
576
601
  /**
577
602
  * @param {Module} module the rendered module
578
- * @param {ChunkRenderContext} renderContext options object
603
+ * @param {ModuleRenderContext} renderContext options object
579
604
  * @param {CompilationHooks} hooks hooks
580
- * @param {boolean} factory true: renders as factory method, false: pure module content
581
605
  * @returns {Source | null} the newly generated source from rendering
582
606
  */
583
- renderModule(module, renderContext, hooks, factory) {
607
+ renderModule(module, renderContext, hooks) {
584
608
  const {
585
609
  chunk,
586
610
  chunkGraph,
587
611
  runtimeTemplate,
588
612
  codeGenerationResults,
589
- strictMode
613
+ strictMode,
614
+ factory
590
615
  } = renderContext;
591
616
  try {
592
617
  const codeGenResult = codeGenerationResults.get(module, chunk.runtime);
@@ -713,7 +738,7 @@ class JavascriptModulesPlugin {
713
738
  let allStrict = renderContext.strictMode;
714
739
  if (
715
740
  !allStrict &&
716
- allModules.every(m => /** @type {BuildInfo} */ (m.buildInfo).strict)
741
+ allModules.every((m) => /** @type {BuildInfo} */ (m.buildInfo).strict)
717
742
  ) {
718
743
  const strictBailout = hooks.strictRuntimeBailout.call(renderContext);
719
744
  strictHeader = strictBailout
@@ -728,8 +753,12 @@ class JavascriptModulesPlugin {
728
753
  strictMode: allStrict
729
754
  };
730
755
  const moduleSources =
731
- Template.renderChunkModules(chunkRenderContext, allModules, module =>
732
- this.renderModule(module, chunkRenderContext, hooks, true)
756
+ Template.renderChunkModules(chunkRenderContext, allModules, (module) =>
757
+ this.renderModule(
758
+ module,
759
+ { ...chunkRenderContext, factory: true },
760
+ hooks
761
+ )
733
762
  ) || new RawSource("{}");
734
763
  let source = tryRunOrWebpackError(
735
764
  () => hooks.renderChunk.call(moduleSources, chunkRenderContext),
@@ -812,7 +841,7 @@ class JavascriptModulesPlugin {
812
841
  let allStrict = renderContext.strictMode;
813
842
  if (
814
843
  !allStrict &&
815
- allModules.every(m => /** @type {BuildInfo} */ (m.buildInfo).strict)
844
+ allModules.every((m) => /** @type {BuildInfo} */ (m.buildInfo).strict)
816
845
  ) {
817
846
  const strictBailout = hooks.strictRuntimeBailout.call(renderContext);
818
847
  if (strictBailout) {
@@ -838,10 +867,15 @@ class JavascriptModulesPlugin {
838
867
  chunkRenderContext,
839
868
  inlinedModules
840
869
  ? allModules.filter(
841
- m => !(/** @type {Set<Module>} */ (inlinedModules).has(m))
870
+ (m) => !(/** @type {Set<Module>} */ (inlinedModules).has(m))
842
871
  )
843
872
  : allModules,
844
- module => this.renderModule(module, chunkRenderContext, hooks, true),
873
+ (module) =>
874
+ this.renderModule(
875
+ module,
876
+ { ...chunkRenderContext, factory: true },
877
+ hooks
878
+ ),
845
879
  prefix
846
880
  );
847
881
  if (
@@ -913,6 +947,8 @@ class JavascriptModulesPlugin {
913
947
  const avoidEntryIife = compilation.options.optimization.avoidEntryIife;
914
948
  /** @type {Map<Module, Source> | false} */
915
949
  let renamedInlinedModule = false;
950
+ let inlinedInIIFE = false;
951
+
916
952
  if (avoidEntryIife) {
917
953
  renamedInlinedModule = this.getRenamedInlineModule(
918
954
  allModules,
@@ -926,31 +962,46 @@ class JavascriptModulesPlugin {
926
962
  }
927
963
 
928
964
  for (const m of inlinedModules) {
965
+ const runtimeRequirements = chunkGraph.getModuleRuntimeRequirements(
966
+ m,
967
+ chunk.runtime
968
+ );
969
+ const exports = runtimeRequirements.has(RuntimeGlobals.exports);
970
+ const webpackExports =
971
+ exports && m.exportsArgument === RuntimeGlobals.exports;
972
+
973
+ const innerStrict =
974
+ !allStrict && /** @type {BuildInfo} */ (m.buildInfo).strict;
975
+
976
+ const iife = innerStrict
977
+ ? "it needs to be in strict mode."
978
+ : inlinedModules.size > 1
979
+ ? // TODO check globals and top-level declarations of other entries and chunk modules
980
+ // to make a better decision
981
+ "it needs to be isolated against other entry modules."
982
+ : chunkModules && !renamedInlinedModule
983
+ ? "it needs to be isolated against other modules in the chunk."
984
+ : exports && !webpackExports
985
+ ? `it uses a non-standard name for the exports (${m.exportsArgument}).`
986
+ : hooks.embedInRuntimeBailout.call(m, renderContext);
987
+
988
+ if (iife) {
989
+ inlinedInIIFE = true;
990
+ }
991
+
929
992
  const renderedModule = renamedInlinedModule
930
993
  ? renamedInlinedModule.get(m)
931
- : this.renderModule(m, chunkRenderContext, hooks, false);
994
+ : this.renderModule(
995
+ m,
996
+ {
997
+ ...chunkRenderContext,
998
+ factory: false,
999
+ inlinedInIIFE
1000
+ },
1001
+ hooks
1002
+ );
932
1003
 
933
1004
  if (renderedModule) {
934
- const innerStrict =
935
- !allStrict && /** @type {BuildInfo} */ (m.buildInfo).strict;
936
- const runtimeRequirements = chunkGraph.getModuleRuntimeRequirements(
937
- m,
938
- chunk.runtime
939
- );
940
- const exports = runtimeRequirements.has(RuntimeGlobals.exports);
941
- const webpackExports =
942
- exports && m.exportsArgument === RuntimeGlobals.exports;
943
- const iife = innerStrict
944
- ? "it needs to be in strict mode."
945
- : inlinedModules.size > 1
946
- ? // TODO check globals and top-level declarations of other entries and chunk modules
947
- // to make a better decision
948
- "it needs to be isolated against other entry modules."
949
- : chunkModules && !renamedInlinedModule
950
- ? "it needs to be isolated against other modules in the chunk."
951
- : exports && !webpackExports
952
- ? `it uses a non-standard name for the exports (${m.exportsArgument}).`
953
- : hooks.embedInRuntimeBailout.call(m, renderContext);
954
1005
  let footer;
955
1006
  if (iife !== undefined) {
956
1007
  startupSource.add(
@@ -989,7 +1040,8 @@ class JavascriptModulesPlugin {
989
1040
  source.add(
990
1041
  hooks.renderStartup.call(startupSource, lastInlinedModule, {
991
1042
  ...renderContext,
992
- inlined: true
1043
+ inlined: true,
1044
+ inlinedInIIFE
993
1045
  })
994
1046
  );
995
1047
  if (bootstrap.afterStartup.length > 0) {
@@ -1011,7 +1063,7 @@ class JavascriptModulesPlugin {
1011
1063
  const toSource = useSourceMap
1012
1064
  ? (content, name) =>
1013
1065
  new OriginalSource(Template.asString(content), name)
1014
- : content => new RawSource(Template.asString(content));
1066
+ : (content) => new RawSource(Template.asString(content));
1015
1067
  source.add(
1016
1068
  new PrefixSource(
1017
1069
  prefix,
@@ -1229,7 +1281,7 @@ class JavascriptModulesPlugin {
1229
1281
  }
1230
1282
  const chunks =
1231
1283
  /** @type {Entrypoint} */
1232
- (entrypoint).chunks.filter(c => c !== chunk);
1284
+ (entrypoint).chunks.filter((c) => c !== chunk);
1233
1285
  if (result.allowInlineStartup && chunks.length > 0) {
1234
1286
  buf2.push(
1235
1287
  "// This entry module depends on other loaded chunks and execution need to be delayed"
@@ -1242,10 +1294,10 @@ class JavascriptModulesPlugin {
1242
1294
  moduleGraph.getIncomingConnectionsByOriginModule(entryModule),
1243
1295
  ([originModule, connections]) =>
1244
1296
  originModule &&
1245
- connections.some(c => c.isTargetActive(chunk.runtime)) &&
1297
+ connections.some((c) => c.isTargetActive(chunk.runtime)) &&
1246
1298
  someInIterable(
1247
1299
  chunkGraph.getModuleRuntimes(originModule),
1248
- runtime =>
1300
+ (runtime) =>
1249
1301
  intersectRuntime(runtime, chunk.runtime) !== undefined
1250
1302
  )
1251
1303
  )
@@ -1309,7 +1361,7 @@ class JavascriptModulesPlugin {
1309
1361
  `${i === 0 ? `var ${RuntimeGlobals.exports} = ` : ""}${
1310
1362
  RuntimeGlobals.onChunksLoaded
1311
1363
  }(undefined, ${JSON.stringify(
1312
- chunks.map(c => c.id)
1364
+ chunks.map((c) => c.id)
1313
1365
  )}, ${runtimeTemplate.returningFunction(
1314
1366
  `${RuntimeGlobals.require}(${moduleIdExpr})`
1315
1367
  )})`
@@ -1554,10 +1606,9 @@ class JavascriptModulesPlugin {
1554
1606
  ) {
1555
1607
  const innerStrict =
1556
1608
  !allStrict &&
1557
- allModules.every(m => /** @type {BuildInfo} */ (m.buildInfo).strict);
1609
+ allModules.every((m) => /** @type {BuildInfo} */ (m.buildInfo).strict);
1558
1610
  const isMultipleEntries = inlinedModules.size > 1;
1559
1611
  const singleEntryWithModules = inlinedModules.size === 1 && hasChunkModules;
1560
-
1561
1612
  // TODO:
1562
1613
  // This step is before the IIFE reason calculation. Ideally, it should only be executed when this function can optimize the
1563
1614
  // IIFE reason. Otherwise, it should directly return false. There are four reasons now, we have skipped two already, the left
@@ -1581,9 +1632,12 @@ class JavascriptModulesPlugin {
1581
1632
  const isInlinedModule = inlinedModules && inlinedModules.has(m);
1582
1633
  const moduleSource = this.renderModule(
1583
1634
  m,
1584
- chunkRenderContext,
1585
- hooks,
1586
- !isInlinedModule
1635
+ {
1636
+ ...chunkRenderContext,
1637
+ factory: !isInlinedModule,
1638
+ inlinedInIIFE: false
1639
+ },
1640
+ hooks
1587
1641
  );
1588
1642
 
1589
1643
  if (!moduleSource) continue;
@@ -1639,7 +1693,7 @@ class JavascriptModulesPlugin {
1639
1693
 
1640
1694
  const info = /** @type {Info} */ (inlinedModulesToInfo.get(m));
1641
1695
  const allUsedNames = new Set(
1642
- Array.from(info.through, v => v.identifier.name)
1696
+ Array.from(info.through, (v) => v.identifier.name)
1643
1697
  );
1644
1698
 
1645
1699
  for (const variable of usedInNonInlined) {
@@ -1660,7 +1714,7 @@ class JavascriptModulesPlugin {
1660
1714
  if (allUsedNames.has(name) || usedNames.has(name)) {
1661
1715
  const references = getAllReferences(variable);
1662
1716
  const allIdentifiers = new Set([
1663
- ...references.map(r => r.identifier),
1717
+ ...references.map((r) => r.identifier),
1664
1718
  ...variable.identifiers
1665
1719
  ]);
1666
1720
  for (const ref of references) {