webpack 5.99.8 → 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 (314) hide show
  1. package/README.md +0 -3
  2. package/bin/webpack.js +8 -2
  3. package/hot/log.js +15 -15
  4. package/hot/poll.js +1 -0
  5. package/lib/APIPlugin.js +3 -3
  6. package/lib/AbstractMethodError.js +1 -0
  7. package/lib/AutomaticPrefetchPlugin.js +1 -0
  8. package/lib/BannerPlugin.js +1 -1
  9. package/lib/CacheFacade.js +2 -1
  10. package/lib/CaseSensitiveModulesWarning.js +4 -4
  11. package/lib/Chunk.js +6 -6
  12. package/lib/ChunkGraph.js +37 -32
  13. package/lib/ChunkGroup.js +17 -10
  14. package/lib/ChunkTemplate.js +1 -1
  15. package/lib/CleanPlugin.js +94 -17
  16. package/lib/CodeGenerationResults.js +1 -1
  17. package/lib/CompatibilityPlugin.js +5 -2
  18. package/lib/Compilation.js +77 -71
  19. package/lib/Compiler.js +46 -16
  20. package/lib/ConcatenationScope.js +15 -6
  21. package/lib/ConstPlugin.js +65 -45
  22. package/lib/ContextModule.js +16 -12
  23. package/lib/ContextModuleFactory.js +4 -3
  24. package/lib/ContextReplacementPlugin.js +4 -2
  25. package/lib/CssModule.js +2 -3
  26. package/lib/DefinePlugin.js +111 -3
  27. package/lib/DelegatedModuleFactoryPlugin.js +18 -18
  28. package/lib/Dependency.js +16 -12
  29. package/lib/DependencyTemplate.js +1 -0
  30. package/lib/DllEntryPlugin.js +3 -1
  31. package/lib/DllPlugin.js +4 -3
  32. package/lib/DllReferencePlugin.js +2 -2
  33. package/lib/DynamicEntryPlugin.js +1 -1
  34. package/lib/EntryOptionPlugin.js +5 -0
  35. package/lib/ErrorHelpers.js +4 -4
  36. package/lib/EvalDevToolModulePlugin.js +3 -3
  37. package/lib/EvalSourceMapDevToolPlugin.js +7 -7
  38. package/lib/ExportsInfo.js +48 -39
  39. package/lib/ExternalModule.js +15 -11
  40. package/lib/ExternalModuleFactoryPlugin.js +5 -2
  41. package/lib/FileSystemInfo.js +51 -38
  42. package/lib/FlagDependencyExportsPlugin.js +14 -7
  43. package/lib/FlagDependencyUsagePlugin.js +1 -1
  44. package/lib/Generator.js +14 -1
  45. package/lib/HookWebpackError.js +1 -0
  46. package/lib/HotModuleReplacementPlugin.js +77 -50
  47. package/lib/IgnorePlugin.js +1 -1
  48. package/lib/InvalidDependenciesModuleWarning.js +1 -1
  49. package/lib/JavascriptMetaInfoPlugin.js +0 -1
  50. package/lib/LibManifestPlugin.js +4 -2
  51. package/lib/LoaderOptionsPlugin.js +6 -4
  52. package/lib/MainTemplate.js +2 -2
  53. package/lib/Module.js +21 -6
  54. package/lib/ModuleFactory.js +1 -0
  55. package/lib/ModuleGraph.js +24 -2
  56. package/lib/ModuleGraphConnection.js +5 -5
  57. package/lib/ModuleInfoHeaderPlugin.js +2 -1
  58. package/lib/ModuleParseError.js +1 -0
  59. package/lib/ModuleSourceTypesConstants.js +12 -12
  60. package/lib/ModuleTemplate.js +1 -1
  61. package/lib/ModuleTypeConstants.js +21 -21
  62. package/lib/MultiCompiler.js +6 -6
  63. package/lib/NormalModule.js +61 -56
  64. package/lib/NormalModuleFactory.js +52 -37
  65. package/lib/NormalModuleReplacementPlugin.js +1 -1
  66. package/lib/NullFactory.js +1 -0
  67. package/lib/OptimizationStages.js +1 -1
  68. package/lib/Parser.js +1 -0
  69. package/lib/ProgressPlugin.js +12 -5
  70. package/lib/ProvidePlugin.js +5 -1
  71. package/lib/RecordIdsPlugin.js +3 -3
  72. package/lib/RuntimeGlobals.js +175 -155
  73. package/lib/RuntimeModule.js +1 -0
  74. package/lib/RuntimePlugin.js +34 -8
  75. package/lib/RuntimeTemplate.js +111 -11
  76. package/lib/SourceMapDevToolModuleOptionsPlugin.js +15 -25
  77. package/lib/SourceMapDevToolPlugin.js +19 -17
  78. package/lib/Template.js +2 -2
  79. package/lib/TemplatedPathPlugin.js +1 -1
  80. package/lib/WarnDeprecatedOptionPlugin.js +7 -8
  81. package/lib/WatchIgnorePlugin.js +4 -3
  82. package/lib/WebpackIsIncludedPlugin.js +2 -1
  83. package/lib/WebpackOptionsApply.js +115 -27
  84. package/lib/asset/AssetGenerator.js +26 -21
  85. package/lib/asset/AssetModulesPlugin.js +19 -17
  86. package/lib/asset/AssetSourceGenerator.js +11 -9
  87. package/lib/asset/RawDataUrlModule.js +4 -2
  88. package/lib/async-modules/AwaitDependenciesInitFragment.js +1 -1
  89. package/lib/buildChunkGraph.js +6 -3
  90. package/lib/cache/AddBuildDependenciesPlugin.js +5 -6
  91. package/lib/cache/IdleFileCachePlugin.js +7 -4
  92. package/lib/cache/MemoryCachePlugin.js +1 -0
  93. package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
  94. package/lib/cache/PackFileCacheStrategy.js +26 -20
  95. package/lib/cache/ResolverCachePlugin.js +16 -8
  96. package/lib/cli.js +15 -10
  97. package/lib/config/browserslistTargetHandler.js +3 -3
  98. package/lib/config/defaults.js +25 -17
  99. package/lib/config/normalization.js +2 -1
  100. package/lib/config/target.js +6 -5
  101. package/lib/container/ContainerPlugin.js +1 -1
  102. package/lib/container/ContainerReferencePlugin.js +1 -1
  103. package/lib/container/FallbackModule.js +2 -1
  104. package/lib/container/HoistContainerReferencesPlugin.js +1 -1
  105. package/lib/container/ModuleFederationPlugin.js +2 -2
  106. package/lib/container/RemoteModule.js +1 -1
  107. package/lib/css/CssGenerator.js +9 -6
  108. package/lib/css/CssModulesPlugin.js +44 -31
  109. package/lib/css/CssParser.js +6 -4
  110. package/lib/css/walkCssTokens.js +33 -37
  111. package/lib/debug/ProfilingPlugin.js +6 -6
  112. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +8 -8
  113. package/lib/dependencies/AMDPlugin.js +12 -8
  114. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +28 -26
  115. package/lib/dependencies/CachedConstDependency.js +1 -5
  116. package/lib/dependencies/CommonJsExportRequireDependency.js +6 -4
  117. package/lib/dependencies/CommonJsExportsParserPlugin.js +22 -25
  118. package/lib/dependencies/CommonJsFullRequireDependency.js +1 -9
  119. package/lib/dependencies/CommonJsImportsParserPlugin.js +100 -114
  120. package/lib/dependencies/CommonJsPlugin.js +15 -16
  121. package/lib/dependencies/ContextDependencyHelpers.js +2 -1
  122. package/lib/dependencies/ContextDependencyTemplateAsId.js +1 -0
  123. package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +1 -0
  124. package/lib/dependencies/CssIcssExportDependency.js +1 -1
  125. package/lib/dependencies/CssLocalIdentifierDependency.js +2 -2
  126. package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
  127. package/lib/dependencies/CssUrlDependency.js +1 -1
  128. package/lib/dependencies/DynamicExports.js +9 -9
  129. package/lib/dependencies/ExportsInfoDependency.js +1 -1
  130. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +122 -101
  131. package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
  132. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +95 -19
  133. package/lib/dependencies/HarmonyExportInitFragment.js +1 -1
  134. package/lib/dependencies/HarmonyImportDependency.js +11 -5
  135. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +238 -162
  136. package/lib/dependencies/HarmonyImportSideEffectDependency.js +4 -1
  137. package/lib/dependencies/HarmonyImportSpecifierDependency.js +20 -9
  138. package/lib/dependencies/HarmonyModulesPlugin.js +23 -12
  139. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -0
  140. package/lib/dependencies/ImportMetaContextPlugin.js +2 -1
  141. package/lib/dependencies/ImportMetaPlugin.js +2 -2
  142. package/lib/dependencies/ImportParserPlugin.js +40 -9
  143. package/lib/dependencies/ImportPlugin.js +3 -1
  144. package/lib/dependencies/LoaderPlugin.js +1 -0
  145. package/lib/dependencies/ModuleDependency.js +1 -1
  146. package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +1 -0
  147. package/lib/dependencies/RequireContextPlugin.js +3 -1
  148. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +3 -0
  149. package/lib/dependencies/RequireEnsurePlugin.js +6 -6
  150. package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +33 -34
  151. package/lib/dependencies/RequireIncludePlugin.js +1 -0
  152. package/lib/dependencies/RuntimeRequirementsDependency.js +1 -1
  153. package/lib/dependencies/SystemPlugin.js +1 -1
  154. package/lib/dependencies/URLContextDependency.js +65 -0
  155. package/lib/dependencies/URLDependency.js +1 -1
  156. package/lib/dependencies/URLPlugin.js +17 -157
  157. package/lib/dependencies/WorkerPlugin.js +23 -10
  158. package/lib/dependencies/processExportInfo.js +2 -1
  159. package/lib/esm/ModuleChunkFormatPlugin.js +269 -185
  160. package/lib/esm/ModuleChunkLoadingPlugin.js +39 -1
  161. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +73 -6
  162. package/lib/hmr/HotModuleReplacement.runtime.js +0 -1
  163. package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -1
  164. package/lib/hmr/JavascriptHotModuleReplacementHelper.js +37 -0
  165. package/lib/hmr/LazyCompilationPlugin.js +4 -2
  166. package/lib/hmr/lazyCompilationBackend.js +4 -2
  167. package/lib/ids/ChunkModuleIdRangePlugin.js +6 -3
  168. package/lib/ids/DeterministicChunkIdsPlugin.js +30 -35
  169. package/lib/ids/DeterministicModuleIdsPlugin.js +4 -3
  170. package/lib/ids/HashedModuleIdsPlugin.js +5 -4
  171. package/lib/ids/IdHelpers.js +21 -17
  172. package/lib/ids/NamedChunkIdsPlugin.js +5 -5
  173. package/lib/ids/NamedModuleIdsPlugin.js +4 -4
  174. package/lib/ids/NaturalChunkIdsPlugin.js +2 -1
  175. package/lib/ids/NaturalModuleIdsPlugin.js +1 -1
  176. package/lib/ids/OccurrenceChunkIdsPlugin.js +3 -2
  177. package/lib/ids/OccurrenceModuleIdsPlugin.js +1 -1
  178. package/lib/ids/SyncModuleIdsPlugin.js +1 -1
  179. package/lib/index.js +13 -3
  180. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +113 -119
  181. package/lib/javascript/BasicEvaluatedExpression.js +2 -1
  182. package/lib/javascript/ChunkHelpers.js +1 -0
  183. package/lib/javascript/CommonJsChunkFormatPlugin.js +121 -136
  184. package/lib/javascript/EnableChunkLoadingPlugin.js +6 -3
  185. package/lib/javascript/JavascriptGenerator.js +14 -2
  186. package/lib/javascript/JavascriptModulesPlugin.js +68 -27
  187. package/lib/javascript/JavascriptParser.js +136 -81
  188. package/lib/javascript/JavascriptParserHelpers.js +41 -41
  189. package/lib/javascript/StartupHelpers.js +17 -17
  190. package/lib/json/JsonGenerator.js +4 -2
  191. package/lib/json/JsonModulesPlugin.js +2 -2
  192. package/lib/json/JsonParser.js +1 -1
  193. package/lib/library/AbstractLibraryPlugin.js +6 -2
  194. package/lib/library/AssignLibraryPlugin.js +21 -6
  195. package/lib/library/EnableLibraryPlugin.js +23 -3
  196. package/lib/library/ModuleLibraryPlugin.js +4 -1
  197. package/lib/library/UmdLibraryPlugin.js +15 -6
  198. package/lib/logging/createConsoleLogger.js +3 -3
  199. package/lib/logging/runtime.js +9 -9
  200. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +4 -22
  201. package/lib/node/RequireChunkLoadingRuntimeModule.js +4 -22
  202. package/lib/node/nodeConsole.js +4 -2
  203. package/lib/optimize/AggressiveMergingPlugin.js +45 -46
  204. package/lib/optimize/AggressiveSplittingPlugin.js +13 -12
  205. package/lib/optimize/ConcatenatedModule.js +227 -57
  206. package/lib/optimize/EnsureChunkConditionsPlugin.js +58 -58
  207. package/lib/optimize/FlagIncludedChunksPlugin.js +3 -1
  208. package/lib/optimize/InnerGraph.js +115 -112
  209. package/lib/optimize/InnerGraphPlugin.js +2 -2
  210. package/lib/optimize/LimitChunkCountPlugin.js +4 -2
  211. package/lib/optimize/MangleExportsPlugin.js +4 -3
  212. package/lib/optimize/MergeDuplicateChunksPlugin.js +80 -81
  213. package/lib/optimize/MinChunkSizePlugin.js +6 -3
  214. package/lib/optimize/ModuleConcatenationPlugin.js +31 -22
  215. package/lib/optimize/RealContentHashPlugin.js +26 -20
  216. package/lib/optimize/RemoveEmptyChunksPlugin.js +2 -1
  217. package/lib/optimize/RemoveParentModulesPlugin.js +1 -0
  218. package/lib/optimize/SideEffectsFlagPlugin.js +6 -3
  219. package/lib/optimize/SplitChunksPlugin.js +16 -13
  220. package/lib/rules/BasicEffectRulePlugin.js +4 -2
  221. package/lib/rules/BasicMatcherRulePlugin.js +3 -1
  222. package/lib/rules/ObjectMatcherRulePlugin.js +3 -1
  223. package/lib/rules/RuleSetCompiler.js +7 -4
  224. package/lib/rules/UseEffectRulePlugin.js +3 -1
  225. package/lib/runtime/AsyncModuleRuntimeModule.js +64 -9
  226. package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +1 -1
  227. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +214 -0
  228. package/lib/runtime/RuntimeIdRuntimeModule.js +2 -1
  229. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +8 -7
  230. package/lib/schemes/DataUriPlugin.js +3 -1
  231. package/lib/schemes/FileUriPlugin.js +1 -1
  232. package/lib/schemes/HttpUriPlugin.js +27 -19
  233. package/lib/schemes/VirtualUrlPlugin.js +222 -0
  234. package/lib/serialization/AggregateErrorSerializer.js +1 -1
  235. package/lib/serialization/BinaryMiddleware.js +5 -4
  236. package/lib/serialization/FileMiddleware.js +7 -4
  237. package/lib/serialization/ObjectMiddleware.js +14 -8
  238. package/lib/serialization/Serializer.js +5 -3
  239. package/lib/serialization/SerializerMiddleware.js +2 -0
  240. package/lib/sharing/ConsumeSharedModule.js +1 -1
  241. package/lib/sharing/ConsumeSharedPlugin.js +3 -3
  242. package/lib/sharing/ConsumeSharedRuntimeModule.js +2 -2
  243. package/lib/sharing/ProvideSharedModule.js +1 -1
  244. package/lib/sharing/ProvideSharedPlugin.js +6 -3
  245. package/lib/sharing/SharePlugin.js +2 -1
  246. package/lib/sharing/ShareRuntimeModule.js +3 -5
  247. package/lib/sharing/utils.js +34 -34
  248. package/lib/stats/DefaultStatsFactoryPlugin.js +49 -46
  249. package/lib/stats/DefaultStatsPresetPlugin.js +4 -2
  250. package/lib/stats/DefaultStatsPrinterPlugin.js +28 -22
  251. package/lib/stats/StatsFactory.js +4 -2
  252. package/lib/stats/StatsPrinter.js +3 -2
  253. package/lib/url/URLParserPlugin.js +266 -0
  254. package/lib/util/ArrayQueue.js +1 -1
  255. package/lib/util/AsyncQueue.js +1 -1
  256. package/lib/util/Hash.js +2 -0
  257. package/lib/util/IterableHelpers.js +1 -1
  258. package/lib/util/LazyBucketSortedSet.js +2 -1
  259. package/lib/util/LazySet.js +11 -6
  260. package/lib/util/ParallelismFactorCalculator.js +1 -1
  261. package/lib/util/SetHelpers.js +3 -3
  262. package/lib/util/SortableSet.js +2 -2
  263. package/lib/util/StackedCacheMap.js +3 -1
  264. package/lib/util/StackedMap.js +2 -2
  265. package/lib/util/StringXor.js +1 -0
  266. package/lib/util/TupleSet.js +1 -0
  267. package/lib/util/URLAbsoluteSpecifier.js +1 -1
  268. package/lib/util/cleverMerge.js +12 -8
  269. package/lib/util/comparators.js +154 -127
  270. package/lib/util/compileBooleanMatcher.js +8 -3
  271. package/lib/util/concatenate.js +8 -7
  272. package/lib/util/conventions.js +72 -73
  273. package/lib/util/create-schema-validation.js +2 -1
  274. package/lib/util/createHash.js +10 -4
  275. package/lib/util/deprecation.js +69 -66
  276. package/lib/util/deterministicGrouping.js +4 -2
  277. package/lib/util/extractUrlAndGlobal.js +1 -1
  278. package/lib/util/findGraphRoots.js +2 -2
  279. package/lib/util/fs.js +30 -23
  280. package/lib/util/hash/md4.js +2 -2
  281. package/lib/util/hash/wasm-hash.js +4 -2
  282. package/lib/util/identifier.js +13 -12
  283. package/lib/util/internalSerializables.js +2 -0
  284. package/lib/util/magicComment.js +5 -5
  285. package/lib/util/processAsyncTree.js +1 -1
  286. package/lib/util/propertyAccess.js +1 -1
  287. package/lib/util/propertyName.js +1 -1
  288. package/lib/util/registerExternalSerializer.js +1 -2
  289. package/lib/util/removeBOM.js +1 -1
  290. package/lib/util/runtime.js +29 -21
  291. package/lib/util/semver.js +1 -1
  292. package/lib/util/serialization.js +3 -0
  293. package/lib/util/source.js +3 -2
  294. package/lib/validateSchema.js +1 -0
  295. package/lib/wasm/EnableWasmLoadingPlugin.js +6 -3
  296. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +4 -1
  297. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +46 -49
  298. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +2 -2
  299. package/lib/wasm-sync/WebAssemblyGenerator.js +2 -3
  300. package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +3 -2
  301. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +3 -0
  302. package/lib/wasm-sync/WebAssemblyUtils.js +1 -1
  303. package/lib/web/JsonpChunkLoadingRuntimeModule.js +4 -22
  304. package/lib/webpack.js +4 -5
  305. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +1 -0
  306. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +6 -24
  307. package/lib/webworker/WebWorkerTemplatePlugin.js +1 -0
  308. package/package.json +121 -114
  309. package/schemas/WebpackOptions.check.js +1 -1
  310. package/schemas/WebpackOptions.json +17 -0
  311. package/schemas/plugins/schemes/VirtualUrlPlugin.check.d.ts +7 -0
  312. package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +6 -0
  313. package/schemas/plugins/schemes/VirtualUrlPlugin.json +77 -0
  314. package/types.d.ts +1261 -366
