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,6 +24,9 @@ const { getEntryRuntime, mergeRuntimeOwned } = require("./util/runtime");
|
|
24
24
|
|
25
25
|
const { NO_EXPORTS_REFERENCED, EXPORTS_OBJECT_REFERENCED } = Dependency;
|
26
26
|
|
27
|
+
const PLUGIN_NAME = "FlagDependencyUsagePlugin";
|
28
|
+
const PLUGIN_LOGGER_NAME = `webpack.${PLUGIN_NAME}`;
|
29
|
+
|
27
30
|
class FlagDependencyUsagePlugin {
|
28
31
|
/**
|
29
32
|
* @param {boolean} global do a global analysis instead of per runtime
|
@@ -38,13 +41,10 @@ class FlagDependencyUsagePlugin {
|
|
38
41
|
* @returns {void}
|
39
42
|
*/
|
40
43
|
apply(compiler) {
|
41
|
-
compiler.hooks.compilation.tap(
|
44
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
42
45
|
const moduleGraph = compilation.moduleGraph;
|
43
46
|
compilation.hooks.optimizeDependencies.tap(
|
44
|
-
{
|
45
|
-
name: "FlagDependencyUsagePlugin",
|
46
|
-
stage: STAGE_DEFAULT
|
47
|
-
},
|
47
|
+
{ name: PLUGIN_NAME, stage: STAGE_DEFAULT },
|
48
48
|
modules => {
|
49
49
|
if (compilation.moduleMemCaches) {
|
50
50
|
throw new Error(
|
@@ -52,9 +52,7 @@ class FlagDependencyUsagePlugin {
|
|
52
52
|
);
|
53
53
|
}
|
54
54
|
|
55
|
-
const logger = compilation.getLogger(
|
56
|
-
"webpack.FlagDependencyUsagePlugin"
|
57
|
-
);
|
55
|
+
const logger = compilation.getLogger(PLUGIN_LOGGER_NAME);
|
58
56
|
/** @type {Map<ExportsInfo, Module>} */
|
59
57
|
const exportInfoToModuleMap = new Map();
|
60
58
|
|
@@ -334,7 +332,9 @@ class FlagDependencyUsagePlugin {
|
|
334
332
|
}
|
335
333
|
|
336
334
|
while (queue.length) {
|
337
|
-
const [module, runtime] =
|
335
|
+
const [module, runtime] = /** @type {[Module, RuntimeSpec]} */ (
|
336
|
+
queue.dequeue()
|
337
|
+
);
|
338
338
|
processModule(module, runtime, false);
|
339
339
|
}
|
340
340
|
logger.timeEnd("trace exports usage in graph");
|
@@ -9,7 +9,13 @@ const { getEntryRuntime } = require("./util/runtime");
|
|
9
9
|
|
10
10
|
/** @typedef {import("./Compiler")} Compiler */
|
11
11
|
|
12
|
+
const PLUGIN_NAME = "FlagEntryExportAsUsedPlugin";
|
13
|
+
|
12
14
|
class FlagEntryExportAsUsedPlugin {
|
15
|
+
/**
|
16
|
+
* @param {boolean} nsObjectUsed true, if the ns object is used
|
17
|
+
* @param {string} explanation explanation for the reason
|
18
|
+
*/
|
13
19
|
constructor(nsObjectUsed, explanation) {
|
14
20
|
this.nsObjectUsed = nsObjectUsed;
|
15
21
|
this.explanation = explanation;
|
@@ -21,32 +27,29 @@ class FlagEntryExportAsUsedPlugin {
|
|
21
27
|
* @returns {void}
|
22
28
|
*/
|
23
29
|
apply(compiler) {
|
24
|
-
compiler.hooks.thisCompilation.tap(
|
25
|
-
|
26
|
-
compilation => {
|
27
|
-
const
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
const
|
34
|
-
|
35
|
-
const
|
36
|
-
if (
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
} else {
|
41
|
-
exportsInfo.setAllKnownExportsUsed(runtime);
|
42
|
-
}
|
43
|
-
moduleGraph.addExtraReason(module, this.explanation);
|
30
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
|
31
|
+
const moduleGraph = compilation.moduleGraph;
|
32
|
+
compilation.hooks.seal.tap(PLUGIN_NAME, () => {
|
33
|
+
for (const [
|
34
|
+
entryName,
|
35
|
+
{ dependencies: deps, options }
|
36
|
+
] of compilation.entries) {
|
37
|
+
const runtime = getEntryRuntime(compilation, entryName, options);
|
38
|
+
for (const dep of deps) {
|
39
|
+
const module = moduleGraph.getModule(dep);
|
40
|
+
if (module) {
|
41
|
+
const exportsInfo = moduleGraph.getExportsInfo(module);
|
42
|
+
if (this.nsObjectUsed) {
|
43
|
+
exportsInfo.setUsedInUnknownWay(runtime);
|
44
|
+
} else {
|
45
|
+
exportsInfo.setAllKnownExportsUsed(runtime);
|
44
46
|
}
|
47
|
+
moduleGraph.addExtraReason(module, this.explanation);
|
45
48
|
}
|
46
49
|
}
|
47
|
-
}
|
48
|
-
}
|
49
|
-
);
|
50
|
+
}
|
51
|
+
});
|
52
|
+
});
|
50
53
|
}
|
51
54
|
}
|
52
55
|
|
package/lib/HookWebpackError.js
CHANGED
@@ -35,6 +35,13 @@ const {
|
|
35
35
|
intersectRuntime
|
36
36
|
} = require("./util/runtime");
|
37
37
|
|
38
|
+
const {
|
39
|
+
JAVASCRIPT_MODULE_TYPE_AUTO,
|
40
|
+
JAVASCRIPT_MODULE_TYPE_DYNAMIC,
|
41
|
+
JAVASCRIPT_MODULE_TYPE_ESM,
|
42
|
+
WEBPACK_MODULE_TYPE_RUNTIME
|
43
|
+
} = require("./ModuleTypeConstants");
|
44
|
+
|
38
45
|
/** @typedef {import("./Chunk")} Chunk */
|
39
46
|
/** @typedef {import("./Compilation").AssetInfo} AssetInfo */
|
40
47
|
/** @typedef {import("./Compiler")} Compiler */
|
@@ -51,6 +58,8 @@ const {
|
|
51
58
|
/** @type {WeakMap<JavascriptParser, HMRJavascriptParserHooks>} */
|
52
59
|
const parserHooksMap = new WeakMap();
|
53
60
|
|
61
|
+
const PLUGIN_NAME = "HotModuleReplacementPlugin";
|
62
|
+
|
54
63
|
class HotModuleReplacementPlugin {
|
55
64
|
/**
|
56
65
|
* @param {JavascriptParser} parser the parser
|
@@ -180,10 +189,14 @@ class HotModuleReplacementPlugin {
|
|
180
189
|
return true;
|
181
190
|
};
|
182
191
|
|
192
|
+
/**
|
193
|
+
* @param {JavascriptParser} parser the parser
|
194
|
+
* @returns {void}
|
195
|
+
*/
|
183
196
|
const applyModuleHot = parser => {
|
184
197
|
parser.hooks.evaluateIdentifier.for("module.hot").tap(
|
185
198
|
{
|
186
|
-
name:
|
199
|
+
name: PLUGIN_NAME,
|
187
200
|
before: "NodeStuffPlugin"
|
188
201
|
},
|
189
202
|
expr => {
|
@@ -198,24 +211,28 @@ class HotModuleReplacementPlugin {
|
|
198
211
|
parser.hooks.call
|
199
212
|
.for("module.hot.accept")
|
200
213
|
.tap(
|
201
|
-
|
214
|
+
PLUGIN_NAME,
|
202
215
|
createAcceptHandler(parser, ModuleHotAcceptDependency)
|
203
216
|
);
|
204
217
|
parser.hooks.call
|
205
218
|
.for("module.hot.decline")
|
206
219
|
.tap(
|
207
|
-
|
220
|
+
PLUGIN_NAME,
|
208
221
|
createDeclineHandler(parser, ModuleHotDeclineDependency)
|
209
222
|
);
|
210
223
|
parser.hooks.expression
|
211
224
|
.for("module.hot")
|
212
|
-
.tap(
|
225
|
+
.tap(PLUGIN_NAME, createHMRExpressionHandler(parser));
|
213
226
|
};
|
214
227
|
|
228
|
+
/**
|
229
|
+
* @param {JavascriptParser} parser the parser
|
230
|
+
* @returns {void}
|
231
|
+
*/
|
215
232
|
const applyImportMetaHot = parser => {
|
216
233
|
parser.hooks.evaluateIdentifier
|
217
234
|
.for("import.meta.webpackHot")
|
218
|
-
.tap(
|
235
|
+
.tap(PLUGIN_NAME, expr => {
|
219
236
|
return evaluateToIdentifier(
|
220
237
|
"import.meta.webpackHot",
|
221
238
|
"import.meta",
|
@@ -226,22 +243,22 @@ class HotModuleReplacementPlugin {
|
|
226
243
|
parser.hooks.call
|
227
244
|
.for("import.meta.webpackHot.accept")
|
228
245
|
.tap(
|
229
|
-
|
246
|
+
PLUGIN_NAME,
|
230
247
|
createAcceptHandler(parser, ImportMetaHotAcceptDependency)
|
231
248
|
);
|
232
249
|
parser.hooks.call
|
233
250
|
.for("import.meta.webpackHot.decline")
|
234
251
|
.tap(
|
235
|
-
|
252
|
+
PLUGIN_NAME,
|
236
253
|
createDeclineHandler(parser, ImportMetaHotDeclineDependency)
|
237
254
|
);
|
238
255
|
parser.hooks.expression
|
239
256
|
.for("import.meta.webpackHot")
|
240
|
-
.tap(
|
257
|
+
.tap(PLUGIN_NAME, createHMRExpressionHandler(parser));
|
241
258
|
};
|
242
259
|
|
243
260
|
compiler.hooks.compilation.tap(
|
244
|
-
|
261
|
+
PLUGIN_NAME,
|
245
262
|
(compilation, { normalModuleFactory }) => {
|
246
263
|
// This applies the HMR plugin only to the targeted compiler
|
247
264
|
// It should not affect child compilations
|
@@ -289,40 +306,37 @@ class HotModuleReplacementPlugin {
|
|
289
306
|
const fullHashChunkModuleHashes = {};
|
290
307
|
const chunkModuleHashes = {};
|
291
308
|
|
292
|
-
compilation.hooks.record.tap(
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
records.
|
303
|
-
|
304
|
-
records.chunkHashes[chunk.id] = chunk.hash;
|
305
|
-
records.chunkRuntime[chunk.id] = getRuntimeKey(chunk.runtime);
|
306
|
-
}
|
307
|
-
records.chunkModuleIds = {};
|
308
|
-
for (const chunk of compilation.chunks) {
|
309
|
-
records.chunkModuleIds[chunk.id] = Array.from(
|
310
|
-
chunkGraph.getOrderedChunkModulesIterable(
|
311
|
-
chunk,
|
312
|
-
compareModulesById(chunkGraph)
|
313
|
-
),
|
314
|
-
m => chunkGraph.getModuleId(m)
|
315
|
-
);
|
316
|
-
}
|
309
|
+
compilation.hooks.record.tap(PLUGIN_NAME, (compilation, records) => {
|
310
|
+
if (records.hash === compilation.hash) return;
|
311
|
+
const chunkGraph = compilation.chunkGraph;
|
312
|
+
records.hash = compilation.hash;
|
313
|
+
records.hotIndex = hotIndex;
|
314
|
+
records.fullHashChunkModuleHashes = fullHashChunkModuleHashes;
|
315
|
+
records.chunkModuleHashes = chunkModuleHashes;
|
316
|
+
records.chunkHashes = {};
|
317
|
+
records.chunkRuntime = {};
|
318
|
+
for (const chunk of compilation.chunks) {
|
319
|
+
records.chunkHashes[chunk.id] = chunk.hash;
|
320
|
+
records.chunkRuntime[chunk.id] = getRuntimeKey(chunk.runtime);
|
317
321
|
}
|
318
|
-
|
322
|
+
records.chunkModuleIds = {};
|
323
|
+
for (const chunk of compilation.chunks) {
|
324
|
+
records.chunkModuleIds[chunk.id] = Array.from(
|
325
|
+
chunkGraph.getOrderedChunkModulesIterable(
|
326
|
+
chunk,
|
327
|
+
compareModulesById(chunkGraph)
|
328
|
+
),
|
329
|
+
m => chunkGraph.getModuleId(m)
|
330
|
+
);
|
331
|
+
}
|
332
|
+
});
|
319
333
|
/** @type {TupleSet<[Module, Chunk]>} */
|
320
334
|
const updatedModules = new TupleSet();
|
321
335
|
/** @type {TupleSet<[Module, Chunk]>} */
|
322
336
|
const fullHashModules = new TupleSet();
|
323
337
|
/** @type {TupleSet<[Module, RuntimeSpec]>} */
|
324
338
|
const nonCodeGeneratedModules = new TupleSet();
|
325
|
-
compilation.hooks.fullHash.tap(
|
339
|
+
compilation.hooks.fullHash.tap(PLUGIN_NAME, hash => {
|
326
340
|
const chunkGraph = compilation.chunkGraph;
|
327
341
|
const records = compilation.records;
|
328
342
|
for (const chunk of compilation.chunks) {
|
@@ -412,7 +426,7 @@ class HotModuleReplacementPlugin {
|
|
412
426
|
});
|
413
427
|
compilation.hooks.processAssets.tap(
|
414
428
|
{
|
415
|
-
name:
|
429
|
+
name: PLUGIN_NAME,
|
416
430
|
stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL
|
417
431
|
},
|
418
432
|
() => {
|
@@ -559,7 +573,7 @@ class HotModuleReplacementPlugin {
|
|
559
573
|
newRuntime
|
560
574
|
);
|
561
575
|
if (hash !== oldHash) {
|
562
|
-
if (module.type ===
|
576
|
+
if (module.type === WEBPACK_MODULE_TYPE_RUNTIME) {
|
563
577
|
newRuntimeModules = newRuntimeModules || [];
|
564
578
|
newRuntimeModules.push(
|
565
579
|
/** @type {RuntimeModule} */ (module)
|
@@ -734,7 +748,7 @@ To fix this, make sure to include [runtime] in the output.hotUpdateMainFilename
|
|
734
748
|
);
|
735
749
|
|
736
750
|
compilation.hooks.additionalTreeRuntimeRequirements.tap(
|
737
|
-
|
751
|
+
PLUGIN_NAME,
|
738
752
|
(chunk, runtimeRequirements) => {
|
739
753
|
runtimeRequirements.add(RuntimeGlobals.hmrDownloadManifest);
|
740
754
|
runtimeRequirements.add(RuntimeGlobals.hmrDownloadUpdateHandlers);
|
@@ -748,24 +762,24 @@ To fix this, make sure to include [runtime] in the output.hotUpdateMainFilename
|
|
748
762
|
);
|
749
763
|
|
750
764
|
normalModuleFactory.hooks.parser
|
751
|
-
.for(
|
752
|
-
.tap(
|
765
|
+
.for(JAVASCRIPT_MODULE_TYPE_AUTO)
|
766
|
+
.tap(PLUGIN_NAME, parser => {
|
753
767
|
applyModuleHot(parser);
|
754
768
|
applyImportMetaHot(parser);
|
755
769
|
});
|
756
770
|
normalModuleFactory.hooks.parser
|
757
|
-
.for(
|
758
|
-
.tap(
|
771
|
+
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC)
|
772
|
+
.tap(PLUGIN_NAME, parser => {
|
759
773
|
applyModuleHot(parser);
|
760
774
|
});
|
761
775
|
normalModuleFactory.hooks.parser
|
762
|
-
.for(
|
763
|
-
.tap(
|
776
|
+
.for(JAVASCRIPT_MODULE_TYPE_ESM)
|
777
|
+
.tap(PLUGIN_NAME, parser => {
|
764
778
|
applyImportMetaHot(parser);
|
765
779
|
});
|
766
780
|
|
767
781
|
NormalModule.getCompilationHooks(compilation).loader.tap(
|
768
|
-
|
782
|
+
PLUGIN_NAME,
|
769
783
|
context => {
|
770
784
|
context.hot = true;
|
771
785
|
}
|
@@ -26,7 +26,7 @@ class IgnoreErrorModuleFactory extends ModuleFactory {
|
|
26
26
|
|
27
27
|
/**
|
28
28
|
* @param {ModuleFactoryCreateData} data data object
|
29
|
-
* @param {function(Error=, ModuleFactoryResult=): void} callback callback
|
29
|
+
* @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback
|
30
30
|
* @returns {void}
|
31
31
|
*/
|
32
32
|
create(data, callback) {
|
package/lib/InitFragment.js
CHANGED
@@ -10,17 +10,21 @@ const makeSerializable = require("./util/makeSerializable");
|
|
10
10
|
|
11
11
|
/** @typedef {import("webpack-sources").Source} Source */
|
12
12
|
/** @typedef {import("./Generator").GenerateContext} GenerateContext */
|
13
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
14
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
13
15
|
|
14
16
|
/**
|
15
|
-
* @
|
17
|
+
* @template T
|
18
|
+
* @param {InitFragment<T>} fragment the init fragment
|
16
19
|
* @param {number} index index
|
17
|
-
* @returns {[InitFragment
|
20
|
+
* @returns {[InitFragment<T>, number]} tuple with both
|
18
21
|
*/
|
19
22
|
const extractFragmentIndex = (fragment, index) => [fragment, index];
|
20
23
|
|
21
24
|
/**
|
22
|
-
* @
|
23
|
-
* @param {[InitFragment
|
25
|
+
* @template T
|
26
|
+
* @param {[InitFragment<T>, number]} a first pair
|
27
|
+
* @param {[InitFragment<T>, number]} b second pair
|
24
28
|
* @returns {number} sort value
|
25
29
|
*/
|
26
30
|
const sortFragmentWithIndex = ([a, i], [b, j]) => {
|
@@ -66,6 +70,14 @@ class InitFragment {
|
|
66
70
|
return this.endContent;
|
67
71
|
}
|
68
72
|
|
73
|
+
/**
|
74
|
+
* @template Context
|
75
|
+
* @template T
|
76
|
+
* @param {Source} source sources
|
77
|
+
* @param {InitFragment<T>[]} initFragments init fragments
|
78
|
+
* @param {Context} context context
|
79
|
+
* @returns {Source} source
|
80
|
+
*/
|
69
81
|
static addToSource(source, initFragments, context) {
|
70
82
|
if (initFragments.length > 0) {
|
71
83
|
// Sort fragments by position. If 2 fragments have the same position,
|
@@ -77,7 +89,12 @@ class InitFragment {
|
|
77
89
|
// Deduplicate fragments. If a fragment has no key, it is always included.
|
78
90
|
const keyedFragments = new Map();
|
79
91
|
for (const [fragment] of sortedFragments) {
|
80
|
-
if (
|
92
|
+
if (
|
93
|
+
typeof (
|
94
|
+
/** @type {InitFragment<T> & { mergeAll?: (fragments: InitFragment[]) => InitFragment[] }} */
|
95
|
+
(fragment).mergeAll
|
96
|
+
) === "function"
|
97
|
+
) {
|
81
98
|
if (!fragment.key) {
|
82
99
|
throw new Error(
|
83
100
|
`InitFragment with mergeAll function must have a valid key: ${fragment.constructor.name}`
|
@@ -125,6 +142,9 @@ class InitFragment {
|
|
125
142
|
}
|
126
143
|
}
|
127
144
|
|
145
|
+
/**
|
146
|
+
* @param {ObjectSerializerContext} context context
|
147
|
+
*/
|
128
148
|
serialize(context) {
|
129
149
|
const { write } = context;
|
130
150
|
|
@@ -135,6 +155,9 @@ class InitFragment {
|
|
135
155
|
write(this.endContent);
|
136
156
|
}
|
137
157
|
|
158
|
+
/**
|
159
|
+
* @param {ObjectDeserializerContext} context context
|
160
|
+
*/
|
138
161
|
deserialize(context) {
|
139
162
|
const { read } = context;
|
140
163
|
|
@@ -5,11 +5,19 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
const {
|
9
|
+
JAVASCRIPT_MODULE_TYPE_AUTO,
|
10
|
+
JAVASCRIPT_MODULE_TYPE_DYNAMIC,
|
11
|
+
JAVASCRIPT_MODULE_TYPE_ESM
|
12
|
+
} = require("./ModuleTypeConstants");
|
8
13
|
const InnerGraph = require("./optimize/InnerGraph");
|
9
14
|
|
10
15
|
/** @typedef {import("./Compiler")} Compiler */
|
16
|
+
/** @typedef {import("./Module").BuildInfo} BuildInfo */
|
11
17
|
/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
|
12
18
|
|
19
|
+
const PLUGIN_NAME = "JavascriptMetaInfoPlugin";
|
20
|
+
|
13
21
|
class JavascriptMetaInfoPlugin {
|
14
22
|
/**
|
15
23
|
* Apply the plugin
|
@@ -18,16 +26,19 @@ class JavascriptMetaInfoPlugin {
|
|
18
26
|
*/
|
19
27
|
apply(compiler) {
|
20
28
|
compiler.hooks.compilation.tap(
|
21
|
-
|
29
|
+
PLUGIN_NAME,
|
22
30
|
(compilation, { normalModuleFactory }) => {
|
23
31
|
/**
|
24
32
|
* @param {JavascriptParser} parser the parser
|
25
33
|
* @returns {void}
|
26
34
|
*/
|
27
35
|
const handler = parser => {
|
28
|
-
parser.hooks.call.for("eval").tap(
|
29
|
-
|
30
|
-
|
36
|
+
parser.hooks.call.for("eval").tap(PLUGIN_NAME, () => {
|
37
|
+
const buildInfo =
|
38
|
+
/** @type {BuildInfo} */
|
39
|
+
(parser.state.module.buildInfo);
|
40
|
+
buildInfo.moduleConcatenationBailout = "eval()";
|
41
|
+
buildInfo.usingEval = true;
|
31
42
|
const currentSymbol = InnerGraph.getTopLevelSymbol(parser.state);
|
32
43
|
if (currentSymbol) {
|
33
44
|
InnerGraph.addUsage(parser.state, null, currentSymbol);
|
@@ -35,12 +46,13 @@ class JavascriptMetaInfoPlugin {
|
|
35
46
|
InnerGraph.bailout(parser.state);
|
36
47
|
}
|
37
48
|
});
|
38
|
-
parser.hooks.finish.tap(
|
39
|
-
|
40
|
-
|
49
|
+
parser.hooks.finish.tap(PLUGIN_NAME, () => {
|
50
|
+
const buildInfo =
|
51
|
+
/** @type {BuildInfo} */
|
52
|
+
(parser.state.module.buildInfo);
|
53
|
+
let topLevelDeclarations = buildInfo.topLevelDeclarations;
|
41
54
|
if (topLevelDeclarations === undefined) {
|
42
|
-
topLevelDeclarations =
|
43
|
-
parser.state.module.buildInfo.topLevelDeclarations = new Set();
|
55
|
+
topLevelDeclarations = buildInfo.topLevelDeclarations = new Set();
|
44
56
|
}
|
45
57
|
for (const name of parser.scope.definitions.asSet()) {
|
46
58
|
const freeInfo = parser.getFreeInfoFromVariable(name);
|
@@ -52,14 +64,14 @@ class JavascriptMetaInfoPlugin {
|
|
52
64
|
};
|
53
65
|
|
54
66
|
normalModuleFactory.hooks.parser
|
55
|
-
.for(
|
56
|
-
.tap(
|
67
|
+
.for(JAVASCRIPT_MODULE_TYPE_AUTO)
|
68
|
+
.tap(PLUGIN_NAME, handler);
|
57
69
|
normalModuleFactory.hooks.parser
|
58
|
-
.for(
|
59
|
-
.tap(
|
70
|
+
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC)
|
71
|
+
.tap(PLUGIN_NAME, handler);
|
60
72
|
normalModuleFactory.hooks.parser
|
61
|
-
.for(
|
62
|
-
.tap(
|
73
|
+
.for(JAVASCRIPT_MODULE_TYPE_ESM)
|
74
|
+
.tap(PLUGIN_NAME, handler);
|
63
75
|
}
|
64
76
|
);
|
65
77
|
}
|
package/lib/LibManifestPlugin.js
CHANGED
@@ -12,15 +12,29 @@ const { compareModulesById } = require("./util/comparators");
|
|
12
12
|
const { dirname, mkdirp } = require("./util/fs");
|
13
13
|
|
14
14
|
/** @typedef {import("./Compiler")} Compiler */
|
15
|
+
/** @typedef {import("./Module").BuildMeta} BuildMeta */
|
15
16
|
|
16
17
|
/**
|
17
18
|
* @typedef {Object} ManifestModuleData
|
18
19
|
* @property {string | number} id
|
19
|
-
* @property {
|
20
|
-
* @property {boolean | string[]} exports
|
20
|
+
* @property {BuildMeta} buildMeta
|
21
|
+
* @property {boolean | string[] | undefined} exports
|
22
|
+
*/
|
23
|
+
|
24
|
+
/**
|
25
|
+
* @typedef {Object} LibManifestPluginOptions
|
26
|
+
* @property {string=} context Context of requests in the manifest file (defaults to the webpack context).
|
27
|
+
* @property {boolean=} entryOnly If true, only entry points will be exposed (default: true).
|
28
|
+
* @property {boolean=} format If true, manifest json file (output) will be formatted.
|
29
|
+
* @property {string=} name Name of the exposed dll function (external name, use value of 'output.library').
|
30
|
+
* @property {string} path Absolute path to the manifest json file (output).
|
31
|
+
* @property {string=} type Type of the dll bundle (external type, use value of 'output.libraryTarget').
|
21
32
|
*/
|
22
33
|
|
23
34
|
class LibManifestPlugin {
|
35
|
+
/**
|
36
|
+
* @param {LibManifestPluginOptions} options the options
|
37
|
+
*/
|
24
38
|
constructor(options) {
|
25
39
|
this.options = options;
|
26
40
|
}
|
@@ -49,7 +63,8 @@ class LibManifestPlugin {
|
|
49
63
|
const name =
|
50
64
|
this.options.name &&
|
51
65
|
compilation.getPath(this.options.name, {
|
52
|
-
chunk
|
66
|
+
chunk,
|
67
|
+
contentHashType: "javascript"
|
53
68
|
});
|
54
69
|
const content = Object.create(null);
|
55
70
|
for (const module of chunkGraph.getOrderedChunkModulesIterable(
|
@@ -66,7 +81,9 @@ class LibManifestPlugin {
|
|
66
81
|
continue;
|
67
82
|
}
|
68
83
|
const ident = module.libIdent({
|
69
|
-
context:
|
84
|
+
context:
|
85
|
+
this.options.context ||
|
86
|
+
/** @type {string} */ (compiler.options.context),
|
70
87
|
associatedObjectForCache: compiler.root
|
71
88
|
});
|
72
89
|
if (ident) {
|
@@ -75,7 +92,7 @@ class LibManifestPlugin {
|
|
75
92
|
/** @type {ManifestModuleData} */
|
76
93
|
const data = {
|
77
94
|
id: chunkGraph.getModuleId(module),
|
78
|
-
buildMeta: module.buildMeta,
|
95
|
+
buildMeta: /** @type {BuildMeta} */ (module.buildMeta),
|
79
96
|
exports: Array.isArray(providedExports)
|
80
97
|
? providedExports
|
81
98
|
: undefined
|
@@ -11,6 +11,7 @@ const createSchemaValidation = require("./util/create-schema-validation");
|
|
11
11
|
|
12
12
|
/** @typedef {import("../declarations/plugins/LoaderOptionsPlugin").LoaderOptionsPluginOptions} LoaderOptionsPluginOptions */
|
13
13
|
/** @typedef {import("./Compiler")} Compiler */
|
14
|
+
/** @typedef {import("./ModuleFilenameHelpers").MatchObject} MatchObject */
|
14
15
|
|
15
16
|
const validate = createSchemaValidation(
|
16
17
|
require("../schemas/plugins/LoaderOptionsPlugin.check.js"),
|
@@ -20,17 +21,26 @@ const validate = createSchemaValidation(
|
|
20
21
|
baseDataPath: "options"
|
21
22
|
}
|
22
23
|
);
|
24
|
+
|
23
25
|
class LoaderOptionsPlugin {
|
24
26
|
/**
|
25
|
-
* @param {LoaderOptionsPluginOptions} options options object
|
27
|
+
* @param {LoaderOptionsPluginOptions & MatchObject} options options object
|
26
28
|
*/
|
27
29
|
constructor(options = {}) {
|
28
30
|
validate(options);
|
31
|
+
// If no options are set then generate empty options object
|
29
32
|
if (typeof options !== "object") options = {};
|
30
33
|
if (!options.test) {
|
31
|
-
|
34
|
+
// This is mocking a RegExp object which always returns true
|
35
|
+
// TODO: Figure out how to do `as unknown as RegExp` for this line
|
36
|
+
// in JSDoc equivalent
|
37
|
+
/** @type {any} */
|
38
|
+
const defaultTrueMockRegExp = {
|
32
39
|
test: () => true
|
33
40
|
};
|
41
|
+
|
42
|
+
/** @type {RegExp} */
|
43
|
+
options.test = defaultTrueMockRegExp;
|
34
44
|
}
|
35
45
|
this.options = options;
|
36
46
|
}
|
package/lib/MainTemplate.js
CHANGED
@@ -306,8 +306,8 @@ class MainTemplate {
|
|
306
306
|
|
307
307
|
Object.defineProperty(MainTemplate.prototype, "requireFn", {
|
308
308
|
get: util.deprecate(
|
309
|
-
() =>
|
310
|
-
|
309
|
+
() => RuntimeGlobals.require,
|
310
|
+
`MainTemplate.requireFn is deprecated (use "${RuntimeGlobals.require}")`,
|
311
311
|
"DEP_WEBPACK_MAIN_TEMPLATE_REQUIRE_FN"
|
312
312
|
)
|
313
313
|
});
|