@depup/webpack 5.105.4-depup.37

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 (709) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +38 -0
  3. package/bin/webpack.js +196 -0
  4. package/hot/dev-server.js +90 -0
  5. package/hot/emitter-event-target.js +7 -0
  6. package/hot/emitter.js +2 -0
  7. package/hot/lazy-compilation-node.js +66 -0
  8. package/hot/lazy-compilation-universal.js +18 -0
  9. package/hot/lazy-compilation-web.js +93 -0
  10. package/hot/load-http.js +7 -0
  11. package/hot/log-apply-result.js +49 -0
  12. package/hot/log.js +78 -0
  13. package/hot/only-dev-server.js +118 -0
  14. package/hot/poll.js +41 -0
  15. package/hot/signal.js +66 -0
  16. package/lib/APIPlugin.js +392 -0
  17. package/lib/AbstractMethodError.js +56 -0
  18. package/lib/AsyncDependenciesBlock.js +128 -0
  19. package/lib/AsyncDependencyToInitialChunkError.js +34 -0
  20. package/lib/AutomaticPrefetchPlugin.js +66 -0
  21. package/lib/BannerPlugin.js +138 -0
  22. package/lib/Cache.js +168 -0
  23. package/lib/CacheFacade.js +349 -0
  24. package/lib/CaseSensitiveModulesWarning.js +72 -0
  25. package/lib/Chunk.js +899 -0
  26. package/lib/ChunkGraph.js +1968 -0
  27. package/lib/ChunkGroup.js +615 -0
  28. package/lib/ChunkRenderError.js +38 -0
  29. package/lib/ChunkTemplate.js +181 -0
  30. package/lib/CleanPlugin.js +495 -0
  31. package/lib/CodeGenerationError.js +35 -0
  32. package/lib/CodeGenerationResults.js +167 -0
  33. package/lib/CommentCompilationWarning.js +33 -0
  34. package/lib/CompatibilityPlugin.js +240 -0
  35. package/lib/Compilation.js +5876 -0
  36. package/lib/Compiler.js +1413 -0
  37. package/lib/ConcatenationScope.js +181 -0
  38. package/lib/ConcurrentCompilationError.js +18 -0
  39. package/lib/ConditionalInitFragment.js +120 -0
  40. package/lib/ConstPlugin.js +567 -0
  41. package/lib/ContextExclusionPlugin.js +33 -0
  42. package/lib/ContextModule.js +1411 -0
  43. package/lib/ContextModuleFactory.js +514 -0
  44. package/lib/ContextReplacementPlugin.js +227 -0
  45. package/lib/CssModule.js +179 -0
  46. package/lib/DefinePlugin.js +878 -0
  47. package/lib/DelegatedModule.js +279 -0
  48. package/lib/DelegatedModuleFactoryPlugin.js +116 -0
  49. package/lib/DelegatedPlugin.js +49 -0
  50. package/lib/DependenciesBlock.js +120 -0
  51. package/lib/Dependency.js +390 -0
  52. package/lib/DependencyTemplate.js +71 -0
  53. package/lib/DependencyTemplates.js +67 -0
  54. package/lib/DllEntryPlugin.js +76 -0
  55. package/lib/DllModule.js +175 -0
  56. package/lib/DllModuleFactory.js +38 -0
  57. package/lib/DllPlugin.js +73 -0
  58. package/lib/DllReferencePlugin.js +189 -0
  59. package/lib/DotenvPlugin.js +468 -0
  60. package/lib/DynamicEntryPlugin.js +93 -0
  61. package/lib/EntryOptionPlugin.js +98 -0
  62. package/lib/EntryPlugin.js +72 -0
  63. package/lib/Entrypoint.js +120 -0
  64. package/lib/EnvironmentNotSupportAsyncWarning.js +51 -0
  65. package/lib/EnvironmentPlugin.js +74 -0
  66. package/lib/ErrorHelpers.js +100 -0
  67. package/lib/EvalDevToolModulePlugin.js +135 -0
  68. package/lib/EvalSourceMapDevToolPlugin.js +252 -0
  69. package/lib/ExportsInfo.js +1663 -0
  70. package/lib/ExportsInfoApiPlugin.js +87 -0
  71. package/lib/ExternalModule.js +1169 -0
  72. package/lib/ExternalModuleFactoryPlugin.js +370 -0
  73. package/lib/ExternalsPlugin.js +93 -0
  74. package/lib/FalseIIFEUmdWarning.js +20 -0
  75. package/lib/FileSystemInfo.js +4131 -0
  76. package/lib/FlagAllModulesAsUsedPlugin.js +55 -0
  77. package/lib/FlagDependencyExportsPlugin.js +437 -0
  78. package/lib/FlagDependencyUsagePlugin.js +348 -0
  79. package/lib/FlagEntryExportAsUsedPlugin.js +56 -0
  80. package/lib/Generator.js +188 -0
  81. package/lib/GraphHelpers.js +46 -0
  82. package/lib/HarmonyLinkingError.js +17 -0
  83. package/lib/HookWebpackError.js +121 -0
  84. package/lib/HotModuleReplacementPlugin.js +930 -0
  85. package/lib/HotUpdateChunk.js +16 -0
  86. package/lib/IgnoreErrorModuleFactory.js +39 -0
  87. package/lib/IgnorePlugin.js +105 -0
  88. package/lib/IgnoreWarningsPlugin.js +41 -0
  89. package/lib/InitFragment.js +204 -0
  90. package/lib/InvalidDependenciesModuleWarning.js +44 -0
  91. package/lib/JavascriptMetaInfoPlugin.js +78 -0
  92. package/lib/LibManifestPlugin.js +144 -0
  93. package/lib/LibraryTemplatePlugin.js +48 -0
  94. package/lib/LoaderOptionsPlugin.js +81 -0
  95. package/lib/LoaderTargetPlugin.js +39 -0
  96. package/lib/MainTemplate.js +371 -0
  97. package/lib/ManifestPlugin.js +242 -0
  98. package/lib/Module.js +1319 -0
  99. package/lib/ModuleBuildError.js +83 -0
  100. package/lib/ModuleDependencyError.js +44 -0
  101. package/lib/ModuleDependencyWarning.js +49 -0
  102. package/lib/ModuleError.js +69 -0
  103. package/lib/ModuleFactory.js +57 -0
  104. package/lib/ModuleFilenameHelpers.js +388 -0
  105. package/lib/ModuleGraph.js +1024 -0
  106. package/lib/ModuleGraphConnection.js +199 -0
  107. package/lib/ModuleHashingError.js +31 -0
  108. package/lib/ModuleInfoHeaderPlugin.js +318 -0
  109. package/lib/ModuleNotFoundError.js +90 -0
  110. package/lib/ModuleParseError.js +125 -0
  111. package/lib/ModuleProfile.js +108 -0
  112. package/lib/ModuleRestoreError.js +46 -0
  113. package/lib/ModuleSourceTypeConstants.js +179 -0
  114. package/lib/ModuleStoreError.js +45 -0
  115. package/lib/ModuleTemplate.js +173 -0
  116. package/lib/ModuleTypeConstants.js +190 -0
  117. package/lib/ModuleWarning.js +68 -0
  118. package/lib/MultiCompiler.js +678 -0
  119. package/lib/MultiStats.js +213 -0
  120. package/lib/MultiWatching.js +77 -0
  121. package/lib/NoEmitOnErrorsPlugin.js +30 -0
  122. package/lib/NoModeWarning.js +23 -0
  123. package/lib/NodeStuffInWebError.js +35 -0
  124. package/lib/NodeStuffPlugin.js +587 -0
  125. package/lib/NormalModule.js +1798 -0
  126. package/lib/NormalModuleFactory.js +1455 -0
  127. package/lib/NormalModuleReplacementPlugin.js +75 -0
  128. package/lib/NullFactory.js +24 -0
  129. package/lib/OptimizationStages.js +10 -0
  130. package/lib/OptionsApply.js +24 -0
  131. package/lib/Parser.js +40 -0
  132. package/lib/PlatformPlugin.js +41 -0
  133. package/lib/PrefetchPlugin.js +56 -0
  134. package/lib/ProgressPlugin.js +712 -0
  135. package/lib/ProvidePlugin.js +121 -0
  136. package/lib/RawModule.js +180 -0
  137. package/lib/RecordIdsPlugin.js +216 -0
  138. package/lib/RequestShortener.js +36 -0
  139. package/lib/RequireJsStuffPlugin.js +84 -0
  140. package/lib/ResolverFactory.js +156 -0
  141. package/lib/RuntimeGlobals.js +450 -0
  142. package/lib/RuntimeModule.js +242 -0
  143. package/lib/RuntimePlugin.js +547 -0
  144. package/lib/RuntimeTemplate.js +1288 -0
  145. package/lib/SelfModuleFactory.js +33 -0
  146. package/lib/SingleEntryPlugin.js +8 -0
  147. package/lib/SizeFormatHelpers.js +25 -0
  148. package/lib/SourceMapDevToolModuleOptionsPlugin.js +52 -0
  149. package/lib/SourceMapDevToolPlugin.js +646 -0
  150. package/lib/Stats.js +89 -0
  151. package/lib/Template.js +427 -0
  152. package/lib/TemplatedPathPlugin.js +400 -0
  153. package/lib/UnhandledSchemeError.js +34 -0
  154. package/lib/UnsupportedFeatureWarning.js +35 -0
  155. package/lib/UseStrictPlugin.js +81 -0
  156. package/lib/WarnCaseSensitiveModulesPlugin.js +64 -0
  157. package/lib/WarnDeprecatedOptionPlugin.js +60 -0
  158. package/lib/WarnNoModeSetPlugin.js +27 -0
  159. package/lib/WatchIgnorePlugin.js +155 -0
  160. package/lib/Watching.js +531 -0
  161. package/lib/WebpackError.js +81 -0
  162. package/lib/WebpackIsIncludedPlugin.js +93 -0
  163. package/lib/WebpackOptionsApply.js +941 -0
  164. package/lib/WebpackOptionsDefaulter.js +26 -0
  165. package/lib/asset/AssetBytesGenerator.js +172 -0
  166. package/lib/asset/AssetBytesParser.js +37 -0
  167. package/lib/asset/AssetGenerator.js +816 -0
  168. package/lib/asset/AssetModulesPlugin.js +358 -0
  169. package/lib/asset/AssetParser.js +73 -0
  170. package/lib/asset/AssetSourceGenerator.js +171 -0
  171. package/lib/asset/AssetSourceParser.js +37 -0
  172. package/lib/asset/RawDataUrlModule.js +179 -0
  173. package/lib/async-modules/AsyncModuleHelpers.js +52 -0
  174. package/lib/async-modules/AwaitDependenciesInitFragment.js +90 -0
  175. package/lib/async-modules/InferAsyncModulesPlugin.js +54 -0
  176. package/lib/buildChunkGraph.js +1392 -0
  177. package/lib/cache/AddBuildDependenciesPlugin.js +32 -0
  178. package/lib/cache/AddManagedPathsPlugin.js +40 -0
  179. package/lib/cache/IdleFileCachePlugin.js +242 -0
  180. package/lib/cache/MemoryCachePlugin.js +57 -0
  181. package/lib/cache/MemoryWithGcCachePlugin.js +142 -0
  182. package/lib/cache/PackFileCacheStrategy.js +1600 -0
  183. package/lib/cache/ResolverCachePlugin.js +450 -0
  184. package/lib/cache/getLazyHashedEtag.js +91 -0
  185. package/lib/cache/mergeEtags.js +71 -0
  186. package/lib/cli.js +859 -0
  187. package/lib/config/browserslistTargetHandler.js +388 -0
  188. package/lib/config/defaults.js +2086 -0
  189. package/lib/config/normalization.js +681 -0
  190. package/lib/config/target.js +389 -0
  191. package/lib/container/ContainerEntryDependency.js +50 -0
  192. package/lib/container/ContainerEntryModule.js +303 -0
  193. package/lib/container/ContainerEntryModuleFactory.js +27 -0
  194. package/lib/container/ContainerExposedDependency.js +62 -0
  195. package/lib/container/ContainerPlugin.js +118 -0
  196. package/lib/container/ContainerReferencePlugin.js +139 -0
  197. package/lib/container/FallbackDependency.js +66 -0
  198. package/lib/container/FallbackItemDependency.js +34 -0
  199. package/lib/container/FallbackModule.js +193 -0
  200. package/lib/container/FallbackModuleFactory.js +27 -0
  201. package/lib/container/HoistContainerReferencesPlugin.js +256 -0
  202. package/lib/container/ModuleFederationPlugin.js +131 -0
  203. package/lib/container/RemoteModule.js +225 -0
  204. package/lib/container/RemoteRuntimeModule.js +144 -0
  205. package/lib/container/RemoteToExternalDependency.js +33 -0
  206. package/lib/container/options.js +105 -0
  207. package/lib/css/CssGenerator.js +587 -0
  208. package/lib/css/CssLoadingRuntimeModule.js +513 -0
  209. package/lib/css/CssMergeStyleSheetsRuntimeModule.js +56 -0
  210. package/lib/css/CssModulesPlugin.js +939 -0
  211. package/lib/css/CssParser.js +2621 -0
  212. package/lib/css/walkCssTokens.js +1740 -0
  213. package/lib/debug/ProfilingPlugin.js +589 -0
  214. package/lib/dependencies/AMDDefineDependency.js +267 -0
  215. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +504 -0
  216. package/lib/dependencies/AMDPlugin.js +243 -0
  217. package/lib/dependencies/AMDRequireArrayDependency.js +124 -0
  218. package/lib/dependencies/AMDRequireContextDependency.js +69 -0
  219. package/lib/dependencies/AMDRequireDependenciesBlock.js +28 -0
  220. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +425 -0
  221. package/lib/dependencies/AMDRequireDependency.js +189 -0
  222. package/lib/dependencies/AMDRequireItemDependency.js +41 -0
  223. package/lib/dependencies/AMDRuntimeModules.js +50 -0
  224. package/lib/dependencies/CachedConstDependency.js +135 -0
  225. package/lib/dependencies/CommonJsDependencyHelpers.js +65 -0
  226. package/lib/dependencies/CommonJsExportRequireDependency.js +416 -0
  227. package/lib/dependencies/CommonJsExportsDependency.js +184 -0
  228. package/lib/dependencies/CommonJsExportsParserPlugin.js +425 -0
  229. package/lib/dependencies/CommonJsFullRequireDependency.js +162 -0
  230. package/lib/dependencies/CommonJsImportsParserPlugin.js +611 -0
  231. package/lib/dependencies/CommonJsPlugin.js +316 -0
  232. package/lib/dependencies/CommonJsRequireContextDependency.js +73 -0
  233. package/lib/dependencies/CommonJsRequireDependency.js +42 -0
  234. package/lib/dependencies/CommonJsSelfReferenceDependency.js +156 -0
  235. package/lib/dependencies/ConstDependency.js +118 -0
  236. package/lib/dependencies/ContextDependency.js +183 -0
  237. package/lib/dependencies/ContextDependencyHelpers.js +277 -0
  238. package/lib/dependencies/ContextDependencyTemplateAsId.js +63 -0
  239. package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +62 -0
  240. package/lib/dependencies/ContextElementDependency.js +147 -0
  241. package/lib/dependencies/CreateRequireParserPlugin.js +356 -0
  242. package/lib/dependencies/CreateScriptUrlDependency.js +75 -0
  243. package/lib/dependencies/CriticalDependencyWarning.js +29 -0
  244. package/lib/dependencies/CssIcssExportDependency.js +539 -0
  245. package/lib/dependencies/CssIcssImportDependency.js +183 -0
  246. package/lib/dependencies/CssIcssSymbolDependency.js +131 -0
  247. package/lib/dependencies/CssImportDependency.js +120 -0
  248. package/lib/dependencies/CssUrlDependency.js +189 -0
  249. package/lib/dependencies/DelegatedSourceDependency.js +33 -0
  250. package/lib/dependencies/DllEntryDependency.js +61 -0
  251. package/lib/dependencies/DynamicExports.js +73 -0
  252. package/lib/dependencies/EntryDependency.js +30 -0
  253. package/lib/dependencies/ExportsInfoDependency.js +161 -0
  254. package/lib/dependencies/ExternalModuleDependency.js +109 -0
  255. package/lib/dependencies/ExternalModuleInitFragment.js +137 -0
  256. package/lib/dependencies/ExternalModuleInitFragmentDependency.js +87 -0
  257. package/lib/dependencies/HarmonyAcceptDependency.js +237 -0
  258. package/lib/dependencies/HarmonyAcceptImportDependency.js +37 -0
  259. package/lib/dependencies/HarmonyCompatibilityDependency.js +91 -0
  260. package/lib/dependencies/HarmonyDetectionParserPlugin.js +103 -0
  261. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +165 -0
  262. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +254 -0
  263. package/lib/dependencies/HarmonyExportExpressionDependency.js +211 -0
  264. package/lib/dependencies/HarmonyExportHeaderDependency.js +78 -0
  265. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +1494 -0
  266. package/lib/dependencies/HarmonyExportInitFragment.js +191 -0
  267. package/lib/dependencies/HarmonyExportSpecifierDependency.js +127 -0
  268. package/lib/dependencies/HarmonyExports.js +46 -0
  269. package/lib/dependencies/HarmonyImportDependency.js +459 -0
  270. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +576 -0
  271. package/lib/dependencies/HarmonyImportSideEffectDependency.js +91 -0
  272. package/lib/dependencies/HarmonyImportSpecifierDependency.js +514 -0
  273. package/lib/dependencies/HarmonyModulesPlugin.js +158 -0
  274. package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +39 -0
  275. package/lib/dependencies/ImportContextDependency.js +81 -0
  276. package/lib/dependencies/ImportDependency.js +158 -0
  277. package/lib/dependencies/ImportEagerDependency.js +76 -0
  278. package/lib/dependencies/ImportMetaContextDependency.js +42 -0
  279. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +312 -0
  280. package/lib/dependencies/ImportMetaContextPlugin.js +72 -0
  281. package/lib/dependencies/ImportMetaHotAcceptDependency.js +41 -0
  282. package/lib/dependencies/ImportMetaHotDeclineDependency.js +42 -0
  283. package/lib/dependencies/ImportMetaPlugin.js +447 -0
  284. package/lib/dependencies/ImportParserPlugin.js +602 -0
  285. package/lib/dependencies/ImportPhase.js +125 -0
  286. package/lib/dependencies/ImportPlugin.js +98 -0
  287. package/lib/dependencies/ImportWeakDependency.js +74 -0
  288. package/lib/dependencies/JsonExportsDependency.js +137 -0
  289. package/lib/dependencies/LoaderDependency.js +38 -0
  290. package/lib/dependencies/LoaderImportDependency.js +39 -0
  291. package/lib/dependencies/LoaderPlugin.js +294 -0
  292. package/lib/dependencies/LocalModule.js +60 -0
  293. package/lib/dependencies/LocalModuleDependency.js +84 -0
  294. package/lib/dependencies/LocalModulesHelpers.js +68 -0
  295. package/lib/dependencies/ModuleDecoratorDependency.js +136 -0
  296. package/lib/dependencies/ModuleDependency.js +100 -0
  297. package/lib/dependencies/ModuleDependencyTemplateAsId.js +35 -0
  298. package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +39 -0
  299. package/lib/dependencies/ModuleHotAcceptDependency.js +41 -0
  300. package/lib/dependencies/ModuleHotDeclineDependency.js +42 -0
  301. package/lib/dependencies/ModuleInitFragmentDependency.js +87 -0
  302. package/lib/dependencies/NullDependency.js +42 -0
  303. package/lib/dependencies/PrefetchDependency.js +27 -0
  304. package/lib/dependencies/ProvidedDependency.js +156 -0
  305. package/lib/dependencies/PureExpressionDependency.js +161 -0
  306. package/lib/dependencies/RequireContextDependency.js +38 -0
  307. package/lib/dependencies/RequireContextDependencyParserPlugin.js +69 -0
  308. package/lib/dependencies/RequireContextPlugin.js +167 -0
  309. package/lib/dependencies/RequireEnsureDependenciesBlock.js +29 -0
  310. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +145 -0
  311. package/lib/dependencies/RequireEnsureDependency.js +115 -0
  312. package/lib/dependencies/RequireEnsureItemDependency.js +36 -0
  313. package/lib/dependencies/RequireEnsurePlugin.js +86 -0
  314. package/lib/dependencies/RequireHeaderDependency.js +70 -0
  315. package/lib/dependencies/RequireIncludeDependency.js +79 -0
  316. package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +100 -0
  317. package/lib/dependencies/RequireIncludePlugin.js +63 -0
  318. package/lib/dependencies/RequireResolveContextDependency.js +67 -0
  319. package/lib/dependencies/RequireResolveDependency.js +58 -0
  320. package/lib/dependencies/RequireResolveHeaderDependency.js +81 -0
  321. package/lib/dependencies/RuntimeRequirementsDependency.js +85 -0
  322. package/lib/dependencies/StaticExportsDependency.js +72 -0
  323. package/lib/dependencies/SystemPlugin.js +168 -0
  324. package/lib/dependencies/SystemRuntimeModule.js +35 -0
  325. package/lib/dependencies/URLContextDependency.js +65 -0
  326. package/lib/dependencies/URLDependency.js +165 -0
  327. package/lib/dependencies/URLPlugin.js +67 -0
  328. package/lib/dependencies/UnsupportedDependency.js +82 -0
  329. package/lib/dependencies/WebAssemblyExportImportedDependency.js +93 -0
  330. package/lib/dependencies/WebAssemblyImportDependency.js +108 -0
  331. package/lib/dependencies/WebpackIsIncludedDependency.js +84 -0
  332. package/lib/dependencies/WorkerDependency.js +141 -0
  333. package/lib/dependencies/WorkerPlugin.js +565 -0
  334. package/lib/dependencies/getFunctionExpression.js +66 -0
  335. package/lib/dependencies/processExportInfo.js +67 -0
  336. package/lib/electron/ElectronTargetPlugin.js +71 -0
  337. package/lib/errors/BuildCycleError.js +30 -0
  338. package/lib/esm/ExportWebpackRequireRuntimeModule.js +30 -0
  339. package/lib/esm/ModuleChunkFormatPlugin.js +273 -0
  340. package/lib/esm/ModuleChunkLoadingPlugin.js +143 -0
  341. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +426 -0
  342. package/lib/formatLocation.js +67 -0
  343. package/lib/hmr/HotModuleReplacement.runtime.js +419 -0
  344. package/lib/hmr/HotModuleReplacementRuntimeModule.js +42 -0
  345. package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +471 -0
  346. package/lib/hmr/JavascriptHotModuleReplacementHelper.js +37 -0
  347. package/lib/hmr/LazyCompilationPlugin.js +473 -0
  348. package/lib/hmr/lazyCompilationBackend.js +167 -0
  349. package/lib/ids/ChunkModuleIdRangePlugin.js +94 -0
  350. package/lib/ids/DeterministicChunkIdsPlugin.js +73 -0
  351. package/lib/ids/DeterministicModuleIdsPlugin.js +98 -0
  352. package/lib/ids/HashedModuleIdsPlugin.js +85 -0
  353. package/lib/ids/IdHelpers.js +492 -0
  354. package/lib/ids/NamedChunkIdsPlugin.js +92 -0
  355. package/lib/ids/NamedModuleIdsPlugin.js +68 -0
  356. package/lib/ids/NaturalChunkIdsPlugin.js +35 -0
  357. package/lib/ids/NaturalModuleIdsPlugin.js +40 -0
  358. package/lib/ids/OccurrenceChunkIdsPlugin.js +86 -0
  359. package/lib/ids/OccurrenceModuleIdsPlugin.js +168 -0
  360. package/lib/ids/SyncModuleIdsPlugin.js +161 -0
  361. package/lib/index.js +681 -0
  362. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +153 -0
  363. package/lib/javascript/BasicEvaluatedExpression.js +603 -0
  364. package/lib/javascript/ChunkFormatHelpers.js +70 -0
  365. package/lib/javascript/ChunkHelpers.js +45 -0
  366. package/lib/javascript/CommonJsChunkFormatPlugin.js +148 -0
  367. package/lib/javascript/EnableChunkLoadingPlugin.js +127 -0
  368. package/lib/javascript/JavascriptGenerator.js +277 -0
  369. package/lib/javascript/JavascriptModulesPlugin.js +1905 -0
  370. package/lib/javascript/JavascriptParser.js +5476 -0
  371. package/lib/javascript/JavascriptParserHelpers.js +129 -0
  372. package/lib/javascript/StartupHelpers.js +178 -0
  373. package/lib/json/JsonData.js +74 -0
  374. package/lib/json/JsonGenerator.js +234 -0
  375. package/lib/json/JsonModulesPlugin.js +66 -0
  376. package/lib/json/JsonParser.js +93 -0
  377. package/lib/library/AbstractLibraryPlugin.js +339 -0
  378. package/lib/library/AmdLibraryPlugin.js +181 -0
  379. package/lib/library/AssignLibraryPlugin.js +445 -0
  380. package/lib/library/EnableLibraryPlugin.js +306 -0
  381. package/lib/library/ExportPropertyLibraryPlugin.js +116 -0
  382. package/lib/library/JsonpLibraryPlugin.js +92 -0
  383. package/lib/library/ModuleLibraryPlugin.js +438 -0
  384. package/lib/library/SystemLibraryPlugin.js +256 -0
  385. package/lib/library/UmdLibraryPlugin.js +355 -0
  386. package/lib/logging/Logger.js +223 -0
  387. package/lib/logging/createConsoleLogger.js +217 -0
  388. package/lib/logging/runtime.js +45 -0
  389. package/lib/logging/truncateArgs.js +83 -0
  390. package/lib/node/CommonJsChunkLoadingPlugin.js +120 -0
  391. package/lib/node/NodeEnvironmentPlugin.js +73 -0
  392. package/lib/node/NodeSourcePlugin.js +19 -0
  393. package/lib/node/NodeTargetPlugin.js +102 -0
  394. package/lib/node/NodeTemplatePlugin.js +42 -0
  395. package/lib/node/NodeWatchFileSystem.js +198 -0
  396. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +286 -0
  397. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +123 -0
  398. package/lib/node/ReadFileCompileWasmPlugin.js +127 -0
  399. package/lib/node/RequireChunkLoadingRuntimeModule.js +239 -0
  400. package/lib/node/nodeConsole.js +185 -0
  401. package/lib/optimize/AggressiveMergingPlugin.js +98 -0
  402. package/lib/optimize/AggressiveSplittingPlugin.js +352 -0
  403. package/lib/optimize/ConcatenatedModule.js +2290 -0
  404. package/lib/optimize/EnsureChunkConditionsPlugin.js +88 -0
  405. package/lib/optimize/FlagIncludedChunksPlugin.js +137 -0
  406. package/lib/optimize/InnerGraph.js +368 -0
  407. package/lib/optimize/InnerGraphPlugin.js +455 -0
  408. package/lib/optimize/LimitChunkCountPlugin.js +302 -0
  409. package/lib/optimize/MangleExportsPlugin.js +194 -0
  410. package/lib/optimize/MergeDuplicateChunksPlugin.js +138 -0
  411. package/lib/optimize/MinChunkSizePlugin.js +121 -0
  412. package/lib/optimize/MinMaxSizeWarning.js +35 -0
  413. package/lib/optimize/ModuleConcatenationPlugin.js +971 -0
  414. package/lib/optimize/RealContentHashPlugin.js +488 -0
  415. package/lib/optimize/RemoveEmptyChunksPlugin.js +60 -0
  416. package/lib/optimize/RemoveParentModulesPlugin.js +216 -0
  417. package/lib/optimize/RuntimeChunkPlugin.js +52 -0
  418. package/lib/optimize/SideEffectsFlagPlugin.js +417 -0
  419. package/lib/optimize/SplitChunksPlugin.js +1836 -0
  420. package/lib/performance/AssetsOverSizeLimitWarning.js +37 -0
  421. package/lib/performance/EntrypointsOverSizeLimitWarning.js +40 -0
  422. package/lib/performance/NoAsyncChunksWarning.js +21 -0
  423. package/lib/performance/SizeLimitsPlugin.js +183 -0
  424. package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +46 -0
  425. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +95 -0
  426. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +56 -0
  427. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +52 -0
  428. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +46 -0
  429. package/lib/rules/BasicEffectRulePlugin.js +56 -0
  430. package/lib/rules/BasicMatcherRulePlugin.js +68 -0
  431. package/lib/rules/ObjectMatcherRulePlugin.js +79 -0
  432. package/lib/rules/RuleSetCompiler.js +447 -0
  433. package/lib/rules/UseEffectRulePlugin.js +236 -0
  434. package/lib/runtime/AsyncModuleRuntimeModule.js +199 -0
  435. package/lib/runtime/AutoPublicPathRuntimeModule.js +90 -0
  436. package/lib/runtime/BaseUriRuntimeModule.js +35 -0
  437. package/lib/runtime/ChunkNameRuntimeModule.js +28 -0
  438. package/lib/runtime/CompatGetDefaultExportRuntimeModule.js +40 -0
  439. package/lib/runtime/CompatRuntimeModule.js +83 -0
  440. package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +69 -0
  441. package/lib/runtime/CreateScriptRuntimeModule.js +38 -0
  442. package/lib/runtime/CreateScriptUrlRuntimeModule.js +38 -0
  443. package/lib/runtime/DefinePropertyGettersRuntimeModule.js +42 -0
  444. package/lib/runtime/EnsureChunkRuntimeModule.js +69 -0
  445. package/lib/runtime/GetChunkFilenameRuntimeModule.js +299 -0
  446. package/lib/runtime/GetFullHashRuntimeModule.js +31 -0
  447. package/lib/runtime/GetMainFilenameRuntimeModule.js +49 -0
  448. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +99 -0
  449. package/lib/runtime/GlobalRuntimeModule.js +47 -0
  450. package/lib/runtime/HasOwnPropertyRuntimeModule.js +35 -0
  451. package/lib/runtime/HelperRuntimeModule.js +18 -0
  452. package/lib/runtime/LoadScriptRuntimeModule.js +174 -0
  453. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +232 -0
  454. package/lib/runtime/MakeNamespaceObjectRuntimeModule.js +39 -0
  455. package/lib/runtime/NonceRuntimeModule.js +24 -0
  456. package/lib/runtime/OnChunksLoadedRuntimeModule.js +78 -0
  457. package/lib/runtime/PublicPathRuntimeModule.js +38 -0
  458. package/lib/runtime/RelativeUrlRuntimeModule.js +44 -0
  459. package/lib/runtime/RuntimeIdRuntimeModule.js +33 -0
  460. package/lib/runtime/StartupChunkDependenciesPlugin.js +88 -0
  461. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +77 -0
  462. package/lib/runtime/StartupEntrypointRuntimeModule.js +54 -0
  463. package/lib/runtime/SystemContextRuntimeModule.js +23 -0
  464. package/lib/runtime/ToBinaryRuntimeModule.js +72 -0
  465. package/lib/schemes/DataUriPlugin.js +47 -0
  466. package/lib/schemes/FileUriPlugin.js +54 -0
  467. package/lib/schemes/HttpUriPlugin.js +1410 -0
  468. package/lib/schemes/VirtualUrlPlugin.js +248 -0
  469. package/lib/serialization/AggregateErrorSerializer.js +41 -0
  470. package/lib/serialization/ArraySerializer.js +38 -0
  471. package/lib/serialization/BinaryMiddleware.js +1164 -0
  472. package/lib/serialization/DateObjectSerializer.js +28 -0
  473. package/lib/serialization/ErrorObjectSerializer.js +49 -0
  474. package/lib/serialization/FileMiddleware.js +766 -0
  475. package/lib/serialization/MapObjectSerializer.js +48 -0
  476. package/lib/serialization/NullPrototypeObjectSerializer.js +53 -0
  477. package/lib/serialization/ObjectMiddleware.js +877 -0
  478. package/lib/serialization/PlainObjectSerializer.js +119 -0
  479. package/lib/serialization/RegExpObjectSerializer.js +29 -0
  480. package/lib/serialization/Serializer.js +82 -0
  481. package/lib/serialization/SerializerMiddleware.js +226 -0
  482. package/lib/serialization/SetObjectSerializer.js +40 -0
  483. package/lib/serialization/SingleItemMiddleware.js +36 -0
  484. package/lib/serialization/types.js +13 -0
  485. package/lib/sharing/ConsumeSharedFallbackDependency.js +33 -0
  486. package/lib/sharing/ConsumeSharedModule.js +344 -0
  487. package/lib/sharing/ConsumeSharedPlugin.js +380 -0
  488. package/lib/sharing/ConsumeSharedRuntimeModule.js +358 -0
  489. package/lib/sharing/ProvideForSharedDependency.js +33 -0
  490. package/lib/sharing/ProvideSharedDependency.js +80 -0
  491. package/lib/sharing/ProvideSharedModule.js +196 -0
  492. package/lib/sharing/ProvideSharedModuleFactory.js +37 -0
  493. package/lib/sharing/ProvideSharedPlugin.js +248 -0
  494. package/lib/sharing/SharePlugin.js +91 -0
  495. package/lib/sharing/ShareRuntimeModule.js +152 -0
  496. package/lib/sharing/resolveMatchedConfigs.js +106 -0
  497. package/lib/sharing/utils.js +421 -0
  498. package/lib/stats/DefaultStatsFactoryPlugin.js +2791 -0
  499. package/lib/stats/DefaultStatsPresetPlugin.js +417 -0
  500. package/lib/stats/DefaultStatsPrinterPlugin.js +1860 -0
  501. package/lib/stats/StatsFactory.js +406 -0
  502. package/lib/stats/StatsPrinter.js +300 -0
  503. package/lib/url/URLParserPlugin.js +266 -0
  504. package/lib/util/AppendOnlyStackedSet.js +78 -0
  505. package/lib/util/ArrayHelpers.js +46 -0
  506. package/lib/util/ArrayQueue.js +104 -0
  507. package/lib/util/AsyncQueue.js +411 -0
  508. package/lib/util/Hash.js +68 -0
  509. package/lib/util/IterableHelpers.js +46 -0
  510. package/lib/util/LazyBucketSortedSet.js +272 -0
  511. package/lib/util/LazySet.js +236 -0
  512. package/lib/util/MapHelpers.js +34 -0
  513. package/lib/util/ParallelismFactorCalculator.js +70 -0
  514. package/lib/util/Queue.js +52 -0
  515. package/lib/util/Semaphore.js +51 -0
  516. package/lib/util/SetHelpers.js +94 -0
  517. package/lib/util/SortableSet.js +176 -0
  518. package/lib/util/StackedCacheMap.js +140 -0
  519. package/lib/util/StackedMap.js +164 -0
  520. package/lib/util/StringXor.js +103 -0
  521. package/lib/util/TupleQueue.js +70 -0
  522. package/lib/util/TupleSet.js +185 -0
  523. package/lib/util/URLAbsoluteSpecifier.js +86 -0
  524. package/lib/util/WeakTupleMap.js +227 -0
  525. package/lib/util/binarySearchBounds.js +136 -0
  526. package/lib/util/chainedImports.js +99 -0
  527. package/lib/util/cleverMerge.js +676 -0
  528. package/lib/util/comparators.js +645 -0
  529. package/lib/util/compileBooleanMatcher.js +313 -0
  530. package/lib/util/concatenate.js +232 -0
  531. package/lib/util/conventions.js +126 -0
  532. package/lib/util/create-schema-validation.js +41 -0
  533. package/lib/util/createHash.js +91 -0
  534. package/lib/util/dataURL.js +39 -0
  535. package/lib/util/deprecation.js +350 -0
  536. package/lib/util/deterministicGrouping.js +561 -0
  537. package/lib/util/extractSourceMap.js +318 -0
  538. package/lib/util/extractUrlAndGlobal.js +18 -0
  539. package/lib/util/findGraphRoots.js +211 -0
  540. package/lib/util/fs.js +675 -0
  541. package/lib/util/generateDebugId.js +33 -0
  542. package/lib/util/hash/BatchedHash.js +115 -0
  543. package/lib/util/hash/BulkUpdateHash.js +145 -0
  544. package/lib/util/hash/DebugHash.js +75 -0
  545. package/lib/util/hash/hash-digest.js +217 -0
  546. package/lib/util/hash/md4.js +20 -0
  547. package/lib/util/hash/wasm-hash.js +232 -0
  548. package/lib/util/hash/xxhash64.js +20 -0
  549. package/lib/util/identifier.js +471 -0
  550. package/lib/util/internalSerializables.js +222 -0
  551. package/lib/util/magicComment.js +25 -0
  552. package/lib/util/makeSerializable.js +60 -0
  553. package/lib/util/memoize.js +36 -0
  554. package/lib/util/nonNumericOnlyHash.js +22 -0
  555. package/lib/util/numberHash.js +95 -0
  556. package/lib/util/objectToMap.js +15 -0
  557. package/lib/util/processAsyncTree.js +68 -0
  558. package/lib/util/propertyAccess.js +30 -0
  559. package/lib/util/propertyName.js +76 -0
  560. package/lib/util/registerExternalSerializer.js +334 -0
  561. package/lib/util/removeBOM.js +25 -0
  562. package/lib/util/runtime.js +717 -0
  563. package/lib/util/semver.js +604 -0
  564. package/lib/util/serialization.js +153 -0
  565. package/lib/util/smartGrouping.js +221 -0
  566. package/lib/util/source.js +62 -0
  567. package/lib/util/traverseDestructuringAssignmentProperties.js +45 -0
  568. package/lib/validateSchema.js +177 -0
  569. package/lib/wasm/EnableWasmLoadingPlugin.js +146 -0
  570. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +154 -0
  571. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +74 -0
  572. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +212 -0
  573. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +209 -0
  574. package/lib/wasm-async/AsyncWebAssemblyParser.js +80 -0
  575. package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +107 -0
  576. package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +20 -0
  577. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +422 -0
  578. package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +91 -0
  579. package/lib/wasm-sync/WebAssemblyGenerator.js +535 -0
  580. package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +111 -0
  581. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +236 -0
  582. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +151 -0
  583. package/lib/wasm-sync/WebAssemblyParser.js +201 -0
  584. package/lib/wasm-sync/WebAssemblyUtils.js +66 -0
  585. package/lib/web/FetchCompileAsyncWasmPlugin.js +70 -0
  586. package/lib/web/FetchCompileWasmPlugin.js +86 -0
  587. package/lib/web/JsonpChunkLoadingPlugin.js +101 -0
  588. package/lib/web/JsonpChunkLoadingRuntimeModule.js +455 -0
  589. package/lib/web/JsonpTemplatePlugin.js +37 -0
  590. package/lib/webpack.js +227 -0
  591. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +110 -0
  592. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +231 -0
  593. package/lib/webworker/WebWorkerTemplatePlugin.js +26 -0
  594. package/module.d.ts +238 -0
  595. package/package.json +258 -0
  596. package/schemas/WebpackOptions.check.d.ts +7 -0
  597. package/schemas/WebpackOptions.check.js +6 -0
  598. package/schemas/WebpackOptions.json +6179 -0
  599. package/schemas/_container.json +155 -0
  600. package/schemas/_sharing.json +118 -0
  601. package/schemas/plugins/BannerPlugin.check.d.ts +7 -0
  602. package/schemas/plugins/BannerPlugin.check.js +6 -0
  603. package/schemas/plugins/BannerPlugin.json +115 -0
  604. package/schemas/plugins/DllPlugin.check.d.ts +7 -0
  605. package/schemas/plugins/DllPlugin.check.js +6 -0
  606. package/schemas/plugins/DllPlugin.json +36 -0
  607. package/schemas/plugins/DllReferencePlugin.check.d.ts +7 -0
  608. package/schemas/plugins/DllReferencePlugin.check.js +6 -0
  609. package/schemas/plugins/DllReferencePlugin.json +206 -0
  610. package/schemas/plugins/IgnorePlugin.check.d.ts +7 -0
  611. package/schemas/plugins/IgnorePlugin.check.js +6 -0
  612. package/schemas/plugins/IgnorePlugin.json +34 -0
  613. package/schemas/plugins/LoaderOptionsPlugin.check.d.ts +7 -0
  614. package/schemas/plugins/LoaderOptionsPlugin.check.js +6 -0
  615. package/schemas/plugins/LoaderOptionsPlugin.json +27 -0
  616. package/schemas/plugins/ManifestPlugin.check.d.ts +7 -0
  617. package/schemas/plugins/ManifestPlugin.check.js +6 -0
  618. package/schemas/plugins/ManifestPlugin.json +98 -0
  619. package/schemas/plugins/ProgressPlugin.check.d.ts +7 -0
  620. package/schemas/plugins/ProgressPlugin.check.js +6 -0
  621. package/schemas/plugins/ProgressPlugin.json +65 -0
  622. package/schemas/plugins/SourceMapDevToolPlugin.check.d.ts +7 -0
  623. package/schemas/plugins/SourceMapDevToolPlugin.check.js +6 -0
  624. package/schemas/plugins/SourceMapDevToolPlugin.json +168 -0
  625. package/schemas/plugins/WatchIgnorePlugin.check.d.ts +7 -0
  626. package/schemas/plugins/WatchIgnorePlugin.check.js +6 -0
  627. package/schemas/plugins/WatchIgnorePlugin.json +25 -0
  628. package/schemas/plugins/asset/AssetGeneratorOptions.check.d.ts +7 -0
  629. package/schemas/plugins/asset/AssetGeneratorOptions.check.js +6 -0
  630. package/schemas/plugins/asset/AssetGeneratorOptions.json +3 -0
  631. package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.d.ts +7 -0
  632. package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.js +6 -0
  633. package/schemas/plugins/asset/AssetInlineGeneratorOptions.json +3 -0
  634. package/schemas/plugins/asset/AssetParserOptions.check.d.ts +7 -0
  635. package/schemas/plugins/asset/AssetParserOptions.check.js +6 -0
  636. package/schemas/plugins/asset/AssetParserOptions.json +3 -0
  637. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.d.ts +7 -0
  638. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +6 -0
  639. package/schemas/plugins/asset/AssetResourceGeneratorOptions.json +3 -0
  640. package/schemas/plugins/container/ContainerPlugin.check.d.ts +7 -0
  641. package/schemas/plugins/container/ContainerPlugin.check.js +6 -0
  642. package/schemas/plugins/container/ContainerPlugin.json +294 -0
  643. package/schemas/plugins/container/ContainerReferencePlugin.check.d.ts +7 -0
  644. package/schemas/plugins/container/ContainerReferencePlugin.check.js +6 -0
  645. package/schemas/plugins/container/ContainerReferencePlugin.json +132 -0
  646. package/schemas/plugins/container/ExternalsType.check.d.ts +7 -0
  647. package/schemas/plugins/container/ExternalsType.check.js +6 -0
  648. package/schemas/plugins/container/ExternalsType.json +3 -0
  649. package/schemas/plugins/container/ModuleFederationPlugin.check.d.ts +7 -0
  650. package/schemas/plugins/container/ModuleFederationPlugin.check.js +6 -0
  651. package/schemas/plugins/container/ModuleFederationPlugin.json +525 -0
  652. package/schemas/plugins/css/CssGeneratorOptions.check.d.ts +7 -0
  653. package/schemas/plugins/css/CssGeneratorOptions.check.js +6 -0
  654. package/schemas/plugins/css/CssGeneratorOptions.json +3 -0
  655. package/schemas/plugins/css/CssModuleGeneratorOptions.check.d.ts +7 -0
  656. package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +6 -0
  657. package/schemas/plugins/css/CssModuleGeneratorOptions.json +3 -0
  658. package/schemas/plugins/css/CssModuleParserOptions.check.d.ts +7 -0
  659. package/schemas/plugins/css/CssModuleParserOptions.check.js +6 -0
  660. package/schemas/plugins/css/CssModuleParserOptions.json +3 -0
  661. package/schemas/plugins/css/CssParserOptions.check.d.ts +7 -0
  662. package/schemas/plugins/css/CssParserOptions.check.js +6 -0
  663. package/schemas/plugins/css/CssParserOptions.json +3 -0
  664. package/schemas/plugins/debug/ProfilingPlugin.check.d.ts +7 -0
  665. package/schemas/plugins/debug/ProfilingPlugin.check.js +6 -0
  666. package/schemas/plugins/debug/ProfilingPlugin.json +12 -0
  667. package/schemas/plugins/ids/HashedModuleIdsPlugin.check.d.ts +7 -0
  668. package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +6 -0
  669. package/schemas/plugins/ids/HashedModuleIdsPlugin.json +57 -0
  670. package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.d.ts +7 -0
  671. package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.js +6 -0
  672. package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.json +11 -0
  673. package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.d.ts +7 -0
  674. package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.js +6 -0
  675. package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.json +11 -0
  676. package/schemas/plugins/json/JsonModulesPluginGenerator.check.d.ts +7 -0
  677. package/schemas/plugins/json/JsonModulesPluginGenerator.check.js +6 -0
  678. package/schemas/plugins/json/JsonModulesPluginGenerator.json +3 -0
  679. package/schemas/plugins/json/JsonModulesPluginParser.check.d.ts +7 -0
  680. package/schemas/plugins/json/JsonModulesPluginParser.check.js +6 -0
  681. package/schemas/plugins/json/JsonModulesPluginParser.json +3 -0
  682. package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.d.ts +7 -0
  683. package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.js +6 -0
  684. package/schemas/plugins/optimize/AggressiveSplittingPlugin.json +23 -0
  685. package/schemas/plugins/optimize/LimitChunkCountPlugin.check.d.ts +7 -0
  686. package/schemas/plugins/optimize/LimitChunkCountPlugin.check.js +6 -0
  687. package/schemas/plugins/optimize/LimitChunkCountPlugin.json +21 -0
  688. package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.d.ts +7 -0
  689. package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.js +6 -0
  690. package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.json +11 -0
  691. package/schemas/plugins/optimize/MinChunkSizePlugin.check.d.ts +7 -0
  692. package/schemas/plugins/optimize/MinChunkSizePlugin.check.js +6 -0
  693. package/schemas/plugins/optimize/MinChunkSizePlugin.json +20 -0
  694. package/schemas/plugins/schemes/HttpUriPlugin.check.d.ts +7 -0
  695. package/schemas/plugins/schemes/HttpUriPlugin.check.js +6 -0
  696. package/schemas/plugins/schemes/HttpUriPlugin.json +74 -0
  697. package/schemas/plugins/schemes/VirtualUrlPlugin.check.d.ts +7 -0
  698. package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +6 -0
  699. package/schemas/plugins/schemes/VirtualUrlPlugin.json +77 -0
  700. package/schemas/plugins/sharing/ConsumeSharedPlugin.check.d.ts +7 -0
  701. package/schemas/plugins/sharing/ConsumeSharedPlugin.check.js +6 -0
  702. package/schemas/plugins/sharing/ConsumeSharedPlugin.json +120 -0
  703. package/schemas/plugins/sharing/ProvideSharedPlugin.check.d.ts +7 -0
  704. package/schemas/plugins/sharing/ProvideSharedPlugin.check.js +6 -0
  705. package/schemas/plugins/sharing/ProvideSharedPlugin.json +94 -0
  706. package/schemas/plugins/sharing/SharePlugin.check.d.ts +7 -0
  707. package/schemas/plugins/sharing/SharePlugin.check.js +6 -0
  708. package/schemas/plugins/sharing/SharePlugin.json +133 -0
  709. package/types.d.ts +20217 -0
