webpack 5.93.0 → 5.94.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 (343) hide show
  1. package/README.md +8 -5
  2. package/bin/webpack.js +6 -7
  3. package/hot/log.js +1 -2
  4. package/hot/only-dev-server.js +1 -1
  5. package/hot/poll.js +1 -1
  6. package/hot/signal.js +1 -1
  7. package/lib/APIPlugin.js +4 -3
  8. package/lib/AbstractMethodError.js +10 -5
  9. package/lib/AutomaticPrefetchPlugin.js +1 -1
  10. package/lib/BannerPlugin.js +12 -6
  11. package/lib/Cache.js +8 -10
  12. package/lib/CacheFacade.js +3 -3
  13. package/lib/CaseSensitiveModulesWarning.js +5 -7
  14. package/lib/Chunk.js +14 -11
  15. package/lib/ChunkGraph.js +58 -36
  16. package/lib/ChunkGroup.js +2 -3
  17. package/lib/ChunkTemplate.js +43 -0
  18. package/lib/CleanPlugin.js +10 -11
  19. package/lib/CodeGenerationResults.js +6 -5
  20. package/lib/CommentCompilationWarning.js +0 -1
  21. package/lib/Compilation.js +223 -191
  22. package/lib/Compiler.js +81 -82
  23. package/lib/ConcatenationScope.js +3 -6
  24. package/lib/ConditionalInitFragment.js +6 -7
  25. package/lib/ConstPlugin.js +7 -15
  26. package/lib/ContextExclusionPlugin.js +3 -3
  27. package/lib/ContextModule.js +33 -20
  28. package/lib/ContextModuleFactory.js +89 -44
  29. package/lib/ContextReplacementPlugin.js +10 -9
  30. package/lib/DefinePlugin.js +75 -68
  31. package/lib/DelegatedModule.js +7 -3
  32. package/lib/DelegatedModuleFactoryPlugin.js +36 -22
  33. package/lib/DelegatedPlugin.js +4 -0
  34. package/lib/DependenciesBlock.js +0 -1
  35. package/lib/Dependency.js +10 -14
  36. package/lib/DllEntryPlugin.js +4 -2
  37. package/lib/DllModuleFactory.js +1 -0
  38. package/lib/DllPlugin.js +9 -7
  39. package/lib/DllReferencePlugin.js +30 -15
  40. package/lib/EntryPlugin.js +1 -3
  41. package/lib/EnvironmentPlugin.js +5 -2
  42. package/lib/ErrorHelpers.js +11 -12
  43. package/lib/EvalDevToolModulePlugin.js +10 -12
  44. package/lib/EvalSourceMapDevToolPlugin.js +15 -13
  45. package/lib/ExportsInfo.js +185 -120
  46. package/lib/ExternalModule.js +104 -64
  47. package/lib/ExternalModuleFactoryPlugin.js +23 -10
  48. package/lib/FileSystemInfo.js +791 -422
  49. package/lib/FlagAllModulesAsUsedPlugin.js +1 -1
  50. package/lib/FlagDependencyExportsPlugin.js +12 -11
  51. package/lib/FlagDependencyUsagePlugin.js +1 -1
  52. package/lib/Generator.js +2 -5
  53. package/lib/GraphHelpers.js +3 -2
  54. package/lib/HookWebpackError.js +8 -10
  55. package/lib/HotModuleReplacementPlugin.js +78 -64
  56. package/lib/IgnoreErrorModuleFactory.js +3 -3
  57. package/lib/IgnorePlugin.js +1 -3
  58. package/lib/IgnoreWarningsPlugin.js +6 -9
  59. package/lib/InitFragment.js +2 -3
  60. package/lib/LibManifestPlugin.js +4 -3
  61. package/lib/MainTemplate.js +72 -19
  62. package/lib/Module.js +25 -9
  63. package/lib/ModuleBuildError.js +4 -11
  64. package/lib/ModuleDependencyError.js +5 -5
  65. package/lib/ModuleDependencyWarning.js +5 -5
  66. package/lib/ModuleError.js +1 -5
  67. package/lib/ModuleFilenameHelpers.js +29 -46
  68. package/lib/ModuleGraph.js +7 -6
  69. package/lib/ModuleGraphConnection.js +6 -6
  70. package/lib/ModuleInfoHeaderPlugin.js +82 -30
  71. package/lib/ModuleParseError.js +8 -9
  72. package/lib/ModuleRestoreError.js +1 -1
  73. package/lib/ModuleStoreError.js +1 -1
  74. package/lib/ModuleTemplate.js +33 -1
  75. package/lib/ModuleTypeConstants.js +21 -22
  76. package/lib/ModuleWarning.js +1 -5
  77. package/lib/MultiCompiler.js +24 -26
  78. package/lib/MultiStats.js +73 -31
  79. package/lib/MultiWatching.js +1 -1
  80. package/lib/NormalModule.js +126 -69
  81. package/lib/NormalModuleFactory.js +53 -49
  82. package/lib/OptimizationStages.js +3 -3
  83. package/lib/ProgressPlugin.js +9 -9
  84. package/lib/ProvidePlugin.js +4 -4
  85. package/lib/RuntimeGlobals.js +71 -70
  86. package/lib/RuntimeModule.js +1 -1
  87. package/lib/RuntimePlugin.js +24 -12
  88. package/lib/RuntimeTemplate.js +40 -44
  89. package/lib/SizeFormatHelpers.js +2 -4
  90. package/lib/SourceMapDevToolPlugin.js +42 -34
  91. package/lib/Stats.js +5 -11
  92. package/lib/Template.js +18 -24
  93. package/lib/TemplatedPathPlugin.js +12 -10
  94. package/lib/WarnDeprecatedOptionPlugin.js +0 -1
  95. package/lib/WatchIgnorePlugin.js +26 -9
  96. package/lib/Watching.js +10 -5
  97. package/lib/WebpackOptionsApply.js +84 -62
  98. package/lib/asset/AssetGenerator.js +107 -42
  99. package/lib/asset/AssetModulesPlugin.js +29 -23
  100. package/lib/asset/AssetSourceGenerator.js +2 -7
  101. package/lib/async-modules/AwaitDependenciesInitFragment.js +6 -7
  102. package/lib/buildChunkGraph.js +14 -19
  103. package/lib/cache/IdleFileCachePlugin.js +4 -4
  104. package/lib/cache/MemoryWithGcCachePlugin.js +5 -5
  105. package/lib/cache/PackFileCacheStrategy.js +51 -50
  106. package/lib/cache/ResolverCachePlugin.js +6 -6
  107. package/lib/cache/mergeEtags.js +16 -21
  108. package/lib/cli.js +148 -104
  109. package/lib/config/browserslistTargetHandler.js +16 -13
  110. package/lib/config/defaults.js +31 -28
  111. package/lib/config/normalization.js +335 -344
  112. package/lib/config/target.js +42 -52
  113. package/lib/container/ContainerEntryModule.js +2 -2
  114. package/lib/container/ContainerPlugin.js +1 -1
  115. package/lib/container/RemoteRuntimeModule.js +11 -8
  116. package/lib/container/options.js +18 -4
  117. package/lib/css/CssExportsGenerator.js +26 -24
  118. package/lib/css/CssGenerator.js +9 -4
  119. package/lib/css/CssLoadingRuntimeModule.js +10 -10
  120. package/lib/css/CssModulesPlugin.js +127 -47
  121. package/lib/css/CssParser.js +20 -18
  122. package/lib/css/walkCssTokens.js +80 -95
  123. package/lib/debug/ProfilingPlugin.js +19 -20
  124. package/lib/dependencies/AMDDefineDependency.js +1 -1
  125. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +83 -47
  126. package/lib/dependencies/AMDRequireArrayDependency.js +9 -10
  127. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +22 -16
  128. package/lib/dependencies/AMDRuntimeModules.js +2 -2
  129. package/lib/dependencies/CommonJsDependencyHelpers.js +6 -2
  130. package/lib/dependencies/CommonJsExportRequireDependency.js +37 -41
  131. package/lib/dependencies/CommonJsExportsDependency.js +0 -1
  132. package/lib/dependencies/CommonJsExportsParserPlugin.js +19 -23
  133. package/lib/dependencies/CommonJsFullRequireDependency.js +1 -1
  134. package/lib/dependencies/CommonJsImportsParserPlugin.js +52 -61
  135. package/lib/dependencies/CommonJsSelfReferenceDependency.js +6 -8
  136. package/lib/dependencies/ConstDependency.js +1 -1
  137. package/lib/dependencies/ContextDependency.js +1 -1
  138. package/lib/dependencies/ContextDependencyHelpers.js +31 -34
  139. package/lib/dependencies/ContextElementDependency.js +2 -2
  140. package/lib/dependencies/CriticalDependencyWarning.js +1 -1
  141. package/lib/dependencies/CssExportDependency.js +7 -7
  142. package/lib/dependencies/CssImportDependency.js +0 -2
  143. package/lib/dependencies/CssLocalIdentifierDependency.js +3 -3
  144. package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
  145. package/lib/dependencies/CssUrlDependency.js +4 -5
  146. package/lib/dependencies/DynamicExports.js +5 -5
  147. package/lib/dependencies/ExportsInfoDependency.js +1 -2
  148. package/lib/dependencies/HarmonyAcceptImportDependency.js +1 -1
  149. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +4 -5
  150. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +27 -16
  151. package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
  152. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +107 -64
  153. package/lib/dependencies/HarmonyExports.js +2 -2
  154. package/lib/dependencies/HarmonyImportDependency.js +2 -4
  155. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +19 -4
  156. package/lib/dependencies/HarmonyImportSpecifierDependency.js +40 -15
  157. package/lib/dependencies/ImportDependency.js +1 -1
  158. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +5 -5
  159. package/lib/dependencies/ImportMetaPlugin.js +11 -13
  160. package/lib/dependencies/ImportParserPlugin.js +39 -44
  161. package/lib/dependencies/JsonExportsDependency.js +22 -18
  162. package/lib/dependencies/LoaderPlugin.js +47 -36
  163. package/lib/dependencies/LocalModule.js +1 -1
  164. package/lib/dependencies/LocalModulesHelpers.js +4 -4
  165. package/lib/dependencies/ModuleDecoratorDependency.js +1 -1
  166. package/lib/dependencies/ProvidedDependency.js +1 -1
  167. package/lib/dependencies/PureExpressionDependency.js +6 -6
  168. package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
  169. package/lib/dependencies/RuntimeRequirementsDependency.js +1 -1
  170. package/lib/dependencies/SystemPlugin.js +1 -1
  171. package/lib/dependencies/URLDependency.js +3 -3
  172. package/lib/dependencies/URLPlugin.js +66 -12
  173. package/lib/dependencies/WorkerPlugin.js +25 -24
  174. package/lib/dependencies/processExportInfo.js +3 -1
  175. package/lib/electron/ElectronTargetPlugin.js +1 -0
  176. package/lib/esm/ModuleChunkFormatPlugin.js +3 -3
  177. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +7 -3
  178. package/lib/formatLocation.js +1 -2
  179. package/lib/hmr/HotModuleReplacement.runtime.js +4 -5
  180. package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -0
  181. package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +9 -12
  182. package/lib/hmr/LazyCompilationPlugin.js +27 -12
  183. package/lib/hmr/lazyCompilationBackend.js +64 -40
  184. package/lib/ids/ChunkModuleIdRangePlugin.js +1 -3
  185. package/lib/ids/DeterministicChunkIdsPlugin.js +2 -4
  186. package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
  187. package/lib/ids/HashedModuleIdsPlugin.js +5 -1
  188. package/lib/ids/IdHelpers.js +29 -39
  189. package/lib/ids/SyncModuleIdsPlugin.js +7 -2
  190. package/lib/index.js +1 -5
  191. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +5 -4
  192. package/lib/javascript/BasicEvaluatedExpression.js +4 -19
  193. package/lib/javascript/ChunkHelpers.js +1 -1
  194. package/lib/javascript/CommonJsChunkFormatPlugin.js +3 -2
  195. package/lib/javascript/EnableChunkLoadingPlugin.js +7 -6
  196. package/lib/javascript/JavascriptGenerator.js +23 -7
  197. package/lib/javascript/JavascriptModulesPlugin.js +91 -69
  198. package/lib/javascript/JavascriptParser.js +179 -200
  199. package/lib/javascript/JavascriptParserHelpers.js +20 -21
  200. package/lib/javascript/StartupHelpers.js +41 -13
  201. package/lib/json/JsonGenerator.js +7 -13
  202. package/lib/json/JsonModulesPlugin.js +1 -4
  203. package/lib/json/JsonParser.js +5 -3
  204. package/lib/library/AmdLibraryPlugin.js +12 -16
  205. package/lib/library/AssignLibraryPlugin.js +8 -10
  206. package/lib/library/EnableLibraryPlugin.js +15 -14
  207. package/lib/library/JsonpLibraryPlugin.js +2 -1
  208. package/lib/library/ModernModuleLibraryPlugin.js +8 -6
  209. package/lib/library/ModuleLibraryPlugin.js +2 -1
  210. package/lib/library/SystemLibraryPlugin.js +2 -1
  211. package/lib/library/UmdLibraryPlugin.js +66 -92
  212. package/lib/logging/Logger.js +32 -4
  213. package/lib/logging/createConsoleLogger.js +12 -13
  214. package/lib/logging/runtime.js +7 -8
  215. package/lib/logging/truncateArgs.js +5 -8
  216. package/lib/node/NodeWatchFileSystem.js +3 -18
  217. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -2
  218. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +1 -0
  219. package/lib/node/RequireChunkLoadingRuntimeModule.js +2 -2
  220. package/lib/node/nodeConsole.js +22 -22
  221. package/lib/optimize/AggressiveMergingPlugin.js +2 -4
  222. package/lib/optimize/AggressiveSplittingPlugin.js +16 -19
  223. package/lib/optimize/ConcatenatedModule.js +80 -48
  224. package/lib/optimize/EnsureChunkConditionsPlugin.js +1 -1
  225. package/lib/optimize/FlagIncludedChunksPlugin.js +3 -3
  226. package/lib/optimize/InnerGraph.js +17 -17
  227. package/lib/optimize/InnerGraphPlugin.js +8 -7
  228. package/lib/optimize/LimitChunkCountPlugin.js +2 -3
  229. package/lib/optimize/MangleExportsPlugin.js +1 -0
  230. package/lib/optimize/MinMaxSizeWarning.js +1 -1
  231. package/lib/optimize/ModuleConcatenationPlugin.js +54 -78
  232. package/lib/optimize/RealContentHashPlugin.js +7 -10
  233. package/lib/optimize/RemoveParentModulesPlugin.js +3 -3
  234. package/lib/optimize/SideEffectsFlagPlugin.js +6 -2
  235. package/lib/optimize/SplitChunksPlugin.js +34 -30
  236. package/lib/performance/SizeLimitsPlugin.js +2 -2
  237. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +1 -1
  238. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +1 -1
  239. package/lib/rules/BasicEffectRulePlugin.js +3 -1
  240. package/lib/rules/BasicMatcherRulePlugin.js +3 -1
  241. package/lib/rules/ObjectMatcherRulePlugin.js +4 -1
  242. package/lib/rules/RuleSetCompiler.js +41 -22
  243. package/lib/rules/UseEffectRulePlugin.js +36 -32
  244. package/lib/runtime/AsyncModuleRuntimeModule.js +1 -1
  245. package/lib/runtime/AutoPublicPathRuntimeModule.js +8 -3
  246. package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +2 -2
  247. package/lib/runtime/DefinePropertyGettersRuntimeModule.js +1 -1
  248. package/lib/runtime/EnsureChunkRuntimeModule.js +10 -11
  249. package/lib/runtime/GetChunkFilenameRuntimeModule.js +11 -17
  250. package/lib/runtime/LoadScriptRuntimeModule.js +17 -18
  251. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -3
  252. package/lib/schemes/DataUriPlugin.js +1 -1
  253. package/lib/schemes/HttpUriPlugin.js +241 -126
  254. package/lib/serialization/BinaryMiddleware.js +44 -28
  255. package/lib/serialization/DateObjectSerializer.js +1 -0
  256. package/lib/serialization/ErrorObjectSerializer.js +2 -0
  257. package/lib/serialization/FileMiddleware.js +154 -106
  258. package/lib/serialization/MapObjectSerializer.js +2 -1
  259. package/lib/serialization/NullPrototypeObjectSerializer.js +3 -2
  260. package/lib/serialization/ObjectMiddleware.js +52 -56
  261. package/lib/serialization/PlainObjectSerializer.js +32 -6
  262. package/lib/serialization/RegExpObjectSerializer.js +1 -0
  263. package/lib/serialization/Serializer.js +4 -5
  264. package/lib/serialization/SerializerMiddleware.js +6 -6
  265. package/lib/serialization/SetObjectSerializer.js +2 -1
  266. package/lib/sharing/ConsumeSharedPlugin.js +116 -97
  267. package/lib/sharing/ConsumeSharedRuntimeModule.js +4 -4
  268. package/lib/sharing/ProvideForSharedDependency.js +0 -1
  269. package/lib/sharing/ProvideSharedPlugin.js +2 -2
  270. package/lib/sharing/resolveMatchedConfigs.js +2 -1
  271. package/lib/sharing/utils.js +15 -27
  272. package/lib/stats/DefaultStatsFactoryPlugin.js +424 -281
  273. package/lib/stats/DefaultStatsPresetPlugin.js +73 -18
  274. package/lib/stats/DefaultStatsPrinterPlugin.js +370 -101
  275. package/lib/stats/StatsFactory.js +127 -56
  276. package/lib/stats/StatsPrinter.js +75 -44
  277. package/lib/util/ArrayHelpers.js +8 -4
  278. package/lib/util/ArrayQueue.js +1 -1
  279. package/lib/util/AsyncQueue.js +31 -12
  280. package/lib/util/IterableHelpers.js +3 -4
  281. package/lib/util/LazyBucketSortedSet.js +60 -44
  282. package/lib/util/LazySet.js +1 -0
  283. package/lib/util/MapHelpers.js +1 -3
  284. package/lib/util/ParallelismFactorCalculator.js +1 -1
  285. package/lib/util/Queue.js +1 -1
  286. package/lib/util/Semaphore.js +4 -7
  287. package/lib/util/SetHelpers.js +5 -5
  288. package/lib/util/SortableSet.js +4 -3
  289. package/lib/util/StackedCacheMap.js +4 -6
  290. package/lib/util/StackedMap.js +1 -3
  291. package/lib/util/StringXor.js +0 -5
  292. package/lib/util/TupleQueue.js +1 -1
  293. package/lib/util/TupleSet.js +15 -5
  294. package/lib/util/URLAbsoluteSpecifier.js +7 -7
  295. package/lib/util/WeakTupleMap.js +19 -21
  296. package/lib/util/binarySearchBounds.js +5 -12
  297. package/lib/util/chainedImports.js +1 -1
  298. package/lib/util/cleverMerge.js +21 -19
  299. package/lib/util/comparators.js +57 -52
  300. package/lib/util/compileBooleanMatcher.js +3 -6
  301. package/lib/util/conventions.js +8 -11
  302. package/lib/util/createHash.js +9 -6
  303. package/lib/util/deprecation.js +22 -12
  304. package/lib/util/deterministicGrouping.js +19 -26
  305. package/lib/util/findGraphRoots.js +2 -2
  306. package/lib/util/fs.js +31 -31
  307. package/lib/util/hash/md4.js +2 -2
  308. package/lib/util/hash/wasm-hash.js +7 -7
  309. package/lib/util/hash/xxhash64.js +2 -2
  310. package/lib/util/identifier.js +81 -59
  311. package/lib/util/memoize.js +8 -10
  312. package/lib/util/mergeScope.js +6 -9
  313. package/lib/util/nonNumericOnlyHash.js +2 -2
  314. package/lib/util/numberHash.js +1 -6
  315. package/lib/util/objectToMap.js +0 -1
  316. package/lib/util/propertyAccess.js +2 -5
  317. package/lib/util/propertyName.js +1 -3
  318. package/lib/util/registerExternalSerializer.js +1 -1
  319. package/lib/util/runtime.js +103 -113
  320. package/lib/util/semver.js +29 -27
  321. package/lib/util/serialization.js +16 -1
  322. package/lib/util/smartGrouping.js +5 -5
  323. package/lib/util/source.js +1 -1
  324. package/lib/wasm/EnableWasmLoadingPlugin.js +5 -4
  325. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +3 -3
  326. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -6
  327. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -3
  328. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +20 -19
  329. package/lib/wasm-sync/WebAssemblyGenerator.js +14 -29
  330. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -1
  331. package/lib/wasm-sync/WebAssemblyUtils.js +2 -2
  332. package/lib/web/JsonpChunkLoadingRuntimeModule.js +2 -3
  333. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -1
  334. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
  335. package/package.json +15 -14
  336. package/schemas/WebpackOptions.check.js +1 -1
  337. package/schemas/WebpackOptions.json +1 -0
  338. package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
  339. package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
  340. package/schemas/plugins/container/ExternalsType.check.js +1 -1
  341. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  342. package/schemas/plugins/container/ModuleFederationPlugin.json +1 -0
  343. package/types.d.ts +667 -347
