webpack 5.99.9 → 5.100.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.
Files changed (306) hide show
  1. package/bin/webpack.js +8 -2
  2. package/hot/log.js +15 -15
  3. package/hot/poll.js +1 -0
  4. package/lib/APIPlugin.js +3 -3
  5. package/lib/AbstractMethodError.js +1 -0
  6. package/lib/AutomaticPrefetchPlugin.js +1 -0
  7. package/lib/BannerPlugin.js +1 -1
  8. package/lib/CaseSensitiveModulesWarning.js +4 -4
  9. package/lib/Chunk.js +6 -6
  10. package/lib/ChunkGraph.js +37 -31
  11. package/lib/ChunkGroup.js +4 -4
  12. package/lib/ChunkTemplate.js +1 -1
  13. package/lib/CleanPlugin.js +94 -17
  14. package/lib/CodeGenerationResults.js +1 -1
  15. package/lib/CompatibilityPlugin.js +5 -2
  16. package/lib/Compilation.js +67 -45
  17. package/lib/Compiler.js +46 -16
  18. package/lib/ConcatenationScope.js +15 -6
  19. package/lib/ConstPlugin.js +5 -3
  20. package/lib/ContextModule.js +16 -12
  21. package/lib/ContextModuleFactory.js +4 -3
  22. package/lib/ContextReplacementPlugin.js +4 -2
  23. package/lib/CssModule.js +2 -2
  24. package/lib/DefinePlugin.js +111 -3
  25. package/lib/DelegatedModuleFactoryPlugin.js +18 -18
  26. package/lib/Dependency.js +6 -1
  27. package/lib/DependencyTemplate.js +1 -0
  28. package/lib/DllEntryPlugin.js +3 -1
  29. package/lib/DllPlugin.js +4 -3
  30. package/lib/DllReferencePlugin.js +2 -2
  31. package/lib/DynamicEntryPlugin.js +1 -1
  32. package/lib/EntryOptionPlugin.js +5 -0
  33. package/lib/ErrorHelpers.js +4 -4
  34. package/lib/EvalDevToolModulePlugin.js +3 -3
  35. package/lib/EvalSourceMapDevToolPlugin.js +7 -7
  36. package/lib/ExportsInfo.js +48 -39
  37. package/lib/ExternalModule.js +15 -11
  38. package/lib/ExternalModuleFactoryPlugin.js +5 -2
  39. package/lib/FileSystemInfo.js +51 -36
  40. package/lib/FlagDependencyExportsPlugin.js +14 -7
  41. package/lib/FlagDependencyUsagePlugin.js +1 -1
  42. package/lib/Generator.js +14 -1
  43. package/lib/HookWebpackError.js +1 -0
  44. package/lib/HotModuleReplacementPlugin.js +77 -50
  45. package/lib/IgnorePlugin.js +1 -1
  46. package/lib/InvalidDependenciesModuleWarning.js +1 -1
  47. package/lib/JavascriptMetaInfoPlugin.js +0 -1
  48. package/lib/LibManifestPlugin.js +4 -2
  49. package/lib/LoaderOptionsPlugin.js +6 -4
  50. package/lib/MainTemplate.js +2 -2
  51. package/lib/Module.js +21 -6
  52. package/lib/ModuleFactory.js +1 -0
  53. package/lib/ModuleGraph.js +24 -2
  54. package/lib/ModuleGraphConnection.js +5 -5
  55. package/lib/ModuleInfoHeaderPlugin.js +2 -1
  56. package/lib/ModuleParseError.js +1 -0
  57. package/lib/ModuleSourceTypesConstants.js +12 -12
  58. package/lib/ModuleTemplate.js +1 -1
  59. package/lib/ModuleTypeConstants.js +21 -21
  60. package/lib/MultiCompiler.js +6 -6
  61. package/lib/NormalModule.js +31 -44
  62. package/lib/NormalModuleFactory.js +29 -19
  63. package/lib/NormalModuleReplacementPlugin.js +1 -1
  64. package/lib/NullFactory.js +1 -0
  65. package/lib/OptimizationStages.js +1 -1
  66. package/lib/Parser.js +1 -0
  67. package/lib/ProgressPlugin.js +12 -5
  68. package/lib/ProvidePlugin.js +5 -1
  69. package/lib/RecordIdsPlugin.js +3 -3
  70. package/lib/RuntimeGlobals.js +175 -155
  71. package/lib/RuntimeModule.js +1 -0
  72. package/lib/RuntimePlugin.js +33 -7
  73. package/lib/RuntimeTemplate.js +111 -11
  74. package/lib/SourceMapDevToolModuleOptionsPlugin.js +15 -25
  75. package/lib/SourceMapDevToolPlugin.js +19 -17
  76. package/lib/Template.js +2 -2
  77. package/lib/TemplatedPathPlugin.js +1 -1
  78. package/lib/WarnDeprecatedOptionPlugin.js +7 -8
  79. package/lib/WatchIgnorePlugin.js +4 -3
  80. package/lib/WebpackIsIncludedPlugin.js +2 -1
  81. package/lib/WebpackOptionsApply.js +115 -27
  82. package/lib/asset/AssetGenerator.js +15 -11
  83. package/lib/asset/AssetModulesPlugin.js +19 -17
  84. package/lib/asset/AssetSourceGenerator.js +4 -4
  85. package/lib/asset/RawDataUrlModule.js +4 -2
  86. package/lib/async-modules/AwaitDependenciesInitFragment.js +1 -1
  87. package/lib/buildChunkGraph.js +6 -3
  88. package/lib/cache/AddBuildDependenciesPlugin.js +5 -6
  89. package/lib/cache/IdleFileCachePlugin.js +7 -4
  90. package/lib/cache/MemoryCachePlugin.js +1 -0
  91. package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
  92. package/lib/cache/PackFileCacheStrategy.js +26 -20
  93. package/lib/cache/ResolverCachePlugin.js +16 -8
  94. package/lib/cli.js +15 -10
  95. package/lib/config/browserslistTargetHandler.js +3 -3
  96. package/lib/config/defaults.js +25 -17
  97. package/lib/config/normalization.js +2 -1
  98. package/lib/config/target.js +6 -5
  99. package/lib/container/ContainerPlugin.js +1 -1
  100. package/lib/container/ContainerReferencePlugin.js +1 -1
  101. package/lib/container/FallbackModule.js +2 -1
  102. package/lib/container/HoistContainerReferencesPlugin.js +1 -1
  103. package/lib/container/ModuleFederationPlugin.js +2 -2
  104. package/lib/container/RemoteModule.js +1 -1
  105. package/lib/css/CssGenerator.js +9 -6
  106. package/lib/css/CssModulesPlugin.js +44 -31
  107. package/lib/css/CssParser.js +6 -4
  108. package/lib/css/walkCssTokens.js +33 -37
  109. package/lib/debug/ProfilingPlugin.js +6 -6
  110. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +8 -8
  111. package/lib/dependencies/AMDPlugin.js +12 -8
  112. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +28 -26
  113. package/lib/dependencies/CachedConstDependency.js +1 -5
  114. package/lib/dependencies/CommonJsExportRequireDependency.js +6 -4
  115. package/lib/dependencies/CommonJsExportsParserPlugin.js +22 -25
  116. package/lib/dependencies/CommonJsFullRequireDependency.js +1 -9
  117. package/lib/dependencies/CommonJsImportsParserPlugin.js +100 -114
  118. package/lib/dependencies/CommonJsPlugin.js +15 -16
  119. package/lib/dependencies/ContextDependencyHelpers.js +2 -1
  120. package/lib/dependencies/ContextDependencyTemplateAsId.js +1 -0
  121. package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +1 -0
  122. package/lib/dependencies/CssIcssExportDependency.js +1 -1
  123. package/lib/dependencies/CssLocalIdentifierDependency.js +2 -2
  124. package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
  125. package/lib/dependencies/DynamicExports.js +9 -9
  126. package/lib/dependencies/ExportsInfoDependency.js +1 -1
  127. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +122 -101
  128. package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
  129. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +95 -19
  130. package/lib/dependencies/HarmonyExportInitFragment.js +1 -1
  131. package/lib/dependencies/HarmonyImportDependency.js +11 -5
  132. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +238 -162
  133. package/lib/dependencies/HarmonyImportSideEffectDependency.js +4 -1
  134. package/lib/dependencies/HarmonyImportSpecifierDependency.js +20 -9
  135. package/lib/dependencies/HarmonyModulesPlugin.js +23 -12
  136. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -0
  137. package/lib/dependencies/ImportMetaContextPlugin.js +2 -1
  138. package/lib/dependencies/ImportMetaPlugin.js +2 -2
  139. package/lib/dependencies/ImportParserPlugin.js +40 -9
  140. package/lib/dependencies/ImportPlugin.js +3 -1
  141. package/lib/dependencies/LoaderPlugin.js +1 -0
  142. package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +1 -0
  143. package/lib/dependencies/RequireContextPlugin.js +3 -1
  144. package/lib/dependencies/RequireEnsurePlugin.js +6 -6
  145. package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +33 -34
  146. package/lib/dependencies/RequireIncludePlugin.js +1 -0
  147. package/lib/dependencies/RuntimeRequirementsDependency.js +1 -1
  148. package/lib/dependencies/SystemPlugin.js +1 -1
  149. package/lib/dependencies/URLContextDependency.js +65 -0
  150. package/lib/dependencies/URLPlugin.js +17 -157
  151. package/lib/dependencies/WorkerPlugin.js +23 -10
  152. package/lib/dependencies/processExportInfo.js +2 -1
  153. package/lib/esm/ModuleChunkFormatPlugin.js +269 -185
  154. package/lib/esm/ModuleChunkLoadingPlugin.js +39 -1
  155. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +70 -3
  156. package/lib/hmr/HotModuleReplacement.runtime.js +0 -1
  157. package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -1
  158. package/lib/hmr/JavascriptHotModuleReplacementHelper.js +37 -0
  159. package/lib/hmr/LazyCompilationPlugin.js +4 -2
  160. package/lib/hmr/lazyCompilationBackend.js +4 -2
  161. package/lib/ids/ChunkModuleIdRangePlugin.js +6 -3
  162. package/lib/ids/DeterministicChunkIdsPlugin.js +30 -35
  163. package/lib/ids/DeterministicModuleIdsPlugin.js +4 -3
  164. package/lib/ids/HashedModuleIdsPlugin.js +5 -4
  165. package/lib/ids/IdHelpers.js +21 -17
  166. package/lib/ids/NamedChunkIdsPlugin.js +5 -5
  167. package/lib/ids/NamedModuleIdsPlugin.js +4 -4
  168. package/lib/ids/NaturalChunkIdsPlugin.js +2 -1
  169. package/lib/ids/NaturalModuleIdsPlugin.js +1 -1
  170. package/lib/ids/OccurrenceChunkIdsPlugin.js +3 -2
  171. package/lib/ids/OccurrenceModuleIdsPlugin.js +1 -1
  172. package/lib/ids/SyncModuleIdsPlugin.js +1 -1
  173. package/lib/index.js +13 -3
  174. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +113 -119
  175. package/lib/javascript/BasicEvaluatedExpression.js +2 -1
  176. package/lib/javascript/ChunkHelpers.js +1 -0
  177. package/lib/javascript/CommonJsChunkFormatPlugin.js +121 -136
  178. package/lib/javascript/EnableChunkLoadingPlugin.js +6 -3
  179. package/lib/javascript/JavascriptGenerator.js +14 -2
  180. package/lib/javascript/JavascriptModulesPlugin.js +68 -27
  181. package/lib/javascript/JavascriptParser.js +117 -76
  182. package/lib/javascript/JavascriptParserHelpers.js +41 -41
  183. package/lib/javascript/StartupHelpers.js +17 -17
  184. package/lib/json/JsonGenerator.js +4 -2
  185. package/lib/json/JsonModulesPlugin.js +2 -2
  186. package/lib/json/JsonParser.js +1 -1
  187. package/lib/library/AbstractLibraryPlugin.js +6 -2
  188. package/lib/library/AssignLibraryPlugin.js +21 -6
  189. package/lib/library/EnableLibraryPlugin.js +23 -3
  190. package/lib/library/UmdLibraryPlugin.js +15 -6
  191. package/lib/logging/createConsoleLogger.js +3 -3
  192. package/lib/logging/runtime.js +9 -9
  193. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +4 -22
  194. package/lib/node/RequireChunkLoadingRuntimeModule.js +4 -22
  195. package/lib/node/nodeConsole.js +4 -2
  196. package/lib/optimize/AggressiveMergingPlugin.js +45 -46
  197. package/lib/optimize/AggressiveSplittingPlugin.js +13 -12
  198. package/lib/optimize/ConcatenatedModule.js +227 -57
  199. package/lib/optimize/EnsureChunkConditionsPlugin.js +58 -58
  200. package/lib/optimize/FlagIncludedChunksPlugin.js +3 -1
  201. package/lib/optimize/InnerGraph.js +115 -112
  202. package/lib/optimize/InnerGraphPlugin.js +2 -2
  203. package/lib/optimize/LimitChunkCountPlugin.js +4 -2
  204. package/lib/optimize/MangleExportsPlugin.js +4 -3
  205. package/lib/optimize/MergeDuplicateChunksPlugin.js +80 -81
  206. package/lib/optimize/MinChunkSizePlugin.js +6 -3
  207. package/lib/optimize/ModuleConcatenationPlugin.js +31 -22
  208. package/lib/optimize/RealContentHashPlugin.js +26 -20
  209. package/lib/optimize/RemoveEmptyChunksPlugin.js +2 -1
  210. package/lib/optimize/RemoveParentModulesPlugin.js +1 -0
  211. package/lib/optimize/SideEffectsFlagPlugin.js +3 -2
  212. package/lib/optimize/SplitChunksPlugin.js +16 -13
  213. package/lib/rules/BasicEffectRulePlugin.js +4 -2
  214. package/lib/rules/BasicMatcherRulePlugin.js +3 -1
  215. package/lib/rules/ObjectMatcherRulePlugin.js +3 -1
  216. package/lib/rules/RuleSetCompiler.js +6 -3
  217. package/lib/rules/UseEffectRulePlugin.js +3 -1
  218. package/lib/runtime/AsyncModuleRuntimeModule.js +64 -9
  219. package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +1 -1
  220. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +214 -0
  221. package/lib/runtime/RuntimeIdRuntimeModule.js +2 -1
  222. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +8 -7
  223. package/lib/schemes/FileUriPlugin.js +1 -1
  224. package/lib/schemes/HttpUriPlugin.js +27 -19
  225. package/lib/schemes/VirtualUrlPlugin.js +222 -0
  226. package/lib/serialization/AggregateErrorSerializer.js +1 -1
  227. package/lib/serialization/BinaryMiddleware.js +5 -4
  228. package/lib/serialization/FileMiddleware.js +7 -4
  229. package/lib/serialization/ObjectMiddleware.js +14 -8
  230. package/lib/serialization/Serializer.js +5 -3
  231. package/lib/serialization/SerializerMiddleware.js +2 -0
  232. package/lib/sharing/ConsumeSharedModule.js +1 -1
  233. package/lib/sharing/ConsumeSharedPlugin.js +3 -3
  234. package/lib/sharing/ConsumeSharedRuntimeModule.js +2 -2
  235. package/lib/sharing/ProvideSharedModule.js +1 -1
  236. package/lib/sharing/ProvideSharedPlugin.js +3 -2
  237. package/lib/sharing/SharePlugin.js +2 -1
  238. package/lib/sharing/ShareRuntimeModule.js +3 -5
  239. package/lib/sharing/utils.js +34 -34
  240. package/lib/stats/DefaultStatsFactoryPlugin.js +49 -46
  241. package/lib/stats/DefaultStatsPresetPlugin.js +4 -2
  242. package/lib/stats/DefaultStatsPrinterPlugin.js +15 -9
  243. package/lib/stats/StatsFactory.js +4 -2
  244. package/lib/stats/StatsPrinter.js +3 -2
  245. package/lib/url/URLParserPlugin.js +266 -0
  246. package/lib/util/ArrayQueue.js +1 -1
  247. package/lib/util/AsyncQueue.js +1 -1
  248. package/lib/util/Hash.js +2 -0
  249. package/lib/util/IterableHelpers.js +1 -1
  250. package/lib/util/LazyBucketSortedSet.js +2 -1
  251. package/lib/util/LazySet.js +11 -6
  252. package/lib/util/ParallelismFactorCalculator.js +1 -1
  253. package/lib/util/SetHelpers.js +3 -3
  254. package/lib/util/SortableSet.js +2 -2
  255. package/lib/util/StackedCacheMap.js +3 -1
  256. package/lib/util/StackedMap.js +2 -2
  257. package/lib/util/StringXor.js +1 -0
  258. package/lib/util/TupleSet.js +1 -0
  259. package/lib/util/URLAbsoluteSpecifier.js +1 -1
  260. package/lib/util/cleverMerge.js +12 -8
  261. package/lib/util/comparators.js +154 -127
  262. package/lib/util/compileBooleanMatcher.js +8 -3
  263. package/lib/util/concatenate.js +8 -7
  264. package/lib/util/conventions.js +72 -73
  265. package/lib/util/create-schema-validation.js +2 -1
  266. package/lib/util/createHash.js +10 -4
  267. package/lib/util/deprecation.js +69 -66
  268. package/lib/util/deterministicGrouping.js +4 -2
  269. package/lib/util/extractUrlAndGlobal.js +1 -1
  270. package/lib/util/findGraphRoots.js +2 -2
  271. package/lib/util/fs.js +30 -23
  272. package/lib/util/hash/md4.js +2 -2
  273. package/lib/util/hash/wasm-hash.js +4 -2
  274. package/lib/util/identifier.js +13 -12
  275. package/lib/util/internalSerializables.js +2 -0
  276. package/lib/util/magicComment.js +5 -5
  277. package/lib/util/processAsyncTree.js +1 -1
  278. package/lib/util/propertyAccess.js +1 -1
  279. package/lib/util/propertyName.js +1 -1
  280. package/lib/util/registerExternalSerializer.js +1 -2
  281. package/lib/util/removeBOM.js +1 -1
  282. package/lib/util/runtime.js +29 -21
  283. package/lib/util/semver.js +1 -1
  284. package/lib/util/serialization.js +3 -0
  285. package/lib/util/source.js +3 -2
  286. package/lib/validateSchema.js +1 -0
  287. package/lib/wasm/EnableWasmLoadingPlugin.js +6 -3
  288. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +4 -1
  289. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +46 -49
  290. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +2 -2
  291. package/lib/wasm-sync/WebAssemblyGenerator.js +2 -3
  292. package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +3 -2
  293. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +3 -0
  294. package/lib/wasm-sync/WebAssemblyUtils.js +1 -1
  295. package/lib/web/JsonpChunkLoadingRuntimeModule.js +4 -22
  296. package/lib/webpack.js +4 -5
  297. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +1 -0
  298. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +6 -24
  299. package/lib/webworker/WebWorkerTemplatePlugin.js +1 -0
  300. package/package.json +119 -113
  301. package/schemas/WebpackOptions.check.js +1 -1
  302. package/schemas/WebpackOptions.json +17 -0
  303. package/schemas/plugins/schemes/VirtualUrlPlugin.check.d.ts +7 -0
  304. package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +6 -0
  305. package/schemas/plugins/schemes/VirtualUrlPlugin.json +77 -0
  306. package/types.d.ts +1230 -360
