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
@@ -24,16 +24,34 @@ const RuntimeRequirementsDependency = require("./RuntimeRequirementsDependency")
|
|
24
24
|
const CommonJsExportsParserPlugin = require("./CommonJsExportsParserPlugin");
|
25
25
|
const CommonJsImportsParserPlugin = require("./CommonJsImportsParserPlugin");
|
26
26
|
|
27
|
+
const {
|
28
|
+
JAVASCRIPT_MODULE_TYPE_AUTO,
|
29
|
+
JAVASCRIPT_MODULE_TYPE_DYNAMIC
|
30
|
+
} = require("../ModuleTypeConstants");
|
27
31
|
const {
|
28
32
|
evaluateToIdentifier,
|
29
33
|
toConstantDependency
|
30
34
|
} = require("../javascript/JavascriptParserHelpers");
|
31
35
|
const CommonJsExportRequireDependency = require("./CommonJsExportRequireDependency");
|
32
36
|
|
37
|
+
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
38
|
+
/** @typedef {import("../Compilation")} Compilation */
|
39
|
+
/** @typedef {import("../Compiler")} Compiler */
|
40
|
+
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
41
|
+
/** @typedef {import("../Module").BuildInfo} BuildInfo */
|
42
|
+
/** @typedef {import("../javascript/JavascriptParser")} Parser */
|
43
|
+
|
44
|
+
const PLUGIN_NAME = "CommonJsPlugin";
|
45
|
+
|
33
46
|
class CommonJsPlugin {
|
47
|
+
/**
|
48
|
+
* Apply the plugin
|
49
|
+
* @param {Compiler} compiler the compiler instance
|
50
|
+
* @returns {void}
|
51
|
+
*/
|
34
52
|
apply(compiler) {
|
35
53
|
compiler.hooks.compilation.tap(
|
36
|
-
|
54
|
+
PLUGIN_NAME,
|
37
55
|
(compilation, { contextModuleFactory, normalModuleFactory }) => {
|
38
56
|
compilation.dependencyFactories.set(
|
39
57
|
CommonJsRequireDependency,
|
@@ -126,21 +144,21 @@ class CommonJsPlugin {
|
|
126
144
|
|
127
145
|
compilation.hooks.runtimeRequirementInModule
|
128
146
|
.for(RuntimeGlobals.harmonyModuleDecorator)
|
129
|
-
.tap(
|
147
|
+
.tap(PLUGIN_NAME, (module, set) => {
|
130
148
|
set.add(RuntimeGlobals.module);
|
131
149
|
set.add(RuntimeGlobals.requireScope);
|
132
150
|
});
|
133
151
|
|
134
152
|
compilation.hooks.runtimeRequirementInModule
|
135
153
|
.for(RuntimeGlobals.nodeModuleDecorator)
|
136
|
-
.tap(
|
154
|
+
.tap(PLUGIN_NAME, (module, set) => {
|
137
155
|
set.add(RuntimeGlobals.module);
|
138
156
|
set.add(RuntimeGlobals.requireScope);
|
139
157
|
});
|
140
158
|
|
141
159
|
compilation.hooks.runtimeRequirementInTree
|
142
160
|
.for(RuntimeGlobals.harmonyModuleDecorator)
|
143
|
-
.tap(
|
161
|
+
.tap(PLUGIN_NAME, (chunk, set) => {
|
144
162
|
compilation.addRuntimeModule(
|
145
163
|
chunk,
|
146
164
|
new HarmonyModuleDecoratorRuntimeModule()
|
@@ -149,27 +167,32 @@ class CommonJsPlugin {
|
|
149
167
|
|
150
168
|
compilation.hooks.runtimeRequirementInTree
|
151
169
|
.for(RuntimeGlobals.nodeModuleDecorator)
|
152
|
-
.tap(
|
170
|
+
.tap(PLUGIN_NAME, (chunk, set) => {
|
153
171
|
compilation.addRuntimeModule(
|
154
172
|
chunk,
|
155
173
|
new NodeModuleDecoratorRuntimeModule()
|
156
174
|
);
|
157
175
|
});
|
158
176
|
|
177
|
+
/**
|
178
|
+
* @param {Parser} parser parser parser
|
179
|
+
* @param {JavascriptParserOptions} parserOptions parserOptions
|
180
|
+
* @returns {void}
|
181
|
+
*/
|
159
182
|
const handler = (parser, parserOptions) => {
|
160
183
|
if (parserOptions.commonjs !== undefined && !parserOptions.commonjs)
|
161
184
|
return;
|
162
185
|
parser.hooks.typeof
|
163
186
|
.for("module")
|
164
187
|
.tap(
|
165
|
-
|
188
|
+
PLUGIN_NAME,
|
166
189
|
toConstantDependency(parser, JSON.stringify("object"))
|
167
190
|
);
|
168
191
|
|
169
192
|
parser.hooks.expression
|
170
193
|
.for("require.main")
|
171
194
|
.tap(
|
172
|
-
|
195
|
+
PLUGIN_NAME,
|
173
196
|
toConstantDependency(
|
174
197
|
parser,
|
175
198
|
`${RuntimeGlobals.moduleCache}[${RuntimeGlobals.entryModuleId}]`,
|
@@ -177,33 +200,35 @@ class CommonJsPlugin {
|
|
177
200
|
)
|
178
201
|
);
|
179
202
|
parser.hooks.expression
|
180
|
-
.for(
|
181
|
-
.tap(
|
182
|
-
|
183
|
-
|
203
|
+
.for(RuntimeGlobals.moduleLoaded)
|
204
|
+
.tap(PLUGIN_NAME, expr => {
|
205
|
+
/** @type {BuildInfo} */
|
206
|
+
(parser.state.module.buildInfo).moduleConcatenationBailout =
|
207
|
+
RuntimeGlobals.moduleLoaded;
|
184
208
|
const dep = new RuntimeRequirementsDependency([
|
185
209
|
RuntimeGlobals.moduleLoaded
|
186
210
|
]);
|
187
|
-
dep.loc = expr.loc;
|
211
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
188
212
|
parser.state.module.addPresentationalDependency(dep);
|
189
213
|
return true;
|
190
214
|
});
|
191
215
|
|
192
216
|
parser.hooks.expression
|
193
|
-
.for(
|
194
|
-
.tap(
|
195
|
-
|
196
|
-
|
217
|
+
.for(RuntimeGlobals.moduleId)
|
218
|
+
.tap(PLUGIN_NAME, expr => {
|
219
|
+
/** @type {BuildInfo} */
|
220
|
+
(parser.state.module.buildInfo).moduleConcatenationBailout =
|
221
|
+
RuntimeGlobals.moduleId;
|
197
222
|
const dep = new RuntimeRequirementsDependency([
|
198
223
|
RuntimeGlobals.moduleId
|
199
224
|
]);
|
200
|
-
dep.loc = expr.loc;
|
225
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
201
226
|
parser.state.module.addPresentationalDependency(dep);
|
202
227
|
return true;
|
203
228
|
});
|
204
229
|
|
205
230
|
parser.hooks.evaluateIdentifier.for("module.hot").tap(
|
206
|
-
|
231
|
+
PLUGIN_NAME,
|
207
232
|
evaluateToIdentifier("module.hot", "module", () => ["hot"], null)
|
208
233
|
);
|
209
234
|
|
@@ -214,11 +239,11 @@ class CommonJsPlugin {
|
|
214
239
|
};
|
215
240
|
|
216
241
|
normalModuleFactory.hooks.parser
|
217
|
-
.for(
|
218
|
-
.tap(
|
242
|
+
.for(JAVASCRIPT_MODULE_TYPE_AUTO)
|
243
|
+
.tap(PLUGIN_NAME, handler);
|
219
244
|
normalModuleFactory.hooks.parser
|
220
|
-
.for(
|
221
|
-
.tap(
|
245
|
+
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC)
|
246
|
+
.tap(PLUGIN_NAME, handler);
|
222
247
|
}
|
223
248
|
);
|
224
249
|
}
|
@@ -230,10 +255,10 @@ class HarmonyModuleDecoratorRuntimeModule extends RuntimeModule {
|
|
230
255
|
}
|
231
256
|
|
232
257
|
/**
|
233
|
-
* @returns {string} runtime code
|
258
|
+
* @returns {string | null} runtime code
|
234
259
|
*/
|
235
260
|
generate() {
|
236
|
-
const { runtimeTemplate } = this.compilation;
|
261
|
+
const { runtimeTemplate } = /** @type {Compilation} */ (this.compilation);
|
237
262
|
return Template.asString([
|
238
263
|
`${
|
239
264
|
RuntimeGlobals.harmonyModuleDecorator
|
@@ -260,10 +285,10 @@ class NodeModuleDecoratorRuntimeModule extends RuntimeModule {
|
|
260
285
|
}
|
261
286
|
|
262
287
|
/**
|
263
|
-
* @returns {string} runtime code
|
288
|
+
* @returns {string | null} runtime code
|
264
289
|
*/
|
265
290
|
generate() {
|
266
|
-
const { runtimeTemplate } = this.compilation;
|
291
|
+
const { runtimeTemplate } = /** @type {Compilation} */ (this.compilation);
|
267
292
|
return Template.asString([
|
268
293
|
`${RuntimeGlobals.nodeModuleDecorator} = ${runtimeTemplate.basicFunction(
|
269
294
|
"module",
|
@@ -9,7 +9,18 @@ const makeSerializable = require("../util/makeSerializable");
|
|
9
9
|
const ContextDependency = require("./ContextDependency");
|
10
10
|
const ContextDependencyTemplateAsRequireCall = require("./ContextDependencyTemplateAsRequireCall");
|
11
11
|
|
12
|
+
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
13
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
14
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
15
|
+
|
12
16
|
class CommonJsRequireContextDependency extends ContextDependency {
|
17
|
+
/**
|
18
|
+
* @param {TODO} options options for the context module
|
19
|
+
* @param {Range} range location in source code
|
20
|
+
* @param {Range | undefined} valueRange location of the require call
|
21
|
+
* @param {boolean | string } inShorthand true or name
|
22
|
+
* @param {string} context context
|
23
|
+
*/
|
13
24
|
constructor(options, range, valueRange, inShorthand, context) {
|
14
25
|
super(options, context);
|
15
26
|
|
@@ -23,6 +34,9 @@ class CommonJsRequireContextDependency extends ContextDependency {
|
|
23
34
|
return "cjs require context";
|
24
35
|
}
|
25
36
|
|
37
|
+
/**
|
38
|
+
* @param {ObjectSerializerContext} context context
|
39
|
+
*/
|
26
40
|
serialize(context) {
|
27
41
|
const { write } = context;
|
28
42
|
|
@@ -33,6 +47,9 @@ class CommonJsRequireContextDependency extends ContextDependency {
|
|
33
47
|
super.serialize(context);
|
34
48
|
}
|
35
49
|
|
50
|
+
/**
|
51
|
+
* @param {ObjectDeserializerContext} context context
|
52
|
+
*/
|
36
53
|
deserialize(context) {
|
37
54
|
const { read } = context;
|
38
55
|
|
@@ -9,7 +9,14 @@ const makeSerializable = require("../util/makeSerializable");
|
|
9
9
|
const ModuleDependency = require("./ModuleDependency");
|
10
10
|
const ModuleDependencyTemplateAsId = require("./ModuleDependencyTemplateAsId");
|
11
11
|
|
12
|
+
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
13
|
+
|
12
14
|
class CommonJsRequireDependency extends ModuleDependency {
|
15
|
+
/**
|
16
|
+
* @param {string} request request
|
17
|
+
* @param {Range=} range location in source code
|
18
|
+
* @param {string=} context request context
|
19
|
+
*/
|
13
20
|
constructor(request, range, context) {
|
14
21
|
super(request);
|
15
22
|
this.range = range;
|
@@ -17,9 +17,19 @@ const NullDependency = require("./NullDependency");
|
|
17
17
|
/** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */
|
18
18
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
19
19
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
20
|
+
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
21
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
22
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
20
23
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
24
|
+
/** @typedef {import("./CommonJsDependencyHelpers").CommonJSDependencyBaseKeywords} CommonJSDependencyBaseKeywords */
|
21
25
|
|
22
26
|
class CommonJsSelfReferenceDependency extends NullDependency {
|
27
|
+
/**
|
28
|
+
* @param {Range} range range
|
29
|
+
* @param {CommonJSDependencyBaseKeywords} base base
|
30
|
+
* @param {string[]} names names
|
31
|
+
* @param {boolean} call is a call
|
32
|
+
*/
|
23
33
|
constructor(range, base, names, call) {
|
24
34
|
super();
|
25
35
|
this.range = range;
|
@@ -53,6 +63,9 @@ class CommonJsSelfReferenceDependency extends NullDependency {
|
|
53
63
|
return [this.call ? this.names.slice(0, -1) : this.names];
|
54
64
|
}
|
55
65
|
|
66
|
+
/**
|
67
|
+
* @param {ObjectSerializerContext} context context
|
68
|
+
*/
|
56
69
|
serialize(context) {
|
57
70
|
const { write } = context;
|
58
71
|
write(this.range);
|
@@ -62,6 +75,9 @@ class CommonJsSelfReferenceDependency extends NullDependency {
|
|
62
75
|
super.serialize(context);
|
63
76
|
}
|
64
77
|
|
78
|
+
/**
|
79
|
+
* @param {ObjectDeserializerContext} context context
|
80
|
+
*/
|
65
81
|
deserialize(context) {
|
66
82
|
const { read } = context;
|
67
83
|
this.range = read();
|
@@ -15,13 +15,16 @@ const NullDependency = require("./NullDependency");
|
|
15
15
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
16
16
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
17
17
|
/** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */
|
18
|
+
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
19
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
20
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
18
21
|
/** @typedef {import("../util/Hash")} Hash */
|
19
22
|
|
20
23
|
class ConstDependency extends NullDependency {
|
21
24
|
/**
|
22
25
|
* @param {string} expression the expression
|
23
|
-
* @param {number|
|
24
|
-
* @param {string[]=} runtimeRequirements runtime requirements
|
26
|
+
* @param {number | Range} range the source range
|
27
|
+
* @param {(string[] | null)=} runtimeRequirements runtime requirements
|
25
28
|
*/
|
26
29
|
constructor(expression, range, runtimeRequirements) {
|
27
30
|
super();
|
@@ -61,6 +64,9 @@ class ConstDependency extends NullDependency {
|
|
61
64
|
return false;
|
62
65
|
}
|
63
66
|
|
67
|
+
/**
|
68
|
+
* @param {ObjectSerializerContext} context context
|
69
|
+
*/
|
64
70
|
serialize(context) {
|
65
71
|
const { write } = context;
|
66
72
|
write(this.expression);
|
@@ -69,6 +75,9 @@ class ConstDependency extends NullDependency {
|
|
69
75
|
super.serialize(context);
|
70
76
|
}
|
71
77
|
|
78
|
+
/**
|
79
|
+
* @param {ObjectDeserializerContext} context context
|
80
|
+
*/
|
72
81
|
deserialize(context) {
|
73
82
|
const { read } = context;
|
74
83
|
this.expression = read();
|
@@ -14,6 +14,8 @@ const memoize = require("../util/memoize");
|
|
14
14
|
/** @typedef {import("../Dependency").TRANSITIVE} TRANSITIVE */
|
15
15
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
16
16
|
/** @typedef {import("../WebpackError")} WebpackError */
|
17
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
18
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
17
19
|
|
18
20
|
const getCriticalDependencyWarning = memoize(() =>
|
19
21
|
require("./CriticalDependencyWarning")
|
@@ -21,6 +23,10 @@ const getCriticalDependencyWarning = memoize(() =>
|
|
21
23
|
|
22
24
|
/** @typedef {ContextOptions & { request: string }} ContextDependencyOptions */
|
23
25
|
|
26
|
+
/**
|
27
|
+
* @param {RegExp | null | undefined} r regexp
|
28
|
+
* @returns {string} stringified regexp
|
29
|
+
*/
|
24
30
|
const regExpToString = r => (r ? r + "" : "");
|
25
31
|
|
26
32
|
class ContextDependency extends Dependency {
|
@@ -33,7 +39,7 @@ class ContextDependency extends Dependency {
|
|
33
39
|
|
34
40
|
this.options = options;
|
35
41
|
this.userRequest = this.options && this.options.request;
|
36
|
-
/** @type {false | string} */
|
42
|
+
/** @type {false | undefined | string} */
|
37
43
|
this.critical = false;
|
38
44
|
this.hadGlobalOrStickyRegExp = false;
|
39
45
|
|
@@ -48,6 +54,7 @@ class ContextDependency extends Dependency {
|
|
48
54
|
this.request = undefined;
|
49
55
|
this.range = undefined;
|
50
56
|
this.valueRange = undefined;
|
57
|
+
/** @type {boolean | string | undefined} */
|
51
58
|
this.inShorthand = undefined;
|
52
59
|
// TODO refactor this
|
53
60
|
this.replaces = undefined;
|
@@ -91,7 +98,7 @@ class ContextDependency extends Dependency {
|
|
91
98
|
/**
|
92
99
|
* Returns warnings
|
93
100
|
* @param {ModuleGraph} moduleGraph module graph
|
94
|
-
* @returns {WebpackError[]} warnings
|
101
|
+
* @returns {WebpackError[] | null | undefined} warnings
|
95
102
|
*/
|
96
103
|
getWarnings(moduleGraph) {
|
97
104
|
let warnings = super.getWarnings(moduleGraph);
|
@@ -115,6 +122,9 @@ class ContextDependency extends Dependency {
|
|
115
122
|
return warnings;
|
116
123
|
}
|
117
124
|
|
125
|
+
/**
|
126
|
+
* @param {ObjectSerializerContext} context context
|
127
|
+
*/
|
118
128
|
serialize(context) {
|
119
129
|
const { write } = context;
|
120
130
|
|
@@ -132,6 +142,9 @@ class ContextDependency extends Dependency {
|
|
132
142
|
super.serialize(context);
|
133
143
|
}
|
134
144
|
|
145
|
+
/**
|
146
|
+
* @param {ObjectDeserializerContext} context context
|
147
|
+
*/
|
135
148
|
deserialize(context) {
|
136
149
|
const { read } = context;
|
137
150
|
|
@@ -38,12 +38,12 @@ const splitContextFromPrefix = prefix => {
|
|
38
38
|
};
|
39
39
|
|
40
40
|
/** @typedef {Partial<Omit<ContextDependencyOptions, "resource">>} PartialContextDependencyOptions */
|
41
|
-
|
42
|
-
/** @typedef {{ new(options: ContextDependencyOptions, range:
|
41
|
+
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
42
|
+
/** @typedef {{ new(options: ContextDependencyOptions, range: Range, valueRange: [number, number], ...args: any[]): ContextDependency }} ContextDependencyConstructor */
|
43
43
|
|
44
44
|
/**
|
45
45
|
* @param {ContextDependencyConstructor} Dep the Dependency class
|
46
|
-
* @param {
|
46
|
+
* @param {Range} range source range
|
47
47
|
* @param {BasicEvaluatedExpression} param context param
|
48
48
|
* @param {EsTreeNode} expr expr
|
49
49
|
* @param {Pick<JavascriptParserOptions, `${"expr"|"wrapped"}Context${"Critical"|"Recursive"|"RegExp"}` | "exprContextRequest">} options options for context creation
|
@@ -11,6 +11,8 @@ const ModuleDependency = require("./ModuleDependency");
|
|
11
11
|
|
12
12
|
/** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */
|
13
13
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
14
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
15
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
14
16
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
15
17
|
|
16
18
|
class ContextElementDependency extends ModuleDependency {
|
@@ -68,6 +70,9 @@ class ContextElementDependency extends ModuleDependency {
|
|
68
70
|
: Dependency.EXPORTS_OBJECT_REFERENCED;
|
69
71
|
}
|
70
72
|
|
73
|
+
/**
|
74
|
+
* @param {ObjectSerializerContext} context context
|
75
|
+
*/
|
71
76
|
serialize(context) {
|
72
77
|
const { write } = context;
|
73
78
|
write(this._typePrefix);
|
@@ -76,6 +81,9 @@ class ContextElementDependency extends ModuleDependency {
|
|
76
81
|
super.serialize(context);
|
77
82
|
}
|
78
83
|
|
84
|
+
/**
|
85
|
+
* @param {ObjectDeserializerContext} context context
|
86
|
+
*/
|
79
87
|
deserialize(context) {
|
80
88
|
const { read } = context;
|
81
89
|
this._typePrefix = read();
|
@@ -12,10 +12,13 @@ const NullDependency = require("./NullDependency");
|
|
12
12
|
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
13
13
|
/** @typedef {import("../Dependency")} Dependency */
|
14
14
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
15
|
+
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
16
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
17
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
15
18
|
|
16
19
|
class CreateScriptUrlDependency extends NullDependency {
|
17
20
|
/**
|
18
|
-
* @param {
|
21
|
+
* @param {Range} range range
|
19
22
|
*/
|
20
23
|
constructor(range) {
|
21
24
|
super();
|
@@ -26,12 +29,18 @@ class CreateScriptUrlDependency extends NullDependency {
|
|
26
29
|
return "create script url";
|
27
30
|
}
|
28
31
|
|
32
|
+
/**
|
33
|
+
* @param {ObjectSerializerContext} context context
|
34
|
+
*/
|
29
35
|
serialize(context) {
|
30
36
|
const { write } = context;
|
31
37
|
write(this.range);
|
32
38
|
super.serialize(context);
|
33
39
|
}
|
34
40
|
|
41
|
+
/**
|
42
|
+
* @param {ObjectDeserializerContext} context context
|
43
|
+
*/
|
35
44
|
deserialize(context) {
|
36
45
|
const { read } = context;
|
37
46
|
this.range = read();
|
@@ -9,6 +9,9 @@ const WebpackError = require("../WebpackError");
|
|
9
9
|
const makeSerializable = require("../util/makeSerializable");
|
10
10
|
|
11
11
|
class CriticalDependencyWarning extends WebpackError {
|
12
|
+
/**
|
13
|
+
* @param {string} message message
|
14
|
+
*/
|
12
15
|
constructor(message) {
|
13
16
|
super();
|
14
17
|
|
@@ -13,6 +13,8 @@ const NullDependency = require("./NullDependency");
|
|
13
13
|
/** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */
|
14
14
|
/** @typedef {import("../DependencyTemplate").CssDependencyTemplateContext} DependencyTemplateContext */
|
15
15
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
16
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
17
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
16
18
|
|
17
19
|
class CssExportDependency extends NullDependency {
|
18
20
|
/**
|
@@ -47,6 +49,9 @@ class CssExportDependency extends NullDependency {
|
|
47
49
|
};
|
48
50
|
}
|
49
51
|
|
52
|
+
/**
|
53
|
+
* @param {ObjectSerializerContext} context context
|
54
|
+
*/
|
50
55
|
serialize(context) {
|
51
56
|
const { write } = context;
|
52
57
|
write(this.name);
|
@@ -54,6 +59,9 @@ class CssExportDependency extends NullDependency {
|
|
54
59
|
super.serialize(context);
|
55
60
|
}
|
56
61
|
|
62
|
+
/**
|
63
|
+
* @param {ObjectDeserializerContext} context context
|
64
|
+
*/
|
57
65
|
deserialize(context) {
|
58
66
|
const { read } = context;
|
59
67
|
this.name = read();
|
@@ -17,19 +17,28 @@ const ModuleDependency = require("./ModuleDependency");
|
|
17
17
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
18
18
|
/** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
|
19
19
|
/** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */
|
20
|
+
/** @typedef {import("../css/CssParser").Range} Range */
|
21
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
22
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
20
23
|
/** @typedef {import("../util/Hash")} Hash */
|
21
24
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
22
25
|
|
23
26
|
class CssImportDependency extends ModuleDependency {
|
24
27
|
/**
|
28
|
+
* Example of dependency:
|
29
|
+
*
|
30
|
+
* \@import url("landscape.css") layer(forms) screen and (orientation: landscape) screen and (orientation: landscape);
|
31
|
+
*
|
25
32
|
* @param {string} request request
|
26
|
-
* @param {
|
33
|
+
* @param {Range} range range of the argument
|
34
|
+
* @param {string | undefined} layer layer
|
27
35
|
* @param {string | undefined} supports list of supports conditions
|
28
36
|
* @param {string | undefined} media list of media conditions
|
29
37
|
*/
|
30
|
-
constructor(request, range, supports, media) {
|
38
|
+
constructor(request, range, layer, supports, media) {
|
31
39
|
super(request);
|
32
40
|
this.range = range;
|
41
|
+
this.layer = layer;
|
33
42
|
this.supports = supports;
|
34
43
|
this.media = media;
|
35
44
|
}
|
@@ -42,13 +51,56 @@ class CssImportDependency extends ModuleDependency {
|
|
42
51
|
return "css-import";
|
43
52
|
}
|
44
53
|
|
54
|
+
/**
|
55
|
+
* @returns {string | null} an identifier to merge equal requests
|
56
|
+
*/
|
57
|
+
getResourceIdentifier() {
|
58
|
+
let str = `context${this._context || ""}|module${this.request}`;
|
59
|
+
|
60
|
+
if (this.layer) {
|
61
|
+
str += `|layer${this.layer}`;
|
62
|
+
}
|
63
|
+
|
64
|
+
if (this.supports) {
|
65
|
+
str += `|supports${this.supports}`;
|
66
|
+
}
|
67
|
+
|
68
|
+
if (this.media) {
|
69
|
+
str += `|media${this.media}`;
|
70
|
+
}
|
71
|
+
|
72
|
+
return str;
|
73
|
+
}
|
74
|
+
|
45
75
|
/**
|
46
76
|
* @param {string} context context directory
|
47
|
-
* @returns {Module} a module
|
77
|
+
* @returns {Module | null} a module
|
48
78
|
*/
|
49
79
|
createIgnoredModule(context) {
|
50
80
|
return null;
|
51
81
|
}
|
82
|
+
|
83
|
+
/**
|
84
|
+
* @param {ObjectSerializerContext} context context
|
85
|
+
*/
|
86
|
+
serialize(context) {
|
87
|
+
const { write } = context;
|
88
|
+
write(this.layer);
|
89
|
+
write(this.supports);
|
90
|
+
write(this.media);
|
91
|
+
super.serialize(context);
|
92
|
+
}
|
93
|
+
|
94
|
+
/**
|
95
|
+
* @param {ObjectDeserializerContext} context context
|
96
|
+
*/
|
97
|
+
deserialize(context) {
|
98
|
+
const { read } = context;
|
99
|
+
this.layer = read();
|
100
|
+
this.supports = read();
|
101
|
+
this.media = read();
|
102
|
+
super.deserialize(context);
|
103
|
+
}
|
52
104
|
}
|
53
105
|
|
54
106
|
CssImportDependency.Template = class CssImportDependencyTemplate extends (
|
@@ -13,11 +13,14 @@ const NullDependency = require("./NullDependency");
|
|
13
13
|
/** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */
|
14
14
|
/** @typedef {import("../DependencyTemplate").CssDependencyTemplateContext} DependencyTemplateContext */
|
15
15
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
16
|
+
/** @typedef {import("../css/CssParser").Range} Range */
|
17
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
18
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
16
19
|
|
17
20
|
class CssLocalIdentifierDependency extends NullDependency {
|
18
21
|
/**
|
19
22
|
* @param {string} name name
|
20
|
-
* @param {
|
23
|
+
* @param {Range} range range
|
21
24
|
* @param {string=} prefix prefix
|
22
25
|
*/
|
23
26
|
constructor(name, range, prefix = "") {
|
@@ -49,6 +52,9 @@ class CssLocalIdentifierDependency extends NullDependency {
|
|
49
52
|
};
|
50
53
|
}
|
51
54
|
|
55
|
+
/**
|
56
|
+
* @param {ObjectSerializerContext} context context
|
57
|
+
*/
|
52
58
|
serialize(context) {
|
53
59
|
const { write } = context;
|
54
60
|
write(this.name);
|
@@ -57,6 +63,9 @@ class CssLocalIdentifierDependency extends NullDependency {
|
|
57
63
|
super.serialize(context);
|
58
64
|
}
|
59
65
|
|
66
|
+
/**
|
67
|
+
* @param {ObjectDeserializerContext} context context
|
68
|
+
*/
|
60
69
|
deserialize(context) {
|
61
70
|
const { read } = context;
|
62
71
|
this.name = read();
|
@@ -66,6 +75,11 @@ class CssLocalIdentifierDependency extends NullDependency {
|
|
66
75
|
}
|
67
76
|
}
|
68
77
|
|
78
|
+
/**
|
79
|
+
* @param {string} str string
|
80
|
+
* @param {string | boolean} omitUnderscore true if you need to omit underscore
|
81
|
+
* @returns {string} escaped css identifier
|
82
|
+
*/
|
69
83
|
const escapeCssIdentifier = (str, omitUnderscore) => {
|
70
84
|
const escaped = `${str}`.replace(
|
71
85
|
// cspell:word uffff
|
@@ -14,12 +14,15 @@ const CssLocalIdentifierDependency = require("./CssLocalIdentifierDependency");
|
|
14
14
|
/** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */
|
15
15
|
/** @typedef {import("../DependencyTemplate").CssDependencyTemplateContext} DependencyTemplateContext */
|
16
16
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
17
|
+
/** @typedef {import("../css/CssParser").Range} Range */
|
18
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
19
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
17
20
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
18
21
|
|
19
22
|
class CssSelfLocalIdentifierDependency extends CssLocalIdentifierDependency {
|
20
23
|
/**
|
21
24
|
* @param {string} name name
|
22
|
-
* @param {
|
25
|
+
* @param {Range} range range
|
23
26
|
* @param {string=} prefix prefix
|
24
27
|
* @param {Set<string>=} declaredSet set of declared names (will only be active when in declared set)
|
25
28
|
*/
|
@@ -64,12 +67,18 @@ class CssSelfLocalIdentifierDependency extends CssLocalIdentifierDependency {
|
|
64
67
|
return [[this.name]];
|
65
68
|
}
|
66
69
|
|
70
|
+
/**
|
71
|
+
* @param {ObjectSerializerContext} context context
|
72
|
+
*/
|
67
73
|
serialize(context) {
|
68
74
|
const { write } = context;
|
69
75
|
write(this.declaredSet);
|
70
76
|
super.serialize(context);
|
71
77
|
}
|
72
78
|
|
79
|
+
/**
|
80
|
+
* @param {ObjectDeserializerContext} context context
|
81
|
+
*/
|
73
82
|
deserialize(context) {
|
74
83
|
const { read } = context;
|
75
84
|
this.declaredSet = read();
|