@@ -43,7 +43,6 @@ const ModuleDecoratorDependency = require("./ModuleDecoratorDependency");
43
43
  * exports.foo = void 0;
44
44
  * exports.foo = "bar";
45
45
  * ```
46
- *
47
46
  * @param {TODO} expr expression
48
47
  * @returns {Expression | undefined} returns the value of property descriptor
49
48
  */
@@ -61,15 +60,13 @@ const getValueOfPropertyDescription = expr => {
61
60
  * The purpose of this function is to check whether an expression is a truthy literal or not. This is
62
61
  * useful when parsing CommonJS exports, because CommonJS modules can export any value, including falsy
63
62
  * values like `null` and `false`. However, exports should only be created if the exported value is truthy.
64
- *
65
63
  * @param {Expression} expr expression being checked
66
64
  * @returns {boolean} true, when the expression is a truthy literal
67
- *
68
65
  */
69
66
  const isTruthyLiteral = expr => {
70
67
  switch (expr.type) {
71
68
  case "Literal":
72
- return !!expr.value;
69
+ return Boolean(expr.value);
73
70
  case "UnaryExpression":
74
71
  if (expr.operator === "!") return isFalsyLiteral(expr.argument);
75
72
  }
@@ -80,7 +77,6 @@ const isTruthyLiteral = expr => {
80
77
  * The purpose of this function is to check whether an expression is a falsy literal or not. This is
81
78
  * useful when parsing CommonJS exports, because CommonJS modules can export any value, including falsy
82
79
  * values like `null` and `false`. However, exports should only be created if the exported value is truthy.
83
- *
84
80
  * @param {Expression} expr expression being checked
85
81
  * @returns {boolean} true, when the expression is a falsy literal
86
82
  */
@@ -215,7 +211,7 @@ class CommonJsExportsParserPlugin {
215
211
  !parser.isStatementLevelExpression(expr)
216
212
  );
217
213
  dep.loc = /** @type {DependencyLocation} */ (expr.loc);
218
- dep.optional = !!parser.scope.inTry;
214
+ dep.optional = Boolean(parser.scope.inTry);
219
215
  parser.state.module.addDependency(dep);
220
216
  return true;
221
217
  }
@@ -241,9 +237,9 @@ class CommonJsExportsParserPlugin {
241
237
  };
242
238
  parser.hooks.assignMemberChain
243
239
  .for("exports")
244
- .tap("CommonJsExportsParserPlugin", (expr, members) => {
245
- return handleAssignExport(expr, "exports", members);
246
- });
240
+ .tap("CommonJsExportsParserPlugin", (expr, members) =>
241
+ handleAssignExport(expr, "exports", members)
242
+ );
247
243
  parser.hooks.assignMemberChain
248
244
  .for("this")
249
245
  .tap("CommonJsExportsParserPlugin", (expr, members) => {
@@ -306,7 +302,7 @@ class CommonJsExportsParserPlugin {
306
302
  * @param {CallExpression=} call call expression
307
303
  * @returns {boolean | void} true, when the expression was handled
308
304
  */
309
- const handleAccessExport = (expr, base, members, call = undefined) => {
305
+ const handleAccessExport = (expr, base, members, call) => {
310
306
  if (HarmonyExports.isEnabled(parser.state)) return;
311
307
  if (members.length === 0) {
312
308
  bailout(
@@ -328,7 +324,7 @@ class CommonJsExportsParserPlugin {
328
324
  /** @type {Range} */ (expr.range),
329
325
  base,
330
326
  members,
331
- !!call
327
+ Boolean(call)
332
328
  );
333
329
  dep.loc = /** @type {DependencyLocation} */ (expr.loc);
334
330
  parser.state.module.addDependency(dep);
@@ -339,19 +335,19 @@ class CommonJsExportsParserPlugin {
339
335
  };
340
336
  parser.hooks.callMemberChain
341
337
  .for("exports")
342
- .tap("CommonJsExportsParserPlugin", (expr, members) => {
343
- return handleAccessExport(expr.callee, "exports", members, expr);
344
- });
338
+ .tap("CommonJsExportsParserPlugin", (expr, members) =>
339
+ handleAccessExport(expr.callee, "exports", members, expr)
340
+ );
345
341
  parser.hooks.expressionMemberChain
346
342
  .for("exports")
347
- .tap("CommonJsExportsParserPlugin", (expr, members) => {
348
- return handleAccessExport(expr, "exports", members);
349
- });
343
+ .tap("CommonJsExportsParserPlugin", (expr, members) =>
344
+ handleAccessExport(expr, "exports", members)
345
+ );
350
346
  parser.hooks.expression
351
347
  .for("exports")
352
- .tap("CommonJsExportsParserPlugin", expr => {
353
- return handleAccessExport(expr, "exports", []);
354
- });
348
+ .tap("CommonJsExportsParserPlugin", expr =>
349
+ handleAccessExport(expr, "exports", [])
350
+ );
355
351
  parser.hooks.callMemberChain
356
352
  .for("module")
357
353
  .tap("CommonJsExportsParserPlugin", (expr, members) => {
@@ -371,9 +367,9 @@ class CommonJsExportsParserPlugin {
371
367
  });
372
368
  parser.hooks.expression
373
369
  .for("module.exports")
374
- .tap("CommonJsExportsParserPlugin", expr => {
375
- return handleAccessExport(expr, "module.exports", []);
376
- });
370
+ .tap("CommonJsExportsParserPlugin", expr =>
371
+ handleAccessExport(expr, "module.exports", [])
372
+ );
377
373
  parser.hooks.callMemberChain
378
374
  .for("this")
379
375
  .tap("CommonJsExportsParserPlugin", (expr, members) => {
@@ -146,7 +146,7 @@ CommonJsFullRequireDependency.Template = class CommonJsFullRequireDependencyTemp
146
146
  if (usedImported) {
147
147
  const comment = equals(usedImported, trimmedIds)
148
148
  ? ""
149
- : Template.toNormalComment(propertyAccess(trimmedIds)) + " ";
149
+ : `${Template.toNormalComment(propertyAccess(trimmedIds))} `;
150
150
  const access = `${comment}${propertyAccess(usedImported)}`;
151
151
  requireExpr =
152
152
  dep.asiSafe === true
@@ -63,7 +63,7 @@ class CommonJsImportsParserPlugin {
63
63
  }
64
64
  };
65
65
 
66
- //#region metadata
66
+ // #region metadata
67
67
  /**
68
68
  * @param {string} expression expression
69
69
  * @param {() => string[]} getMembers get members
@@ -102,7 +102,7 @@ class CommonJsImportsParserPlugin {
102
102
  tapRequireExpression("require", () => []);
103
103
  tapRequireExpression("require.resolve", () => ["resolve"]);
104
104
  tapRequireExpression("require.resolveWeak", () => ["resolveWeak"]);
105
- //#endregion
105
+ // #endregion
106
106
 
107
107
  // Weird stuff //
108
108
  parser.hooks.assign
@@ -115,7 +115,7 @@ class CommonJsImportsParserPlugin {
115
115
  return true;
116
116
  });
117
117
 
118
- //#region Unsupported
118
+ // #region Unsupported
119
119
  parser.hooks.expression
120
120
  .for("require.main")
121
121
  .tap(
@@ -152,9 +152,9 @@ class CommonJsImportsParserPlugin {
152
152
  "module.parent.require is not supported by webpack."
153
153
  )
154
154
  );
155
- //#endregion
155
+ // #endregion
156
156
 
157
- //#region Renaming
157
+ // #region Renaming
158
158
  /**
159
159
  * @param {Expression} expr expression
160
160
  * @returns {boolean} true when set undefined
@@ -175,9 +175,9 @@ class CommonJsImportsParserPlugin {
175
175
  parser.hooks.rename
176
176
  .for("require")
177
177
  .tap("CommonJsImportsParserPlugin", defineUndefined);
178
- //#endregion
178
+ // #endregion
179
179
 
180
- //#region Inspection
180
+ // #region Inspection
181
181
  const requireCache = toConstantDependency(
182
182
  parser,
183
183
  RuntimeGlobals.moduleCache,
@@ -191,9 +191,9 @@ class CommonJsImportsParserPlugin {
191
191
  parser.hooks.expression
192
192
  .for("require.cache")
193
193
  .tap("CommonJsImportsParserPlugin", requireCache);
194
- //#endregion
194
+ // #endregion
195
195
 
196
- //#region Require as expression
196
+ // #region Require as expression
197
197
  /**
198
198
  * @param {Expression} expr expression
199
199
  * @returns {boolean} true when handled
@@ -215,16 +215,16 @@ class CommonJsImportsParserPlugin {
215
215
  options.unknownContextCritical &&
216
216
  "require function is used in a way in which dependencies cannot be statically extracted";
217
217
  dep.loc = /** @type {DependencyLocation} */ (expr.loc);
218
- dep.optional = !!parser.scope.inTry;
218
+ dep.optional = Boolean(parser.scope.inTry);
219
219
  parser.state.current.addDependency(dep);
220
220
  return true;
221
221
  };
222
222
  parser.hooks.expression
223
223
  .for("require")
224
224
  .tap("CommonJsImportsParserPlugin", requireAsExpressionHandler);
225
- //#endregion
225
+ // #endregion
226
226
 
227
- //#region Require
227
+ // #region Require
228
228
  /**
229
229
  * @param {CallExpression | NewExpression} expr expression
230
230
  * @param {BasicEvaluatedExpression} param param
@@ -238,7 +238,7 @@ class CommonJsImportsParserPlugin {
238
238
  getContext()
239
239
  );
240
240
  dep.loc = /** @type {DependencyLocation} */ (expr.loc);
241
- dep.optional = !!parser.scope.inTry;
241
+ dep.optional = Boolean(parser.scope.inTry);
242
242
  parser.state.current.addDependency(dep);
243
243
  return true;
244
244
  }
@@ -264,7 +264,7 @@ class CommonJsImportsParserPlugin {
264
264
  );
265
265
  if (!dep) return;
266
266
  dep.loc = /** @type {DependencyLocation} */ (expr.loc);
267
- dep.optional = !!parser.scope.inTry;
267
+ dep.optional = Boolean(parser.scope.inTry);
268
268
  parser.state.current.addDependency(dep);
269
269
  return true;
270
270
  };
@@ -288,21 +288,17 @@ class CommonJsImportsParserPlugin {
288
288
  );
289
289
  }
290
290
  }
291
- if (requireOptions) {
292
- if (requireOptions.webpackIgnore !== undefined) {
293
- if (typeof requireOptions.webpackIgnore !== "boolean") {
294
- parser.state.module.addWarning(
295
- new UnsupportedFeatureWarning(
296
- `\`webpackIgnore\` expected a boolean, but received: ${requireOptions.webpackIgnore}.`,
297
- /** @type {DependencyLocation} */ (expr.loc)
298
- )
299
- );
300
- } else {
301
- // Do not instrument `require()` if `webpackIgnore` is `true`
302
- if (requireOptions.webpackIgnore) {
303
- return true;
304
- }
305
- }
291
+ if (requireOptions && requireOptions.webpackIgnore !== undefined) {
292
+ if (typeof requireOptions.webpackIgnore !== "boolean") {
293
+ parser.state.module.addWarning(
294
+ new UnsupportedFeatureWarning(
295
+ `\`webpackIgnore\` expected a boolean, but received: ${requireOptions.webpackIgnore}.`,
296
+ /** @type {DependencyLocation} */ (expr.loc)
297
+ )
298
+ );
299
+ } else if (requireOptions.webpackIgnore) {
300
+ // Do not instrument `require()` if `webpackIgnore` is `true`
301
+ return true;
306
302
  }
307
303
  }