@@ -0,0 +1,2621 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Tobias Koppers @sokra
4
+ */
5
+
6
+ "use strict";
7
+
8
+ const vm = require("vm");
9
+ const CommentCompilationWarning = require("../CommentCompilationWarning");
10
+ const CssModule = require("../CssModule");
11
+ const ModuleDependencyWarning = require("../ModuleDependencyWarning");
12
+ const { CSS_MODULE_TYPE_AUTO } = require("../ModuleTypeConstants");
13
+ const Parser = require("../Parser");
14
+ const UnsupportedFeatureWarning = require("../UnsupportedFeatureWarning");
15
+ const WebpackError = require("../WebpackError");
16
+ const ConstDependency = require("../dependencies/ConstDependency");
17
+ const CssIcssExportDependency = require("../dependencies/CssIcssExportDependency");
18
+ const CssIcssImportDependency = require("../dependencies/CssIcssImportDependency");
19
+ const CssIcssSymbolDependency = require("../dependencies/CssIcssSymbolDependency");
20
+ const CssImportDependency = require("../dependencies/CssImportDependency");
21
+ const CssUrlDependency = require("../dependencies/CssUrlDependency");
22
+ const StaticExportsDependency = require("../dependencies/StaticExportsDependency");
23
+ const binarySearchBounds = require("../util/binarySearchBounds");
24
+ const { parseResource } = require("../util/identifier");
25
+ const {
26
+ createMagicCommentContext,
27
+ webpackCommentRegExp
28
+ } = require("../util/magicComment");
29
+ const walkCssTokens = require("./walkCssTokens");
30
+
31
+ /** @typedef {import("../Module").BuildInfo} BuildInfo */
32
+ /** @typedef {import("../Module").BuildMeta} BuildMeta */
33
+ /** @typedef {import("../Parser").ParserState} ParserState */
34
+ /** @typedef {import("../Parser").PreparsedAst} PreparsedAst */
35
+ /** @typedef {import("./walkCssTokens").CssTokenCallbacks} CssTokenCallbacks */
36
+ /** @typedef {import("../../declarations/WebpackOptions").CssModuleParserOptions} CssModuleParserOptions */
37
+
38
+ /** @typedef {[number, number]} Range */
39
+ /** @typedef {{ line: number, column: number }} Position */
40
+ /** @typedef {{ value: string, range: Range, loc: { start: Position, end: Position } }} Comment */
41
+
42
+ const CC_COLON = ":".charCodeAt(0);
43
+ const CC_SEMICOLON = ";".charCodeAt(0);
44
+ const CC_COMMA = ",".charCodeAt(0);
45
+ const CC_LEFT_PARENTHESIS = "(".charCodeAt(0);
46
+ const CC_RIGHT_PARENTHESIS = ")".charCodeAt(0);
47
+ const CC_LOWER_F = "f".charCodeAt(0);
48
+ const CC_UPPER_F = "F".charCodeAt(0);
49
+ const CC_RIGHT_CURLY = "}".charCodeAt(0);
50
+ const CC_HYPHEN_MINUS = "-".charCodeAt(0);
51
+ const CC_TILDE = "~".charCodeAt(0);
52
+ const CC_EQUAL = "=".charCodeAt(0);
53
+
54
+ // https://www.w3.org/TR/css-syntax-3/#newline
55
+ // We don't have `preprocessing` stage, so we need specify all of them
56
+ const STRING_MULTILINE = /\\[\n\r\f]/g;
57
+ // https://www.w3.org/TR/css-syntax-3/#whitespace
58
+ const TRIM_WHITE_SPACES = /(^[ \t\n\r\f]*|[ \t\n\r\f]*$)/g;
59
+ const UNESCAPE = /\\([0-9a-f]{1,6}[ \t\n\r\f]?|[\s\S])/gi;
60
+ const IMAGE_SET_FUNCTION = /^(?:-\w+-)?image-set$/i;
61
+ const OPTIONALLY_VENDOR_PREFIXED_KEYFRAMES_AT_RULE = /^@(?:-\w+-)?keyframes$/;
62
+ const COMPOSES_PROPERTY = /^(?:composes|compose-with)$/i;
63
+ const IS_MODULES = /\.modules?\.[^.]+$/i;
64
+ const CSS_COMMENT = /\/\*((?!\*\/).*?)\*\//g;
65
+
66
+ /**
67
+ * @param {RegExp} regexp a regexp
68
+ * @param {string} str a string
69
+ * @returns {RegExpExecArray[]} matches
70
+ */
71
+ const matchAll = (regexp, str) => {
72
+ /** @type {RegExpExecArray[]} */
73
+ const result = [];
74
+
75
+ /** @type {null | RegExpExecArray} */
76
+ let match;
77
+
78
+ // Use a while loop with exec() to find all matches
79
+ while ((match = regexp.exec(str)) !== null) {
80
+ result.push(match);
81
+ }
82
+ // Return an array to be easily iterable (note: a true spec-compliant polyfill
83
+ // returns an iterator object, but an array spread often suffices for basic use)
84
+ return result;
85
+ };
86
+
87
+ /**
88
+ * @param {string} str url string
89
+ * @param {boolean} isString is url wrapped in quotes
90
+ * @returns {string} normalized url
91
+ */
92
+ const normalizeUrl = (str, isString) => {
93
+ // Remove extra spaces and newlines:
94
+ // `url("im\
95
+ // g.png")`
96
+ if (isString) {
97
+ str = str.replace(STRING_MULTILINE, "");
98
+ }
99
+
100
+ str = str
101
+ // Remove unnecessary spaces from `url(" img.png ")`
102
+ .replace(TRIM_WHITE_SPACES, "")
103
+ // Unescape
104
+ .replace(UNESCAPE, (match) => {
105
+ if (match.length > 2) {
106
+ return String.fromCharCode(Number.parseInt(match.slice(1).trim(), 16));
107
+ }
108
+ return match[1];
109
+ });
110
+
111
+ if (/^data:/i.test(str)) {
112
+ return str;
113
+ }
114
+
115
+ if (str.includes("%")) {
116
+ // Convert `url('%2E/img.png')` -> `url('./img.png')`
117
+ try {
118
+ str = decodeURIComponent(str);
119
+ } catch (_err) {
120
+ // Ignore
121
+ }
122
+ }
123
+
124
+ return str;
125
+ };
126
+
127
+ const regexSingleEscape = /[ -,./:-@[\]^`{-~]/;
128
+ const regexExcessiveSpaces =
129
+ /(^|\\+)?(\\[A-F0-9]{1,6})\u0020(?![a-fA-F0-9\u0020])/g;
130
+
131
+ /**
132
+ * @param {string} str string
133
+ * @returns {string} escaped identifier
134
+ */
135
+ const escapeIdentifier = (str) => {
136
+ let output = "";
137
+ let counter = 0;
138
+
139
+ while (counter < str.length) {
140
+ const character = str.charAt(counter++);
141
+
142
+ /** @type {string} */
143
+ let value;
144
+
145
+ if (/[\t\n\f\r\v]/.test(character)) {
146
+ const codePoint = character.charCodeAt(0);
147
+
148
+ value = `\\${codePoint.toString(16).toUpperCase()} `;
149
+ } else if (character === "\\" || regexSingleEscape.test(character)) {
150
+ value = `\\${character}`;
151
+ } else {
152
+ value = character;
153
+ }
154
+
155
+ output += value;
156
+ }
157
+
158
+ const firstChar = str.charAt(0);
159
+
160
+ if (/^-[-\d]/.test(output)) {
161
+ output = `\\-${output.slice(1)}`;
162
+ } else if (/\d/.test(firstChar)) {
163
+ output = `\\3${firstChar} ${output.slice(1)}`;
164
+ }
165
+
166
+ // Remove spaces after `\HEX` escapes that are not followed by a hex digit,
167
+ // since they’re redundant. Note that this is only possible if the escape
168
+ // sequence isn’t preceded by an odd number of backslashes.
169
+ output = output.replace(regexExcessiveSpaces, ($0, $1, $2) => {
170
+ if ($1 && $1.length % 2) {
171
+ // It’s not safe to remove the space, so don’t.
172
+ return $0;
173
+ }
174
+
175
+ // Strip the space.
176
+ return ($1 || "") + $2;
177
+ });
178
+
179
+ return output;
180
+ };
181
+
182
+ const CONTAINS_ESCAPE = /\\/;
183
+
184
+ /**
185
+ * @param {string} str string
186
+ * @returns {[string, number] | undefined} hex
187
+ */
188
+ const gobbleHex = (str) => {
189
+ const lower = str.toLowerCase();
190
+ let hex = "";
191
+ let spaceTerminated = false;
192
+
193
+ for (let i = 0; i < 6 && lower[i] !== undefined; i++) {
194
+ const code = lower.charCodeAt(i);
195
+ // check to see if we are dealing with a valid hex char [a-f|0-9]
196
+ const valid = (code >= 97 && code <= 102) || (code >= 48 && code <= 57);
197
+ // https://drafts.csswg.org/css-syntax/#consume-escaped-code-point
198
+ spaceTerminated = code === 32;
199
+ if (!valid) break;
200
+ hex += lower[i];
201
+ }
202
+
203
+ if (hex.length === 0) return undefined;
204
+
205
+ const codePoint = Number.parseInt(hex, 16);
206
+ const isSurrogate = codePoint >= 0xd800 && codePoint <= 0xdfff;
207
+
208
+ // Add special case for
209
+ // "If this number is zero, or is for a surrogate, or is greater than the maximum allowed code point"
210
+ // https://drafts.csswg.org/css-syntax/#maximum-allowed-code-point
211
+ if (isSurrogate || codePoint === 0x0000 || codePoint > 0x10ffff) {
212
+ return ["\uFFFD", hex.length + (spaceTerminated ? 1 : 0)];
213
+ }
214
+
215
+ return [
216
+ String.fromCodePoint(codePoint),
217
+ hex.length + (spaceTerminated ? 1 : 0)
218
+ ];
219
+ };
220
+
221
+ /**
222
+ * @param {string} str string
223
+ * @returns {string} unescaped string
224
+ */
225
+ const unescapeIdentifier = (str) => {
226
+ const needToProcess = CONTAINS_ESCAPE.test(str);
227
+ if (!needToProcess) return str;
228
+ let ret = "";
229
+ for (let i = 0; i < str.length; i++) {
230
+ if (str[i] === "\\") {
231
+ const gobbled = gobbleHex(str.slice(i + 1, i + 7));
232
+ if (gobbled !== undefined) {
233
+ ret += gobbled[0];
234
+ i += gobbled[1];
235
+ continue;
236
+ }
237
+ // Retain a pair of \\ if double escaped `\\\\`
238
+ // https://github.com/postcss/postcss-selector-parser/commit/268c9a7656fb53f543dc620aa5b73a30ec3ff20e
239
+ if (str[i + 1] === "\\") {
240
+ ret += "\\";
241
+ i += 1;
242
+ continue;
243
+ }
244
+ // if \\ is at the end of the string retain it
245
+ // https://github.com/postcss/postcss-selector-parser/commit/01a6b346e3612ce1ab20219acc26abdc259ccefb
246
+ if (str.length === i + 1) {
247
+ ret += str[i];
248
+ }
249
+ continue;
250
+ }
251
+ ret += str[i];
252
+ }
253
+
254
+ return ret;
255
+ };
256
+
257
+ /**
258
+ * A custom property is any property whose name starts with two dashes (U+002D HYPHEN-MINUS), like --foo.
259
+ * The <custom-property-name> production corresponds to this:
260
+ * it’s defined as any <dashed-ident> (a valid identifier that starts with two dashes),
261
+ * except -- itself, which is reserved for future use by CSS.
262
+ * @param {string} identifier identifier
263
+ * @returns {boolean} true when identifier is dashed, otherwise false
264
+ */
265
+ const isDashedIdentifier = (identifier) =>
266
+ identifier.startsWith("--") && identifier.length >= 3;
267
+
268
+ /** @type {Record<string, number>} */
269
+ const PREDEFINED_COUNTER_STYLES = {
270
+ decimal: 1,
271
+ "decimal-leading-zero": 1,
272
+ "arabic-indic": 1,
273
+ armenian: 1,
274
+ "upper-armenian": 1,
275
+ "lower-armenian": 1,
276
+ bengali: 1,
277
+ cambodian: 1,
278
+ khmer: 1,
279
+ "cjk-decimal": 1,
280
+ devanagari: 1,
281
+ georgian: 1,
282
+ gujarati: 1,
283
+ /* cspell:disable-next-line */
284
+ gurmukhi: 1,
285
+ hebrew: 1,
286
+ kannada: 1,
287
+ lao: 1,
288
+ malayalam: 1,
289
+ mongolian: 1,
290
+ myanmar: 1,
291
+ oriya: 1,
292
+ persian: 1,
293
+ "lower-roman": 1,
294
+ "upper-roman": 1,
295
+ tamil: 1,
296
+ telugu: 1,
297
+ thai: 1,
298
+ tibetan: 1,
299
+
300
+ "lower-alpha": 1,
301
+ "lower-latin": 1,
302
+ "upper-alpha": 1,
303
+ "upper-latin": 1,
304
+ "lower-greek": 1,
305
+ hiragana: 1,
306
+ /* cspell:disable-next-line */
307
+ "hiragana-iroha": 1,
308
+ katakana: 1,
309
+ /* cspell:disable-next-line */
310
+ "katakana-iroha": 1,
311
+
312
+ disc: 1,
313
+ circle: 1,
314
+ square: 1,
315
+ "disclosure-open": 1,
316
+ "disclosure-closed": 1,
317
+
318
+ "cjk-earthly-branch": 1,
319
+ "cjk-heavenly-stem": 1,
320
+
321
+ "japanese-informal": 1,
322
+ "japanese-formal": 1,
323
+
324
+ "korean-hangul-formal": 1,
325
+ /* cspell:disable-next-line */
326
+ "korean-hanja-informal": 1,
327
+ /* cspell:disable-next-line */
328
+ "korean-hanja-formal": 1,
329
+
330
+ "simp-chinese-informal": 1,
331
+ "simp-chinese-formal": 1,
332
+ "trad-chinese-informal": 1,
333
+ "trad-chinese-formal": 1,
334
+ "cjk-ideographic": 1,
335
+
336
+ "ethiopic-numeric": 1
337
+ };
338
+
339
+ /** @type {Record<string, number>} */
340
+ const GLOBAL_VALUES = {
341
+ // Global values
342
+ initial: Infinity,
343
+ inherit: Infinity,
344
+ unset: Infinity,
345
+ revert: Infinity,
346
+ "revert-layer": Infinity
347
+ };
348
+
349
+ /** @type {Record<string, number>} */
350
+ const GRID_AREA_OR_COLUMN_OR_ROW = {
351
+ auto: Infinity,
352
+ span: Infinity,
353
+ ...GLOBAL_VALUES
354
+ };
355
+
356
+ /** @type {Record<string, number>} */
357
+ const GRID_AUTO_COLUMNS_OR_ROW = {
358
+ "min-content": Infinity,
359
+ "max-content": Infinity,
360
+ auto: Infinity,
361
+ ...GLOBAL_VALUES
362
+ };
363
+
364
+ /** @type {Record<string, number>} */
365
+ const GRID_AUTO_FLOW = {
366
+ row: 1,
367
+ column: 1,
368
+ dense: 1,
369
+ ...GLOBAL_VALUES
370
+ };
371
+
372
+ /** @type {Record<string, number>} */
373
+ const GRID_TEMPLATE_ARES = {
374
+ // Special
375
+ none: 1,
376
+ ...GLOBAL_VALUES
377
+ };
378
+
379
+ /** @type {Record<string, number>} */
380
+ const GRID_TEMPLATE_COLUMNS_OR_ROWS = {
381
+ none: 1,
382
+ subgrid: 1,
383
+ masonry: 1,
384
+ "max-content": Infinity,
385
+ "min-content": Infinity,
386
+ auto: Infinity,
387
+ ...GLOBAL_VALUES
388
+ };
389
+
390
+ /** @type {Record<string, number>} */
391
+ const GRID_TEMPLATE = {
392
+ ...GRID_TEMPLATE_ARES,
393
+ ...GRID_TEMPLATE_COLUMNS_OR_ROWS
394
+ };
395
+
396
+ /** @type {Record<string, number>} */
397
+ const GRID = {
398
+ "auto-flow": 1,
399
+ dense: 1,
400
+ ...GRID_AUTO_COLUMNS_OR_ROW,
401
+ ...GRID_AUTO_FLOW,
402
+ ...GRID_TEMPLATE_ARES,
403
+ ...GRID_TEMPLATE_COLUMNS_OR_ROWS
404
+ };
405
+
406
+ /**
407
+ * @param {{ animation?: boolean, container?: boolean, customIdents?: boolean, grid?: boolean }=} options options
408
+ * @returns {Map<string, Record<string, number>>} list of known properties
409
+ */
410
+ const getKnownProperties = (options = {}) => {
411
+ /** @type {Map<string, Record<string, number>>} */
412
+ const knownProperties = new Map();
413
+
414
+ if (options.animation) {
415
+ knownProperties.set("animation", {
416
+ // animation-direction
417
+ normal: 1,
418
+ reverse: 1,
419
+ alternate: 1,
420
+ "alternate-reverse": 1,
421
+ // animation-fill-mode
422
+ forwards: 1,
423
+ backwards: 1,
424
+ both: 1,
425
+ // animation-iteration-count
426
+ infinite: 1,
427
+ // animation-play-state
428
+ paused: 1,
429
+ running: 1,
430
+ // animation-timing-function
431
+ ease: 1,
432
+ "ease-in": 1,
433
+ "ease-out": 1,
434
+ "ease-in-out": 1,
435
+ linear: 1,
436
+ "step-end": 1,
437
+ "step-start": 1,
438
+ // Special
439
+ none: Infinity, // No matter how many times you write none, it will never be an animation name
440
+ ...GLOBAL_VALUES
441
+ });
442
+ knownProperties.set("animation-name", {
443
+ // Special
444
+ none: Infinity, // No matter how many times you write none, it will never be an animation name
445
+ ...GLOBAL_VALUES
446
+ });
447
+ }
448
+
449
+ if (options.container) {
450
+ knownProperties.set("container", {
451
+ // container-type
452
+ normal: 1,
453
+ size: 1,
454
+ "inline-size": 1,
455
+ "scroll-state": 1,
456
+ // Special
457
+ none: Infinity,
458
+ ...GLOBAL_VALUES
459
+ });
460
+ knownProperties.set("container-name", {
461
+ // Special
462
+ none: Infinity,
463
+ ...GLOBAL_VALUES
464
+ });
465
+ }
466
+
467
+ if (options.customIdents) {
468
+ knownProperties.set("list-style", {
469
+ // list-style-position
470
+ inside: 1,
471
+ outside: 1,
472
+ // list-style-type
473
+ ...PREDEFINED_COUNTER_STYLES,
474
+ // Special
475
+ none: Infinity,
476
+ ...GLOBAL_VALUES
477
+ });
478
+ knownProperties.set("list-style-type", {
479
+ // list-style-type
480
+ ...PREDEFINED_COUNTER_STYLES,
481
+ // Special
482
+ none: Infinity,
483
+ ...GLOBAL_VALUES
484
+ });
485
+ knownProperties.set("system", {
486
+ cyclic: 1,
487
+ numeric: 1,
488
+ alphabetic: 1,
489
+ symbolic: 1,
490
+ additive: 1,
491
+ fixed: 1,
492
+ extends: 1,
493
+ ...PREDEFINED_COUNTER_STYLES
494
+ });
495
+ knownProperties.set("fallback", {
496
+ ...PREDEFINED_COUNTER_STYLES
497
+ });
498
+ knownProperties.set("speak-as", {
499
+ auto: 1,
500
+ bullets: 1,
501
+ numbers: 1,
502
+ words: 1,
503
+ "spell-out": 1,
504
+ ...PREDEFINED_COUNTER_STYLES
505
+ });
506
+ }
507
+
508
+ if (options.grid) {
509
+ knownProperties.set("grid", GRID);
510
+ knownProperties.set("grid-area", GRID_AREA_OR_COLUMN_OR_ROW);
511
+ knownProperties.set("grid-column", GRID_AREA_OR_COLUMN_OR_ROW);
512
+ knownProperties.set("grid-column-end", GRID_AREA_OR_COLUMN_OR_ROW);
513
+ knownProperties.set("grid-column-start", GRID_AREA_OR_COLUMN_OR_ROW);
514
+ knownProperties.set("grid-column-start", GRID_AREA_OR_COLUMN_OR_ROW);
515
+ knownProperties.set("grid-row", GRID_AREA_OR_COLUMN_OR_ROW);
516
+ knownProperties.set("grid-row-end", GRID_AREA_OR_COLUMN_OR_ROW);
517
+ knownProperties.set("grid-row-start", GRID_AREA_OR_COLUMN_OR_ROW);
518
+ knownProperties.set("grid-template", GRID_TEMPLATE);
519
+ knownProperties.set("grid-template-areas", GRID_TEMPLATE_ARES);
520
+ knownProperties.set("grid-template-columns", GRID_TEMPLATE_COLUMNS_OR_ROWS);
521
+ knownProperties.set("grid-template-rows", GRID_TEMPLATE_COLUMNS_OR_ROWS);
522
+ }
523
+
524
+ return knownProperties;
525
+ };
526
+
527
+ class LocConverter {
528
+ /**
529
+ * @param {string} input input
530
+ */
531
+ constructor(input) {
532
+ this._input = input;
533
+ this.line = 1;
534
+ this.column = 0;
535
+ this.pos = 0;
536
+ }
537
+
538
+ /**
539
+ * @param {number} pos position
540
+ * @returns {LocConverter} location converter
541
+ */
542
+ get(pos) {
543
+ if (this.pos !== pos) {
544
+ if (this.pos < pos) {
545
+ const str = this._input.slice(this.pos, pos);
546
+ let i = str.lastIndexOf("\n");
547
+ if (i === -1) {
548
+ this.column += str.length;
549
+ } else {
550
+ this.column = str.length - i - 1;
551
+ this.line++;
552
+ while (i > 0 && (i = str.lastIndexOf("\n", i - 1)) !== -1) {
553
+ this.line++;
554
+ }
555
+ }
556
+ } else {
557
+ let i = this._input.lastIndexOf("\n", this.pos);
558
+ while (i >= pos) {
559
+ this.line--;
560
+ i = i > 0 ? this._input.lastIndexOf("\n", i - 1) : -1;
561
+ }
562
+ this.column = pos - i;
563
+ }
564
+ this.pos = pos;
565
+ }
566
+ return this;
567
+ }
568
+ }
569
+
570
+ const EMPTY_COMMENT_OPTIONS = {
571
+ options: null,
572
+ errors: null
573
+ };
574
+
575
+ const CSS_MODE_TOP_LEVEL = 0;
576
+ const CSS_MODE_IN_BLOCK = 1;
577
+
578
+ const LOCAL_MODE = 0;
579
+ const GLOBAL_MODE = 1;
580
+
581
+ const eatUntilSemi = walkCssTokens.eatUntil(";");
582
+ const eatUntilLeftCurly = walkCssTokens.eatUntil("{");
583
+
584
+ /**
585
+ * @typedef {object} CssParserOwnOptions
586
+ * @property {("pure" | "global" | "local" | "auto")=} defaultMode default mode
587
+ */
588
+
589
+ /** @typedef {CssModuleParserOptions & CssParserOwnOptions} CssParserOptions */
590
+
591
+ class CssParser extends Parser {
592
+ /**
593
+ * @param {CssParserOptions=} options options
594
+ */
595
+ constructor(options = {}) {
596
+ super();
597
+ this.defaultMode =
598
+ typeof options.defaultMode !== "undefined" ? options.defaultMode : "pure";
599
+ this.options = {
600
+ url: true,
601
+ import: true,
602
+ namedExports: true,
603
+ animation: true,
604
+ container: true,
605
+ customIdents: true,
606
+ dashedIdents: true,
607
+ function: true,
608
+ grid: true,
609
+ ...options
610
+ };
611
+ /** @type {Comment[] | undefined} */
612
+ this.comments = undefined;
613
+ this.magicCommentContext = createMagicCommentContext();
614
+ }
615
+
616
+ /**
617
+ * @param {ParserState} state parser state
618
+ * @param {string} message warning message
619
+ * @param {LocConverter} locConverter location converter
620
+ * @param {number} start start offset
621
+ * @param {number} end end offset
622
+ */
623
+ _emitWarning(state, message, locConverter, start, end) {
624
+ const { line: sl, column: sc } = locConverter.get(start);
625
+ const { line: el, column: ec } = locConverter.get(end);
626
+
627
+ state.current.addWarning(
628
+ new ModuleDependencyWarning(state.module, new WebpackError(message), {
629
+ start: { line: sl, column: sc },
630
+ end: { line: el, column: ec }
631
+ })
632
+ );
633
+ }
634
+
635
+ /**
636
+ * @param {string | Buffer | PreparsedAst} source the source to parse
637
+ * @param {ParserState} state the parser state
638
+ * @returns {ParserState} the parser state
639
+ */
640
+ parse(source, state) {
641
+ if (Buffer.isBuffer(source)) {
642
+ source = source.toString("utf8");
643
+ } else if (typeof source === "object") {
644
+ throw new Error("webpackAst is unexpected for the CssParser");
645
+ }
646
+ if (source[0] === "\uFEFF") {
647
+ source = source.slice(1);
648
+ }
649
+
650
+ let mode = this.defaultMode;
651
+
652
+ const module = state.module;
653
+
654
+ if (
655
+ mode === "auto" &&
656
+ module.type === CSS_MODULE_TYPE_AUTO &&
657
+ IS_MODULES.test(
658
+ // TODO matchResource
659
+ parseResource(/** @type {string} */ (module.getResource())).path
660
+ )
661
+ ) {
662
+ mode = "local";
663
+ }
664
+
665
+ const isModules = mode === "global" || mode === "local";
666
+ const knownProperties = getKnownProperties({
667
+ animation: this.options.animation,
668
+ container: this.options.container,
669
+ customIdents: this.options.customIdents,
670
+ grid: this.options.grid
671
+ });
672
+
673
+ /** @type {BuildMeta} */
674
+ (module.buildMeta).isCSSModule = isModules;
675
+
676
+ const locConverter = new LocConverter(source);
677
+
678
+ /** @type {number} */
679
+ let scope = CSS_MODE_TOP_LEVEL;
680
+ /** @type {boolean} */
681
+ let allowImportAtRule = true;
682
+ /** @type {[string, number, number, boolean?][]} */
683
+ const balanced = [];
684
+ let lastTokenEndForComments = 0;
685
+
686
+ /** @type {boolean} */
687
+ let isNextRulePrelude = isModules;
688
+ /** @type {number} */
689
+ let blockNestingLevel = 0;
690
+ /** @type {0 | 1 | undefined} */
691
+ let modeData;
692
+
693
+ /** @type {string[]} */
694
+ let lastLocalIdentifiers = [];
695
+
696
+ /** @typedef {{ value: string, isReference?: boolean }} IcssDefinition */
697
+ /** @type {Map<string, IcssDefinition>} */
698
+ const icssDefinitions = new Map();
699
+
700
+ /**
701
+ * @param {string} input input
702
+ * @param {number} pos position
703
+ * @returns {boolean} true, when next is nested syntax
704
+ */
705
+ const isNextNestedSyntax = (input, pos) => {
706
+ pos = walkCssTokens.eatWhitespaceAndComments(input, pos)[0];
707
+
708
+ if (
709
+ input.charCodeAt(pos) === CC_RIGHT_CURLY ||
710
+ (input.charCodeAt(pos) === CC_HYPHEN_MINUS &&
711
+ input.charCodeAt(pos + 1) === CC_HYPHEN_MINUS)
712
+ ) {
713
+ return false;
714
+ }
715
+
716
+ const identifier = walkCssTokens.eatIdentSequence(input, pos);
717
+
718
+ if (!identifier) {
719
+ return true;
720
+ }
721
+
722
+ const leftCurly = eatUntilLeftCurly(input, pos);
723
+ const content = input.slice(identifier[0], leftCurly);
724
+
725
+ if (content.includes(";") || content.includes("}")) {
726
+ return false;
727
+ }
728
+
729
+ return true;
730
+ };
731
+ /**
732
+ * @returns {boolean} true, when in local scope
733
+ */
734
+ const isLocalMode = () =>
735
+ modeData === LOCAL_MODE || (mode === "local" && modeData === undefined);
736
+
737
+ /**
738
+ * @param {string} input input
739
+ * @param {number} start start
740
+ * @param {number} end end
741
+ * @returns {number} end
742
+ */
743
+ const comment = (input, start, end) => {
744
+ if (!this.comments) this.comments = [];
745
+ const { line: sl, column: sc } = locConverter.get(start);
746
+ const { line: el, column: ec } = locConverter.get(end);
747
+
748
+ /** @type {Comment} */
749
+ const comment = {
750
+ value: input.slice(start + 2, end - 2),
751
+ range: [start, end],
752
+ loc: {
753
+ start: { line: sl, column: sc },
754
+ end: { line: el, column: ec }
755
+ }
756
+ };
757
+ this.comments.push(comment);
758
+ return end;
759
+ };
760
+
761
+ // Vanilla CSS stuff
762
+
763
+ /**
764
+ * @param {string} input input
765
+ * @param {number} start name start position
766
+ * @param {number} end name end position
767
+ * @returns {number} position after handling
768
+ */
769
+ const processAtImport = (input, start, end) => {
770
+ const tokens = walkCssTokens.eatImportTokens(input, end, {
771
+ comment
772
+ });
773
+ if (!tokens[3]) return end;
774
+ const semi = tokens[3][1];
775
+ if (!tokens[0]) {
776
+ this._emitWarning(
777
+ state,
778
+ `Expected URL in '${input.slice(start, semi)}'`,
779
+ locConverter,
780
+ start,
781
+ semi
782
+ );
783
+ return end;
784
+ }
785
+
786
+ const urlToken = tokens[0];
787
+ const url = normalizeUrl(input.slice(urlToken[2], urlToken[3]), true);
788
+ const newline = walkCssTokens.eatWhiteLine(input, semi);
789
+ const { options, errors: commentErrors } = this.parseCommentOptions([
790
+ end,
791
+ urlToken[1]
792
+ ]);
793
+ if (commentErrors) {
794
+ for (const e of commentErrors) {
795
+ const { comment } = e;
796
+ state.module.addWarning(
797
+ new CommentCompilationWarning(
798
+ `Compilation error while processing magic comment(-s): /*${comment.value}*/: ${e.message}`,
799
+ comment.loc
800
+ )
801
+ );
802
+ }
803
+ }
804
+ if (options && options.webpackIgnore !== undefined) {
805
+ if (typeof options.webpackIgnore !== "boolean") {
806
+ const { line: sl, column: sc } = locConverter.get(start);
807
+ const { line: el, column: ec } = locConverter.get(newline);
808
+
809
+ state.module.addWarning(
810
+ new UnsupportedFeatureWarning(
811
+ `\`webpackIgnore\` expected a boolean, but received: ${options.webpackIgnore}.`,
812
+ {
813
+ start: { line: sl, column: sc },
814
+ end: { line: el, column: ec }
815
+ }
816
+ )
817
+ );
818
+ } else if (options.webpackIgnore) {
819
+ return newline;
820
+ }
821
+ }
822
+ if (url.length === 0) {
823
+ const { line: sl, column: sc } = locConverter.get(start);
824
+ const { line: el, column: ec } = locConverter.get(newline);
825
+ const dep = new ConstDependency("", [start, newline]);
826
+ module.addPresentationalDependency(dep);
827
+ dep.setLoc(sl, sc, el, ec);
828
+
829
+ return newline;
830
+ }
831
+
832
+ /** @type {undefined | string} */
833
+ let layer;
834
+
835
+ if (tokens[1]) {
836
+ layer = input.slice(tokens[1][0] + 6, tokens[1][1] - 1).trim();
837
+ }
838
+
839
+ /** @type {undefined | string} */
840
+ let supports;
841
+
842
+ if (tokens[2]) {
843
+ supports = input.slice(tokens[2][0] + 9, tokens[2][1] - 1).trim();
844
+ }
845
+
846
+ const last = tokens[2] || tokens[1] || tokens[0];
847
+ const mediaStart = walkCssTokens.eatWhitespaceAndComments(
848
+ input,
849
+ last[1]
850
+ )[0];
851
+
852
+ /** @type {undefined | string} */
853
+ let media;
854
+
855
+ if (mediaStart !== semi - 1) {
856
+ media = input.slice(mediaStart, semi - 1).trim();
857
+ }
858
+
859
+ const { line: sl, column: sc } = locConverter.get(start);
860
+ const { line: el, column: ec } = locConverter.get(newline);
861
+ const dep = new CssImportDependency(
862
+ url,
863
+ [start, newline],
864
+ mode === "local" || mode === "global" ? mode : undefined,
865
+ layer,
866
+ supports && supports.length > 0 ? supports : undefined,
867
+ media && media.length > 0 ? media : undefined
868
+ );
869
+ dep.setLoc(sl, sc, el, ec);
870
+ module.addDependency(dep);
871
+
872
+ return newline;
873
+ };
874
+
875
+ /**
876
+ * @param {string} input input
877
+ * @param {number} end end position
878
+ * @param {string} name the name of function
879
+ * @returns {number} position after handling
880
+ */
881
+ const processURLFunction = (input, end, name) => {
882
+ const string = walkCssTokens.eatString(input, end);
883
+ if (!string) return end;
884
+ const { options, errors: commentErrors } = this.parseCommentOptions([
885
+ lastTokenEndForComments,
886
+ end
887
+ ]);
888
+ if (commentErrors) {
889
+ for (const e of commentErrors) {
890
+ const { comment } = e;
891
+ state.module.addWarning(
892
+ new CommentCompilationWarning(
893
+ `Compilation error while processing magic comment(-s): /*${comment.value}*/: ${e.message}`,
894
+ comment.loc
895
+ )
896
+ );
897
+ }
898
+ }
899
+ if (options && options.webpackIgnore !== undefined) {
900
+ if (typeof options.webpackIgnore !== "boolean") {
901
+ const { line: sl, column: sc } = locConverter.get(string[0]);
902
+ const { line: el, column: ec } = locConverter.get(string[1]);
903
+
904
+ state.module.addWarning(
905
+ new UnsupportedFeatureWarning(
906
+ `\`webpackIgnore\` expected a boolean, but received: ${options.webpackIgnore}.`,
907
+ {
908
+ start: { line: sl, column: sc },
909
+ end: { line: el, column: ec }
910
+ }
911
+ )
912
+ );
913
+ } else if (options.webpackIgnore) {
914
+ return end;
915
+ }
916
+ }
917
+ const value = normalizeUrl(
918
+ input.slice(string[0] + 1, string[1] - 1),
919
+ true
920
+ );
921
+ // Ignore `url()`, `url('')` and `url("")`, they are valid by spec
922
+ if (value.length === 0) return end;
923
+ const isUrl = name === "url" || name === "src";
924
+ const dep = new CssUrlDependency(
925
+ value,
926
+ [string[0], string[1]],
927
+ isUrl ? "string" : "url"
928
+ );
929
+ const { line: sl, column: sc } = locConverter.get(string[0]);
930
+ const { line: el, column: ec } = locConverter.get(string[1]);
931
+ dep.setLoc(sl, sc, el, ec);
932
+ module.addDependency(dep);
933
+ module.addCodeGenerationDependency(dep);
934
+ return string[1];
935
+ };
936
+
937
+ /**
938
+ * @param {string} input input
939
+ * @param {number} start start position
940
+ * @param {number} end end position
941
+ * @param {number} contentStart start position
942
+ * @param {number} contentEnd end position
943
+ * @returns {number} position after handling
944
+ */
945
+ const processOldURLFunction = (
946
+ input,
947
+ start,
948
+ end,
949
+ contentStart,
950
+ contentEnd
951
+ ) => {
952
+ const { options, errors: commentErrors } = this.parseCommentOptions([
953
+ lastTokenEndForComments,
954
+ end
955
+ ]);
956
+ if (commentErrors) {
957
+ for (const e of commentErrors) {
958
+ const { comment } = e;
959
+ state.module.addWarning(
960
+ new CommentCompilationWarning(
961
+ `Compilation error while processing magic comment(-s): /*${comment.value}*/: ${e.message}`,
962
+ comment.loc
963
+ )
964
+ );
965
+ }
966
+ }
967
+ if (options && options.webpackIgnore !== undefined) {
968
+ if (typeof options.webpackIgnore !== "boolean") {
969
+ const { line: sl, column: sc } = locConverter.get(
970
+ lastTokenEndForComments
971
+ );
972
+ const { line: el, column: ec } = locConverter.get(end);
973
+
974
+ state.module.addWarning(
975
+ new UnsupportedFeatureWarning(
976
+ `\`webpackIgnore\` expected a boolean, but received: ${options.webpackIgnore}.`,
977
+ {
978
+ start: { line: sl, column: sc },
979
+ end: { line: el, column: ec }
980
+ }
981
+ )
982
+ );
983
+ } else if (options.webpackIgnore) {
984
+ return end;
985
+ }
986
+ }
987
+ const value = normalizeUrl(input.slice(contentStart, contentEnd), false);
988
+ // Ignore `url()`, `url('')` and `url("")`, they are valid by spec
989
+ if (value.length === 0) return end;
990
+ const dep = new CssUrlDependency(value, [start, end], "url");
991
+ const { line: sl, column: sc } = locConverter.get(start);
992
+ const { line: el, column: ec } = locConverter.get(end);
993
+ dep.setLoc(sl, sc, el, ec);
994
+ module.addDependency(dep);
995
+ module.addCodeGenerationDependency(dep);
996
+ return end;
997
+ };
998
+
999
+ /**
1000
+ * @param {string} input input
1001
+ * @param {number} start start position
1002
+ * @param {number} end end position
1003
+ * @returns {number} position after handling
1004
+ */
1005
+ const processImageSetFunction = (input, start, end) => {
1006
+ lastTokenEndForComments = end;
1007
+ const values = walkCssTokens.eatImageSetStrings(input, end, {
1008
+ comment
1009
+ });
1010
+ if (values.length === 0) return end;
1011
+ for (const [index, string] of values.entries()) {
1012
+ const value = normalizeUrl(
1013
+ input.slice(string[0] + 1, string[1] - 1),
1014
+ true
1015
+ );
1016
+ if (value.length === 0) return end;
1017
+ const { options, errors: commentErrors } = this.parseCommentOptions([
1018
+ index === 0 ? start : values[index - 1][1],
1019
+ string[1]
1020
+ ]);
1021
+ if (commentErrors) {
1022
+ for (const e of commentErrors) {
1023
+ const { comment } = e;
1024
+ state.module.addWarning(
1025
+ new CommentCompilationWarning(
1026
+ `Compilation error while processing magic comment(-s): /*${comment.value}*/: ${e.message}`,
1027
+ comment.loc
1028
+ )
1029
+ );
1030
+ }
1031
+ }
1032
+ if (options && options.webpackIgnore !== undefined) {
1033
+ if (typeof options.webpackIgnore !== "boolean") {
1034
+ const { line: sl, column: sc } = locConverter.get(string[0]);
1035
+ const { line: el, column: ec } = locConverter.get(string[1]);
1036
+
1037
+ state.module.addWarning(
1038
+ new UnsupportedFeatureWarning(
1039
+ `\`webpackIgnore\` expected a boolean, but received: ${options.webpackIgnore}.`,
1040
+ {
1041
+ start: { line: sl, column: sc },
1042
+ end: { line: el, column: ec }
1043
+ }
1044
+ )
1045
+ );
1046
+ } else if (options.webpackIgnore) {
1047
+ continue;
1048
+ }
1049
+ }
1050
+ const dep = new CssUrlDependency(value, [string[0], string[1]], "url");
1051
+ const { line: sl, column: sc } = locConverter.get(string[0]);
1052
+ const { line: el, column: ec } = locConverter.get(string[1]);
1053
+ dep.setLoc(sl, sc, el, ec);
1054
+ module.addDependency(dep);
1055
+ module.addCodeGenerationDependency(dep);
1056
+ }
1057
+ // Can contain `url()` inside, so let's return end to allow parse them
1058
+ return end;
1059
+ };
1060
+
1061
+ // CSS modules stuff
1062
+
1063
+ /**
1064
+ * @param {string} value value to resolve
1065
+ * @returns {string | [string, string, boolean]} resolved reexport
1066
+ */
1067
+ const getReexport = (value) => {
1068
+ const reexport = icssDefinitions.get(value);
1069
+
1070
+ if (reexport) {
1071
+ if (reexport.isReference) {
1072
+ return [value, reexport.value, true];
1073
+ }
1074
+ return [value, reexport.value, false];
1075
+ }
1076
+
1077
+ return value;
1078
+ };
1079
+
1080
+ /**
1081
+ * @param {0 | 1} type import or export
1082
+ * @param {string} input input
1083
+ * @param {number} pos start position
1084
+ * @returns {number} position after parse
1085
+ */
1086
+ const processImportOrExport = (type, input, pos) => {
1087
+ pos = walkCssTokens.eatWhitespaceAndComments(input, pos)[0];
1088
+ /** @type {string | undefined} */
1089
+ let request;
1090
+ if (type === 0) {
1091
+ let cc = input.charCodeAt(pos);
1092
+ if (cc !== CC_LEFT_PARENTHESIS) {
1093
+ this._emitWarning(
1094
+ state,
1095
+ `Unexpected '${input[pos]}' at ${pos} during parsing of ':import' (expected '(')`,
1096
+ locConverter,
1097
+ pos,
1098
+ pos
1099
+ );
1100
+ return pos;
1101
+ }
1102
+ pos++;
1103
+ const stringStart = pos;
1104
+ const str = walkCssTokens.eatString(input, pos);
1105
+ if (!str) {
1106
+ this._emitWarning(
1107
+ state,
1108
+ `Unexpected '${input[pos]}' at ${pos} during parsing of '${type ? ":import" : ":export"}' (expected string)`,
1109
+ locConverter,
1110
+ stringStart,
1111
+ pos
1112
+ );
1113
+ return pos;
1114
+ }
1115
+ request = input.slice(str[0] + 1, str[1] - 1);
1116
+ pos = str[1];
1117
+ pos = walkCssTokens.eatWhitespaceAndComments(input, pos)[0];
1118
+ cc = input.charCodeAt(pos);
1119
+ if (cc !== CC_RIGHT_PARENTHESIS) {
1120
+ this._emitWarning(
1121
+ state,
1122
+ `Unexpected '${input[pos]}' at ${pos} during parsing of ':import' (expected ')')`,
1123
+ locConverter,
1124
+ pos,
1125
+ pos
1126
+ );
1127
+ return pos;
1128
+ }
1129
+ pos++;
1130
+ pos = walkCssTokens.eatWhitespaceAndComments(input, pos)[0];
1131
+ }
1132
+
1133
+ /**
1134
+ * @param {string} name name
1135
+ * @param {string} value value
1136
+ * @param {number} start start of position
1137
+ * @param {number} end end of position
1138
+ */
1139
+ const createDep = (name, value, start, end) => {
1140
+ if (type === 0) {
1141
+ const dep = new CssIcssImportDependency(
1142
+ /** @type {string} */
1143
+ (request),
1144
+ [0, 0],
1145
+ /** @type {"local" | "global"} */
1146
+ (mode),
1147
+ value
1148
+ );
1149
+ const { line: sl, column: sc } = locConverter.get(start);
1150
+ const { line: el, column: ec } = locConverter.get(end);
1151
+ dep.setLoc(sl, sc, el, ec);
1152
+ module.addDependency(dep);
1153
+
1154
+ icssDefinitions.set(name, { value, isReference: true });
1155
+ } else if (type === 1) {
1156
+ const dep = new CssIcssExportDependency(name, getReexport(value));
1157
+ const { line: sl, column: sc } = locConverter.get(start);
1158
+ const { line: el, column: ec } = locConverter.get(end);
1159
+ dep.setLoc(sl, sc, el, ec);
1160
+ module.addDependency(dep);
1161
+ }
1162
+ };
1163
+
1164
+ let needTerminate = false;
1165
+ let balanced = 0;
1166
+ /** @type {undefined | 0 | 1 | 2} */
1167
+ let scope;
1168
+
1169
+ /** @typedef {[number, number]} Name */
1170
+
1171
+ /** @type {Name | undefined} */
1172
+ let name;
1173
+ /** @type {number | undefined} */
1174
+ let value;
1175
+
1176
+ /** @type {CssTokenCallbacks} */
1177
+ const callbacks = {
1178
+ leftCurlyBracket: (_input, _start, end) => {
1179
+ balanced++;
1180
+
1181
+ if (scope === undefined) {
1182
+ scope = 0;
1183
+ }
1184
+
1185
+ return end;
1186
+ },
1187
+ rightCurlyBracket: (_input, _start, end) => {
1188
+ balanced--;
1189
+
1190
+ if (scope === 2) {
1191
+ const [nameStart, nameEnd] = /** @type {Name} */ (name);
1192
+ createDep(
1193
+ input.slice(nameStart, nameEnd),
1194
+ input.slice(value, end - 1).trim(),
1195
+ nameEnd,
1196
+ end - 1
1197
+ );
1198
+ scope = 0;
1199
+ }
1200
+
1201
+ if (balanced === 0 && scope === 0) {
1202
+ needTerminate = true;
1203
+ }
1204
+
1205
+ return end;
1206
+ },
1207
+ identifier: (_input, start, end) => {
1208
+ if (scope === 0) {
1209
+ name = [start, end];
1210
+ scope = 1;
1211
+ }
1212
+
1213
+ return end;
1214
+ },
1215
+ colon: (_input, _start, end) => {
1216
+ if (scope === 1) {
1217
+ scope = 2;
1218
+ value = walkCssTokens.eatWhitespace(input, end);
1219
+ return value;
1220
+ }
1221
+
1222
+ return end;
1223
+ },
1224
+ semicolon: (input, _start, end) => {
1225
+ if (scope === 2) {
1226
+ const [nameStart, nameEnd] = /** @type {Name} */ (name);
1227
+ createDep(
1228
+ input.slice(nameStart, nameEnd),
1229
+ input.slice(value, end - 1),
1230
+ nameEnd,
1231
+ end - 1
1232
+ );
1233
+ scope = 0;
1234
+ }
1235
+
1236
+ return end;
1237
+ },
1238
+ needTerminate: () => needTerminate
1239
+ };
1240
+
1241
+ pos = walkCssTokens(input, pos, callbacks);
1242
+ pos = walkCssTokens.eatWhiteLine(input, pos);
1243
+
1244
+ return pos;
1245
+ };
1246
+
1247
+ /**
1248
+ * @param {string} input input
1249
+ * @param {number} start name start position
1250
+ * @param {number} end name end position
1251
+ * @returns {number} position after handling
1252
+ */
1253
+ const processAtValue = (input, start, end) => {
1254
+ const semi = eatUntilSemi(input, end);
1255
+ const atRuleEnd = semi + 1;
1256
+ const params = input.slice(end, semi);
1257
+ let [alias, request] = params.split(/\s*from\s*/);
1258
+
1259
+ if (request) {
1260
+ const aliases = alias
1261
+ .replace(CSS_COMMENT, " ")
1262
+ .trim()
1263
+ .replace(/^\(\s*|\s*\)$/g, "")
1264
+ .split(/\s*,\s*/);
1265
+
1266
+ request = request.replace(CSS_COMMENT, "").trim();
1267
+
1268
+ const isExplicitImport = request[0] === "'" || request[0] === '"';
1269
+
1270
+ if (isExplicitImport) {
1271
+ request = request.slice(1, -1);
1272
+ }
1273
+
1274
+ for (const alias of aliases) {
1275
+ const [name, aliasName] = alias.split(/\s+as\s+/);
1276
+
1277
+ {
1278
+ const reexport = icssDefinitions.get(request);
1279
+
1280
+ if (reexport) {
1281
+ request = reexport.value.slice(1, -1);
1282
+ }
1283
+
1284
+ const dep = new CssIcssImportDependency(
1285
+ request,
1286
+ [0, 0],
1287
+ /** @type {"local" | "global"} */
1288
+ (mode),
1289
+ name
1290
+ );
1291
+ const { line: sl, column: sc } = locConverter.get(start);
1292
+ const { line: el, column: ec } = locConverter.get(end);
1293
+ dep.setLoc(sl, sc, el, ec);
1294
+ module.addDependency(dep);
1295
+
1296
+ icssDefinitions.set(aliasName || name, {
1297
+ value: name,
1298
+ isReference: true
1299
+ });
1300
+ }
1301
+
1302
+ {
1303
+ const dep = new CssIcssExportDependency(
1304
+ aliasName || name,
1305
+ getReexport(aliasName || name),
1306
+ undefined,
1307
+ false,
1308
+ CssIcssExportDependency.EXPORT_MODE.REPLACE
1309
+ );
1310
+ const { line: sl, column: sc } = locConverter.get(start);
1311
+ const { line: el, column: ec } = locConverter.get(end);
1312
+ dep.setLoc(sl, sc, el, ec);
1313
+ module.addDependency(dep);
1314
+ }
1315
+ }
1316
+ } else {
1317
+ const ident = walkCssTokens.eatIdentSequence(alias, 0);
1318
+
1319
+ if (!ident) {
1320
+ this._emitWarning(
1321
+ state,
1322
+ `Broken '@value' at-rule: ${input.slice(start, atRuleEnd)}'`,
1323
+ locConverter,
1324
+ start,
1325
+ atRuleEnd
1326
+ );
1327
+
1328
+ const dep = new ConstDependency("", [start, atRuleEnd]);
1329
+ module.addPresentationalDependency(dep);
1330
+ return atRuleEnd;
1331
+ }
1332
+
1333
+ const pos = walkCssTokens.eatWhitespaceAndComments(alias, ident[1])[0];
1334
+
1335
+ const name = alias.slice(ident[0], ident[1]);
1336
+ let value =
1337
+ alias.charCodeAt(pos) === CC_COLON
1338
+ ? alias.slice(pos + 1)
1339
+ : alias.slice(ident[1]);
1340
+
1341
+ if (value && !/^\s+$/.test(value.replace(CSS_COMMENT, ""))) {
1342
+ value = value.trim();
1343
+ }
1344
+
1345
+ if (icssDefinitions.has(value)) {
1346
+ const def =
1347
+ /** @type {IcssDefinition} */
1348
+ (icssDefinitions.get(value));
1349
+
1350
+ value = def.value;
1351
+ }
1352
+
1353
+ icssDefinitions.set(name, { value });
1354
+
1355
+ const dep = new CssIcssExportDependency(name, value);
1356
+ const { line: sl, column: sc } = locConverter.get(start);
1357
+ const { line: el, column: ec } = locConverter.get(end);
1358
+ dep.setLoc(sl, sc, el, ec);
1359
+ module.addDependency(dep);
1360
+ }
1361
+
1362
+ const dep = new ConstDependency("", [start, atRuleEnd]);
1363
+ module.addPresentationalDependency(dep);
1364
+ return atRuleEnd;
1365
+ };
1366
+
1367
+ /**
1368
+ * @param {string} name ICSS symbol name
1369
+ * @param {number} start start position
1370
+ * @param {number} end end position
1371
+ * @returns {number} position after handling
1372
+ */
1373
+ const processICSSSymbol = (name, start, end) => {
1374
+ const { value, isReference } =
1375
+ /** @type {IcssDefinition} */
1376
+ (icssDefinitions.get(name));
1377
+ const { line: sl, column: sc } = locConverter.get(start);
1378
+ const { line: el, column: ec } = locConverter.get(end);
1379
+ const dep = new CssIcssSymbolDependency(
1380
+ name,
1381
+ value,
1382
+ [start, end],
1383
+ isReference
1384
+ );
1385
+ dep.setLoc(sl, sc, el, ec);
1386
+ module.addDependency(dep);
1387
+ return end;
1388
+ };
1389
+
1390
+ /**
1391
+ * @param {string} input input
1392
+ * @param {1 | 2} type type of function
1393
+ * @param {number} start start position
1394
+ * @param {number} end end position
1395
+ * @returns {number} position after handling
1396
+ */
1397
+ const processLocalOrGlobalFunction = (input, type, start, end) => {
1398
+ // Replace `local(`/` or `global(` (handle legacy `:local(` or `:global(` too)
1399
+ {
1400
+ const isColon = input.charCodeAt(start - 1) === CC_COLON;
1401
+ const dep = new ConstDependency("", [isColon ? start - 1 : start, end]);
1402
+ module.addPresentationalDependency(dep);
1403
+ }
1404
+
1405
+ end = walkCssTokens.consumeUntil(
1406
+ input,
1407
+ start,
1408
+ {
1409
+ identifier(input, start, end) {
1410
+ if (type === 1) {
1411
+ let identifier = unescapeIdentifier(input.slice(start, end));
1412
+ const { line: sl, column: sc } = locConverter.get(start);
1413
+ const { line: el, column: ec } = locConverter.get(end);
1414
+ const isDashedIdent = isDashedIdentifier(identifier);
1415
+
1416
+ if (isDashedIdent) {
1417
+ identifier = identifier.slice(2);
1418
+ }
1419
+
1420
+ const dep = new CssIcssExportDependency(
1421
+ identifier,
1422
+ getReexport(identifier),
1423
+ [start, end],
1424
+ true,
1425
+ CssIcssExportDependency.EXPORT_MODE.ONCE,
1426
+ isDashedIdent
1427
+ ? CssIcssExportDependency.EXPORT_TYPE.CUSTOM_VARIABLE
1428
+ : CssIcssExportDependency.EXPORT_TYPE.NORMAL
1429
+ );
1430
+
1431
+ dep.setLoc(sl, sc, el, ec);
1432
+ module.addDependency(dep);
1433
+ }
1434
+
1435
+ return end;
1436
+ }
1437
+ },
1438
+ {},
1439
+ { onlyTopLevel: true, functionValue: true }
1440
+ );
1441
+
1442
+ {
1443
+ // Replace the last `)`
1444
+ const dep = new ConstDependency("", [end, end + 1]);
1445
+ module.addPresentationalDependency(dep);
1446
+ }
1447
+
1448
+ return end;
1449
+ };
1450
+
1451
+ /**
1452
+ * @param {string} input input
1453
+ * @param {number} end name end position
1454
+ * @param {{ string?: boolean, identifier?: boolean | RegExp }} options types which allowed to handle
1455
+ * @returns {number} position after handling
1456
+ */
1457
+ const processLocalAtRule = (input, end, options) => {
1458
+ let found = false;
1459
+
1460
+ return walkCssTokens.consumeUntil(
1461
+ input,
1462
+ end,
1463
+ {
1464
+ string(_input, start, end) {
1465
+ if (!found && options.string) {
1466
+ const value = unescapeIdentifier(input.slice(start + 1, end - 1));
1467
+ const { line: sl, column: sc } = locConverter.get(start);
1468
+ const { line: el, column: ec } = locConverter.get(end);
1469
+ const dep = new CssIcssExportDependency(
1470
+ value,
1471
+ value,
1472
+ [start, end],
1473
+ true,
1474
+ CssIcssExportDependency.EXPORT_MODE.ONCE
1475
+ );
1476
+ dep.setLoc(sl, sc, el, ec);
1477
+ module.addDependency(dep);
1478
+ found = true;
1479
+ }
1480
+ return end;
1481
+ },
1482
+ identifier(input, start, end) {
1483
+ if (!found) {
1484
+ const value = input.slice(start, end);
1485
+
1486
+ if (options.identifier) {
1487
+ const identifier = unescapeIdentifier(value);
1488
+
1489
+ if (
1490
+ options.identifier instanceof RegExp &&
1491
+ options.identifier.test(identifier)
1492
+ ) {
1493
+ return end;
1494
+ }
1495
+
1496
+ const { line: sl, column: sc } = locConverter.get(start);
1497
+ const { line: el, column: ec } = locConverter.get(end);
1498
+
1499
+ const dep = new CssIcssExportDependency(
1500
+ identifier,
1501
+ getReexport(identifier),
1502
+ [start, end],
1503
+ true,
1504
+ CssIcssExportDependency.EXPORT_MODE.ONCE,
1505
+ CssIcssExportDependency.EXPORT_TYPE.NORMAL
1506
+ );
1507
+ dep.setLoc(sl, sc, el, ec);
1508
+ module.addDependency(dep);
1509
+ found = true;
1510
+ }
1511
+ }
1512
+ return end;
1513
+ }
1514
+ },
1515
+ {
1516
+ function: (input, start, end) => {
1517
+ // No need to handle `:` (COLON), because it's always a function
1518
+ const name = input
1519
+ .slice(start, end - 1)
1520
+ .replace(/\\/g, "")
1521
+ .toLowerCase();
1522
+
1523
+ const type =
1524
+ name === "local" ? 1 : name === "global" ? 2 : undefined;
1525
+
1526
+ if (!found && type) {
1527
+ found = true;
1528
+ return processLocalOrGlobalFunction(input, type, start, end);
1529
+ }
1530
+
1531
+ if (
1532
+ this.options.dashedIdents &&
1533
+ isLocalMode() &&
1534
+ (name === "var" || name === "style")
1535
+ ) {
1536
+ return processDashedIdent(input, end, end);
1537
+ }
1538
+
1539
+ return end;
1540
+ }
1541
+ },
1542
+ { onlyTopLevel: true, atRulePrelude: true }
1543
+ );
1544
+ };
1545
+ /**
1546
+ * @param {string} input input
1547
+ * @param {number} start start position
1548
+ * @param {number} end end position
1549
+ * @returns {number} position after handling
1550
+ */
1551
+ const processDashedIdent = (input, start, end) => {
1552
+ const customIdent = walkCssTokens.eatIdentSequence(input, start);
1553
+ if (!customIdent) return end;
1554
+ const identifier = unescapeIdentifier(
1555
+ input.slice(customIdent[0] + 2, customIdent[1])
1556
+ );
1557
+ const afterCustomIdent = walkCssTokens.eatWhitespaceAndComments(
1558
+ input,
1559
+ customIdent[1]
1560
+ )[0];
1561
+ if (
1562
+ input.charCodeAt(afterCustomIdent) === CC_LOWER_F ||
1563
+ input.charCodeAt(afterCustomIdent) === CC_UPPER_F
1564
+ ) {
1565
+ const fromWord = walkCssTokens.eatIdentSequence(
1566
+ input,
1567
+ afterCustomIdent
1568
+ );
1569
+ if (
1570
+ !fromWord ||
1571
+ input.slice(fromWord[0], fromWord[1]).toLowerCase() !== "from"
1572
+ ) {
1573
+ return end;
1574
+ }
1575
+ const from = walkCssTokens.eatIdentSequenceOrString(
1576
+ input,
1577
+ walkCssTokens.eatWhitespaceAndComments(input, fromWord[1])[0]
1578
+ );
1579
+ if (!from) {
1580
+ return end;
1581
+ }
1582
+ const path = input.slice(from[0], from[1]);
1583
+ if (from[2] === true && path === "global") {
1584
+ const dep = new ConstDependency("", [customIdent[1], from[1]]);
1585
+ module.addPresentationalDependency(dep);
1586
+ return end;
1587
+ } else if (from[2] === false) {
1588
+ const { line: sl, column: sc } = locConverter.get(customIdent[0]);
1589
+ const { line: el, column: ec } = locConverter.get(from[1] - 1);
1590
+ const dep = new CssIcssImportDependency(
1591
+ path.slice(1, -1),
1592
+ [customIdent[0], from[1] - 1],
1593
+ /** @type {"local" | "global"} */
1594
+ (mode),
1595
+ identifier,
1596
+ identifier,
1597
+ CssIcssExportDependency.EXPORT_MODE.NONE,
1598
+ CssIcssExportDependency.EXPORT_TYPE.CUSTOM_VARIABLE
1599
+ );
1600
+
1601
+ dep.setLoc(sl, sc, el, ec);
1602
+ module.addDependency(dep);
1603
+
1604
+ {
1605
+ const dep = new ConstDependency("", [fromWord[0], from[1]]);
1606
+ module.addPresentationalDependency(dep);
1607
+ return end;
1608
+ }
1609
+ }
1610
+ } else {
1611
+ const { line: sl, column: sc } = locConverter.get(customIdent[0]);
1612
+ const { line: el, column: ec } = locConverter.get(customIdent[1]);
1613
+ const dep = new CssIcssExportDependency(
1614
+ identifier,
1615
+ getReexport(identifier),
1616
+ [customIdent[0], customIdent[1]],
1617
+ true,
1618
+ CssIcssExportDependency.EXPORT_MODE.ONCE,
1619
+ CssIcssExportDependency.EXPORT_TYPE.CUSTOM_VARIABLE
1620
+ );
1621
+ dep.setLoc(sl, sc, el, ec);
1622
+ module.addDependency(dep);
1623
+ return end;
1624
+ }
1625
+
1626
+ return end;
1627
+ };
1628
+ /**
1629
+ * @param {string} input input
1630
+ * @param {number} pos name start position
1631
+ * @param {number} end name end position
1632
+ * @returns {number} position after handling
1633
+ */
1634
+ const processLocalDeclaration = (input, pos, end) => {
1635
+ pos = walkCssTokens.eatWhitespaceAndComments(input, pos)[0];
1636
+ const identifier = walkCssTokens.eatIdentSequence(input, pos);
1637
+
1638
+ if (!identifier) {
1639
+ return end;
1640
+ }
1641
+
1642
+ const propertyNameStart = identifier[0];
1643
+
1644
+ pos = walkCssTokens.eatWhitespaceAndComments(input, identifier[1])[0];
1645
+
1646
+ if (input.charCodeAt(pos) !== CC_COLON) {
1647
+ return end;
1648
+ }
1649
+
1650
+ pos += 1;
1651
+
1652
+ // Remove prefix and lowercase
1653
+ const propertyName = input
1654
+ .slice(identifier[0], identifier[1])
1655
+ .replace(/^(-\w+-)/, "")
1656
+ .toLowerCase();
1657
+
1658
+ if (isLocalMode() && knownProperties.has(propertyName)) {
1659
+ /** @type {[number, number, boolean?][]} */
1660
+ const values = [];
1661
+ /** @type {Record<string, number>} */
1662
+ let parsedKeywords = Object.create(null);
1663
+
1664
+ const isGridProperty = Boolean(propertyName.startsWith("grid"));
1665
+ const isGridTemplate = isGridProperty
1666
+ ? Boolean(
1667
+ propertyName === "grid" ||
1668
+ propertyName === "grid-template" ||
1669
+ propertyName === "grid-template-columns" ||
1670
+ propertyName === "grid-template-rows"
1671
+ )
1672
+ : false;
1673
+
1674
+ const end = walkCssTokens.consumeUntil(
1675
+ input,
1676
+ pos,
1677
+ {
1678
+ leftSquareBracket(input, start, end) {
1679
+ let i = end;
1680
+
1681
+ while (true) {
1682
+ i = walkCssTokens.eatWhitespaceAndComments(input, i)[0];
1683
+ const name = walkCssTokens.eatIdentSequence(input, i);
1684
+
1685
+ if (!name) {
1686
+ break;
1687
+ }
1688
+
1689
+ values.push(name);
1690
+ i = name[1];
1691
+ }
1692
+
1693
+ return end;
1694
+ },
1695
+ string(_input, start, end) {
1696
+ if (
1697
+ propertyName === "animation" ||
1698
+ propertyName === "animation-name"
1699
+ ) {
1700
+ values.push([start, end, true]);
1701
+ }
1702
+
1703
+ if (
1704
+ propertyName === "grid" ||
1705
+ propertyName === "grid-template" ||
1706
+ propertyName === "grid-template-areas"
1707
+ ) {
1708
+ const areas = unescapeIdentifier(
1709
+ input.slice(start + 1, end - 1)
1710
+ );
1711
+ const matches = matchAll(/\b\w+\b/g, areas);
1712
+
1713
+ for (const match of matches) {
1714
+ const areaStart = start + 1 + match.index;
1715
+ values.push([areaStart, areaStart + match[0].length, false]);
1716
+ }
1717
+ }
1718
+
1719
+ return end;
1720
+ },
1721
+ identifier(input, start, end) {
1722
+ if (isGridTemplate) {
1723
+ return end;
1724
+ }
1725
+
1726
+ const identifier = input.slice(start, end);
1727
+ const keyword = identifier.toLowerCase();
1728
+
1729
+ parsedKeywords[keyword] =
1730
+ typeof parsedKeywords[keyword] !== "undefined"
1731
+ ? parsedKeywords[keyword] + 1
1732
+ : 0;
1733
+ const keywords =
1734
+ /** @type {Record<string, number>} */
1735
+ (knownProperties.get(propertyName));
1736
+
1737
+ if (
1738
+ keywords[keyword] &&
1739
+ parsedKeywords[keyword] < keywords[keyword]
1740
+ ) {
1741
+ return end;
1742
+ }
1743
+
1744
+ values.push([start, end]);
1745
+ return end;
1746
+ },
1747
+ comma(_input, _start, end) {
1748
+ parsedKeywords = {};
1749
+
1750
+ return end;
1751
+ }
1752
+ },
1753
+ {
1754
+ function: (input, start, end) => {
1755
+ const name = input
1756
+ .slice(start, end - 1)
1757
+ .replace(/\\/g, "")
1758
+ .toLowerCase();
1759
+
1760
+ const type =
1761
+ name === "local" ? 1 : name === "global" ? 2 : undefined;
1762
+
1763
+ if (type) {
1764
+ return processLocalOrGlobalFunction(input, type, start, end);
1765
+ }
1766
+
1767
+ if (
1768
+ this.options.dashedIdents &&
1769
+ isLocalMode() &&
1770
+ name === "var"
1771
+ ) {
1772
+ return processDashedIdent(input, end, end);
1773
+ }
1774
+
1775
+ if (this.options.url) {
1776
+ if (name === "src" || name === "url") {
1777
+ return processURLFunction(input, end, name);
1778
+ } else if (IMAGE_SET_FUNCTION.test(name)) {
1779
+ return processImageSetFunction(input, start, end);
1780
+ }
1781
+ }
1782
+
1783
+ return end;
1784
+ }
1785
+ },
1786
+ {
1787
+ onlyTopLevel: !isGridTemplate,
1788
+ declarationValue: true
1789
+ }
1790
+ );
1791
+
1792
+ if (values.length > 0) {
1793
+ for (const value of values) {
1794
+ const { line: sl, column: sc } = locConverter.get(value[0]);
1795
+ const { line: el, column: ec } = locConverter.get(value[1]);
1796
+ const [start, end, isString] = value;
1797
+ const name = unescapeIdentifier(
1798
+ isString
1799
+ ? input.slice(start + 1, end - 1)
1800
+ : input.slice(start, end)
1801
+ );
1802
+ const dep = new CssIcssExportDependency(
1803
+ name,
1804
+ getReexport(name),
1805
+ [start, end],
1806
+ true,
1807
+ CssIcssExportDependency.EXPORT_MODE.ONCE,
1808
+ isGridProperty
1809
+ ? CssIcssExportDependency.EXPORT_TYPE.GRID_CUSTOM_IDENTIFIER
1810
+ : CssIcssExportDependency.EXPORT_TYPE.NORMAL
1811
+ );
1812
+ dep.setLoc(sl, sc, el, ec);
1813
+ module.addDependency(dep);
1814
+ }
1815
+ }
1816
+
1817
+ return end;
1818
+ } else if (COMPOSES_PROPERTY.test(propertyName)) {
1819
+ if (lastLocalIdentifiers.length > 1) {
1820
+ const end = eatUntilSemi(input, pos);
1821
+ this._emitWarning(
1822
+ state,
1823
+ `Composition is only allowed when selector is single local class name not in "${lastLocalIdentifiers.join('", "')}"`,
1824
+ locConverter,
1825
+ pos,
1826
+ end
1827
+ );
1828
+
1829
+ return end;
1830
+ }
1831
+
1832
+ if (lastLocalIdentifiers.length !== 1) return pos;
1833
+
1834
+ const lastLocalIdentifier = lastLocalIdentifiers[0];
1835
+ let end = pos;
1836
+
1837
+ /** @type {Set<[number, number]>} */
1838
+ const classNames = new Set();
1839
+
1840
+ while (true) {
1841
+ pos = walkCssTokens.eatWhitespaceAndComments(input, pos)[0];
1842
+
1843
+ let className = walkCssTokens.eatIdentSequence(input, pos);
1844
+
1845
+ const ifFunction =
1846
+ className && input.charCodeAt(className[1]) === CC_LEFT_PARENTHESIS;
1847
+ let isGlobalFunction = false;
1848
+
1849
+ if (className && ifFunction) {
1850
+ const name = input
1851
+ .slice(className[0], className[1])
1852
+ .replace(/\\/g, "")
1853
+ .toLowerCase();
1854
+
1855
+ isGlobalFunction = name === "global";
1856
+ pos = walkCssTokens.eatWhitespaceAndComments(
1857
+ input,
1858
+ className[1] + 1
1859
+ )[0];
1860
+ className = walkCssTokens.eatIdentSequence(input, pos);
1861
+ if (className) {
1862
+ pos = walkCssTokens.eatWhitespaceAndComments(
1863
+ input,
1864
+ className[1]
1865
+ )[0];
1866
+ pos += 1;
1867
+ }
1868
+ } else if (className) {
1869
+ pos = walkCssTokens.eatWhitespaceAndComments(
1870
+ input,
1871
+ className[1]
1872
+ )[0];
1873
+ pos = className[1];
1874
+ }
1875
+
1876
+ // True when we have multiple values
1877
+ const isComma = input.charCodeAt(pos) === CC_COMMA;
1878
+ const isSemicolon = input.charCodeAt(pos) === CC_SEMICOLON;
1879
+ const isRightCurly = input.charCodeAt(pos) === CC_RIGHT_CURLY;
1880
+
1881
+ if (isComma || isSemicolon || isRightCurly) {
1882
+ if (className) {
1883
+ classNames.add(className);
1884
+ }
1885
+
1886
+ for (const className of classNames) {
1887
+ const [start, end] = className;
1888
+ const identifier = unescapeIdentifier(input.slice(start, end));
1889
+ const resolvedClassName = getReexport(identifier);
1890
+ const dep = new CssIcssExportDependency(
1891
+ lastLocalIdentifier,
1892
+ resolvedClassName,
1893
+ [start, end],
1894
+ isGlobalFunction ? false : !Array.isArray(resolvedClassName),
1895
+ isGlobalFunction
1896
+ ? CssIcssExportDependency.EXPORT_MODE.APPEND
1897
+ : CssIcssExportDependency.EXPORT_MODE.SELF_REFERENCE
1898
+ );
1899
+ const { line: sl, column: sc } = locConverter.get(start);
1900
+ const { line: el, column: ec } = locConverter.get(end);
1901
+ dep.setLoc(sl, sc, el, ec);
1902
+ module.addDependency(dep);
1903
+ }
1904
+
1905
+ classNames.clear();
1906
+
1907
+ if (isSemicolon || isRightCurly) {
1908
+ end = isSemicolon
1909
+ ? walkCssTokens.eatWhitespace(input, pos + 1)
1910
+ : pos;
1911
+ break;
1912
+ }
1913
+
1914
+ pos += 1;
1915
+ } else if (
1916
+ classNames.size > 0 &&
1917
+ className &&
1918
+ input.slice(className[0], className[1]).toLowerCase() === "from"
1919
+ ) {
1920
+ let from = walkCssTokens.eatString(input, pos);
1921
+
1922
+ if (from) {
1923
+ const request = input.slice(from[0] + 1, from[1] - 1);
1924
+
1925
+ for (const className of classNames) {
1926
+ const [start, end] = className;
1927
+ const identifier = unescapeIdentifier(input.slice(start, end));
1928
+ const dep = new CssIcssImportDependency(
1929
+ request,
1930
+ [start, end],
1931
+ /** @type {"local" | "global"} */
1932
+ (mode),
1933
+ identifier,
1934
+ /** @type {string} */
1935
+ (lastLocalIdentifier),
1936
+ CssIcssExportDependency.EXPORT_MODE.APPEND
1937
+ );
1938
+ const { line: sl, column: sc } = locConverter.get(start);
1939
+ const { line: el, column: ec } = locConverter.get(end);
1940
+ dep.setLoc(sl, sc, el, ec);
1941
+ module.addDependency(dep);
1942
+ }
1943
+
1944
+ classNames.clear();
1945
+ pos = from[1];
1946
+ } else {
1947
+ from = walkCssTokens.eatIdentSequence(input, pos);
1948
+
1949
+ if (from && input.slice(from[0], from[1]) === "global") {
1950
+ for (const className of classNames) {
1951
+ const [start, end] = className;
1952
+ const identifier = unescapeIdentifier(
1953
+ input.slice(start, end)
1954
+ );
1955
+ const dep = new CssIcssExportDependency(
1956
+ /** @type {string} */
1957
+ (lastLocalIdentifier),
1958
+ getReexport(identifier),
1959
+ [start, end],
1960
+ false,
1961
+ CssIcssExportDependency.EXPORT_MODE.APPEND
1962
+ );
1963
+ const { line: sl, column: sc } = locConverter.get(start);
1964
+ const { line: el, column: ec } = locConverter.get(end);
1965
+ dep.setLoc(sl, sc, el, ec);
1966
+ module.addDependency(dep);
1967
+ }
1968
+
1969
+ classNames.clear();
1970
+ pos = from[1];
1971
+ } else {
1972
+ const end = eatUntilSemi(input, pos);
1973
+ this._emitWarning(
1974
+ state,
1975
+ "Incorrect composition, expected global keyword or string value",
1976
+ locConverter,
1977
+ pos,
1978
+ end
1979
+ );
1980
+ return end;
1981
+ }
1982
+ }
1983
+ } else if (className) {
1984
+ classNames.add(className);
1985
+ } else {
1986
+ const end = eatUntilSemi(input, pos);
1987
+ this._emitWarning(
1988
+ state,
1989
+ "Incorrect composition, expected class named",
1990
+ locConverter,
1991
+ pos,
1992
+ end
1993
+ );
1994
+ return end;
1995
+ }
1996
+ }
1997
+
1998
+ // Remove `composes` from source code
1999
+ const dep = new ConstDependency("", [propertyNameStart, end]);
2000
+ module.addPresentationalDependency(dep);
2001
+ }
2002
+
2003
+ return pos;
2004
+ };
2005
+
2006
+ /**
2007
+ * @param {string} input input
2008
+ * @param {number} start start position
2009
+ * @param {number} end end position
2010
+ * @returns {number} position after handling
2011
+ */
2012
+ const processIdSelector = (input, start, end) => {
2013
+ const valueStart = start + 1;
2014
+ const name = unescapeIdentifier(input.slice(valueStart, end));
2015
+ const dep = new CssIcssExportDependency(
2016
+ name,
2017
+ getReexport(name),
2018
+ [valueStart, end],
2019
+ true,
2020
+ CssIcssExportDependency.EXPORT_MODE.ONCE
2021
+ );
2022
+ const { line: sl, column: sc } = locConverter.get(start);
2023
+ const { line: el, column: ec } = locConverter.get(end);
2024
+ dep.setLoc(sl, sc, el, ec);
2025
+ module.addDependency(dep);
2026
+ return end;
2027
+ };
2028
+
2029
+ /**
2030
+ * @param {string} input input
2031
+ * @param {number} start start position
2032
+ * @param {number} end end position
2033
+ * @returns {number} position after handling
2034
+ */
2035
+ const processClassSelector = (input, start, end) => {
2036
+ const ident = walkCssTokens.skipCommentsAndEatIdentSequence(input, end);
2037
+ if (!ident) return end;
2038
+ const name = unescapeIdentifier(input.slice(ident[0], ident[1]));
2039
+ lastLocalIdentifiers.push(name);
2040
+ const dep = new CssIcssExportDependency(
2041
+ name,
2042
+ getReexport(name),
2043
+ [ident[0], ident[1]],
2044
+ true,
2045
+ CssIcssExportDependency.EXPORT_MODE.ONCE
2046
+ );
2047
+ const { line: sl, column: sc } = locConverter.get(ident[0]);
2048
+ const { line: el, column: ec } = locConverter.get(ident[1]);
2049
+ dep.setLoc(sl, sc, el, ec);
2050
+ module.addDependency(dep);
2051
+ return ident[1];
2052
+ };
2053
+
2054
+ /**
2055
+ * @param {string} input input
2056
+ * @param {number} start start position
2057
+ * @param {number} end end position
2058
+ * @returns {number} position after handling
2059
+ */
2060
+ const processAttributeSelector = (input, start, end) => {
2061
+ end = walkCssTokens.eatWhitespaceAndComments(input, end)[0];
2062
+ const identifier = walkCssTokens.eatIdentSequence(input, end);
2063
+ if (!identifier) return end;
2064
+ const name = unescapeIdentifier(
2065
+ input.slice(identifier[0], identifier[1])
2066
+ );
2067
+ if (name.toLowerCase() !== "class") {
2068
+ return end;
2069
+ }
2070
+ end = walkCssTokens.eatWhitespaceAndComments(input, identifier[1])[0];
2071
+
2072
+ const isTilde = input.charCodeAt(end) === CC_TILDE;
2073
+
2074
+ if (
2075
+ input.charCodeAt(end) !== CC_EQUAL &&
2076
+ input.charCodeAt(end) !== CC_TILDE
2077
+ ) {
2078
+ return end;
2079
+ }
2080
+
2081
+ end += 1;
2082
+
2083
+ if (isTilde) {
2084
+ if (input.charCodeAt(end) !== CC_EQUAL) {
2085
+ return end;
2086
+ }
2087
+
2088
+ end += 1;
2089
+ }
2090
+
2091
+ end = walkCssTokens.eatWhitespaceAndComments(input, end)[0];
2092
+ const value = walkCssTokens.eatIdentSequenceOrString(input, end);
2093
+
2094
+ if (!value) {
2095
+ return end;
2096
+ }
2097
+
2098
+ const classNameStart = value[2] ? value[0] : value[0] + 1;
2099
+ const classNameEnd = value[2] ? value[1] : value[1] - 1;
2100
+ const className = unescapeIdentifier(
2101
+ input.slice(classNameStart, classNameEnd)
2102
+ );
2103
+ const dep = new CssIcssExportDependency(
2104
+ className,
2105
+ getReexport(className),
2106
+ [classNameStart, classNameEnd],
2107
+ true,
2108
+ CssIcssExportDependency.EXPORT_MODE.NONE
2109
+ );
2110
+ const { line: sl, column: sc } = locConverter.get(classNameStart);
2111
+ const { line: el, column: ec } = locConverter.get(classNameEnd);
2112
+ dep.setLoc(sl, sc, el, ec);
2113
+ module.addDependency(dep);
2114
+ return value[2] ? classNameEnd : classNameEnd + 1;
2115
+ };
2116
+
2117
+ walkCssTokens(source, 0, {
2118
+ comment,
2119
+ leftCurlyBracket: (input, start, end) => {
2120
+ switch (scope) {
2121
+ case CSS_MODE_TOP_LEVEL: {
2122
+ allowImportAtRule = false;
2123
+ scope = CSS_MODE_IN_BLOCK;
2124
+
2125
+ if (isModules) {
2126
+ blockNestingLevel = 1;
2127
+ isNextRulePrelude = isNextNestedSyntax(input, end);
2128
+ }
2129
+
2130
+ break;
2131
+ }
2132
+ case CSS_MODE_IN_BLOCK: {
2133
+ if (isModules) {
2134
+ blockNestingLevel++;
2135
+ isNextRulePrelude = isNextNestedSyntax(input, end);
2136
+ }
2137
+ break;
2138
+ }
2139
+ }
2140
+ return end;
2141
+ },
2142
+ rightCurlyBracket: (input, start, end) => {
2143
+ switch (scope) {
2144
+ case CSS_MODE_IN_BLOCK: {
2145
+ if (--blockNestingLevel === 0) {
2146
+ scope = CSS_MODE_TOP_LEVEL;
2147
+
2148
+ if (isModules) {
2149
+ isNextRulePrelude = true;
2150
+ modeData = undefined;
2151
+ lastLocalIdentifiers = [];
2152
+ }
2153
+ } else if (isModules) {
2154
+ isNextRulePrelude = isNextNestedSyntax(input, end);
2155
+ }
2156
+ break;
2157
+ }
2158
+ }
2159
+ return end;
2160
+ },
2161
+ url: (input, start, end, contentStart, contentEnd) => {
2162
+ if (!this.options.url) {
2163
+ return end;
2164
+ }
2165
+
2166
+ return processOldURLFunction(
2167
+ input,
2168
+ start,
2169
+ end,
2170
+ contentStart,
2171
+ contentEnd
2172
+ );
2173
+ },
2174
+ atKeyword: (input, start, end) => {
2175
+ const name = input.slice(start, end).toLowerCase();
2176
+
2177
+ switch (name) {
2178
+ case "@namespace": {
2179
+ this._emitWarning(
2180
+ state,
2181
+ "'@namespace' is not supported in bundled CSS",
2182
+ locConverter,
2183
+ start,
2184
+ end
2185
+ );
2186
+
2187
+ return eatUntilSemi(input, start);
2188
+ }
2189
+ case "@import": {
2190
+ if (!this.options.import) {
2191
+ return eatUntilSemi(input, end);
2192
+ }
2193
+
2194
+ if (!allowImportAtRule) {
2195
+ this._emitWarning(
2196
+ state,
2197
+ "Any '@import' rules must precede all other rules",
2198
+ locConverter,
2199
+ start,
2200
+ end
2201
+ );
2202
+ return end;
2203
+ }
2204
+
2205
+ return processAtImport(input, start, end);
2206
+ }
2207
+ default: {
2208
+ if (isModules) {
2209
+ if (name === "@value") {
2210
+ return processAtValue(input, start, end);
2211
+ } else if (
2212
+ this.options.animation &&
2213
+ OPTIONALLY_VENDOR_PREFIXED_KEYFRAMES_AT_RULE.test(name) &&
2214
+ isLocalMode()
2215
+ ) {
2216
+ return processLocalAtRule(input, end, {
2217
+ string: true,
2218
+ identifier: true
2219
+ });
2220
+ } else if (
2221
+ this.options.customIdents &&
2222
+ name === "@counter-style" &&
2223
+ isLocalMode()
2224
+ ) {
2225
+ return processLocalAtRule(input, end, {
2226
+ identifier: true
2227
+ });
2228
+ } else if (
2229
+ this.options.container &&
2230
+ name === "@container" &&
2231
+ isLocalMode()
2232
+ ) {
2233
+ return processLocalAtRule(input, end, {
2234
+ identifier: /^(none|and|or|not)$/
2235
+ });
2236
+ } else if (name === "@scope") {
2237
+ isNextRulePrelude = true;
2238
+ return end;
2239
+ }
2240
+
2241
+ isNextRulePrelude = false;
2242
+ }
2243
+ }
2244
+ }
2245
+
2246
+ return end;
2247
+ },
2248
+ semicolon: (input, start, end) => {
2249
+ if (isModules && scope === CSS_MODE_IN_BLOCK) {
2250
+ isNextRulePrelude = isNextNestedSyntax(input, end);
2251
+ }
2252
+ return end;
2253
+ },
2254
+ identifier: (input, start, end) => {
2255
+ if (isModules) {
2256
+ const identifier = input.slice(start, end);
2257
+
2258
+ if (icssDefinitions.has(identifier)) {
2259
+ return processICSSSymbol(identifier, start, end);
2260
+ }
2261
+
2262
+ if (
2263
+ this.options.dashedIdents &&
2264
+ isLocalMode() &&
2265
+ isDashedIdentifier(identifier)
2266
+ ) {
2267
+ return processDashedIdent(input, start, end);
2268
+ }
2269
+
2270
+ switch (scope) {
2271
+ case CSS_MODE_IN_BLOCK: {
2272
+ if (isModules && !isNextRulePrelude) {
2273
+ // Handle only top level values and not inside functions
2274
+ return processLocalDeclaration(input, start, end);
2275
+ }
2276
+ break;
2277
+ }
2278
+ }
2279
+ }
2280
+
2281
+ return end;
2282
+ },
2283
+ delim: (input, start, end) => {
2284
+ if (isNextRulePrelude && isLocalMode()) {
2285
+ return processClassSelector(input, start, end);
2286
+ }
2287
+
2288
+ return end;
2289
+ },
2290
+ hash: (input, start, end, isID) => {
2291
+ if (isNextRulePrelude && isLocalMode() && isID) {
2292
+ return processIdSelector(input, start, end);
2293
+ }
2294
+
2295
+ return end;
2296
+ },
2297
+ colon: (input, start, end) => {
2298
+ if (isModules) {
2299
+ const ident = walkCssTokens.skipCommentsAndEatIdentSequence(
2300
+ input,
2301
+ end
2302
+ );
2303
+ if (!ident) return end;
2304
+ const name = input.slice(ident[0], ident[1]).toLowerCase();
2305
+
2306
+ switch (scope) {
2307
+ case CSS_MODE_TOP_LEVEL: {
2308
+ if (name === "import") {
2309
+ const pos = processImportOrExport(0, input, ident[1]);
2310
+ const dep = new ConstDependency("", [start, pos]);
2311
+ module.addPresentationalDependency(dep);
2312
+ return pos;
2313
+ } else if (name === "export") {
2314
+ const pos = processImportOrExport(1, input, ident[1]);
2315
+ const dep = new ConstDependency("", [start, pos]);
2316
+ module.addPresentationalDependency(dep);
2317
+ return pos;
2318
+ }
2319
+ }
2320
+ // falls through
2321
+ default: {
2322
+ if (isNextRulePrelude) {
2323
+ const isFn = input.charCodeAt(ident[1]) === CC_LEFT_PARENTHESIS;
2324
+
2325
+ if (isFn && name === "local") {
2326
+ // Eat extra whitespace
2327
+ const end = walkCssTokens.eatWhitespaceAndComments(
2328
+ input,
2329
+ ident[1] + 1
2330
+ )[0];
2331
+ modeData = LOCAL_MODE;
2332
+ const dep = new ConstDependency("", [start, end]);
2333
+ module.addPresentationalDependency(dep);
2334
+ balanced.push([":local", start, end, true]);
2335
+ return end;
2336
+ } else if (name === "local") {
2337
+ modeData = LOCAL_MODE;
2338
+ const found = walkCssTokens.eatWhitespaceAndComments(
2339
+ input,
2340
+ ident[1]
2341
+ );
2342
+
2343
+ if (!found[1]) {
2344
+ this._emitWarning(
2345
+ state,
2346
+ `Missing whitespace after ':local' in '${input.slice(
2347
+ start,
2348
+ eatUntilLeftCurly(input, end) + 1
2349
+ )}'`,
2350
+ locConverter,
2351
+ start,
2352
+ end
2353
+ );
2354
+ }
2355
+
2356
+ end = walkCssTokens.eatWhitespace(input, ident[1]);
2357
+ const dep = new ConstDependency("", [start, end]);
2358
+ module.addPresentationalDependency(dep);
2359
+ return end;
2360
+ } else if (isFn && name === "global") {
2361
+ // Eat extra whitespace
2362
+ const end = walkCssTokens.eatWhitespaceAndComments(
2363
+ input,
2364
+ ident[1] + 1
2365
+ )[0];
2366
+ modeData = GLOBAL_MODE;
2367
+ const dep = new ConstDependency("", [start, end]);
2368
+ module.addPresentationalDependency(dep);
2369
+ balanced.push([":global", start, end, true]);
2370
+ return end;
2371
+ } else if (name === "global") {
2372
+ modeData = GLOBAL_MODE;
2373
+ // Eat extra whitespace
2374
+ const found = walkCssTokens.eatWhitespaceAndComments(
2375
+ input,
2376
+ ident[1]
2377
+ );
2378
+
2379
+ if (!found[1]) {
2380
+ this._emitWarning(
2381
+ state,
2382
+ `Missing whitespace after ':global' in '${input.slice(
2383
+ start,
2384
+ eatUntilLeftCurly(input, end) + 1
2385
+ )}'`,
2386
+ locConverter,
2387
+ start,
2388
+ end
2389
+ );
2390
+ }
2391
+
2392
+ end = walkCssTokens.eatWhitespace(input, ident[1]);
2393
+ const dep = new ConstDependency("", [start, end]);
2394
+ module.addPresentationalDependency(dep);
2395
+ return end;
2396
+ }
2397
+ }
2398
+ }
2399
+ }
2400
+ }
2401
+
2402
+ lastTokenEndForComments = end;
2403
+
2404
+ return end;
2405
+ },
2406
+ function: (input, start, end) => {
2407
+ const name = input
2408
+ .slice(start, end - 1)
2409
+ .replace(/\\/g, "")
2410
+ .toLowerCase();
2411
+
2412
+ balanced.push([name, start, end]);
2413
+
2414
+ switch (name) {
2415
+ case "src":
2416
+ case "url": {
2417
+ if (!this.options.url) {
2418
+ return end;
2419
+ }
2420
+
2421
+ return processURLFunction(input, end, name);
2422
+ }
2423
+ default: {
2424
+ if (this.options.url && IMAGE_SET_FUNCTION.test(name)) {
2425
+ return processImageSetFunction(input, start, end);
2426
+ }
2427
+
2428
+ if (isModules) {
2429
+ if (
2430
+ this.options.function &&
2431
+ isLocalMode() &&
2432
+ isDashedIdentifier(name)
2433
+ ) {
2434
+ return processDashedIdent(input, start, end);
2435
+ }
2436
+
2437
+ const type =
2438
+ name === "local" ? 1 : name === "global" ? 2 : undefined;
2439
+
2440
+ if (type && !isNextRulePrelude) {
2441
+ return processLocalOrGlobalFunction(input, type, start, end);
2442
+ }
2443
+ }
2444
+ }
2445
+ }
2446
+
2447
+ return end;
2448
+ },
2449
+ leftSquareBracket: (input, start, end) => {
2450
+ if (isNextRulePrelude && isLocalMode()) {
2451
+ return processAttributeSelector(input, start, end);
2452
+ }
2453
+ return end;
2454
+ },
2455
+ leftParenthesis: (input, start, end) => {
2456
+ balanced.push(["(", start, end]);
2457
+
2458
+ return end;
2459
+ },
2460
+ rightParenthesis: (input, start, end) => {
2461
+ const popped = balanced.pop();
2462
+
2463
+ if (isModules && popped) {
2464
+ const isLocal = popped[0] === ":local";
2465
+ const isGlobal = popped[0] === ":global";
2466
+ if (isLocal || isGlobal) {
2467
+ modeData = balanced[balanced.length - 1]
2468
+ ? balanced[balanced.length - 1][0] === ":local"
2469
+ ? LOCAL_MODE
2470
+ : balanced[balanced.length - 1][0] === ":global"
2471
+ ? GLOBAL_MODE
2472
+ : undefined
2473
+ : undefined;
2474
+ if (popped[3] && isLocal) {
2475
+ while (walkCssTokens.isWhiteSpace(input.charCodeAt(start - 1))) {
2476
+ start -= 1;
2477
+ }
2478
+ }
2479
+ const dep = new ConstDependency("", [start, end]);
2480
+ module.addPresentationalDependency(dep);
2481
+ } else if (isNextRulePrelude) {
2482
+ modeData = undefined;
2483
+ }
2484
+ }
2485
+
2486
+ return end;
2487
+ },
2488
+ comma: (input, start, end) => {
2489
+ if (isModules) {
2490
+ const popped = balanced.pop();
2491
+
2492
+ if (!popped) {
2493
+ // Reset stack for `:global .class :local .class-other` selector after
2494
+ modeData = undefined;
2495
+ }
2496
+ }
2497
+
2498
+ lastTokenEndForComments = start;
2499
+
2500
+ return end;
2501
+ }
2502
+ });
2503
+
2504
+ /** @type {BuildInfo} */
2505
+ (module.buildInfo).strict = true;
2506
+
2507
+ const buildMeta = /** @type {BuildMeta} */ (state.module.buildMeta);
2508
+
2509
+ buildMeta.exportsType = this.options.namedExports ? "namespace" : "default";
2510
+ buildMeta.defaultObject = this.options.namedExports
2511
+ ? false
2512
+ : "redirect-warn";
2513
+ buildMeta.exportType = this.options.exportType;
2514
+
2515
+ if (!buildMeta.exportType) {
2516
+ // Inherit exportType from parent module to ensure consistency.
2517
+ // When a CSS file is imported with syntax like `import "./basic.css" with { type: "css" }`,
2518
+ // the parent module's exportType is set to "css-style-sheet".
2519
+ // Child modules imported via @import should inherit this exportType
2520
+ // instead of using the default "link", ensuring that the entire
2521
+ // import chain uses the same export format.
2522
+ const parent = state.compilation.moduleGraph.getIssuer(module);
2523
+ if (parent instanceof CssModule) {
2524
+ buildMeta.exportType = /** @type {BuildMeta} */ (
2525
+ parent.buildMeta
2526
+ ).exportType;
2527
+ }
2528
+ }
2529
+ if (!buildMeta.exportType) {
2530
+ buildMeta.exportType = "link";
2531
+ }
2532
+
2533
+ // TODO this.namedExports?
2534
+ if (
2535
+ buildMeta.exportType === "text" ||
2536
+ buildMeta.exportType === "css-style-sheet"
2537
+ ) {
2538
+ module.addDependency(new StaticExportsDependency(["default"], true));
2539
+ } else {
2540
+ module.addDependency(new StaticExportsDependency([], true));
2541
+ }
2542
+
2543
+ return state;
2544
+ }
2545
+
2546
+ /**
2547
+ * @param {Range} range range
2548
+ * @returns {Comment[]} comments in the range
2549
+ */
2550
+ getComments(range) {
2551
+ if (!this.comments) return [];
2552
+ const [rangeStart, rangeEnd] = range;
2553
+ /**
2554
+ * @param {Comment} comment comment
2555
+ * @param {number} needle needle
2556
+ * @returns {number} compared
2557
+ */
2558
+ const compare = (comment, needle) =>
2559
+ /** @type {Range} */ (comment.range)[0] - needle;
2560
+ const comments = /** @type {Comment[]} */ (this.comments);
2561
+ let idx = binarySearchBounds.ge(comments, rangeStart, compare);
2562
+ /** @type {Comment[]} */
2563
+ const commentsInRange = [];
2564
+ while (
2565
+ comments[idx] &&
2566
+ /** @type {Range} */ (comments[idx].range)[1] <= rangeEnd
2567
+ ) {
2568
+ commentsInRange.push(comments[idx]);
2569
+ idx++;
2570
+ }
2571
+
2572
+ return commentsInRange;
2573
+ }
2574
+
2575
+ /**
2576
+ * @param {Range} range range of the comment
2577
+ * @returns {{ options: Record<string, EXPECTED_ANY> | null, errors: (Error & { comment: Comment })[] | null }} result
2578
+ */
2579
+ parseCommentOptions(range) {
2580
+ const comments = this.getComments(range);
2581
+ if (comments.length === 0) {
2582
+ return EMPTY_COMMENT_OPTIONS;
2583
+ }
2584
+ /** @type {Record<string, EXPECTED_ANY>} */
2585
+ const options = {};
2586
+ /** @type {(Error & { comment: Comment })[]} */
2587
+ const errors = [];
2588
+ for (const comment of comments) {
2589
+ const { value } = comment;
2590
+ if (value && webpackCommentRegExp.test(value)) {
2591
+ // try compile only if webpack options comment is present
2592
+ try {
2593
+ for (let [key, val] of Object.entries(
2594
+ vm.runInContext(
2595
+ `(function(){return {${value}};})()`,
2596
+ this.magicCommentContext
2597
+ )
2598
+ )) {
2599
+ if (typeof val === "object" && val !== null) {
2600
+ val =
2601
+ val.constructor.name === "RegExp"
2602
+ ? new RegExp(val)
2603
+ : JSON.parse(JSON.stringify(val));
2604
+ }
2605
+ options[key] = val;
2606
+ }
2607
+ } catch (err) {
2608
+ const newErr = new Error(String(/** @type {Error} */ (err).message));
2609
+ newErr.stack = String(/** @type {Error} */ (err).stack);
2610
+ Object.assign(newErr, { comment });
2611
+ errors.push(/** @type {(Error & { comment: Comment })} */ (newErr));
2612
+ }
2613
+ }
2614
+ }
2615
+ return { options, errors };
2616
+ }
2617
+ }
2618
+
2619
+ module.exports = CssParser;
2620
+ module.exports.escapeIdentifier = escapeIdentifier;
2621
+ module.exports.unescapeIdentifier = unescapeIdentifier;