@@ -25,6 +25,7 @@ const GetTrustedTypesPolicyRuntimeModule = require("./runtime/GetTrustedTypesPol
25
25
  const GlobalRuntimeModule = require("./runtime/GlobalRuntimeModule");
26
26
  const HasOwnPropertyRuntimeModule = require("./runtime/HasOwnPropertyRuntimeModule");
27
27
  const LoadScriptRuntimeModule = require("./runtime/LoadScriptRuntimeModule");
28
+ const MakeDeferredNamespaceObjectRuntime = require("./runtime/MakeDeferredNamespaceObjectRuntime");
28
29
  const MakeNamespaceObjectRuntimeModule = require("./runtime/MakeNamespaceObjectRuntimeModule");
29
30
  const NonceRuntimeModule = require("./runtime/NonceRuntimeModule");
30
31
  const OnChunksLoadedRuntimeModule = require("./runtime/OnChunksLoadedRuntimeModule");
@@ -79,7 +80,8 @@ const GLOBALS_ON_REQUIRE = [
79
80
  RuntimeGlobals.initializeSharing,
80
81
  RuntimeGlobals.loadScript,
81
82
  RuntimeGlobals.systemContext,
82
- RuntimeGlobals.onChunksLoaded
83
+ RuntimeGlobals.onChunksLoaded,
84
+ RuntimeGlobals.makeDeferredNamespaceObject
83
85
  ];
84
86
 
85
87
  const MODULE_DEPENDENCIES = {
@@ -97,6 +99,13 @@ const TREE_DEPENDENCIES = {
97
99
  RuntimeGlobals.makeNamespaceObject,
98
100
  RuntimeGlobals.require
99
101
  ],
102
+ [RuntimeGlobals.makeDeferredNamespaceObject]: [
103
+ RuntimeGlobals.definePropertyGetters,
104
+ RuntimeGlobals.makeNamespaceObject,
105
+ RuntimeGlobals.createFakeNamespaceObject,
106
+ RuntimeGlobals.hasOwnProperty,
107
+ RuntimeGlobals.require
108
+ ],
100
109
  [RuntimeGlobals.initializeSharing]: [RuntimeGlobals.shareScopeMap],
101
110
  [RuntimeGlobals.shareScopeMap]: [RuntimeGlobals.hasOwnProperty]
102
111
  };
@@ -184,6 +193,17 @@ class RuntimePlugin {
184
193
  );
185
194
  return true;
186
195
  });