308
304
  }
@@ -370,9 +366,9 @@ class CommonJsImportsParserPlugin {
370
366
  parser.hooks.new
371
367
  .for("module.require")
372
368
  .tap("CommonJsImportsParserPlugin", createRequireHandler(true));
373
- //#endregion
369
+ // #endregion
374
370
 
375
- //#region Require with property access
371
+ // #region Require with property access
376
372
  /**
377
373
  * @param {Expression} expr expression
378
374
  * @param {string[]} calleeMembers callee members
@@ -403,7 +399,7 @@ class CommonJsImportsParserPlugin {
403
399
  dep.asiSafe = !parser.isAsiPosition(
404
400
  /** @type {Range} */ (expr.range)[0]
405
401
  );
406
- dep.optional = !!parser.scope.inTry;
402
+ dep.optional = Boolean(parser.scope.inTry);
407
403
  dep.loc = /** @type {DependencyLocation} */ (expr.loc);
408
404
  parser.state.current.addDependency(dep);
409
405
  return true;
@@ -440,7 +436,7 @@ class CommonJsImportsParserPlugin {
440
436
  dep.asiSafe = !parser.isAsiPosition(
441
437
  /** @type {Range} */ (expr.range)[0]
442
438
  );
443
- dep.optional = !!parser.scope.inTry;
439
+ dep.optional = Boolean(parser.scope.inTry);
444
440
  dep.loc = /** @type {DependencyLocation} */ (expr.callee.loc);
445
441
  parser.state.current.addDependency(dep);
446
442
  parser.walkExpressions(expr.arguments);
@@ -459,9 +455,9 @@ class CommonJsImportsParserPlugin {
459
455
  parser.hooks.callMemberChainOfCallMemberChain
460
456
  .for("module.require")
461
457
  .tap("CommonJsImportsParserPlugin", callChainHandler);
462
- //#endregion
458
+ // #endregion
463
459
 
464
- //#region Require.resolve
460
+ // #region Require.resolve
465
461
  /**
466
462
  * @param {CallExpression} expr call expression
467
463
  * @param {boolean} weak weak
@@ -485,18 +481,17 @@ class CommonJsImportsParserPlugin {
485
481
  dep.loc = /** @type {DependencyLocation} */ (expr.loc);
486
482
  parser.state.module.addPresentationalDependency(dep);
487
483
  return true;
488
- } else {
489
- const result = processResolveItem(expr, param, weak);
490
- if (result === undefined) {
491
- processResolveContext(expr, param, weak);
492
- }
493
- const dep = new RequireResolveHeaderDependency(
494
- /** @type {Range} */ (expr.callee.range)
495
- );
496
- dep.loc = /** @type {DependencyLocation} */ (expr.loc);
497
- parser.state.module.addPresentationalDependency(dep);
498
- return true;
499
484
  }
485
+ const result = processResolveItem(expr, param, weak);
486
+ if (result === undefined) {
487
+ processResolveContext(expr, param, weak);
488
+ }
489
+ const dep = new RequireResolveHeaderDependency(
490
+ /** @type {Range} */ (expr.callee.range)
491
+ );
492
+ dep.loc = /** @type {DependencyLocation} */ (expr.loc);
493
+ parser.state.module.addPresentationalDependency(dep);
494
+ return true;
500
495
  };
