webpack 5.76.1 → 5.88.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of webpack might be problematic. Click here for more details.
- package/README.md +10 -4
- package/bin/webpack.js +26 -2
- package/hot/dev-server.js +2 -1
- package/hot/lazy-compilation-node.js +10 -0
- package/hot/lazy-compilation-web.js +9 -0
- package/hot/log-apply-result.js +5 -0
- package/hot/log.js +22 -0
- package/hot/only-dev-server.js +2 -1
- package/hot/poll.js +3 -0
- package/hot/signal.js +4 -0
- package/lib/APIPlugin.js +174 -116
- package/lib/AsyncDependenciesBlock.js +13 -5
- package/lib/AutomaticPrefetchPlugin.js +1 -0
- package/lib/BannerPlugin.js +4 -0
- package/lib/CacheFacade.js +4 -0
- package/lib/CaseSensitiveModulesWarning.js +3 -1
- package/lib/Chunk.js +36 -18
- package/lib/ChunkGraph.js +4 -4
- package/lib/ChunkGroup.js +25 -10
- package/lib/CleanPlugin.js +30 -7
- package/lib/CodeGenerationResults.js +2 -2
- package/lib/CompatibilityPlugin.js +85 -46
- package/lib/Compilation.js +17 -8
- package/lib/Compiler.js +12 -8
- package/lib/ConcatenationScope.js +2 -2
- package/lib/ConditionalInitFragment.js +11 -1
- package/lib/ConstPlugin.js +79 -44
- package/lib/ContextModule.js +20 -6
- package/lib/ContextModuleFactory.js +2 -1
- package/lib/ContextReplacementPlugin.js +13 -0
- package/lib/CssModule.js +169 -0
- package/lib/DefinePlugin.js +152 -86
- package/lib/DelegatedModule.js +22 -4
- package/lib/DelegatedModuleFactoryPlugin.js +6 -0
- package/lib/DependenciesBlock.js +17 -1
- package/lib/Dependency.js +19 -5
- package/lib/DllEntryPlugin.js +16 -1
- package/lib/DllModule.js +17 -2
- package/lib/DllModuleFactory.js +1 -1
- package/lib/DllReferencePlugin.js +13 -1
- package/lib/Entrypoint.js +1 -1
- package/lib/ErrorHelpers.js +62 -22
- package/lib/EvalSourceMapDevToolPlugin.js +9 -2
- package/lib/ExportsInfo.js +20 -3
- package/lib/ExportsInfoApiPlugin.js +30 -14
- package/lib/ExternalModule.js +30 -9
- package/lib/FileSystemInfo.js +9 -1
- package/lib/FlagAllModulesAsUsedPlugin.js +27 -27
- package/lib/FlagDependencyExportsPlugin.js +336 -348
- package/lib/FlagDependencyUsagePlugin.js +9 -9
- package/lib/FlagEntryExportAsUsedPlugin.js +26 -23
- package/lib/HookWebpackError.js +1 -1
- package/lib/HotModuleReplacementPlugin.js +60 -46
- package/lib/IgnoreErrorModuleFactory.js +1 -1
- package/lib/InitFragment.js +28 -5
- package/lib/JavascriptMetaInfoPlugin.js +27 -15
- package/lib/LibManifestPlugin.js +22 -5
- package/lib/LoaderOptionsPlugin.js +12 -2
- package/lib/MainTemplate.js +2 -2
- package/lib/Module.js +44 -12
- package/lib/ModuleBuildError.js +9 -0
- package/lib/ModuleDependencyError.js +4 -2
- package/lib/ModuleDependencyWarning.js +4 -2
- package/lib/ModuleError.js +9 -0
- package/lib/ModuleFactory.js +1 -1
- package/lib/ModuleFilenameHelpers.js +114 -4
- package/lib/ModuleGraph.js +33 -23
- package/lib/ModuleGraphConnection.js +19 -6
- package/lib/ModuleInfoHeaderPlugin.js +9 -2
- package/lib/ModuleNotFoundError.js +5 -2
- package/lib/ModuleParseError.js +9 -0
- package/lib/ModuleProfile.js +1 -0
- package/lib/ModuleRestoreError.js +2 -0
- package/lib/ModuleStoreError.js +2 -1
- package/lib/ModuleTypeConstants.js +169 -0
- package/lib/ModuleWarning.js +9 -0
- package/lib/MultiWatching.js +4 -0
- package/lib/NodeStuffPlugin.js +65 -35
- package/lib/NormalModule.js +12 -2
- package/lib/NormalModuleFactory.js +56 -8
- package/lib/NormalModuleReplacementPlugin.js +5 -3
- package/lib/NullFactory.js +1 -1
- package/lib/PrefetchPlugin.js +4 -0
- package/lib/ProgressPlugin.js +71 -15
- package/lib/ProvidePlugin.js +30 -14
- package/lib/RawModule.js +13 -2
- package/lib/RecordIdsPlugin.js +4 -4
- package/lib/RequireJsStuffPlugin.js +22 -15
- package/lib/RuntimeGlobals.js +5 -0
- package/lib/RuntimeModule.js +12 -11
- package/lib/RuntimePlugin.js +10 -3
- package/lib/RuntimeTemplate.js +29 -11
- package/lib/SelfModuleFactory.js +12 -0
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +4 -0
- package/lib/SourceMapDevToolPlugin.js +47 -11
- package/lib/Template.js +5 -3
- package/lib/UseStrictPlugin.js +29 -11
- package/lib/WarnCaseSensitiveModulesPlugin.js +12 -0
- package/lib/WarnDeprecatedOptionPlugin.js +7 -0
- package/lib/WatchIgnorePlugin.js +4 -0
- package/lib/WebpackError.js +14 -5
- package/lib/WebpackIsIncludedPlugin.js +22 -13
- package/lib/WebpackOptionsApply.js +41 -44
- package/lib/WebpackOptionsDefaulter.js +10 -3
- package/lib/asset/AssetGenerator.js +24 -9
- package/lib/asset/AssetModulesPlugin.js +28 -12
- package/lib/asset/AssetParser.js +15 -7
- package/lib/asset/AssetSourceParser.js +8 -3
- package/lib/asset/RawDataUrlModule.js +15 -4
- package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -0
- package/lib/async-modules/InferAsyncModulesPlugin.js +1 -1
- package/lib/cache/IdleFileCachePlugin.js +2 -1
- package/lib/cache/MemoryWithGcCachePlugin.js +2 -0
- package/lib/cache/PackFileCacheStrategy.js +42 -15
- package/lib/cache/ResolverCachePlugin.js +3 -0
- package/lib/config/browserslistTargetHandler.js +10 -10
- package/lib/config/defaults.js +306 -105
- package/lib/config/normalization.js +110 -71
- package/lib/config/target.js +37 -10
- package/lib/container/ContainerEntryModule.js +11 -1
- package/lib/container/ContainerEntryModuleFactory.js +1 -1
- package/lib/container/ContainerExposedDependency.js +9 -0
- package/lib/container/ContainerPlugin.js +3 -1
- package/lib/container/FallbackDependency.js +13 -0
- package/lib/container/FallbackItemDependency.js +3 -0
- package/lib/container/FallbackModule.js +12 -2
- package/lib/container/FallbackModuleFactory.js +1 -1
- package/lib/container/RemoteModule.js +11 -1
- package/lib/container/RemoteRuntimeModule.js +3 -2
- package/lib/container/RemoteToExternalDependency.js +3 -0
- package/lib/css/CssExportsGenerator.js +9 -0
- package/lib/css/CssGenerator.js +5 -1
- package/lib/css/CssLoadingRuntimeModule.js +53 -22
- package/lib/css/CssModulesPlugin.js +253 -74
- package/lib/css/CssParser.js +697 -282
- package/lib/css/walkCssTokens.js +269 -138
- package/lib/debug/ProfilingPlugin.js +33 -12
- package/lib/dependencies/AMDDefineDependency.js +54 -10
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +13 -2
- package/lib/dependencies/AMDPlugin.js +33 -20
- package/lib/dependencies/AMDRequireArrayDependency.js +13 -0
- package/lib/dependencies/AMDRequireContextDependency.js +15 -0
- package/lib/dependencies/AMDRequireDependenciesBlock.js +6 -0
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +8 -2
- package/lib/dependencies/AMDRequireDependency.js +16 -1
- package/lib/dependencies/AMDRequireItemDependency.js +6 -0
- package/lib/dependencies/AMDRuntimeModules.js +2 -2
- package/lib/dependencies/CachedConstDependency.js +14 -0
- package/lib/dependencies/CommonJsDependencyHelpers.js +9 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +19 -0
- package/lib/dependencies/CommonJsExportsDependency.js +16 -0
- package/lib/dependencies/CommonJsExportsParserPlugin.js +77 -5
- package/lib/dependencies/CommonJsFullRequireDependency.js +10 -1
- package/lib/dependencies/CommonJsImportsParserPlugin.js +174 -63
- package/lib/dependencies/CommonJsPlugin.js +51 -26
- package/lib/dependencies/CommonJsRequireContextDependency.js +17 -0
- package/lib/dependencies/CommonJsRequireDependency.js +7 -0
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +16 -0
- package/lib/dependencies/ConstDependency.js +11 -2
- package/lib/dependencies/ContextDependency.js +15 -2
- package/lib/dependencies/ContextDependencyHelpers.js +3 -3
- package/lib/dependencies/ContextElementDependency.js +8 -0
- package/lib/dependencies/CreateScriptUrlDependency.js +10 -1
- package/lib/dependencies/CriticalDependencyWarning.js +3 -0
- package/lib/dependencies/CssExportDependency.js +8 -0
- package/lib/dependencies/CssImportDependency.js +55 -3
- package/lib/dependencies/CssLocalIdentifierDependency.js +15 -1
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +10 -1
- package/lib/dependencies/CssUrlDependency.js +46 -16
- package/lib/dependencies/DelegatedSourceDependency.js +3 -0
- package/lib/dependencies/DllEntryDependency.js +14 -0
- package/lib/dependencies/DynamicExports.js +10 -6
- package/lib/dependencies/ExportsInfoDependency.js +25 -4
- package/lib/dependencies/HarmonyAcceptDependency.js +10 -1
- package/lib/dependencies/HarmonyAcceptImportDependency.js +3 -0
- package/lib/dependencies/HarmonyCompatibilityDependency.js +2 -1
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +22 -2
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +32 -6
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +5 -0
- package/lib/dependencies/HarmonyExportExpressionDependency.js +20 -3
- package/lib/dependencies/HarmonyExportHeaderDependency.js +13 -0
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +22 -6
- package/lib/dependencies/HarmonyExportInitFragment.js +2 -1
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +12 -0
- package/lib/dependencies/HarmonyExports.js +11 -5
- package/lib/dependencies/HarmonyImportDependency.js +10 -1
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +53 -22
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +7 -2
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +139 -16
- package/lib/dependencies/HarmonyModulesPlugin.js +23 -5
- package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +15 -3
- package/lib/dependencies/ImportContextDependency.js +15 -0
- package/lib/dependencies/ImportDependency.js +15 -4
- package/lib/dependencies/ImportEagerDependency.js +7 -4
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +51 -13
- package/lib/dependencies/ImportMetaContextPlugin.js +18 -5
- package/lib/dependencies/ImportMetaHotAcceptDependency.js +6 -0
- package/lib/dependencies/ImportMetaHotDeclineDependency.js +6 -0
- package/lib/dependencies/ImportMetaPlugin.js +103 -51
- package/lib/dependencies/ImportParserPlugin.js +83 -25
- package/lib/dependencies/ImportPlugin.js +21 -7
- package/lib/dependencies/ImportWeakDependency.js +7 -4
- package/lib/dependencies/JsonExportsDependency.js +9 -1
- package/lib/dependencies/LocalModule.js +16 -0
- package/lib/dependencies/LocalModuleDependency.js +15 -0
- package/lib/dependencies/LocalModulesHelpers.js +18 -0
- package/lib/dependencies/ModuleDecoratorDependency.js +8 -0
- package/lib/dependencies/ModuleDependency.js +9 -1
- package/lib/dependencies/ModuleDependencyTemplateAsId.js +2 -1
- package/lib/dependencies/ModuleHotAcceptDependency.js +6 -0
- package/lib/dependencies/ModuleHotDeclineDependency.js +6 -0
- package/lib/dependencies/PrefetchDependency.js +3 -0
- package/lib/dependencies/ProvidedDependency.js +14 -2
- package/lib/dependencies/PureExpressionDependency.js +10 -1
- package/lib/dependencies/RequireContextDependency.js +6 -0
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +13 -5
- package/lib/dependencies/RequireContextPlugin.js +19 -6
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +7 -0
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +6 -1
- package/lib/dependencies/RequireEnsureDependency.js +16 -2
- package/lib/dependencies/RequireEnsureItemDependency.js +3 -0
- package/lib/dependencies/RequireEnsurePlugin.js +27 -7
- package/lib/dependencies/RequireHeaderDependency.js +14 -1
- package/lib/dependencies/RequireIncludeDependency.js +5 -0
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +29 -5
- package/lib/dependencies/RequireIncludePlugin.js +25 -5
- package/lib/dependencies/RequireResolveContextDependency.js +17 -0
- package/lib/dependencies/RequireResolveDependency.js +6 -0
- package/lib/dependencies/RequireResolveHeaderDependency.js +18 -0
- package/lib/dependencies/RuntimeRequirementsDependency.js +8 -0
- package/lib/dependencies/StaticExportsDependency.js +8 -0
- package/lib/dependencies/SystemPlugin.js +48 -21
- package/lib/dependencies/SystemRuntimeModule.js +1 -1
- package/lib/dependencies/URLDependency.js +13 -4
- package/lib/dependencies/URLPlugin.js +31 -18
- package/lib/dependencies/UnsupportedDependency.js +13 -0
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +14 -0
- package/lib/dependencies/WebAssemblyImportDependency.js +9 -1
- package/lib/dependencies/WebpackIsIncludedDependency.js +5 -0
- package/lib/dependencies/WorkerDependency.js +47 -3
- package/lib/dependencies/WorkerPlugin.js +105 -32
- package/lib/dependencies/getFunctionExpression.js +7 -0
- package/lib/esm/ExportWebpackRequireRuntimeModule.js +3 -2
- package/lib/esm/ModuleChunkFormatPlugin.js +21 -8
- package/lib/esm/ModuleChunkLoadingPlugin.js +9 -0
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +19 -12
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -1
- package/lib/hmr/LazyCompilationPlugin.js +14 -5
- package/lib/ids/ChunkModuleIdRangePlugin.js +11 -0
- package/lib/ids/DeterministicChunkIdsPlugin.js +11 -2
- package/lib/ids/DeterministicModuleIdsPlugin.js +11 -7
- package/lib/ids/HashedModuleIdsPlugin.js +9 -2
- package/lib/ids/IdHelpers.js +6 -0
- package/lib/ids/NamedChunkIdsPlugin.js +13 -1
- package/lib/ids/NamedModuleIdsPlugin.js +14 -3
- package/lib/ids/OccurrenceChunkIdsPlugin.js +6 -2
- package/lib/ids/OccurrenceModuleIdsPlugin.js +1 -1
- package/lib/ids/SyncModuleIdsPlugin.js +3 -2
- package/lib/index.js +8 -0
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +3 -3
- package/lib/javascript/BasicEvaluatedExpression.js +137 -11
- package/lib/javascript/ChunkHelpers.js +2 -2
- package/lib/javascript/CommonJsChunkFormatPlugin.js +7 -3
- package/lib/javascript/EnableChunkLoadingPlugin.js +4 -0
- package/lib/javascript/JavascriptModulesPlugin.js +194 -194
- package/lib/javascript/JavascriptParser.js +941 -256
- package/lib/javascript/JavascriptParserHelpers.js +37 -15
- package/lib/javascript/StartupHelpers.js +2 -2
- package/lib/json/JsonData.js +26 -1
- package/lib/json/JsonGenerator.js +21 -7
- package/lib/json/JsonModulesPlugin.js +14 -5
- package/lib/json/JsonParser.js +27 -13
- package/lib/library/AbstractLibraryPlugin.js +4 -0
- package/lib/library/AmdLibraryPlugin.js +22 -6
- package/lib/library/AssignLibraryPlugin.js +6 -4
- package/lib/library/ExportPropertyLibraryPlugin.js +4 -1
- package/lib/library/ModuleLibraryPlugin.js +8 -4
- package/lib/library/SystemLibraryPlugin.js +1 -0
- package/lib/library/UmdLibraryPlugin.js +4 -0
- package/lib/logging/runtime.js +1 -1
- package/lib/logging/truncateArgs.js +4 -0
- package/lib/node/CommonJsChunkLoadingPlugin.js +17 -2
- package/lib/node/NodeTargetPlugin.js +3 -0
- package/lib/node/NodeTemplatePlugin.js +10 -2
- package/lib/node/NodeWatchFileSystem.js +1 -1
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +18 -9
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +12 -2
- package/lib/node/ReadFileCompileWasmPlugin.js +21 -3
- package/lib/node/RequireChunkLoadingRuntimeModule.js +15 -8
- package/lib/node/nodeConsole.js +2 -4
- package/lib/optimize/AggressiveMergingPlugin.js +8 -0
- package/lib/optimize/AggressiveSplittingPlugin.js +9 -2
- package/lib/optimize/ConcatenatedModule.js +8 -6
- package/lib/optimize/EnsureChunkConditionsPlugin.js +3 -0
- package/lib/optimize/FlagIncludedChunksPlugin.js +11 -5
- package/lib/optimize/InnerGraph.js +5 -5
- package/lib/optimize/InnerGraphPlugin.js +57 -48
- package/lib/optimize/LimitChunkCountPlugin.js +29 -4
- package/lib/optimize/MangleExportsPlugin.js +1 -1
- package/lib/optimize/MinMaxSizeWarning.js +5 -0
- package/lib/optimize/ModuleConcatenationPlugin.js +59 -2
- package/lib/optimize/RealContentHashPlugin.js +86 -30
- package/lib/optimize/RemoveParentModulesPlugin.js +6 -0
- package/lib/optimize/RuntimeChunkPlugin.js +9 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +53 -44
- package/lib/optimize/SplitChunksPlugin.js +71 -31
- package/lib/performance/SizeLimitsPlugin.js +7 -4
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +4 -2
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +3 -1
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +6 -3
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +4 -2
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +4 -2
- package/lib/rules/BasicEffectRulePlugin.js +4 -0
- package/lib/rules/BasicMatcherRulePlugin.js +5 -0
- package/lib/rules/RuleSetCompiler.js +3 -3
- package/lib/rules/UseEffectRulePlugin.js +6 -4
- package/lib/runtime/AsyncModuleRuntimeModule.js +9 -6
- package/lib/runtime/AutoPublicPathRuntimeModule.js +16 -5
- package/lib/runtime/BaseUriRuntimeModule.js +8 -4
- package/lib/runtime/ChunkNameRuntimeModule.js +1 -1
- package/lib/runtime/CompatGetDefaultExportRuntimeModule.js +5 -2
- package/lib/runtime/CompatRuntimeModule.js +7 -2
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +5 -2
- package/lib/runtime/CreateScriptRuntimeModule.js +4 -2
- package/lib/runtime/CreateScriptUrlRuntimeModule.js +4 -2
- package/lib/runtime/DefinePropertyGettersRuntimeModule.js +5 -2
- package/lib/runtime/EnsureChunkRuntimeModule.js +18 -4
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +45 -26
- package/lib/runtime/GetFullHashRuntimeModule.js +4 -3
- package/lib/runtime/GetMainFilenameRuntimeModule.js +5 -2
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +27 -6
- package/lib/runtime/GlobalRuntimeModule.js +1 -1
- package/lib/runtime/HasOwnPropertyRuntimeModule.js +5 -2
- package/lib/runtime/LoadScriptRuntimeModule.js +65 -50
- package/lib/runtime/MakeNamespaceObjectRuntimeModule.js +5 -2
- package/lib/runtime/NonceRuntimeModule.js +1 -1
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +4 -2
- package/lib/runtime/PublicPathRuntimeModule.js +9 -2
- package/lib/runtime/RelativeUrlRuntimeModule.js +5 -2
- package/lib/runtime/RuntimeIdRuntimeModule.js +6 -2
- package/lib/runtime/StartupChunkDependenciesPlugin.js +15 -0
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +13 -4
- package/lib/runtime/StartupEntrypointRuntimeModule.js +11 -7
- package/lib/runtime/SystemContextRuntimeModule.js +1 -1
- package/lib/schemes/DataUriPlugin.js +16 -3
- package/lib/schemes/HttpUriPlugin.js +38 -0
- package/lib/serialization/ArraySerializer.js +22 -6
- package/lib/serialization/BinaryMiddleware.js +164 -1
- package/lib/serialization/DateObjectSerializer.js +15 -4
- package/lib/serialization/ErrorObjectSerializer.js +23 -8
- package/lib/serialization/FileMiddleware.js +17 -0
- package/lib/serialization/MapObjectSerializer.js +24 -8
- package/lib/serialization/NullPrototypeObjectSerializer.js +25 -8
- package/lib/serialization/ObjectMiddleware.js +33 -2
- package/lib/serialization/PlainObjectSerializer.js +23 -12
- package/lib/serialization/RegExpObjectSerializer.js +16 -5
- package/lib/serialization/SetObjectSerializer.js +21 -6
- package/lib/serialization/types.js +1 -1
- package/lib/sharing/ConsumeSharedFallbackDependency.js +3 -0
- package/lib/sharing/ConsumeSharedModule.js +13 -2
- package/lib/sharing/ConsumeSharedPlugin.js +4 -0
- package/lib/sharing/ConsumeSharedRuntimeModule.js +22 -7
- package/lib/sharing/ProvideSharedDependency.js +17 -0
- package/lib/sharing/ProvideSharedModule.js +11 -1
- package/lib/sharing/ProvideSharedModuleFactory.js +1 -1
- package/lib/sharing/ProvideSharedPlugin.js +22 -21
- package/lib/sharing/ShareRuntimeModule.js +19 -9
- package/lib/sharing/resolveMatchedConfigs.js +1 -1
- package/lib/sharing/utils.js +320 -7
- package/lib/stats/DefaultStatsFactoryPlugin.js +105 -29
- package/lib/stats/DefaultStatsPresetPlugin.js +9 -0
- package/lib/stats/DefaultStatsPrinterPlugin.js +43 -0
- package/lib/util/AsyncQueue.js +4 -2
- package/lib/util/LazySet.js +10 -2
- package/lib/util/MapHelpers.js +19 -5
- package/lib/util/ParallelismFactorCalculator.js +10 -0
- package/lib/util/Semaphore.js +1 -1
- package/lib/util/StackedCacheMap.js +6 -0
- package/lib/util/StringXor.js +51 -0
- package/lib/util/binarySearchBounds.js +49 -0
- package/lib/util/compileBooleanMatcher.js +31 -0
- package/lib/util/createHash.js +35 -13
- package/lib/util/deprecation.js +18 -3
- package/lib/util/deterministicGrouping.js +50 -11
- package/lib/util/findGraphRoots.js +4 -2
- package/lib/util/hash/md4.js +2 -2
- package/lib/util/hash/xxhash64.js +1 -1
- package/lib/util/identifier.js +4 -0
- package/lib/util/internalSerializables.js +1 -0
- package/lib/util/makeSerializable.js +7 -0
- package/lib/util/memoize.js +3 -3
- package/lib/util/numberHash.js +75 -21
- package/lib/util/processAsyncTree.js +7 -1
- package/lib/util/propertyAccess.js +9 -54
- package/lib/util/propertyName.js +79 -0
- package/lib/util/registerExternalSerializer.js +1 -1
- package/lib/util/runtime.js +14 -1
- package/lib/util/semver.js +1 -1
- package/lib/util/serialization.js +10 -0
- package/lib/util/smartGrouping.js +1 -1
- package/lib/validateSchema.js +6 -2
- package/lib/wasm/EnableWasmLoadingPlugin.js +4 -0
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +15 -2
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +9 -1
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +14 -3
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +28 -8
- package/lib/wasm-async/AsyncWebAssemblyParser.js +11 -4
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +39 -8
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +17 -6
- package/lib/wasm-sync/WebAssemblyGenerator.js +19 -5
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -1
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +53 -43
- package/lib/wasm-sync/WebAssemblyParser.js +15 -4
- package/lib/wasm-sync/WebAssemblyUtils.js +1 -1
- package/lib/web/FetchCompileAsyncWasmPlugin.js +11 -1
- package/lib/web/FetchCompileWasmPlugin.js +59 -42
- package/lib/web/JsonpChunkLoadingPlugin.js +9 -0
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +26 -9
- package/lib/webpack.js +12 -3
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +9 -0
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +20 -17
- package/module.d.ts +55 -37
- package/package.json +59 -56
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +132 -5
- package/schemas/plugins/ProgressPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.json +4 -0
- package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerPlugin.json +8 -0
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +8 -0
- package/schemas/plugins/css/CssGeneratorOptions.json +1 -1
- package/schemas/plugins/css/CssParserOptions.json +1 -1
- package/schemas/plugins/sharing/SharePlugin.check.js +1 -1
- package/types.d.ts +1608 -667
package/lib/css/CssParser.js
CHANGED
@@ -5,7 +5,10 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
const ModuleDependencyWarning = require("../ModuleDependencyWarning");
|
9
|
+
const { CSS_MODULE_TYPE_AUTO } = require("../ModuleTypeConstants");
|
8
10
|
const Parser = require("../Parser");
|
11
|
+
const WebpackError = require("../WebpackError");
|
9
12
|
const ConstDependency = require("../dependencies/ConstDependency");
|
10
13
|
const CssExportDependency = require("../dependencies/CssExportDependency");
|
11
14
|
const CssImportDependency = require("../dependencies/CssImportDependency");
|
@@ -13,10 +16,12 @@ const CssLocalIdentifierDependency = require("../dependencies/CssLocalIdentifier
|
|
13
16
|
const CssSelfLocalIdentifierDependency = require("../dependencies/CssSelfLocalIdentifierDependency");
|
14
17
|
const CssUrlDependency = require("../dependencies/CssUrlDependency");
|
15
18
|
const StaticExportsDependency = require("../dependencies/StaticExportsDependency");
|
19
|
+
const { parseResource } = require("../util/identifier");
|
16
20
|
const walkCssTokens = require("./walkCssTokens");
|
17
21
|
|
18
22
|
/** @typedef {import("../Parser").ParserState} ParserState */
|
19
23
|
/** @typedef {import("../Parser").PreparsedAst} PreparsedAst */
|
24
|
+
/** @typedef {[number, number]} Range */
|
20
25
|
|
21
26
|
const CC_LEFT_CURLY = "{".charCodeAt(0);
|
22
27
|
const CC_RIGHT_CURLY = "}".charCodeAt(0);
|
@@ -24,17 +29,63 @@ const CC_COLON = ":".charCodeAt(0);
|
|
24
29
|
const CC_SLASH = "/".charCodeAt(0);
|
25
30
|
const CC_SEMICOLON = ";".charCodeAt(0);
|
26
31
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
32
|
+
// https://www.w3.org/TR/css-syntax-3/#newline
|
33
|
+
// We don't have `preprocessing` stage, so we need specify all of them
|
34
|
+
const STRING_MULTILINE = /\\[\n\r\f]/g;
|
35
|
+
// https://www.w3.org/TR/css-syntax-3/#whitespace
|
36
|
+
const TRIM_WHITE_SPACES = /(^[ \t\n\r\f]*|[ \t\n\r\f]*$)/g;
|
37
|
+
const UNESCAPE = /\\([0-9a-fA-F]{1,6}[ \t\n\r\f]?|[\s\S])/g;
|
38
|
+
const IMAGE_SET_FUNCTION = /^(-\w+-)?image-set$/i;
|
39
|
+
const OPTIONALLY_VENDOR_PREFIXED_KEYFRAMES_AT_RULE = /^@(-\w+-)?keyframes$/;
|
40
|
+
const OPTIONALLY_VENDOR_PREFIXED_ANIMATION_PROPERTY =
|
41
|
+
/^(-\w+-)?animation(-name)?$/i;
|
42
|
+
const IS_MODULES = /\.module(s)?\.[^.]+$/i;
|
43
|
+
|
44
|
+
/**
|
45
|
+
* @param {string} str url string
|
46
|
+
* @param {boolean} isString is url wrapped in quotes
|
47
|
+
* @returns {string} normalized url
|
48
|
+
*/
|
49
|
+
const normalizeUrl = (str, isString) => {
|
50
|
+
// Remove extra spaces and newlines:
|
51
|
+
// `url("im\
|
52
|
+
// g.png")`
|
53
|
+
if (isString) {
|
54
|
+
str = str.replace(STRING_MULTILINE, "");
|
55
|
+
}
|
56
|
+
|
57
|
+
str = str
|
58
|
+
// Remove unnecessary spaces from `url(" img.png ")`
|
59
|
+
.replace(TRIM_WHITE_SPACES, "")
|
60
|
+
// Unescape
|
61
|
+
.replace(UNESCAPE, match => {
|
62
|
+
if (match.length > 2) {
|
63
|
+
return String.fromCharCode(parseInt(match.slice(1).trim(), 16));
|
64
|
+
} else {
|
65
|
+
return match[1];
|
66
|
+
}
|
67
|
+
});
|
68
|
+
|
69
|
+
if (/^data:/i.test(str)) {
|
70
|
+
return str;
|
71
|
+
}
|
72
|
+
|
73
|
+
if (str.includes("%")) {
|
74
|
+
// Convert `url('%2E/img.png')` -> `url('./img.png')`
|
75
|
+
try {
|
76
|
+
str = decodeURIComponent(str);
|
77
|
+
} catch (error) {
|
78
|
+
// Ignore
|
33
79
|
}
|
34
|
-
}
|
80
|
+
}
|
81
|
+
|
82
|
+
return str;
|
35
83
|
};
|
36
84
|
|
37
85
|
class LocConverter {
|
86
|
+
/**
|
87
|
+
* @param {string} input input
|
88
|
+
*/
|
38
89
|
constructor(input) {
|
39
90
|
this._input = input;
|
40
91
|
this.line = 1;
|
@@ -42,6 +93,10 @@ class LocConverter {
|
|
42
93
|
this.pos = 0;
|
43
94
|
}
|
44
95
|
|
96
|
+
/**
|
97
|
+
* @param {number} pos position
|
98
|
+
* @returns {LocConverter} location converter
|
99
|
+
*/
|
45
100
|
get(pos) {
|
46
101
|
if (this.pos !== pos) {
|
47
102
|
if (this.pos < pos) {
|
@@ -70,47 +125,37 @@ class LocConverter {
|
|
70
125
|
}
|
71
126
|
|
72
127
|
const CSS_MODE_TOP_LEVEL = 0;
|
73
|
-
const
|
74
|
-
const
|
75
|
-
const
|
76
|
-
|
77
|
-
const CSS_MODE_AT_IMPORT_EXPECT_SUPPORTS = 4;
|
78
|
-
const CSS_MODE_AT_IMPORT_EXPECT_MEDIA = 5;
|
79
|
-
const CSS_MODE_AT_OTHER = 6;
|
80
|
-
|
81
|
-
const explainMode = mode => {
|
82
|
-
switch (mode) {
|
83
|
-
case CSS_MODE_TOP_LEVEL:
|
84
|
-
return "parsing top level css";
|
85
|
-
case CSS_MODE_IN_RULE:
|
86
|
-
return "parsing css rule content (global)";
|
87
|
-
case CSS_MODE_IN_LOCAL_RULE:
|
88
|
-
return "parsing css rule content (local)";
|
89
|
-
case CSS_MODE_AT_IMPORT_EXPECT_URL:
|
90
|
-
return "parsing @import (expecting url)";
|
91
|
-
case CSS_MODE_AT_IMPORT_EXPECT_SUPPORTS:
|
92
|
-
return "parsing @import (expecting optionally supports or media query)";
|
93
|
-
case CSS_MODE_AT_IMPORT_EXPECT_MEDIA:
|
94
|
-
return "parsing @import (expecting optionally media query)";
|
95
|
-
case CSS_MODE_AT_OTHER:
|
96
|
-
return "parsing at-rule";
|
97
|
-
default:
|
98
|
-
return mode;
|
99
|
-
}
|
100
|
-
};
|
128
|
+
const CSS_MODE_IN_BLOCK = 1;
|
129
|
+
const CSS_MODE_IN_AT_IMPORT = 2;
|
130
|
+
const CSS_MODE_AT_IMPORT_INVALID = 3;
|
131
|
+
const CSS_MODE_AT_NAMESPACE_INVALID = 4;
|
101
132
|
|
102
133
|
class CssParser extends Parser {
|
103
|
-
constructor({
|
104
|
-
allowPseudoBlocks = true,
|
105
|
-
allowModeSwitch = true,
|
106
|
-
defaultMode = "global"
|
107
|
-
} = {}) {
|
134
|
+
constructor({ allowModeSwitch = true, defaultMode = "global" } = {}) {
|
108
135
|
super();
|
109
|
-
this.allowPseudoBlocks = allowPseudoBlocks;
|
110
136
|
this.allowModeSwitch = allowModeSwitch;
|
111
137
|
this.defaultMode = defaultMode;
|
112
138
|
}
|
113
139
|
|
140
|
+
/**
|
141
|
+
* @param {ParserState} state parser state
|
142
|
+
* @param {string} message warning message
|
143
|
+
* @param {LocConverter} locConverter location converter
|
144
|
+
* @param {number} start start offset
|
145
|
+
* @param {number} end end offset
|
146
|
+
*/
|
147
|
+
_emitWarning(state, message, locConverter, start, end) {
|
148
|
+
const { line: sl, column: sc } = locConverter.get(start);
|
149
|
+
const { line: el, column: ec } = locConverter.get(end);
|
150
|
+
|
151
|
+
state.current.addWarning(
|
152
|
+
new ModuleDependencyWarning(state.module, new WebpackError(message), {
|
153
|
+
start: { line: sl, column: sc },
|
154
|
+
end: { line: el, column: ec }
|
155
|
+
})
|
156
|
+
);
|
157
|
+
}
|
158
|
+
|
114
159
|
/**
|
115
160
|
* @param {string | Buffer | PreparsedAst} source the source to parse
|
116
161
|
* @param {ParserState} state the parser state
|
@@ -128,31 +173,71 @@ class CssParser extends Parser {
|
|
128
173
|
|
129
174
|
const module = state.module;
|
130
175
|
|
131
|
-
|
176
|
+
/** @type {string | undefined} */
|
177
|
+
let oldDefaultMode;
|
178
|
+
|
179
|
+
if (
|
180
|
+
module.type === CSS_MODULE_TYPE_AUTO &&
|
181
|
+
IS_MODULES.test(
|
182
|
+
parseResource(module.matchResource || module.resource).path
|
183
|
+
)
|
184
|
+
) {
|
185
|
+
oldDefaultMode = this.defaultMode;
|
186
|
+
|
187
|
+
this.defaultMode = "local";
|
188
|
+
}
|
132
189
|
|
133
190
|
const locConverter = new LocConverter(source);
|
134
|
-
|
135
|
-
|
136
|
-
|
191
|
+
/** @type {Set<string>}*/
|
192
|
+
const declaredCssVariables = new Set();
|
193
|
+
/** @type {number} */
|
194
|
+
let scope = CSS_MODE_TOP_LEVEL;
|
195
|
+
/** @type {number} */
|
196
|
+
let blockNestingLevel = 0;
|
197
|
+
/** @type {boolean} */
|
198
|
+
let allowImportAtRule = true;
|
199
|
+
/** @type {"local" | "global" | undefined} */
|
137
200
|
let modeData = undefined;
|
138
|
-
|
201
|
+
/** @type {[number, number] | undefined} */
|
139
202
|
let lastIdentifier = undefined;
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
203
|
+
/** @type [string, number, number][] */
|
204
|
+
let balanced = [];
|
205
|
+
/** @type {undefined | { start: number, url?: string, urlStart?: number, urlEnd?: number, layer?: string, layerStart?: number, layerEnd?: number, supports?: string, supportsStart?: number, supportsEnd?: number, inSupports?:boolean, media?: string }} */
|
206
|
+
let importData = undefined;
|
207
|
+
/** @type {boolean} */
|
208
|
+
let inAnimationProperty = false;
|
209
|
+
/** @type {boolean} */
|
210
|
+
let isNextRulePrelude = true;
|
211
|
+
|
212
|
+
/**
|
213
|
+
* @param {string} input input
|
214
|
+
* @param {number} pos position
|
215
|
+
* @returns {boolean} true, when next is nested syntax
|
216
|
+
*/
|
217
|
+
const isNextNestedSyntax = (input, pos) => {
|
218
|
+
pos = walkCssTokens.eatWhitespaceAndComments(input, pos);
|
219
|
+
|
220
|
+
if (input[pos] === "}") {
|
221
|
+
return false;
|
153
222
|
}
|
154
|
-
|
223
|
+
|
224
|
+
// According spec only identifier can be used as a property name
|
225
|
+
const isIdentifier = walkCssTokens.isIdentStartCodePoint(
|
226
|
+
input.charCodeAt(pos)
|
227
|
+
);
|
228
|
+
|
229
|
+
return !isIdentifier;
|
155
230
|
};
|
231
|
+
/**
|
232
|
+
* @returns {boolean} true, when in local scope
|
233
|
+
*/
|
234
|
+
const isLocalMode = () =>
|
235
|
+
modeData === "local" ||
|
236
|
+
(this.defaultMode === "local" && modeData === undefined);
|
237
|
+
/**
|
238
|
+
* @param {string} chars characters
|
239
|
+
* @returns {(input: string, pos: number) => number} function to eat characters
|
240
|
+
*/
|
156
241
|
const eatUntil = chars => {
|
157
242
|
const charCodes = Array.from({ length: chars.length }, (_, i) =>
|
158
243
|
chars.charCodeAt(i)
|
@@ -173,6 +258,12 @@ class CssParser extends Parser {
|
|
173
258
|
}
|
174
259
|
};
|
175
260
|
};
|
261
|
+
/**
|
262
|
+
* @param {string} input input
|
263
|
+
* @param {number} pos start position
|
264
|
+
* @param {(input: string, pos: number) => number} eater eater
|
265
|
+
* @returns {[number,string]} new position and text
|
266
|
+
*/
|
176
267
|
const eatText = (input, pos, eater) => {
|
177
268
|
let text = "";
|
178
269
|
for (;;) {
|
@@ -200,13 +291,24 @@ class CssParser extends Parser {
|
|
200
291
|
};
|
201
292
|
const eatExportName = eatUntil(":};/");
|
202
293
|
const eatExportValue = eatUntil("};/");
|
294
|
+
/**
|
295
|
+
* @param {string} input input
|
296
|
+
* @param {number} pos start position
|
297
|
+
* @returns {number} position after parse
|
298
|
+
*/
|
203
299
|
const parseExports = (input, pos) => {
|
204
300
|
pos = walkCssTokens.eatWhitespaceAndComments(input, pos);
|
205
301
|
const cc = input.charCodeAt(pos);
|
206
|
-
if (cc !== CC_LEFT_CURLY)
|
207
|
-
|
208
|
-
|
302
|
+
if (cc !== CC_LEFT_CURLY) {
|
303
|
+
this._emitWarning(
|
304
|
+
state,
|
305
|
+
`Unexpected '${input[pos]}' at ${pos} during parsing of ':export' (expected '{')`,
|
306
|
+
locConverter,
|
307
|
+
pos,
|
308
|
+
pos
|
209
309
|
);
|
310
|
+
return pos;
|
311
|
+
}
|
210
312
|
pos++;
|
211
313
|
pos = walkCssTokens.eatWhitespaceAndComments(input, pos);
|
212
314
|
for (;;) {
|
@@ -218,9 +320,14 @@ class CssParser extends Parser {
|
|
218
320
|
[pos, name] = eatText(input, pos, eatExportName);
|
219
321
|
if (pos === input.length) return pos;
|
220
322
|
if (input.charCodeAt(pos) !== CC_COLON) {
|
221
|
-
|
222
|
-
|
323
|
+
this._emitWarning(
|
324
|
+
state,
|
325
|
+
`Unexpected '${input[pos]}' at ${pos} during parsing of export name in ':export' (expected ':')`,
|
326
|
+
locConverter,
|
327
|
+
start,
|
328
|
+
pos
|
223
329
|
);
|
330
|
+
return pos;
|
224
331
|
}
|
225
332
|
pos++;
|
226
333
|
if (pos === input.length) return pos;
|
@@ -236,9 +343,14 @@ class CssParser extends Parser {
|
|
236
343
|
pos = walkCssTokens.eatWhitespaceAndComments(input, pos);
|
237
344
|
if (pos === input.length) return pos;
|
238
345
|
} else if (cc !== CC_RIGHT_CURLY) {
|
239
|
-
|
240
|
-
|
346
|
+
this._emitWarning(
|
347
|
+
state,
|
348
|
+
`Unexpected '${input[pos]}' at ${pos} during parsing of export value in ':export' (expected ';' or '}')`,
|
349
|
+
locConverter,
|
350
|
+
start,
|
351
|
+
pos
|
241
352
|
);
|
353
|
+
return pos;
|
242
354
|
}
|
243
355
|
const dep = new CssExportDependency(name, value);
|
244
356
|
const { line: sl, column: sc } = locConverter.get(start);
|
@@ -248,13 +360,18 @@ class CssParser extends Parser {
|
|
248
360
|
}
|
249
361
|
pos++;
|
250
362
|
if (pos === input.length) return pos;
|
251
|
-
pos = eatWhiteLine(input, pos);
|
363
|
+
pos = walkCssTokens.eatWhiteLine(input, pos);
|
252
364
|
return pos;
|
253
365
|
};
|
254
366
|
const eatPropertyName = eatUntil(":{};");
|
255
|
-
|
367
|
+
/**
|
368
|
+
* @param {string} input input
|
369
|
+
* @param {number} pos name start position
|
370
|
+
* @param {number} end name end position
|
371
|
+
* @returns {number} position after handling
|
372
|
+
*/
|
373
|
+
const processLocalDeclaration = (input, pos, end) => {
|
256
374
|
modeData = undefined;
|
257
|
-
const start = pos;
|
258
375
|
pos = walkCssTokens.eatWhitespaceAndComments(input, pos);
|
259
376
|
const propertyNameStart = pos;
|
260
377
|
const [propertyNameEnd, propertyName] = eatText(
|
@@ -262,7 +379,7 @@ class CssParser extends Parser {
|
|
262
379
|
pos,
|
263
380
|
eatPropertyName
|
264
381
|
);
|
265
|
-
if (input.charCodeAt(propertyNameEnd) !== CC_COLON) return
|
382
|
+
if (input.charCodeAt(propertyNameEnd) !== CC_COLON) return end;
|
266
383
|
pos = propertyNameEnd + 1;
|
267
384
|
if (propertyName.startsWith("--")) {
|
268
385
|
// CSS Variable
|
@@ -278,47 +395,74 @@ class CssParser extends Parser {
|
|
278
395
|
module.addDependency(dep);
|
279
396
|
declaredCssVariables.add(name);
|
280
397
|
} else if (
|
281
|
-
propertyName
|
282
|
-
propertyName
|
398
|
+
!propertyName.startsWith("--") &&
|
399
|
+
OPTIONALLY_VENDOR_PREFIXED_ANIMATION_PROPERTY.test(propertyName)
|
283
400
|
) {
|
284
|
-
|
285
|
-
lastIdentifier = undefined;
|
401
|
+
inAnimationProperty = true;
|
286
402
|
}
|
287
403
|
return pos;
|
288
404
|
};
|
289
|
-
|
290
|
-
|
405
|
+
/**
|
406
|
+
* @param {string} input input
|
407
|
+
*/
|
408
|
+
const processDeclarationValueDone = input => {
|
409
|
+
if (inAnimationProperty && lastIdentifier) {
|
291
410
|
const { line: sl, column: sc } = locConverter.get(lastIdentifier[0]);
|
292
411
|
const { line: el, column: ec } = locConverter.get(lastIdentifier[1]);
|
293
412
|
const name = input.slice(lastIdentifier[0], lastIdentifier[1]);
|
294
413
|
const dep = new CssSelfLocalIdentifierDependency(name, lastIdentifier);
|
295
414
|
dep.setLoc(sl, sc, el, ec);
|
296
415
|
module.addDependency(dep);
|
416
|
+
lastIdentifier = undefined;
|
297
417
|
}
|
298
418
|
};
|
299
419
|
const eatKeyframes = eatUntil("{};/");
|
300
420
|
const eatNameInVar = eatUntil(",)};/");
|
301
421
|
walkCssTokens(source, {
|
302
422
|
isSelector: () => {
|
303
|
-
return
|
423
|
+
return isNextRulePrelude;
|
304
424
|
},
|
305
425
|
url: (input, start, end, contentStart, contentEnd) => {
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
426
|
+
let value = normalizeUrl(input.slice(contentStart, contentEnd), false);
|
427
|
+
|
428
|
+
switch (scope) {
|
429
|
+
case CSS_MODE_IN_AT_IMPORT: {
|
430
|
+
// Do not parse URLs in `supports(...)`
|
431
|
+
if (importData.inSupports) {
|
432
|
+
break;
|
433
|
+
}
|
434
|
+
|
435
|
+
if (importData.url) {
|
436
|
+
this._emitWarning(
|
437
|
+
state,
|
438
|
+
`Duplicate of 'url(...)' in '${input.slice(
|
439
|
+
importData.start,
|
440
|
+
end
|
441
|
+
)}'`,
|
442
|
+
locConverter,
|
317
443
|
start,
|
318
444
|
end
|
319
|
-
)
|
320
|
-
|
321
|
-
|
445
|
+
);
|
446
|
+
|
447
|
+
break;
|
448
|
+
}
|
449
|
+
|
450
|
+
importData.url = value;
|
451
|
+
importData.urlStart = start;
|
452
|
+
importData.urlEnd = end;
|
453
|
+
break;
|
454
|
+
}
|
455
|
+
// Do not parse URLs in import between rules
|
456
|
+
case CSS_MODE_AT_NAMESPACE_INVALID:
|
457
|
+
case CSS_MODE_AT_IMPORT_INVALID: {
|
458
|
+
break;
|
459
|
+
}
|
460
|
+
case CSS_MODE_IN_BLOCK: {
|
461
|
+
// Ignore `url()`, `url('')` and `url("")`, they are valid by spec
|
462
|
+
if (value.length === 0) {
|
463
|
+
break;
|
464
|
+
}
|
465
|
+
|
322
466
|
const dep = new CssUrlDependency(value, [start, end], "url");
|
323
467
|
const { line: sl, column: sc } = locConverter.get(start);
|
324
468
|
const { line: el, column: ec } = locConverter.get(end);
|
@@ -331,283 +475,554 @@ class CssParser extends Parser {
|
|
331
475
|
return end;
|
332
476
|
},
|
333
477
|
string: (input, start, end) => {
|
334
|
-
switch (
|
335
|
-
case
|
336
|
-
|
337
|
-
|
478
|
+
switch (scope) {
|
479
|
+
case CSS_MODE_IN_AT_IMPORT: {
|
480
|
+
const insideURLFunction =
|
481
|
+
balanced[balanced.length - 1] &&
|
482
|
+
balanced[balanced.length - 1][0] === "url";
|
483
|
+
|
484
|
+
// Do not parse URLs in `supports(...)` and other strings if we already have a URL
|
485
|
+
if (
|
486
|
+
importData.inSupports ||
|
487
|
+
(!insideURLFunction && importData.url)
|
488
|
+
) {
|
489
|
+
break;
|
490
|
+
}
|
491
|
+
|
492
|
+
if (insideURLFunction && importData.url) {
|
493
|
+
this._emitWarning(
|
494
|
+
state,
|
495
|
+
`Duplicate of 'url(...)' in '${input.slice(
|
496
|
+
importData.start,
|
497
|
+
end
|
498
|
+
)}'`,
|
499
|
+
locConverter,
|
500
|
+
start,
|
501
|
+
end
|
502
|
+
);
|
503
|
+
|
504
|
+
break;
|
505
|
+
}
|
506
|
+
|
507
|
+
importData.url = normalizeUrl(
|
508
|
+
input.slice(start + 1, end - 1),
|
509
|
+
true
|
510
|
+
);
|
511
|
+
|
512
|
+
if (!insideURLFunction) {
|
513
|
+
importData.urlStart = start;
|
514
|
+
importData.urlEnd = end;
|
515
|
+
}
|
516
|
+
|
338
517
|
break;
|
339
518
|
}
|
519
|
+
case CSS_MODE_IN_BLOCK: {
|
520
|
+
// TODO move escaped parsing to tokenizer
|
521
|
+
const last = balanced[balanced.length - 1];
|
522
|
+
|
523
|
+
if (
|
524
|
+
last &&
|
525
|
+
(last[0].replace(/\\/g, "").toLowerCase() === "url" ||
|
526
|
+
IMAGE_SET_FUNCTION.test(last[0].replace(/\\/g, "")))
|
527
|
+
) {
|
528
|
+
let value = normalizeUrl(input.slice(start + 1, end - 1), true);
|
529
|
+
|
530
|
+
// Ignore `url()`, `url('')` and `url("")`, they are valid by spec
|
531
|
+
if (value.length === 0) {
|
532
|
+
break;
|
533
|
+
}
|
534
|
+
|
535
|
+
const isUrl = last[0].replace(/\\/g, "").toLowerCase() === "url";
|
536
|
+
const dep = new CssUrlDependency(
|
537
|
+
value,
|
538
|
+
[start, end],
|
539
|
+
isUrl ? "string" : "url"
|
540
|
+
);
|
541
|
+
const { line: sl, column: sc } = locConverter.get(start);
|
542
|
+
const { line: el, column: ec } = locConverter.get(end);
|
543
|
+
dep.setLoc(sl, sc, el, ec);
|
544
|
+
module.addDependency(dep);
|
545
|
+
module.addCodeGenerationDependency(dep);
|
546
|
+
}
|
547
|
+
}
|
340
548
|
}
|
341
549
|
return end;
|
342
550
|
},
|
343
551
|
atKeyword: (input, start, end) => {
|
344
|
-
const name = input.slice(start, end);
|
552
|
+
const name = input.slice(start, end).toLowerCase();
|
345
553
|
if (name === "@namespace") {
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
554
|
+
scope = CSS_MODE_AT_NAMESPACE_INVALID;
|
555
|
+
this._emitWarning(
|
556
|
+
state,
|
557
|
+
"'@namespace' is not supported in bundled CSS",
|
558
|
+
locConverter,
|
559
|
+
start,
|
560
|
+
end
|
561
|
+
);
|
562
|
+
return end;
|
563
|
+
} else if (name === "@import") {
|
564
|
+
if (!allowImportAtRule) {
|
565
|
+
scope = CSS_MODE_AT_IMPORT_INVALID;
|
566
|
+
this._emitWarning(
|
567
|
+
state,
|
568
|
+
"Any '@import' rules must precede all other rules",
|
569
|
+
locConverter,
|
570
|
+
start,
|
571
|
+
end
|
352
572
|
);
|
573
|
+
return end;
|
353
574
|
}
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
}
|
362
|
-
if (name === "@keyframes") {
|
575
|
+
|
576
|
+
scope = CSS_MODE_IN_AT_IMPORT;
|
577
|
+
importData = { start };
|
578
|
+
} else if (
|
579
|
+
this.allowModeSwitch &&
|
580
|
+
OPTIONALLY_VENDOR_PREFIXED_KEYFRAMES_AT_RULE.test(name)
|
581
|
+
) {
|
363
582
|
let pos = end;
|
364
583
|
pos = walkCssTokens.eatWhitespaceAndComments(input, pos);
|
365
584
|
if (pos === input.length) return pos;
|
366
585
|
const [newPos, name] = eatText(input, pos, eatKeyframes);
|
586
|
+
if (newPos === input.length) return newPos;
|
587
|
+
if (input.charCodeAt(newPos) !== CC_LEFT_CURLY) {
|
588
|
+
this._emitWarning(
|
589
|
+
state,
|
590
|
+
`Unexpected '${input[newPos]}' at ${newPos} during parsing of @keyframes (expected '{')`,
|
591
|
+
locConverter,
|
592
|
+
start,
|
593
|
+
end
|
594
|
+
);
|
595
|
+
|
596
|
+
return newPos;
|
597
|
+
}
|
367
598
|
const { line: sl, column: sc } = locConverter.get(pos);
|
368
599
|
const { line: el, column: ec } = locConverter.get(newPos);
|
369
600
|
const dep = new CssLocalIdentifierDependency(name, [pos, newPos]);
|
370
601
|
dep.setLoc(sl, sc, el, ec);
|
371
602
|
module.addDependency(dep);
|
372
603
|
pos = newPos;
|
604
|
+
return pos + 1;
|
605
|
+
} else if (this.allowModeSwitch && name === "@property") {
|
606
|
+
let pos = end;
|
607
|
+
pos = walkCssTokens.eatWhitespaceAndComments(input, pos);
|
373
608
|
if (pos === input.length) return pos;
|
374
|
-
|
375
|
-
|
376
|
-
|
609
|
+
const propertyNameStart = pos;
|
610
|
+
const [propertyNameEnd, propertyName] = eatText(
|
611
|
+
input,
|
612
|
+
pos,
|
613
|
+
eatKeyframes
|
614
|
+
);
|
615
|
+
if (propertyNameEnd === input.length) return propertyNameEnd;
|
616
|
+
if (!propertyName.startsWith("--")) return propertyNameEnd;
|
617
|
+
if (input.charCodeAt(propertyNameEnd) !== CC_LEFT_CURLY) {
|
618
|
+
this._emitWarning(
|
619
|
+
state,
|
620
|
+
`Unexpected '${input[propertyNameEnd]}' at ${propertyNameEnd} during parsing of @property (expected '{')`,
|
621
|
+
locConverter,
|
622
|
+
start,
|
623
|
+
end
|
377
624
|
);
|
625
|
+
|
626
|
+
return propertyNameEnd;
|
378
627
|
}
|
379
|
-
|
380
|
-
|
628
|
+
const { line: sl, column: sc } = locConverter.get(pos);
|
629
|
+
const { line: el, column: ec } = locConverter.get(propertyNameEnd);
|
630
|
+
const name = propertyName.slice(2);
|
631
|
+
const dep = new CssLocalIdentifierDependency(
|
632
|
+
name,
|
633
|
+
[propertyNameStart, propertyNameEnd],
|
634
|
+
"--"
|
635
|
+
);
|
636
|
+
dep.setLoc(sl, sc, el, ec);
|
637
|
+
module.addDependency(dep);
|
638
|
+
declaredCssVariables.add(name);
|
639
|
+
pos = propertyNameEnd;
|
381
640
|
return pos + 1;
|
641
|
+
} else if (
|
642
|
+
name === "@media" ||
|
643
|
+
name === "@supports" ||
|
644
|
+
name === "@layer" ||
|
645
|
+
name === "@container"
|
646
|
+
) {
|
647
|
+
modeData = isLocalMode() ? "local" : "global";
|
648
|
+
isNextRulePrelude = true;
|
649
|
+
return end;
|
650
|
+
} else if (this.allowModeSwitch) {
|
651
|
+
modeData = "global";
|
652
|
+
isNextRulePrelude = false;
|
382
653
|
}
|
383
654
|
return end;
|
384
655
|
},
|
385
656
|
semicolon: (input, start, end) => {
|
386
|
-
switch (
|
387
|
-
case
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
657
|
+
switch (scope) {
|
658
|
+
case CSS_MODE_IN_AT_IMPORT: {
|
659
|
+
const { start } = importData;
|
660
|
+
|
661
|
+
if (importData.url === undefined) {
|
662
|
+
this._emitWarning(
|
663
|
+
state,
|
664
|
+
`Expected URL in '${input.slice(start, end)}'`,
|
665
|
+
locConverter,
|
666
|
+
start,
|
667
|
+
end
|
668
|
+
);
|
669
|
+
importData = undefined;
|
670
|
+
scope = CSS_MODE_TOP_LEVEL;
|
671
|
+
return end;
|
672
|
+
}
|
673
|
+
if (
|
674
|
+
importData.urlStart > importData.layerStart ||
|
675
|
+
importData.urlStart > importData.supportsStart
|
676
|
+
) {
|
677
|
+
this._emitWarning(
|
678
|
+
state,
|
679
|
+
`An URL in '${input.slice(
|
680
|
+
start,
|
681
|
+
end
|
682
|
+
)}' should be before 'layer(...)' or 'supports(...)'`,
|
683
|
+
locConverter,
|
684
|
+
start,
|
685
|
+
end
|
686
|
+
);
|
687
|
+
importData = undefined;
|
688
|
+
scope = CSS_MODE_TOP_LEVEL;
|
689
|
+
return end;
|
690
|
+
}
|
691
|
+
if (importData.layerStart > importData.supportsStart) {
|
692
|
+
this._emitWarning(
|
693
|
+
state,
|
694
|
+
`The 'layer(...)' in '${input.slice(
|
695
|
+
start,
|
696
|
+
end
|
697
|
+
)}' should be before 'supports(...)'`,
|
698
|
+
locConverter,
|
699
|
+
start,
|
700
|
+
end
|
701
|
+
);
|
702
|
+
importData = undefined;
|
703
|
+
scope = CSS_MODE_TOP_LEVEL;
|
704
|
+
return end;
|
705
|
+
}
|
706
|
+
|
707
|
+
const semicolonPos = end;
|
708
|
+
end = walkCssTokens.eatWhiteLine(input, end + 1);
|
709
|
+
const { line: sl, column: sc } = locConverter.get(start);
|
392
710
|
const { line: el, column: ec } = locConverter.get(end);
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
)
|
401
|
-
|
402
|
-
|
711
|
+
const lastEnd =
|
712
|
+
importData.supportsEnd ||
|
713
|
+
importData.layerEnd ||
|
714
|
+
importData.urlEnd ||
|
715
|
+
start;
|
716
|
+
const pos = walkCssTokens.eatWhitespaceAndComments(input, lastEnd);
|
717
|
+
// Prevent to consider comments as a part of media query
|
718
|
+
if (pos !== semicolonPos - 1) {
|
719
|
+
importData.media = input.slice(lastEnd, semicolonPos - 1).trim();
|
720
|
+
}
|
721
|
+
|
722
|
+
const url = importData.url.trim();
|
723
|
+
|
724
|
+
if (url.length === 0) {
|
725
|
+
const dep = new ConstDependency("", [start, end]);
|
726
|
+
module.addPresentationalDependency(dep);
|
727
|
+
dep.setLoc(sl, sc, el, ec);
|
728
|
+
} else {
|
729
|
+
const dep = new CssImportDependency(
|
730
|
+
url,
|
731
|
+
[start, end],
|
732
|
+
importData.layer,
|
733
|
+
importData.supports,
|
734
|
+
importData.media && importData.media.length > 0
|
735
|
+
? importData.media
|
736
|
+
: undefined
|
737
|
+
);
|
738
|
+
dep.setLoc(sl, sc, el, ec);
|
739
|
+
module.addDependency(dep);
|
740
|
+
}
|
741
|
+
|
742
|
+
importData = undefined;
|
743
|
+
scope = CSS_MODE_TOP_LEVEL;
|
744
|
+
|
403
745
|
break;
|
404
746
|
}
|
405
|
-
case
|
406
|
-
|
407
|
-
|
747
|
+
case CSS_MODE_AT_IMPORT_INVALID:
|
748
|
+
case CSS_MODE_AT_NAMESPACE_INVALID: {
|
749
|
+
scope = CSS_MODE_TOP_LEVEL;
|
750
|
+
|
751
|
+
break;
|
408
752
|
}
|
409
|
-
case
|
410
|
-
|
753
|
+
case CSS_MODE_IN_BLOCK: {
|
754
|
+
if (this.allowModeSwitch) {
|
755
|
+
processDeclarationValueDone(input);
|
756
|
+
inAnimationProperty = false;
|
757
|
+
isNextRulePrelude = isNextNestedSyntax(input, end);
|
758
|
+
}
|
759
|
+
break;
|
411
760
|
}
|
412
761
|
}
|
413
|
-
mode = CSS_MODE_TOP_LEVEL;
|
414
|
-
modeData = undefined;
|
415
|
-
singleClassSelector = undefined;
|
416
762
|
return end;
|
417
763
|
},
|
418
764
|
leftCurlyBracket: (input, start, end) => {
|
419
|
-
switch (
|
420
|
-
case CSS_MODE_TOP_LEVEL:
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
if (
|
426
|
-
|
765
|
+
switch (scope) {
|
766
|
+
case CSS_MODE_TOP_LEVEL: {
|
767
|
+
allowImportAtRule = false;
|
768
|
+
scope = CSS_MODE_IN_BLOCK;
|
769
|
+
blockNestingLevel = 1;
|
770
|
+
|
771
|
+
if (this.allowModeSwitch) {
|
772
|
+
isNextRulePrelude = isNextNestedSyntax(input, end);
|
773
|
+
}
|
774
|
+
|
427
775
|
break;
|
428
|
-
|
429
|
-
case
|
430
|
-
|
776
|
+
}
|
777
|
+
case CSS_MODE_IN_BLOCK: {
|
778
|
+
blockNestingLevel++;
|
779
|
+
|
780
|
+
if (this.allowModeSwitch) {
|
781
|
+
isNextRulePrelude = isNextNestedSyntax(input, end);
|
782
|
+
}
|
431
783
|
break;
|
784
|
+
}
|
432
785
|
}
|
433
786
|
return end;
|
434
787
|
},
|
435
788
|
rightCurlyBracket: (input, start, end) => {
|
436
|
-
switch (
|
437
|
-
case
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
if (--modeNestingLevel === 0) {
|
442
|
-
mode = CSS_MODE_TOP_LEVEL;
|
443
|
-
modeData = undefined;
|
444
|
-
singleClassSelector = undefined;
|
789
|
+
switch (scope) {
|
790
|
+
case CSS_MODE_IN_BLOCK: {
|
791
|
+
if (isLocalMode()) {
|
792
|
+
processDeclarationValueDone(input);
|
793
|
+
inAnimationProperty = false;
|
445
794
|
}
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
const name = input.slice(start + 1, end);
|
456
|
-
const dep = new CssLocalIdentifierDependency(name, [
|
457
|
-
start + 1,
|
458
|
-
end
|
459
|
-
]);
|
460
|
-
const { line: sl, column: sc } = locConverter.get(start);
|
461
|
-
const { line: el, column: ec } = locConverter.get(end);
|
462
|
-
dep.setLoc(sl, sc, el, ec);
|
463
|
-
module.addDependency(dep);
|
795
|
+
if (--blockNestingLevel === 0) {
|
796
|
+
scope = CSS_MODE_TOP_LEVEL;
|
797
|
+
|
798
|
+
if (this.allowModeSwitch) {
|
799
|
+
isNextRulePrelude = true;
|
800
|
+
modeData = undefined;
|
801
|
+
}
|
802
|
+
} else if (this.allowModeSwitch) {
|
803
|
+
isNextRulePrelude = isNextNestedSyntax(input, end);
|
464
804
|
}
|
465
805
|
break;
|
806
|
+
}
|
466
807
|
}
|
467
808
|
return end;
|
468
809
|
},
|
469
810
|
identifier: (input, start, end) => {
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
811
|
+
switch (scope) {
|
812
|
+
case CSS_MODE_IN_BLOCK: {
|
813
|
+
if (isLocalMode()) {
|
814
|
+
// Handle only top level values and not inside functions
|
815
|
+
if (inAnimationProperty && balanced.length === 0) {
|
816
|
+
lastIdentifier = [start, end];
|
817
|
+
} else {
|
818
|
+
return processLocalDeclaration(input, start, end);
|
819
|
+
}
|
820
|
+
}
|
821
|
+
break;
|
822
|
+
}
|
823
|
+
case CSS_MODE_IN_AT_IMPORT: {
|
824
|
+
if (input.slice(start, end).toLowerCase() === "layer") {
|
825
|
+
importData.layer = "";
|
826
|
+
importData.layerStart = start;
|
827
|
+
importData.layerEnd = end;
|
475
828
|
}
|
476
829
|
break;
|
830
|
+
}
|
477
831
|
}
|
478
832
|
return end;
|
479
833
|
},
|
480
834
|
class: (input, start, end) => {
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
]);
|
489
|
-
const { line: sl, column: sc } = locConverter.get(start);
|
490
|
-
const { line: el, column: ec } = locConverter.get(end);
|
491
|
-
dep.setLoc(sl, sc, el, ec);
|
492
|
-
module.addDependency(dep);
|
493
|
-
if (singleClassSelector === undefined) singleClassSelector = name;
|
494
|
-
} else {
|
495
|
-
singleClassSelector = false;
|
496
|
-
}
|
497
|
-
break;
|
498
|
-
}
|
835
|
+
if (isLocalMode()) {
|
836
|
+
const name = input.slice(start + 1, end);
|
837
|
+
const dep = new CssLocalIdentifierDependency(name, [start + 1, end]);
|
838
|
+
const { line: sl, column: sc } = locConverter.get(start);
|
839
|
+
const { line: el, column: ec } = locConverter.get(end);
|
840
|
+
dep.setLoc(sl, sc, el, ec);
|
841
|
+
module.addDependency(dep);
|
499
842
|
}
|
843
|
+
|
500
844
|
return end;
|
501
845
|
},
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
846
|
+
id: (input, start, end) => {
|
847
|
+
if (isLocalMode()) {
|
848
|
+
const name = input.slice(start + 1, end);
|
849
|
+
const dep = new CssLocalIdentifierDependency(name, [start + 1, end]);
|
850
|
+
const { line: sl, column: sc } = locConverter.get(start);
|
851
|
+
const { line: el, column: ec } = locConverter.get(end);
|
852
|
+
dep.setLoc(sl, sc, el, ec);
|
853
|
+
module.addDependency(dep);
|
854
|
+
}
|
855
|
+
return end;
|
856
|
+
},
|
857
|
+
function: (input, start, end) => {
|
858
|
+
let name = input.slice(start, end - 1);
|
859
|
+
|
860
|
+
balanced.push([name, start, end]);
|
861
|
+
|
862
|
+
if (
|
863
|
+
scope === CSS_MODE_IN_AT_IMPORT &&
|
864
|
+
name.toLowerCase() === "supports"
|
865
|
+
) {
|
866
|
+
importData.inSupports = true;
|
867
|
+
}
|
868
|
+
|
869
|
+
if (isLocalMode()) {
|
870
|
+
name = name.toLowerCase();
|
871
|
+
|
872
|
+
// Don't rename animation name when we have `var()` function
|
873
|
+
if (inAnimationProperty && balanced.length === 1) {
|
874
|
+
lastIdentifier = undefined;
|
875
|
+
}
|
876
|
+
|
877
|
+
if (name === "var") {
|
878
|
+
let pos = walkCssTokens.eatWhitespaceAndComments(input, end);
|
879
|
+
if (pos === input.length) return pos;
|
880
|
+
const [newPos, name] = eatText(input, pos, eatNameInVar);
|
881
|
+
if (!name.startsWith("--")) return end;
|
882
|
+
const { line: sl, column: sc } = locConverter.get(pos);
|
883
|
+
const { line: el, column: ec } = locConverter.get(newPos);
|
884
|
+
const dep = new CssSelfLocalIdentifierDependency(
|
885
|
+
name.slice(2),
|
886
|
+
[pos, newPos],
|
887
|
+
"--",
|
888
|
+
declaredCssVariables
|
889
|
+
);
|
890
|
+
dep.setLoc(sl, sc, el, ec);
|
891
|
+
module.addDependency(dep);
|
892
|
+
return newPos;
|
507
893
|
}
|
508
894
|
}
|
895
|
+
|
896
|
+
return end;
|
897
|
+
},
|
898
|
+
leftParenthesis: (input, start, end) => {
|
899
|
+
balanced.push(["(", start, end]);
|
900
|
+
|
509
901
|
return end;
|
510
902
|
},
|
511
903
|
rightParenthesis: (input, start, end) => {
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
904
|
+
const last = balanced[balanced.length - 1];
|
905
|
+
const popped = balanced.pop();
|
906
|
+
|
907
|
+
if (
|
908
|
+
this.allowModeSwitch &&
|
909
|
+
popped &&
|
910
|
+
(popped[0] === ":local" || popped[0] === ":global")
|
911
|
+
) {
|
912
|
+
modeData = balanced[balanced.length - 1]
|
913
|
+
? /** @type {"local" | "global"} */
|
914
|
+
(balanced[balanced.length - 1][0])
|
915
|
+
: undefined;
|
916
|
+
const dep = new ConstDependency("", [start, end]);
|
917
|
+
module.addPresentationalDependency(dep);
|
918
|
+
|
919
|
+
return end;
|
920
|
+
}
|
921
|
+
|
922
|
+
switch (scope) {
|
923
|
+
case CSS_MODE_IN_AT_IMPORT: {
|
924
|
+
if (last && last[0] === "url" && !importData.inSupports) {
|
925
|
+
importData.urlStart = last[1];
|
926
|
+
importData.urlEnd = end;
|
927
|
+
} else if (
|
928
|
+
last &&
|
929
|
+
last[0].toLowerCase() === "layer" &&
|
930
|
+
!importData.inSupports
|
931
|
+
) {
|
932
|
+
importData.layer = input.slice(last[2], end - 1).trim();
|
933
|
+
importData.layerStart = last[1];
|
934
|
+
importData.layerEnd = end;
|
935
|
+
} else if (last && last[0].toLowerCase() === "supports") {
|
936
|
+
importData.supports = input.slice(last[2], end - 1).trim();
|
937
|
+
importData.supportsStart = last[1];
|
938
|
+
importData.supportsEnd = end;
|
939
|
+
importData.inSupports = false;
|
519
940
|
}
|
520
941
|
break;
|
521
942
|
}
|
522
943
|
}
|
944
|
+
|
523
945
|
return end;
|
524
946
|
},
|
525
947
|
pseudoClass: (input, start, end) => {
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
948
|
+
if (this.allowModeSwitch) {
|
949
|
+
const name = input.slice(start, end).toLowerCase();
|
950
|
+
|
951
|
+
if (name === ":global") {
|
952
|
+
modeData = "global";
|
953
|
+
// Eat extra whitespace and comments
|
954
|
+
end = walkCssTokens.eatWhitespace(input, end);
|
955
|
+
const dep = new ConstDependency("", [start, end]);
|
956
|
+
module.addPresentationalDependency(dep);
|
957
|
+
return end;
|
958
|
+
} else if (name === ":local") {
|
959
|
+
modeData = "local";
|
960
|
+
// Eat extra whitespace and comments
|
961
|
+
end = walkCssTokens.eatWhitespace(input, end);
|
962
|
+
const dep = new ConstDependency("", [start, end]);
|
963
|
+
module.addPresentationalDependency(dep);
|
964
|
+
return end;
|
965
|
+
}
|
966
|
+
|
967
|
+
switch (scope) {
|
968
|
+
case CSS_MODE_TOP_LEVEL: {
|
969
|
+
if (name === ":export") {
|
970
|
+
const pos = parseExports(input, end);
|
971
|
+
const dep = new ConstDependency("", [start, pos]);
|
972
|
+
module.addPresentationalDependency(dep);
|
973
|
+
return pos;
|
974
|
+
}
|
975
|
+
break;
|
543
976
|
}
|
544
|
-
break;
|
545
977
|
}
|
546
978
|
}
|
979
|
+
|
547
980
|
return end;
|
548
981
|
},
|
549
982
|
pseudoFunction: (input, start, end) => {
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
}
|
566
|
-
break;
|
983
|
+
let name = input.slice(start, end - 1);
|
984
|
+
|
985
|
+
balanced.push([name, start, end]);
|
986
|
+
|
987
|
+
if (this.allowModeSwitch) {
|
988
|
+
name = name.toLowerCase();
|
989
|
+
|
990
|
+
if (name === ":global") {
|
991
|
+
modeData = "global";
|
992
|
+
const dep = new ConstDependency("", [start, end]);
|
993
|
+
module.addPresentationalDependency(dep);
|
994
|
+
} else if (name === ":local") {
|
995
|
+
modeData = "local";
|
996
|
+
const dep = new ConstDependency("", [start, end]);
|
997
|
+
module.addPresentationalDependency(dep);
|
567
998
|
}
|
568
999
|
}
|
1000
|
+
|
569
1001
|
return end;
|
570
1002
|
},
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
name.slice(2),
|
584
|
-
[pos, newPos],
|
585
|
-
"--",
|
586
|
-
declaredCssVariables
|
587
|
-
);
|
588
|
-
dep.setLoc(sl, sc, el, ec);
|
589
|
-
module.addDependency(dep);
|
590
|
-
return newPos;
|
1003
|
+
comma: (input, start, end) => {
|
1004
|
+
if (this.allowModeSwitch) {
|
1005
|
+
// Reset stack for `:global .class :local .class-other` selector after
|
1006
|
+
modeData = undefined;
|
1007
|
+
|
1008
|
+
switch (scope) {
|
1009
|
+
case CSS_MODE_IN_BLOCK: {
|
1010
|
+
if (isLocalMode()) {
|
1011
|
+
processDeclarationValueDone(input);
|
1012
|
+
}
|
1013
|
+
|
1014
|
+
break;
|
591
1015
|
}
|
592
|
-
break;
|
593
1016
|
}
|
594
1017
|
}
|
595
1018
|
return end;
|
596
|
-
},
|
597
|
-
comma: (input, start, end) => {
|
598
|
-
switch (mode) {
|
599
|
-
case CSS_MODE_TOP_LEVEL:
|
600
|
-
modeData = undefined;
|
601
|
-
modeStack.length = 0;
|
602
|
-
break;
|
603
|
-
case CSS_MODE_IN_LOCAL_RULE:
|
604
|
-
processDeclarationValueDone(input, start);
|
605
|
-
break;
|
606
|
-
}
|
607
|
-
return end;
|
608
1019
|
}
|
609
1020
|
});
|
610
1021
|
|
1022
|
+
if (oldDefaultMode) {
|
1023
|
+
this.defaultMode = oldDefaultMode;
|
1024
|
+
}
|
1025
|
+
|
611
1026
|
module.buildInfo.strict = true;
|
612
1027
|
module.buildMeta.exportsType = "namespace";
|
613
1028
|
module.addDependency(new StaticExportsDependency([], true));
|