196
+ compilation.hooks.runtimeRequirementInTree
197
+ .for(RuntimeGlobals.makeDeferredNamespaceObject)
198
+ .tap("RuntimePlugin", (chunk, runtimeRequirement) => {
199
+ compilation.addRuntimeModule(
200
+ chunk,
201
+ new MakeDeferredNamespaceObjectRuntime(
202
+ runtimeRequirement.has(RuntimeGlobals.asyncModule)
203
+ )
204
+ );
205
+ return true;
206
+ });
187
207
  compilation.hooks.runtimeRequirementInTree
188
208
  .for(RuntimeGlobals.hasOwnProperty)
189
209
  .tap(PLUGIN_NAME, chunk => {
@@ -246,7 +266,11 @@ class RuntimePlugin {
246
266
  compilation.hooks.runtimeRequirementInTree
247
267
  .for(RuntimeGlobals.asyncModule)
248
268
  .tap(PLUGIN_NAME, chunk => {
249
- compilation.addRuntimeModule(chunk, new AsyncModuleRuntimeModule());
269
+ const experiments = compilation.options.experiments;
270
+ compilation.addRuntimeModule(
271
+ chunk,
272
+ new AsyncModuleRuntimeModule(experiments.deferImport)
273
+ );
250
274
  return true;
251
275
  });
252
276
  compilation.hooks.runtimeRequirementInTree
@@ -292,7 +316,7 @@ class RuntimePlugin {
292
316
  ? compilation.outputOptions.filename
293
317
  : compilation.outputOptions.chunkFilename)
294
318
  ),
295
- false
319
+ set.has(RuntimeGlobals.hmrDownloadUpdateHandlers)
296
320
  )
297
321
  );