501
496
  /**
502
497
  * @param {CallExpression} expr call expression
@@ -512,7 +507,7 @@ class CommonJsImportsParserPlugin {
512
507
  getContext()
513
508
  );
514
509
  dep.loc = /** @type {DependencyLocation} */ (expr.loc);
515
- dep.optional = !!parser.scope.inTry;
510
+ dep.optional = Boolean(parser.scope.inTry);
516
511
  dep.weak = weak;
517
512
  parser.state.current.addDependency(dep);
518
513
  return true;
@@ -540,24 +535,20 @@ class CommonJsImportsParserPlugin {
540
535
  );
541
536
  if (!dep) return;
542
537
  dep.loc = /** @type {DependencyLocation} */ (expr.loc);
543
- dep.optional = !!parser.scope.inTry;
538
+ dep.optional = Boolean(parser.scope.inTry);
544
539
  parser.state.current.addDependency(dep);
545
540
  return true;
546
541
  };
547
542
 
548
543
  parser.hooks.call
549
544
  .for("require.resolve")
550
- .tap("CommonJsImportsParserPlugin", expr => {
551
- return processResolve(expr, false);
552
- });
545
+ .tap("CommonJsImportsParserPlugin", expr => processResolve(expr, false));
553
546
  parser.hooks.call