@@ -19,7 +19,7 @@ const SortableSet = require("./SortableSet");
19
19
  * @param {EntryOptions=} options optionally already received entry options
20
20
  * @returns {RuntimeSpec} runtime
21
21
  */
22
- module.exports.getEntryRuntime = (compilation, name, options) => {
22
+ const getEntryRuntime = (compilation, name, options) => {
23
23
  let dependOn;
24
24
  let runtime;
25
25
  if (options) {
@@ -68,7 +68,6 @@ const forEachRuntime = (runtime, fn, deterministicOrder = false) => {
68
68
  }
69
69
  }
70
70
  };
71
- module.exports.forEachRuntime = forEachRuntime;
72
71
 
73
72
  /**
74
73
  * @template T
@@ -77,7 +76,7 @@ module.exports.forEachRuntime = forEachRuntime;
77
76
  */
78
77
  const getRuntimesKey = set => {
79
78
  set.sort();
80
- return Array.from(set).join("\n");
79
+ return [...set].join("\n");
81
80
  };
82
81
 
83
82
  /**
@@ -89,7 +88,6 @@ const getRuntimeKey = runtime => {
89
88
  if (typeof runtime === "string") return runtime;
90
89
  return runtime.getFromUnorderedCache(getRuntimesKey);
91
90
  };
92
- module.exports.getRuntimeKey = getRuntimeKey;
93
91
 
94
92
  /**
95
93
  * @param {string} key key of runtimes
@@ -101,7 +99,6 @@ const keyToRuntime = key => {
101
99
  if (items.length === 1) return items[0];
102
100
  return new SortableSet(items);
103
101
  };
104
- module.exports.keyToRuntime = keyToRuntime;
105
102
 
106
103
  /**
107
104
  * @template T
@@ -110,7 +107,7 @@ module.exports.keyToRuntime = keyToRuntime;
110
107
  */
111
108
  const getRuntimesString = set => {
112
109
  set.sort();
113
- return Array.from(set).join("+");
110
+ return [...set].join("+");
114
111
  };
115
112
 
116
113
  /**
@@ -122,13 +119,12 @@ const runtimeToString = runtime => {
122
119
  if (typeof runtime === "string") return runtime;
123
120
  return runtime.getFromUnorderedCache(getRuntimesString);
124
121
  };
125
- module.exports.runtimeToString = runtimeToString;
126
122
 
127
123
  /**
128
124
  * @param {RuntimeCondition} runtimeCondition runtime condition
129
125
  * @returns {string} readable version
130
126
  */
131
- module.exports.runtimeConditionToString = runtimeCondition => {
127
+ const runtimeConditionToString = runtimeCondition => {
132
128
  if (runtimeCondition === true) return "true";
133
129
  if (runtimeCondition === false) return "false";
134
130
  return runtimeToString(runtimeCondition);
@@ -163,14 +159,13 @@ const runtimeEqual = (a, b) => {
163
159
  if (aV.value !== bV.value) return false;
164
160
  }
165
161
  };
166
- module.exports.runtimeEqual = runtimeEqual;
167
162
 
168
163
  /**
169
164
  * @param {RuntimeSpec} a first
170
165
  * @param {RuntimeSpec} b second
171
166
  * @returns {-1|0|1} compare
172
167
  */
173
- module.exports.compareRuntime = (a, b) => {
168
+ const compareRuntime = (a, b) => {
174
169
  if (a === b) {
175
170
  return 0;
176
171
  } else if (a === undefined) {
@@ -221,7 +216,6 @@ const mergeRuntime = (a, b) => {
221
216
  if (set.size === a.size) return a;
222
217
  return set;
223
218
  };
224
- module.exports.mergeRuntime = mergeRuntime;
225
219
 
226
220
  /**
227
221
  * @param {RuntimeCondition} a first
@@ -229,7 +223,7 @@ module.exports.mergeRuntime = mergeRuntime;
229
223
  * @param {RuntimeSpec} runtime full runtime
230
224
  * @returns {RuntimeCondition} result
231
225
  */
232
- module.exports.mergeRuntimeCondition = (a, b, runtime) => {
226
+ const mergeRuntimeCondition = (a, b, runtime) => {
233
227
  if (a === false) return b;
234
228
  if (b === false) return a;
235
229
  if (a === true || b === true) return true;
@@ -250,7 +244,7 @@ module.exports.mergeRuntimeCondition = (a, b, runtime) => {
250
244
  * @param {RuntimeSpec} runtime full runtime
251
245
  * @returns {RuntimeSpec | true} result
252
246
  */
253
- module.exports.mergeRuntimeConditionNonFalse = (a, b, runtime) => {
247
+ const mergeRuntimeConditionNonFalse = (a, b, runtime) => {
254
248
  if (a === true || b === true) return true;
255
249
  const merged = mergeRuntime(a, b);
256
250
  if (merged === undefined) return;
@@ -296,14 +290,13 @@ const mergeRuntimeOwned = (a, b) => {
296
290
  for (const item of b) a.add(item);
297
291
  return a;
298
292
  };
299
- module.exports.mergeRuntimeOwned = mergeRuntimeOwned;
300
293
 
301
294
  /**
302
295
  * @param {RuntimeSpec} a first
303
296
  * @param {RuntimeSpec} b second
304
297
  * @returns {RuntimeSpec} merged
305
298
  */
306
- module.exports.intersectRuntime = (a, b) => {
299
+ const intersectRuntime = (a, b) => {
307
300
  if (a === undefined) {
308
301
  return b;
309
302
  } else if (b === undefined) {
@@ -376,7 +369,6 @@ const subtractRuntime = (a, b) => {
376
369
  }
377
370
  return set;
378
371
  };
379
- module.exports.subtractRuntime = subtractRuntime;
380
372
 
381
373
  /**
382
374
  * @param {RuntimeCondition} a first
@@ -384,7 +376,7 @@ module.exports.subtractRuntime = subtractRuntime;
384
376
  * @param {RuntimeSpec} runtime runtime
385
377
  * @returns {RuntimeCondition} result
386
378
  */
387
- module.exports.subtractRuntimeCondition = (a, b, runtime) => {
379
+ const subtractRuntimeCondition = (a, b, runtime) => {
388
380
  if (b === true) return false;
389
381
  if (b === false) return a;
390
382
  if (a === false) return false;
@@ -397,7 +389,7 @@ module.exports.subtractRuntimeCondition = (a, b, runtime) => {
397
389
  * @param {(runtime?: RuntimeSpec) => boolean} filter filter function
398
390
  * @returns {boolean | RuntimeSpec} true/false if filter is constant for all runtimes, otherwise runtimes that are active
399
391
  */
400
- module.exports.filterRuntime = (runtime, filter) => {
392
+ const filterRuntime = (runtime, filter) => {
401
393
  if (runtime === undefined) return filter();
402
394
  if (typeof runtime === "string") return filter(runtime);
403
395
  let some = false;
@@ -604,9 +596,10 @@ class RuntimeSpecMap {
604
596
  /** @type {RuntimeSpecMapInnerMap<R>} */
605
597
  (this._map).get(key);
606
598
  const newValue = fn(oldValue);
607
- if (newValue !== oldValue)
599
+ if (newValue !== oldValue) {
608
600
  /** @type {RuntimeSpecMapInnerMap<R>} */
609
601
  (this._map).set(key, newValue);
602
+ }
610
603
  }
611
604
  }
612
605
  }
@@ -649,8 +642,6 @@ class RuntimeSpecMap {
649
642
  }
650
643
  }
651
644
 
652
- module.exports.RuntimeSpecMap = RuntimeSpecMap;
653
-
654
645
  class RuntimeSpecSet {
655
646
  /**
656
647
  * @param {Iterable<RuntimeSpec>=} iterable iterable
@@ -692,4 +683,21 @@ class RuntimeSpecSet {
692
683
  }
693
684
  }
694
685
 
686
+ module.exports.RuntimeSpecMap = RuntimeSpecMap;
695
687
  module.exports.RuntimeSpecSet = RuntimeSpecSet;
688
+ module.exports.compareRuntime = compareRuntime;
689
+ module.exports.filterRuntime = filterRuntime;
690
+ module.exports.forEachRuntime = forEachRuntime;
691
+ module.exports.getEntryRuntime = getEntryRuntime;
692
+ module.exports.getRuntimeKey = getRuntimeKey;
693
+ module.exports.intersectRuntime = intersectRuntime;
694
+ module.exports.keyToRuntime = keyToRuntime;
695
+ module.exports.mergeRuntime = mergeRuntime;
696
+ module.exports.mergeRuntimeCondition = mergeRuntimeCondition;
697
+ module.exports.mergeRuntimeConditionNonFalse = mergeRuntimeConditionNonFalse;
698
+ module.exports.mergeRuntimeOwned = mergeRuntimeOwned;
699
+ module.exports.runtimeConditionToString = runtimeConditionToString;
700
+ module.exports.runtimeEqual = runtimeEqual;
701
+ module.exports.runtimeToString = runtimeToString;
702
+ module.exports.subtractRuntime = subtractRuntime;
703
+ module.exports.subtractRuntimeCondition = subtractRuntimeCondition;
@@ -561,7 +561,7 @@ module.exports.stringifyHoley = json => {
561
561
  exports.parseVersionRuntimeCode = runtimeTemplate =>
562
562
  `var parseVersion = ${runtimeTemplate.basicFunction("str", [
563
563
  "// see webpack/lib/util/semver.js for original code",
564
- `var p=${runtimeTemplate.supportsArrowFunction() ? "p=>" : "function(p)"}{return p.split(".").map((${runtimeTemplate.supportsArrowFunction() ? "p=>" : "function(p)"}{return+p==p?+p:p}))},n=/^([^-+]+)?(?:-([^+]+))?(?:\\+(.+))?$/.exec(str),r=n[1]?p(n[1]):[];return n[2]&&(r.length++,r.push.apply(r,p(n[2]))),n[3]&&(r.push([]),r.push.apply(r,p(n[3]))),r;`
564
+ `var p=${runtimeTemplate.supportsArrowFunction() ? "p=>" : "function(p)"}{return p.split(".").map(${runtimeTemplate.supportsArrowFunction() ? "p=>" : "function(p)"}{return+p==p?+p:p})},n=/^([^-+]+)?(?:-([^+]+))?(?:\\+(.+))?$/.exec(str),r=n[1]?p(n[1]):[];return n[2]&&(r.length++,r.push.apply(r,p(n[2]))),n[3]&&(r.push([]),r.push.apply(r,p(n[3]))),r;`
565
565
  ])}`;
566
566
  //#endregion
567
567
 
@@ -41,6 +41,7 @@ const registerSerializers = memoize(() => {
41
41
  // Load internal paths with a relative require
42
42
  // This allows bundling all internal serializers
43
43
  const internalSerializables = require("./internalSerializables");
44
+
44
45
  getObjectMiddleware().registerLoader(/^webpack\/lib\//, req => {
45
46
  const loader =
46
47
  internalSerializables[
@@ -116,7 +117,9 @@ module.exports = {
116
117
  createFileSerializer: (fs, hashFunction) => {
117
118
  registerSerializers();
118
119
  const Serializer = getSerializer();
120
+
119
121
  const FileMiddleware = require("../serialization/FileMiddleware");
122
+
120
123
  const fileMiddleware = new FileMiddleware(fs, hashFunction);
121
124
  const binaryMiddleware = getBinaryMiddlewareInstance();
122
125
  const SerializerMiddleware = getSerializerMiddleware();
@@ -23,8 +23,8 @@ const _isSourceEqual = (a, b) => {
23
23
  let bSource = typeof b.buffer === "function" ? b.buffer() : b.source();
24
24
  if (aSource === bSource) return true;
25
25
  if (typeof aSource === "string" && typeof bSource === "string") return false;
26
- if (!Buffer.isBuffer(aSource)) aSource = Buffer.from(aSource, "utf-8");
27
- if (!Buffer.isBuffer(bSource)) bSource = Buffer.from(bSource, "utf-8");
26
+ if (!Buffer.isBuffer(aSource)) aSource = Buffer.from(aSource, "utf8");
27
+ if (!Buffer.isBuffer(bSource)) bSource = Buffer.from(bSource, "utf8");
28
28
  return aSource.equals(bSource);
29
29
  };
30
30
 
@@ -58,4 +58,5 @@ const isSourceEqual = (a, b) => {
58
58
  }
59
59
  return result;
60
60
  };
61
+
61
62
  module.exports.isSourceEqual = isSourceEqual;
@@ -173,4 +173,5 @@ const validateSchema = (schema, options, validationConfiguration) => {
173
173
  }
174
174
  );
175
175
  };
176
+
176
177
  module.exports = validateSchema;
@@ -54,9 +54,7 @@ class EnableWasmLoadingPlugin {
54
54
  "EnableWasmLoadingPlugin need to be used to enable this type of wasm loading. " +
55
55
  'This usually happens through the "output.enabledWasmLoadingTypes" option. ' +
56
56
  'If you are using a function as entry which sets "wasmLoading", you need to add all potential library types to "output.enabledWasmLoadingTypes". ' +
57
- `These types are enabled: ${Array.from(
58
- getEnabledTypes(compiler)
59
- ).join(", ")}`
57
+ `These types are enabled: ${[...getEnabledTypes(compiler)].join(", ")}`
60
58
  );
61
59
  }
62
60
  }
@@ -80,6 +78,7 @@ class EnableWasmLoadingPlugin {
80
78
  if (compiler.options.experiments.syncWebAssembly) {
81
79
  // TODO webpack 6 remove FetchCompileWasmPlugin
82
80
  const FetchCompileWasmPlugin = require("../web/FetchCompileWasmPlugin");
81
+
83
82
  new FetchCompileWasmPlugin({
84
83
  mangleImports: compiler.options.optimization.mangleWasmImports
85
84
  }).apply(compiler);
@@ -87,6 +86,7 @@ class EnableWasmLoadingPlugin {
87
86
 
88
87
  if (compiler.options.experiments.asyncWebAssembly) {
89
88
  const FetchCompileAsyncWasmPlugin = require("../web/FetchCompileAsyncWasmPlugin");
89
+
90
90
  new FetchCompileAsyncWasmPlugin().apply(compiler);
91
91
  }
92
92
 
@@ -96,6 +96,7 @@ class EnableWasmLoadingPlugin {
96
96
  if (compiler.options.experiments.syncWebAssembly) {
97
97
  // TODO webpack 6 remove ReadFileCompileWasmPlugin
98
98
  const ReadFileCompileWasmPlugin = require("../node/ReadFileCompileWasmPlugin");
99
+
99
100
  new ReadFileCompileWasmPlugin({
100
101
  mangleImports: compiler.options.optimization.mangleWasmImports,
101
102
  import:
@@ -106,6 +107,7 @@ class EnableWasmLoadingPlugin {
106
107
 
107
108
  if (compiler.options.experiments.asyncWebAssembly) {
108
109
  const ReadFileCompileAsyncWasmPlugin = require("../node/ReadFileCompileAsyncWasmPlugin");
110
+
109
111
  new ReadFileCompileAsyncWasmPlugin({
110
112
  import:
111
113
  compiler.options.output.module &&
@@ -117,6 +119,7 @@ class EnableWasmLoadingPlugin {
117
119
  }
118
120
  case "universal": {
119
121
  const UniversalCompileAsyncWasmPlugin = require("../wasm-async/UniversalCompileAsyncWasmPlugin");
122
+
120
123
  new UniversalCompileAsyncWasmPlugin().apply(compiler);
121
124
  break;
122
125
  }
@@ -105,6 +105,7 @@ class AsyncWebAssemblyJavascriptGenerator extends Generator {
105
105
  return runtimeTemplate.importStatement({
106
106
  update: false,
107
107
  module: importedModule,
108
+ moduleGraph,
108
109
  chunkGraph,
109
110
  request,
110
111
  originModule: module,
@@ -131,6 +132,7 @@ class AsyncWebAssemblyJavascriptGenerator extends Generator {
131
132
  )}: ${runtimeTemplate.exportFromImport({
132
133
  moduleGraph,
133
134
  module: importedModule,
135
+ chunkGraph,
134
136
  request,
135
137
  exportName: dep.name,
136
138
  originModule: module,
@@ -167,8 +169,9 @@ class AsyncWebAssemblyJavascriptGenerator extends Generator {
167
169
  chunkGraph.getRenderedModuleHash(module, runtime)
168
170
  )}${importsObj ? `, ${importsObj})` : ")"}`;
169
171
 
170
- if (promises.length > 0)
172
+ if (promises.length > 0) {
171
173
  runtimeRequirements.add(RuntimeGlobals.asyncModule);
174
+ }
172
175
 
173
176
  const source = new RawSource(
174
177
  promises.length > 0
@@ -133,58 +133,55 @@ class AsyncWebAssemblyModulesPlugin {
133
133
  });
134
134
  });
135
135
 
136
- compilation.hooks.renderManifest.tap(
137
- "WebAssemblyModulesPlugin",
138
- (result, options) => {
139
- const { moduleGraph, chunkGraph, runtimeTemplate } = compilation;
140
- const {
141
- chunk,
142
- outputOptions,
143
- dependencyTemplates,
144
- codeGenerationResults
145
- } = options;
146
-
147
- for (const module of chunkGraph.getOrderedChunkModulesIterable(
148
- chunk,
149
- compareModulesByIdOrIdentifier(chunkGraph)
150
- )) {
151
- if (module.type === WEBASSEMBLY_MODULE_TYPE_ASYNC) {
152
- const filenameTemplate =
153
- /** @type {NonNullable<OutputOptions["webassemblyModuleFilename"]>} */
154
- (outputOptions.webassemblyModuleFilename);
155
-
156
- result.push({
157
- render: () =>
158
- this.renderModule(
159
- module,
160
- {
161
- chunk,
162
- dependencyTemplates,
163
- runtimeTemplate,
164
- moduleGraph,
165
- chunkGraph,
166
- codeGenerationResults
167
- },
168
- hooks
169
- ),
170
- filenameTemplate,
171
- pathOptions: {
136
+ compilation.hooks.renderManifest.tap(PLUGIN_NAME, (result, options) => {
137
+ const { moduleGraph, chunkGraph, runtimeTemplate } = compilation;
138
+ const {
139
+ chunk,
140
+ outputOptions,
141
+ dependencyTemplates,
142
+ codeGenerationResults
143
+ } = options;
144
+
145
+ for (const module of chunkGraph.getOrderedChunkModulesIterable(
146
+ chunk,
147
+ compareModulesByIdOrIdentifier(chunkGraph)
148
+ )) {
149
+ if (module.type === WEBASSEMBLY_MODULE_TYPE_ASYNC) {
150
+ const filenameTemplate =
151
+ /** @type {NonNullable<OutputOptions["webassemblyModuleFilename"]>} */
152
+ (outputOptions.webassemblyModuleFilename);
153
+
154
+ result.push({
155
+ render: () =>
156
+ this.renderModule(
172
157
  module,
173
- runtime: chunk.runtime,
174
- chunkGraph
175
- },
176
- auxiliary: true,
177
- identifier: `webassemblyAsyncModule${chunkGraph.getModuleId(
178
- module
179
- )}`,
180
- hash: chunkGraph.getModuleHash(module, chunk.runtime)
181
- });
182
- }
158
+ {
159
+ chunk,
160
+ dependencyTemplates,
161
+ runtimeTemplate,
162
+ moduleGraph,
163
+ chunkGraph,
164
+ codeGenerationResults
165
+ },
166
+ hooks
167
+ ),
168
+ filenameTemplate,
169
+ pathOptions: {
170
+ module,
171
+ runtime: chunk.runtime,
172
+ chunkGraph
173
+ },
174
+ auxiliary: true,
175
+ identifier: `webassemblyAsyncModule${chunkGraph.getModuleId(
176
+ module
177
+ )}`,
178
+ hash: chunkGraph.getModuleHash(module, chunk.runtime)
179
+ });
183
180
  }
184
-
185
- return result;
186
181
  }
187
- );
182
+
183
+ return result;
184
+ });
188
185
  }
189
186
  );
190
187
  }
@@ -172,9 +172,9 @@ const generateImportObject = (
172
172
 
173
173
  const moduleIdStringified = JSON.stringify(chunkGraph.getModuleId(module));
174
174
  if (waitForInstances.size === 1) {
175
- const moduleId = Array.from(waitForInstances.values())[0];
175
+ const moduleId = [...waitForInstances.values()][0];
176
176
  const promise = `installedWasmModules[${JSON.stringify(moduleId)}]`;
177
- const variable = Array.from(waitForInstances.keys())[0];
177
+ const variable = [...waitForInstances.keys()][0];
178
178
  return Template.asString([
179
179
  `${moduleIdStringified}: function() {`,
180
180
  Template.indent([
@@ -7,14 +7,13 @@
7
7
 
8
8
  const t = require("@webassemblyjs/ast");
9
9
  const { moduleContextFromModuleAST } = require("@webassemblyjs/ast");
10
- const { editWithAST, addWithAST } = require("@webassemblyjs/wasm-edit");
10
+ const { addWithAST, editWithAST } = require("@webassemblyjs/wasm-edit");
11
11
  const { decode } = require("@webassemblyjs/wasm-parser");
12
12
  const { RawSource } = require("webpack-sources");
13
13
  const Generator = require("../Generator");
14
14
  const { WEBASSEMBLY_TYPES } = require("../ModuleSourceTypesConstants");
15
- const WebAssemblyUtils = require("./WebAssemblyUtils");
16
-
17
15
  const WebAssemblyExportImportedDependency = require("../dependencies/WebAssemblyExportImportedDependency");
16
+ const WebAssemblyUtils = require("./WebAssemblyUtils");
18
17
 
19
18
  /** @typedef {import("webpack-sources").Source} Source */
20
19
  /** @typedef {import("../DependencyTemplates")} DependencyTemplates */
@@ -42,8 +42,9 @@ const getInitialModuleChains = (
42
42
  for (const connection of moduleGraph.getIncomingConnections(head)) {
43
43
  const newHead = connection.originModule;
44
44
  if (newHead) {
45
- if (!chunkGraph.getModuleChunks(newHead).some(c => c.canBeInitial()))
45
+ if (!chunkGraph.getModuleChunks(newHead).some(c => c.canBeInitial())) {
46
46
  continue;
47
+ }
47
48
  final = false;
48
49
  if (alreadyReferencedModules.has(newHead)) continue;
49
50
  alreadyReferencedModules.add(newHead);
@@ -76,7 +77,7 @@ const getInitialModuleChains = (
76
77
  for (const result of incompleteResults) {
77
78
  results.add(result);
78
79
  }
79
- return Array.from(results);
80
+ return [...results];
80
81
  };
81
82
 
82
83
  module.exports = class WebAssemblyInInitialChunkError extends WebpackError {
@@ -97,6 +97,7 @@ class WebAssemblyJavascriptGenerator extends Generator {
97
97
  initParams.push(
98
98
  runtimeTemplate.exportFromImport({
99
99
  moduleGraph,
100
+ chunkGraph,
100
101
  module: importedModule,
101
102
  request: dep.request,
102
103
  importVar: importData.importVar,
@@ -129,6 +130,7 @@ class WebAssemblyJavascriptGenerator extends Generator {
129
130
  `${exportProp} = ${runtimeTemplate.exportFromImport({
130
131
  moduleGraph,
131
132
  module: /** @type {Module} */ (moduleGraph.getModule(dep)),
133
+ chunkGraph,
132
134
  request: dep.request,
133
135
  importVar: importData.importVar,
134
136
  originModule: module,
@@ -158,6 +160,7 @@ class WebAssemblyJavascriptGenerator extends Generator {
158
160
  ([module, { importVar, request, reexports }]) => {
159
161
  const importStatement = runtimeTemplate.importStatement({
160
162
  module,
163
+ moduleGraph,
161
164
  chunkGraph,
162
165
  request,
163
166
  importVar,
@@ -62,5 +62,5 @@ const getUsedDependencies = (moduleGraph, module, mangle) => {
62
62
  return array;
63
63
  };
64
64
 
65
- module.exports.getUsedDependencies = getUsedDependencies;
66
65
  module.exports.MANGLED_MODULE = MANGLED_MODULE;
66
+ module.exports.getUsedDependencies = getUsedDependencies;
@@ -9,6 +9,9 @@ const Compilation = require("../Compilation");
9
9
  const RuntimeGlobals = require("../RuntimeGlobals");
10
10
  const RuntimeModule = require("../RuntimeModule");
11
11
  const Template = require("../Template");
12
+ const {
13
+ generateJavascriptHMR
14
+ } = require("../hmr/JavascriptHotModuleReplacementHelper");
12
15
  const chunkHasJs = require("../javascript/JavascriptModulesPlugin").chunkHasJs;
13
16
  const { getInitialChunkIds } = require("../javascript/StartupHelpers");
14
17
  const compileBooleanMatcher = require("../util/compileBooleanMatcher");
@@ -363,28 +366,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
363
366
  ]
364
367
  )};`,
365
368
  "",
366
- Template.getFunctionContent(
367
- require("../hmr/JavascriptHotModuleReplacement.runtime.js")
368
- )
369
- .replace(/\$key\$/g, "jsonp")
370
- .replace(/\$installedChunks\$/g, "installedChunks")
371
- .replace(/\$loadUpdateChunk\$/g, "loadUpdateChunk")
372
- .replace(/\$moduleCache\$/g, RuntimeGlobals.moduleCache)
373
- .replace(/\$moduleFactories\$/g, RuntimeGlobals.moduleFactories)
374
- .replace(
375
- /\$ensureChunkHandlers\$/g,
376
- RuntimeGlobals.ensureChunkHandlers
377
- )
378
- .replace(/\$hasOwnProperty\$/g, RuntimeGlobals.hasOwnProperty)
379
- .replace(/\$hmrModuleData\$/g, RuntimeGlobals.hmrModuleData)
380
- .replace(
381
- /\$hmrDownloadUpdateHandlers\$/g,
382
- RuntimeGlobals.hmrDownloadUpdateHandlers
383
- )
384
- .replace(
385
- /\$hmrInvalidateModuleHandlers\$/g,
386
- RuntimeGlobals.hmrInvalidateModuleHandlers
387
- )
369
+ generateJavascriptHMR("jsonp")
388
370
  ])
389
371
  : "// no HMR",
390
372
  "",
package/lib/webpack.js CHANGED
@@ -6,14 +6,14 @@
6
6
  "use strict";
7
7
 
8
8
  const util = require("util");
9
- const webpackOptionsSchemaCheck = require("../schemas/WebpackOptions.check.js");
9
+ const webpackOptionsSchemaCheck = require("../schemas/WebpackOptions.check");
10
10
  const webpackOptionsSchema = require("../schemas/WebpackOptions.json");
11
11
  const Compiler = require("./Compiler");
12
12
  const MultiCompiler = require("./MultiCompiler");
13
13
  const WebpackOptionsApply = require("./WebpackOptionsApply");
14
14
  const {
15
- applyWebpackOptionsDefaults,
16
- applyWebpackOptionsBaseDefaults
15
+ applyWebpackOptionsBaseDefaults,
16
+ applyWebpackOptionsDefaults
17
17
  } = require("./config/defaults");
18
18
  const { getNormalizedWebpackOptions } = require("./config/normalization");
19
19
  const NodeEnvironmentPlugin = require("./node/NodeEnvironmentPlugin");
@@ -115,8 +115,7 @@ const createCompiler = (rawOptions, compilerIndex) => {
115
115
  * @param {Array<T> | T} options options
116
116
  * @returns {Array<T>} array of options
117
117
  */
118
- const asArray = options =>
119
- Array.isArray(options) ? Array.from(options) : [options];
118
+ const asArray = options => (Array.isArray(options) ? [...options] : [options]);
120
119
 
121
120
  const webpack = /** @type {WebpackFunctionSingle & WebpackFunctionMulti} */ (
122
121
  /**
@@ -104,4 +104,5 @@ class ImportScriptsChunkLoadingPlugin {
104
104
  });
105
105
  }
106
106
  }
107
+
107
108
  module.exports = ImportScriptsChunkLoadingPlugin;
@@ -8,8 +8,11 @@ const RuntimeGlobals = require("../RuntimeGlobals");
8
8
  const RuntimeModule = require("../RuntimeModule");
9
9
  const Template = require("../Template");
10
10
  const {
11
- getChunkFilenameTemplate,
12
- chunkHasJs
11
+ generateJavascriptHMR
12
+ } = require("../hmr/JavascriptHotModuleReplacementHelper");
13
+ const {
14
+ chunkHasJs,
15
+ getChunkFilenameTemplate
13
16
  } = require("../javascript/JavascriptModulesPlugin");
14
17
  const { getInitialChunkIds } = require("../javascript/StartupHelpers");
15
18
  const compileBooleanMatcher = require("../util/compileBooleanMatcher");
@@ -199,28 +202,7 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
199
202
  ]),
200
203
  "}",
201
204
  "",
202
- Template.getFunctionContent(
203
- require("../hmr/JavascriptHotModuleReplacement.runtime.js")
204
- )
205
- .replace(/\$key\$/g, "importScripts")
206
- .replace(/\$installedChunks\$/g, "installedChunks")
207
- .replace(/\$loadUpdateChunk\$/g, "loadUpdateChunk")
208
- .replace(/\$moduleCache\$/g, RuntimeGlobals.moduleCache)
209
- .replace(/\$moduleFactories\$/g, RuntimeGlobals.moduleFactories)
210
- .replace(
211
- /\$ensureChunkHandlers\$/g,
212
- RuntimeGlobals.ensureChunkHandlers
213
- )
214
- .replace(/\$hasOwnProperty\$/g, RuntimeGlobals.hasOwnProperty)
215
- .replace(/\$hmrModuleData\$/g, RuntimeGlobals.hmrModuleData)
216
- .replace(
217
- /\$hmrDownloadUpdateHandlers\$/g,
218
- RuntimeGlobals.hmrDownloadUpdateHandlers
219
- )
220
- .replace(
221
- /\$hmrInvalidateModuleHandlers\$/g,
222
- RuntimeGlobals.hmrInvalidateModuleHandlers
223
- )
205
+ generateJavascriptHMR("importScripts")
224
206
  ])
225
207
  : "// no HMR",
226
208
  "",
@@ -22,4 +22,5 @@ class WebWorkerTemplatePlugin {
22
22
  new EnableChunkLoadingPlugin("import-scripts").apply(compiler);
23
23
  }
24
24
  }
25
+
25
26
  module.exports = WebWorkerTemplatePlugin;