298
322
  return true;
@@ -330,15 +354,16 @@ class RuntimePlugin {
330
354
  /** @type {NonNullable<OutputNormalized["hotUpdateChunkFilename"]>} */
331
355
  (compilation.outputOptions.hotUpdateChunkFilename)
332
356
  )
333
- )
357
+ ) {
334
358
  set.add(RuntimeGlobals.getFullHash);
359
+ }
335
360
  compilation.addRuntimeModule(
336
361
  chunk,
337
362
  new GetChunkFilenameRuntimeModule(
338
363
  "javascript",
339
364
  "javascript update",
340
365
  RuntimeGlobals.getChunkUpdateScriptFilename,
341
- c =>
366
+ _chunk =>
342
367
  /** @type {NonNullable<OutputNormalized["hotUpdateChunkFilename"]>} */
343
368
  (compilation.outputOptions.hotUpdateChunkFilename),
344
369
  true
@@ -440,13 +465,13 @@ class RuntimePlugin {
440
465
  });
441
466
  compilation.hooks.runtimeRequirementInTree
442
467
  .for(RuntimeGlobals.relativeUrl)
443
- .tap(PLUGIN_NAME, (chunk, set) => {
468
+ .tap(PLUGIN_NAME, (chunk, _set) => {
444
469
  compilation.addRuntimeModule(chunk, new RelativeUrlRuntimeModule());
445
470
  return true;
446
471
  });
447
472
  compilation.hooks.runtimeRequirementInTree
448
473
  .for(RuntimeGlobals.onChunksLoaded)
449
- .tap(PLUGIN_NAME, (chunk, set) => {
474
+ .tap(PLUGIN_NAME, (chunk, _set) => {
450
475
  compilation.addRuntimeModule(
451
476
  chunk,
452
477
  new OnChunksLoadedRuntimeModule()
@@ -470,7 +495,7 @@ class RuntimePlugin {
470
495
  // TODO webpack 6: remove CompatRuntimeModule
471
496
  compilation.hooks.additionalTreeRuntimeRequirements.tap(
472
497
  PLUGIN_NAME,
473
- (chunk, set) => {
498
+ (chunk, _set) => {
474
499
  const { mainTemplate } = compilation;
475
500
  if (
476
501
  mainTemplate.hooks.bootstrap.isUsed() ||
@@ -495,4 +520,5 @@ class RuntimePlugin {
495
520
  });
496
521
  }
497
522
  }
523
+
498
524
  module.exports = RuntimePlugin;
@@ -8,6 +8,10 @@
8
8
  const InitFragment = require("./InitFragment");
9
9
  const RuntimeGlobals = require("./RuntimeGlobals");
10
10
  const Template = require("./Template");
11
+ const {
12
+ getMakeDeferredNamespaceModeFromExportsType,
13
+ getOptimizedDeferredModule
14
+ } = require("./runtime/MakeDeferredNamespaceObjectRuntime");
11
15
  const { equals } = require("./util/ArrayHelpers");
12
16
  const compileBooleanMatcher = require("./util/compileBooleanMatcher");
13
17
  const propertyAccess = require("./util/propertyAccess");
@@ -51,9 +55,7 @@ Module has these incoming connections: ${Array.from(
51
55
  `\n - ${
52
56
  connection.originModule && connection.originModule.identifier()
53
57
  } ${connection.dependency && connection.dependency.type} ${
54
- (connection.explanations &&
55
- Array.from(connection.explanations).join(", ")) ||
56
- ""
58
+ (connection.explanations && [...connection.explanations].join(", ")) || ""
57
59
  }`
58
60
  ).join("")}`;
59
61
 
@@ -72,8 +74,9 @@ function getGlobalObject(definition) {
72
74
  // call expression
73
75
  // expression in parentheses
74
76
  /^([_\p{L}][_0-9\p{L}]*)?\(.*\)$/iu.test(trimmed)
75
- )
77
+ ) {
76
78
  return trimmed;
79
+ }
77
80
 
78
81
  return `Object(${trimmed})`;
79
82
  }
@@ -216,8 +219,9 @@ class RuntimeTemplate {
216
219
  lastWasExpr = isExpr;
217
220
  }
218
221
  if (lastWasExpr) concatenationCost -= 3;
219
- if (typeof args[0] !== "string" && typeof args[1] === "string")
222
+ if (typeof args[0] !== "string" && typeof args[1] === "string") {
220
223
  concatenationCost -= 3;
224
+ }
221
225
 
222
226
  if (concatenationCost <= templateCost) return this._es5Concatenation(args);
223
227
 
@@ -770,8 +774,8 @@ class RuntimeTemplate {
770
774
  );
771
775
  runtimeRequirements.add(RuntimeGlobals.runtimeId);
772
776
  return compileBooleanMatcher.fromLists(
773
- Array.from(positiveRuntimeIds),
774
- Array.from(negativeRuntimeIds)
777
+ [...positiveRuntimeIds],
778
+ [...negativeRuntimeIds]
775
779
  )(RuntimeGlobals.runtimeId);
776
780
  }
777
781
 
@@ -779,22 +783,26 @@ class RuntimeTemplate {
779
783
  * @param {object} options options object
780
784
  * @param {boolean=} options.update whether a new variable should be created or the existing one updated
781
785
  * @param {Module} options.module the module
786
+ * @param {ModuleGraph} options.moduleGraph the module graph
782
787
  * @param {ChunkGraph} options.chunkGraph the chunk graph
783
788
  * @param {string} options.request the request that should be printed as comment
784
789
  * @param {string} options.importVar name of the import variable
785
790
  * @param {Module} options.originModule module in which the statement is emitted
786
791
  * @param {boolean=} options.weak true, if this is a weak dependency
787
792
  * @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements
793
+ * @param {boolean=} options.defer if set, the module will be deferred
788
794
  * @returns {[string, string]} the import statement and the compat statement
789
795
  */
790
796
  importStatement({
791
797
  update,
792
798
  module,
799
+ moduleGraph,
793
800
  chunkGraph,
794
801
  request,
795
802
  importVar,
796
803
  originModule,
797
804
  weak,
805
+ defer,
798
806
  runtimeRequirements
799
807
  }) {
800
808
  if (!module) {
@@ -805,6 +813,29 @@ class RuntimeTemplate {
805
813
  ""
806
814
  ];
807
815
  }
816
+
817
+ /** @type {Set<Module>} */
818
+ const innerAsyncDependencies = new Set();
819
+ defer = defer && (module.buildMeta ? !module.buildMeta.async : true);
820
+
821
+ if (this.compilation.options.experiments.deferImport && defer) {
822
+ const seen = new Set();
823
+ (function gatherInnerAsyncDependencies(mod) {
824
+ if (!moduleGraph.isAsync(mod) || seen.has(mod)) return;
825
+ seen.add(mod);
826
+ if (mod.buildMeta && mod.buildMeta.async) {
827
+ innerAsyncDependencies.add(mod);
828
+ } else {
829
+ for (const dep of mod.dependencies) {
830
+ const module = moduleGraph.getModule(dep);
831
+ if (module) {
832
+ gatherInnerAsyncDependencies(module);
833
+ }
834
+ }
835
+ }
836
+ })(module);
837
+ }
838
+
808
839
  if (chunkGraph.getModuleId(module) === null) {
809
840
  if (weak) {
810
841
  // only weak referenced modules don't get an id
@@ -840,9 +871,19 @@ class RuntimeTemplate {
840
871
  (originModule.buildMeta).strictHarmonyModule
841
872
  );
842
873
  runtimeRequirements.add(RuntimeGlobals.require);
843
- const importContent = `/* harmony import */ ${optDeclaration}${importVar} = ${RuntimeGlobals.require}(${moduleId});\n`;
874
+ let importContent;
875
+ if (defer) {
876
+ importContent = `/* deferred harmony import */ ${optDeclaration}${importVar} = ${getOptimizedDeferredModule(
877
+ this,
878
+ exportsType,
879
+ moduleId,
880
+ Array.from(innerAsyncDependencies, mod => chunkGraph.getModuleId(mod))
881
+ )};\n`;
882
+ } else {
883
+ importContent = `/* harmony import */ ${optDeclaration}${importVar} = ${RuntimeGlobals.require}(${moduleId});\n`;
884
+ }
844
885
 
845
- if (exportsType === "dynamic") {
886
+ if (exportsType === "dynamic" && !defer) {
846
887
  runtimeRequirements.add(RuntimeGlobals.compatGetDefaultExport);
847
888
  return [
848
889
  importContent,
@@ -856,6 +897,7 @@ class RuntimeTemplate {
856
897
  * @template GenerateContext
857
898
  * @param {object} options options
858
899
  * @param {ModuleGraph} options.moduleGraph the module graph
900
+ * @param {ChunkGraph} options.chunkGraph the chunk graph
859
901
  * @param {Module} options.module the module
860
902
  * @param {string} options.request the request
861
903
  * @param {string | string[]} options.exportName the export name
@@ -868,10 +910,12 @@ class RuntimeTemplate {
868
910
  * @param {InitFragment<GenerateContext>[]} options.initFragments init fragments will be added here
869
911
  * @param {RuntimeSpec} options.runtime runtime for which this code will be generated
870
912
  * @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements
913
+ * @param {boolean=} options.defer if true, the module will be deferred.
871
914
  * @returns {string} expression
872
915
  */
873
916
  exportFromImport({
874
917
  moduleGraph,
918
+ chunkGraph,
875
919
  module,
876
920
  request,
877
921
  exportName,
@@ -883,13 +927,16 @@ class RuntimeTemplate {
883
927
  importVar,
884
928
  initFragments,
885
929
  runtime,
886
- runtimeRequirements
930
+ runtimeRequirements,
931
+ defer
887
932
  }) {
888
933
  if (!module) {
889
934
  return this.missingModule({
890
935
  request
891
936
  });
892
937
  }
938
+
939
+ defer = defer && (module.buildMeta ? !module.buildMeta.async : true);
893
940
  if (!Array.isArray(exportName)) {
894
941
  exportName = exportName ? [exportName] : [];
895
942
  }
@@ -900,7 +947,21 @@ class RuntimeTemplate {
900
947
  );
901
948
 
902
949
  if (defaultInterop) {
950
+ // when the defaultInterop is used (when a ESM imports a CJS module),
903
951
  if (exportName.length > 0 && exportName[0] === "default") {
952
+ if (defer && exportsType !== "namespace") {
953
+ const access = `${importVar}.a${propertyAccess(exportName, 1)}`;
954
+ if (isCall || asiSafe === undefined) {
955
+ return access;
956
+ }
957
+ return asiSafe ? `(${access})` : `;(${access})`;
958
+ }
959
+ // accessing the .default property is same thing as `require()` the module.
960
+
961
+ // For example:
962
+ // import mod from "cjs"; mod.default.x;
963
+ // is translated to
964
+ // var mod = require("cjs"); mod.x;
904
965
  switch (exportsType) {
905
966
  case "dynamic":
906
967
  if (isCall) {
@@ -918,7 +979,11 @@ class RuntimeTemplate {
918
979
  break;
919
980
  }
920
981
  } else if (exportName.length > 0) {
982
+ // the property used is not .default.
983
+ // For example:
984
+ // import * as ns from "cjs"; cjs.prop;
921
985
  if (exportsType === "default-only") {
986
+ // in the strictest case, it is a runtime error (e.g. NodeJS behavior of CJS-ESM interop).
922
987
  return `/* non-default import from non-esm module */undefined${propertyAccess(
923
988
  exportName,
924
989
  1
@@ -929,10 +994,17 @@ class RuntimeTemplate {
929
994
  ) {
930
995
  return "/* __esModule */true";
931
996
  }
997
+ } else if (defer) {
998
+ // now exportName.length is 0
999
+ // fall through to the end of this function, create the namespace there.
932
1000
  } else if (
933
1001
  exportsType === "default-only" ||
934
1002
  exportsType === "default-with-named"
935
1003
  ) {
1004
+ // now exportName.length is 0, which means the namespace object is used in an unknown way
1005
+ // for example:
1006
+ // import * as ns from "cjs"; console.log(ns);
1007
+ // we will need to createFakeNamespaceObject that simulates ES Module namespace object
936
1008
  runtimeRequirements.add(RuntimeGlobals.createFakeNamespaceObject);
937
1009
  initFragments.push(
938
1010
  new InitFragment(
@@ -952,6 +1024,8 @@ class RuntimeTemplate {
952
1024
 
953
1025
  if (exportName.length > 0) {
954
1026
  const exportsInfo = moduleGraph.getExportsInfo(module);
1027
+ // in some case the exported item is renamed (get this by getUsedName). for example,
1028
+ // x.default might be emitted as x.Z (default is renamed to Z)
955
1029
  const used = exportsInfo.getUsedName(exportName, runtime);
956
1030
  if (!used) {
957
1031
  const comment = Template.toNormalComment(
@@ -962,7 +1036,9 @@ class RuntimeTemplate {
962
1036
  const comment = equals(used, exportName)
963
1037
  ? ""
964
1038
  : `${Template.toNormalComment(propertyAccess(exportName))} `;
965
- const access = `${importVar}${comment}${propertyAccess(used)}`;
1039
+ const access = `${importVar}${
1040
+ defer ? ".a" : ""
1041
+ }${comment}${propertyAccess(used)}`;
966
1042
  if (isCall && callContext === false) {
967
1043
  return asiSafe
968
1044
  ? `(0,${access})`
@@ -972,6 +1048,30 @@ class RuntimeTemplate {
972
1048
  }
973
1049
  return access;
974
1050
  }
1051
+ if (defer) {
1052
+ initFragments.push(
1053
+ new InitFragment(
1054
+ `var ${importVar}_deferred_namespace_cache;\n`,
1055
+ InitFragment.STAGE_CONSTANTS,
1056
+ -1,
1057
+ `${importVar}_deferred_namespace_cache`
1058
+ )
1059
+ );
1060
+
1061
+ runtimeRequirements.add(RuntimeGlobals.makeDeferredNamespaceObject);
1062
+ const id = chunkGraph.getModuleId(module);
1063
+ const type = getMakeDeferredNamespaceModeFromExportsType(exportsType);
1064
+ const init = `${
1065
+ RuntimeGlobals.makeDeferredNamespaceObject
1066
+ }(${JSON.stringify(id)}, ${type})`;
1067
+
1068
+ return `/*#__PURE__*/ ${
1069
+ asiSafe ? "" : asiSafe === false ? ";" : "Object"
1070
+ }(${importVar}_deferred_namespace_cache || (${importVar}_deferred_namespace_cache = ${init}))`;
1071
+ }
1072
+ // if we hit here, the importVar is either
1073
+ // - already a ES module namespace object
1074
+ // - or imported by a way that does not need interop.
975
1075
  return importVar;
976
1076
  }
977
1077
 
@@ -10,6 +10,8 @@ const JavascriptModulesPlugin = require("./javascript/JavascriptModulesPlugin");
10
10
  /** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").SourceMapDevToolPluginOptions} SourceMapDevToolPluginOptions */
11
11
  /** @typedef {import("./Compilation")} Compilation */
12
12
 
13
+ const PLUGIN_NAME = "SourceMapDevToolModuleOptionsPlugin";
14
+
13
15
  class SourceMapDevToolModuleOptionsPlugin {
14
16
  /**
15
17
  * @param {SourceMapDevToolPluginOptions} options options
@@ -25,34 +27,22 @@ class SourceMapDevToolModuleOptionsPlugin {
25
27
  apply(compilation) {
26
28
  const options = this.options;
27
29
  if (options.module !== false) {
28
- compilation.hooks.buildModule.tap(
29
- "SourceMapDevToolModuleOptionsPlugin",
30
- module => {
31
- module.useSourceMap = true;
32
- }
33
- );
34
- compilation.hooks.runtimeModule.tap(
35
- "SourceMapDevToolModuleOptionsPlugin",
36
- module => {
37
- module.useSourceMap = true;
38
- }
39
- );
30
+ compilation.hooks.buildModule.tap(PLUGIN_NAME, module => {
31
+ module.useSourceMap = true;
32
+ });
33
+ compilation.hooks.runtimeModule.tap(PLUGIN_NAME, module => {
34
+ module.useSourceMap = true;
35
+ });
40
36
  } else {
41
- compilation.hooks.buildModule.tap(
42
- "SourceMapDevToolModuleOptionsPlugin",
43
- module => {
44
- module.useSimpleSourceMap = true;
45
- }
46
- );
47
- compilation.hooks.runtimeModule.tap(
48
- "SourceMapDevToolModuleOptionsPlugin",
49
- module => {
50
- module.useSimpleSourceMap = true;
51
- }
52
- );
37
+ compilation.hooks.buildModule.tap(PLUGIN_NAME, module => {
38
+ module.useSimpleSourceMap = true;
39
+ });
40
+ compilation.hooks.runtimeModule.tap(PLUGIN_NAME, module => {
41
+ module.useSimpleSourceMap = true;
42
+ });
53
43
  }
54
44
  JavascriptModulesPlugin.getCompilationHooks(compilation).useSourceMap.tap(
55
- "SourceMapDevToolModuleOptionsPlugin",
45
+ PLUGIN_NAME,
56
46
  () => true
57
47
  );
58
48
  }
@@ -13,7 +13,7 @@ const ProgressPlugin = require("./ProgressPlugin");
13
13
  const SourceMapDevToolModuleOptionsPlugin = require("./SourceMapDevToolModuleOptionsPlugin");
14
14
  const createSchemaValidation = require("./util/create-schema-validation");
15
15
  const createHash = require("./util/createHash");
16
- const { relative, dirname } = require("./util/fs");
16
+ const { dirname, relative } = require("./util/fs");
17
17
  const generateDebugId = require("./util/generateDebugId");
18
18
  const { makePathsAbsolute } = require("./util/identifier");
19
19
 
@@ -28,12 +28,12 @@ const { makePathsAbsolute } = require("./util/identifier");
28
28
  /** @typedef {import("./Compilation").AssetInfo} AssetInfo */
29
29
  /** @typedef {import("./Compiler")} Compiler */
30
30
  /** @typedef {import("./Module")} Module */
31
- /** @typedef {import("./NormalModule").SourceMap} SourceMap */
31
+ /** @typedef {import("./NormalModule").RawSourceMap} RawSourceMap */
32
32
  /** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */
33
33
  /** @typedef {import("./util/fs").OutputFileSystem} OutputFileSystem */
34
34
 
35
35
  const validate = createSchemaValidation(
36
- require("../schemas/plugins/SourceMapDevToolPlugin.check.js"),
36
+ require("../schemas/plugins/SourceMapDevToolPlugin.check"),
37
37
  () => require("../schemas/plugins/SourceMapDevToolPlugin.json"),
38
38
  {
39
39
  name: "SourceMap DevTool Plugin",
@@ -47,7 +47,7 @@ const validate = createSchemaValidation(
47
47
  * @property {(string | Module)[]} modules
48
48
  * @property {string} source
49
49
  * @property {string} file
50
- * @property {SourceMap} sourceMap
50
+ * @property {RawSourceMap} sourceMap
51
51
  * @property {ItemCacheFacade} cacheItem cache item
52
52
  */
53
53
 
@@ -95,17 +95,17 @@ const getTaskForFile = (
95
95
  cacheItem
96
96
  ) => {
97
97
  let source;
98
- /** @type {SourceMap} */
98
+ /** @type {RawSourceMap} */
99
99
  let sourceMap;
100
100
  /**
101
101
  * Check if asset can build source map
102
102
  */
103
103
  if (asset.sourceAndMap) {
104
104
  const sourceAndMap = asset.sourceAndMap(options);
105
- sourceMap = /** @type {SourceMap} */ (sourceAndMap.map);
105
+ sourceMap = /** @type {RawSourceMap} */ (sourceAndMap.map);
106
106
  source = sourceAndMap.source;
107
107
  } else {
108
- sourceMap = /** @type {SourceMap} */ (asset.map(options));
108
+ sourceMap = /** @type {RawSourceMap} */ (asset.map(options));
109
109
  source = asset.source();
110
110
  }
111
111
  if (!sourceMap || typeof source !== "string") return;
@@ -270,8 +270,9 @@ class SourceMapDevToolPlugin {
270
270
  /**
271
271
  * Add file to chunk, if not presented there
272
272
  */
273
- if (cachedFile !== file && chunk !== undefined)
273
+ if (cachedFile !== file && chunk !== undefined) {
274
274
  chunk.auxiliaryFiles.add(cachedFile);
275
+ }
275
276
  }
276
277
 
277
278
  reportProgress(
@@ -362,13 +363,13 @@ class SourceMapDevToolPlugin {
362
363
  * all modules in defined order (longest identifier first)
363
364
  * @type {Array<string | Module>}
364
365
  */
365
- const allModules = Array.from(
366
- moduleToSourceNameMapping.keys()
367
- ).sort((a, b) => {
368
- const ai = typeof a === "string" ? a : a.identifier();
369
- const bi = typeof b === "string" ? b : b.identifier();
370
- return ai.length - bi.length;
371
- });
366
+ const allModules = [...moduleToSourceNameMapping.keys()].sort(
367
+ (a, b) => {
368
+ const ai = typeof a === "string" ? a : a.identifier();
369
+ const bi = typeof b === "string" ? b : b.identifier();
370
+ return ai.length - bi.length;
371
+ }
372
+ );
372
373
 
373
374
  // find modules with conflicting source names
374
375
  for (let idx = 0; idx < allModules.length; idx++) {
@@ -548,8 +549,9 @@ class SourceMapDevToolPlugin {
548
549
  sourceMapAsset,
549
550
  sourceMapAssetInfo
550
551
  );
551
- if (chunk !== undefined)
552
+ if (chunk !== undefined) {
552
553
  chunk.auxiliaryFiles.add(sourceMapFile);
554
+ }
553
555
  } else {
554
556
  if (currentSourceMappingURLComment === false) {
555
557
  throw new Error(
@@ -573,7 +575,7 @@ class SourceMapDevToolPlugin {
573
575
  () =>
574
576
  `data:application/json;charset=utf-8;base64,${Buffer.from(
575
577
  sourceMapString,
576
- "utf-8"
578
+ "utf8"
577
579
  ).toString("base64")}`
578
580
  )
579
581
  );
package/lib/Template.js CHANGED
@@ -410,7 +410,7 @@ class Template {
410
410
  }
411
411
 
412
412
  module.exports = Template;
413
- module.exports.NUMBER_OF_IDENTIFIER_START_CHARS =
414
- NUMBER_OF_IDENTIFIER_START_CHARS;
415
413
  module.exports.NUMBER_OF_IDENTIFIER_CONTINUATION_CHARS =
416
414
  NUMBER_OF_IDENTIFIER_CONTINUATION_CHARS;
415
+ module.exports.NUMBER_OF_IDENTIFIER_START_CHARS =
416
+ NUMBER_OF_IDENTIFIER_START_CHARS;
@@ -5,9 +5,9 @@
5
5
 
6
6
  "use strict";
7
7
 
8
- const mime = require("mime-types");
9
8
  const { basename, extname } = require("path");
10
9
  const util = require("util");
10
+ const mime = require("mime-types");
11
11
  const Chunk = require("./Chunk");
12
12
  const Module = require("./Module");
13
13
  const { parseResource } = require("./util/identifier");
@@ -9,6 +9,8 @@ const WebpackError = require("./WebpackError");
9
9
 
10
10
  /** @typedef {import("./Compiler")} Compiler */
11
11
 
12
+ const PLUGIN_NAME = "WarnDeprecatedOptionPlugin";
13
+
12
14
  class WarnDeprecatedOptionPlugin {
13
15
  /**
14
16
  * Create an instance of the plugin
@@ -28,14 +30,11 @@ class WarnDeprecatedOptionPlugin {
28
30
  * @returns {void}
29
31
  */
30
32
  apply(compiler) {
31
- compiler.hooks.thisCompilation.tap(
32
- "WarnDeprecatedOptionPlugin",
33
- compilation => {
34
- compilation.warnings.push(
35
- new DeprecatedOptionWarning(this.option, this.value, this.suggestion)
36
- );
37
- }
38
- );
33
+ compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
34
+ compilation.warnings.push(
35
+ new DeprecatedOptionWarning(this.option, this.value, this.suggestion)
36
+ );
37
+ });
39
38
  }
40
39
  }
41
40
 
@@ -15,8 +15,9 @@ const createSchemaValidation = require("./util/create-schema-validation");
15
15
  /** @typedef {import("./util/fs").WatchFileSystem} WatchFileSystem */
16
16
  /** @typedef {import("./util/fs").WatchMethod} WatchMethod */
17
17
  /** @typedef {import("./util/fs").Watcher} Watcher */
18
+
18
19
  const validate = createSchemaValidation(
19
- require("../schemas/plugins/WatchIgnorePlugin.check.js"),
20
+ require("../schemas/plugins/WatchIgnorePlugin.check"),
20
21
  () => require("../schemas/plugins/WatchIgnorePlugin.json"),
21
22
  {
22
23
  name: "Watch Ignore Plugin",
@@ -38,8 +39,8 @@ class IgnoringWatchFileSystem {
38
39
 
39
40
  /** @type {WatchMethod} */
40
41
  watch(files, dirs, missing, startTime, options, callback, callbackUndelayed) {
41
- files = Array.from(files);
42
- dirs = Array.from(dirs);
42
+ files = [...files];
43
+ dirs = [...dirs];
43
44
  /**
44
45
  * @param {string} path path to check
45
46
  * @returns {boolean} true, if path is ignored
@@ -55,8 +55,9 @@ class WebpackIsIncludedPlugin {
55
55
  expr.type !== "CallExpression" ||
56
56
  expr.arguments.length !== 1 ||
57
57
  expr.arguments[0].type === "SpreadElement"
58
- )
58
+ ) {
59
59
  return;
60
+ }
60
61
 
61
62
  const request = parser.evaluateExpression(expr.arguments[0]);
62
63