554
547
  .for("require.resolveWeak")
555
- .tap("CommonJsImportsParserPlugin", expr => {
556
- return processResolve(expr, true);
557
- });
558
- //#endregion
548
+ .tap("CommonJsImportsParserPlugin", expr => processResolve(expr, true));
549
+ // #endregion
559
550
 
560
- //#region Create require
551
+ // #region Create require
561
552
 
562
553
  if (!options.createRequire) return;
563
554
 
@@ -610,12 +601,12 @@ class CommonJsImportsParserPlugin {
610
601
  });
611
602
  parser.hooks.unhandledExpressionMemberChain
612
603
  .for(createdRequireIdentifierTag)
613
- .tap("CommonJsImportsParserPlugin", (expr, members) => {
614
- return expressionIsUnsupported(
604
+ .tap("CommonJsImportsParserPlugin", (expr, members) =>
605
+ expressionIsUnsupported(
615
606
  parser,
616
607
  `createRequire().${members.join(".")} is not supported by webpack.`
617
- )(expr);
618
- });
608
+ )(expr)
609
+ );
619
610
  parser.hooks.canRename
620
611
  .for(createdRequireIdentifierTag)
621
612
  .tap("CommonJsImportsParserPlugin", () => true);
@@ -789,7 +780,7 @@ class CommonJsImportsParserPlugin {
789
780
  parser.state.module.addPresentationalDependency(clearDep);
790
781
  return true;
791
782
  });
792
- //#endregion
783
+ // #endregion
793
784
  }
794
785
  }
795
786
  module.exports = CommonJsImportsParserPlugin;
@@ -50,7 +50,7 @@ class CommonJsSelfReferenceDependency extends NullDependency {
50
50
  * @returns {string | null} an identifier to merge equal requests
51
51
  */
52
52
  getResourceIdentifier() {
53
- return `self`;
53
+ return "self";
54
54
  }
55
55
 
56
56
  /**
@@ -108,19 +108,17 @@ CommonJsSelfReferenceDependency.Template = class CommonJsSelfReferenceDependency
108
108
  { module, moduleGraph, runtime, runtimeRequirements }
109
109
  ) {
110
110
  const dep = /** @type {CommonJsSelfReferenceDependency} */ (dependency);
111
- let used;
112
- if (dep.names.length === 0) {
113
- used = dep.names;
114
- } else {
115
- used = moduleGraph.getExportsInfo(module).getUsedName(dep.names, runtime);
116
- }
111
+ const used =
112
+ dep.names.length === 0
113
+ ? dep.names
114
+ : moduleGraph.getExportsInfo(module).getUsedName(dep.names, runtime);
117
115
  if (!used) {
118
116
  throw new Error(
119
117
  "Self-reference dependency has unused export name: This should not happen"
120
118
  );
121
119
  }
122
120
 
123
- let base = undefined;
121
+ let base;
124
122
  switch (dep.base) {
125
123
  case "exports":
126
124
  runtimeRequirements.add(RuntimeGlobals.exports);
@@ -44,7 +44,7 @@ class ConstDependency extends NullDependency {
44
44
  */
45
45
  updateHash(hash, context) {
46
46
  if (this._hashUpdate === undefined) {
47
- let hashUpdate = "" + this.range + "|" + this.expression;
47
+ let hashUpdate = `${this.range}|${this.expression}`;
48
48
  if (this.runtimeRequirements) {
49
49
  for (const item of this.runtimeRequirements) {
50
50
  hashUpdate += "|";
@@ -27,7 +27,7 @@ const getCriticalDependencyWarning = memoize(() =>
27
27
  * @param {RegExp | null | undefined} r regexp
28
28
  * @returns {string} stringified regexp
29
29
  */
30
- const regExpToString = r => (r ? r + "" : "");
30
+ const regExpToString = r => (r ? String(r) : "");
31
31
 
32
32
  class ContextDependency extends Dependency {
33
33
  /**
@@ -22,9 +22,7 @@ const { parseResource } = require("../util/identifier");
22
22
  * @param {string} str String to quote
23
23
  * @returns {string} Escaped string
24
24
  */
25
- const quoteMeta = str => {
26
- return str.replace(/[-[\]\\/{}()*+?.^$|]/g, "\\$&");
27
- };
25
+ const quoteMeta = str => str.replace(/[-[\]\\/{}()*+?.^$|]/g, "\\$&");
28
26
 
29
27
  /**
30
28
  * @param {string} prefix prefix
@@ -57,7 +55,7 @@ const splitContextFromPrefix = prefix => {
57
55
  * @param {...any} depArgs depArgs
58
56
  * @returns {ContextDependency} the created Dependency
59
57
  */
60
- exports.create = (
58
+ module.exports.create = (
61
59
  Dep,
62
60
  range,
63
61
  param,
@@ -69,8 +67,8 @@ exports.create = (
69
67
  ) => {
70
68
  if (param.isTemplateString()) {
71
69
  const quasis = /** @type {BasicEvaluatedExpression[]} */ (param.quasis);
72
- let prefixRaw = /** @type {string} */ (quasis[0].string);
73
- let postfixRaw =
70
+ const prefixRaw = /** @type {string} */ (quasis[0].string);
71
+ const postfixRaw =
74
72
  /** @type {string} */
75
73
  (quasis.length > 1 ? quasis[quasis.length - 1].string : "");
76
74
 
@@ -84,7 +82,7 @@ exports.create = (
84
82
 
85
83
  // When there are more than two quasis, the generated RegExp can be more precise
86
84
  // We join the quasis with the expression regexp
87
- const innerQuasis = quasis.slice(1, quasis.length - 1);
85
+ const innerQuasis = quasis.slice(1, -1);
88
86
  const innerRegExp =
89
87
  /** @type {RegExp} */ (options.wrappedContextRegExp).source +
90
88
  innerQuasis
@@ -125,14 +123,14 @@ exports.create = (
125
123
  const replaces = [];
126
124
  const parts = /** @type {BasicEvaluatedExpression[]} */ (param.parts);
127
125
 
128
- parts.forEach((part, i) => {
126
+ for (const [i, part] of parts.entries()) {
129
127
  if (i % 2 === 0) {
130
128
  // Quasis or merged quasi
131
129
  let range = /** @type {Range} */ (part.range);
132
130
  let value = /** @type {string} */ (part.string);
133
131
  if (param.templateStringKind === "cooked") {
134
132
  value = JSON.stringify(value);
135
- value = value.slice(1, value.length - 1);
133
+ value = value.slice(1, -1);
136
134
  }
137
135
  if (i === 0) {
138
136
  // prefix
@@ -151,14 +149,14 @@ exports.create = (
151
149
  /** @type {Range} */ (part.range)[0],
152
150
  /** @type {Range} */ (param.range)[1]
153
151
  ];
154
- value = value + "`";
152
+ value = `${value}\``;
155
153
  } else if (
156
154
  part.expression &&
157
155
  part.expression.type === "TemplateElement" &&
158
156
  part.expression.value.raw === value
159
157
  ) {
160
158
  // Shortcut when it's a single quasi and doesn't need to be replaced
161
- return;
159
+ continue;
162
160
  }
163
161
  replaces.push({
164
162
  range,
@@ -168,7 +166,7 @@ exports.create = (
168
166
  // Expression
169
167
  parser.walkExpression(part.expression);
170
168
  }
171
- });
169
+ }
172
170
 
173
171
  dep.replaces = replaces;
174
172
  dep.critical =
@@ -180,10 +178,10 @@ exports.create = (
180
178
  ((param.prefix && param.prefix.isString()) ||
181
179
  (param.postfix && param.postfix.isString()))
182
180
  ) {
183
- let prefixRaw =
181
+ const prefixRaw =
184
182
  /** @type {string} */
185
183
  (param.prefix && param.prefix.isString() ? param.prefix.string : "");
186
- let postfixRaw =
184
+ const postfixRaw =
187
185
  /** @type {string} */
188
186
  (param.postfix && param.postfix.isString() ? param.postfix.string : "");
189
187
  const prefixRange =
@@ -240,26 +238,25 @@ exports.create = (
240
238
  }
241
239
 
242
240
  return dep;
243
- } else {
244
- const dep = new Dep(
245
- {
246
- request: /** @type {string} */ (options.exprContextRequest),
247
- recursive: /** @type {boolean} */ (options.exprContextRecursive),
248
- regExp: /** @type {RegExp} */ (options.exprContextRegExp),
249
- mode: "sync",
250
- ...contextOptions
251
- },
252
- range,
253
- /** @type {Range} */ (param.range),
254
- ...depArgs
255
- );
256
- dep.loc = /** @type {DependencyLocation} */ (expr.loc);
257
- dep.critical =
258
- options.exprContextCritical &&
259
- "the request of a dependency is an expression";
241
+ }
242
+ const dep = new Dep(
243
+ {
244
+ request: /** @type {string} */ (options.exprContextRequest),
245
+ recursive: /** @type {boolean} */ (options.exprContextRecursive),
246
+ regExp: /** @type {RegExp} */ (options.exprContextRegExp),
247
+ mode: "sync",
248
+ ...contextOptions
249
+ },
250
+ range,
251
+ /** @type {Range} */ (param.range),
252
+ ...depArgs
253
+ );
254
+ dep.loc = /** @type {DependencyLocation} */ (expr.loc);
255
+ dep.critical =
256
+ options.exprContextCritical &&
257
+ "the request of a dependency is an expression";
260
258
 
261
- parser.walkExpression(param.expression);
259
+ parser.walkExpression(param.expression);
262
260
 
263
- return dep;
264
- }
261
+ return dep;
265
262
  };
@@ -20,9 +20,9 @@ class ContextElementDependency extends ModuleDependency {
20
20
  /**
21
21
  * @param {string} request request
22
22
  * @param {string|undefined} userRequest user request
23
- * @param {string} typePrefix type prefix
23
+ * @param {string | undefined} typePrefix type prefix
24
24
  * @param {string} category category
25
- * @param {string[][]=} referencedExports referenced exports
25
+ * @param {(string[][] | null)=} referencedExports referenced exports
26
26
  * @param {string=} context context
27
27
  * @param {ImportAttributes=} attributes import assertions
28
28
  */
@@ -16,7 +16,7 @@ class CriticalDependencyWarning extends WebpackError {
16
16
  super();
17
17
 
18
18
  this.name = "CriticalDependencyWarning";
19
- this.message = "Critical dependency: " + message;
19
+ this.message = `Critical dependency: ${message}`;
20
20
  }
21
21
  }
22
22
 
@@ -58,9 +58,9 @@ class CssExportDependency extends NullDependency {
58
58
  */
59
59
  getExports(moduleGraph) {
60
60
  const module = /** @type {CssModule} */ (moduleGraph.getParentModule(this));
61
- const convention = /** @type {CssGenerator | CssExportsGenerator} */ (
62
- module.generator
63
- ).convention;
61
+ const convention =
62
+ /** @type {CssGenerator | CssExportsGenerator} */
63
+ (module.generator).convention;
64
64
  const names = this.getExportsConventionNames(this.name, convention);
65
65
  return {
66
66
  exports: names.map(name => ({
@@ -81,14 +81,14 @@ class CssExportDependency extends NullDependency {
81
81
  const module = /** @type {CssModule} */ (
82
82
  chunkGraph.moduleGraph.getParentModule(this)
83
83
  );
84
- const generator = /** @type {CssGenerator | CssExportsGenerator} */ (
85
- module.generator
86
- );
84
+ const generator =
85
+ /** @type {CssGenerator | CssExportsGenerator} */
86
+ (module.generator);
87
87
  const names = this.getExportsConventionNames(
88
88
  this.name,
89
89
  generator.convention
90
90
  );
91
- hash.update(`exportsConvention`);
91
+ hash.update("exportsConvention");
92
92
  hash.update(JSON.stringify(names));
93
93
  }
94
94
 
@@ -26,9 +26,7 @@ const ModuleDependency = require("./ModuleDependency");
26
26
  class CssImportDependency extends ModuleDependency {
27
27
  /**
28
28
  * Example of dependency:
29
- *
30
29
  * \@import url("landscape.css") layer(forms) screen and (orientation: landscape) screen and (orientation: landscape);
31
- *
32
30
  * @param {string} request request
33
31
  * @param {Range} range range of the argument
34
32
  * @param {string | undefined} layer layer
@@ -141,9 +141,9 @@ class CssLocalIdentifierDependency extends NullDependency {
141
141
  this.name,
142
142
  generator.convention
143
143
  );
144
- hash.update(`exportsConvention`);
144
+ hash.update("exportsConvention");
145
145
  hash.update(JSON.stringify(names));
146
- hash.update(`localIdentName`);
146
+ hash.update("localIdentName");
147
147
  hash.update(generator.localIdentName);
148
148
  }
149
149
 
@@ -178,7 +178,7 @@ class CssLocalIdentifierDependency extends NullDependency {
178
178
  const escapeCssIdentifier = (str, omitUnderscore) => {
179
179
  const escaped = `${str}`.replace(
180
180
  // cspell:word uffff
181
- /[^a-zA-Z0-9_\u0081-\uffff-]/g,
181
+ /[^a-zA-Z0-9_\u0081-\uFFFF-]/g,
182
182
  s => `\\${s}`
183
183
  );
184
184
  return !omitUnderscore && /^(?!--)[0-9-]/.test(escaped)