webpack 5.97.1 → 5.104.1
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.
- package/README.md +368 -434
- package/bin/webpack.js +15 -9
- package/hot/dev-server.js +18 -3
- package/hot/emitter-event-target.js +7 -0
- package/hot/lazy-compilation-node.js +45 -29
- package/hot/lazy-compilation-universal.js +18 -0
- package/hot/lazy-compilation-web.js +15 -5
- package/hot/load-http.js +7 -0
- package/hot/log.js +15 -15
- package/hot/only-dev-server.js +19 -4
- package/hot/poll.js +1 -0
- package/lib/APIPlugin.js +48 -50
- package/lib/AbstractMethodError.js +1 -0
- package/lib/AsyncDependenciesBlock.js +4 -5
- package/lib/AutomaticPrefetchPlugin.js +22 -22
- package/lib/BannerPlugin.js +35 -40
- package/lib/Cache.js +12 -9
- package/lib/CacheFacade.js +13 -13
- package/lib/CaseSensitiveModulesWarning.js +6 -6
- package/lib/Chunk.js +68 -47
- package/lib/ChunkGraph.js +174 -95
- package/lib/ChunkGroup.js +32 -24
- package/lib/ChunkTemplate.js +8 -8
- package/lib/CleanPlugin.js +90 -42
- package/lib/CodeGenerationResults.js +12 -9
- package/lib/CompatibilityPlugin.js +70 -21
- package/lib/Compilation.js +827 -550
- package/lib/Compiler.js +137 -109
- package/lib/ConcatenationScope.js +45 -8
- package/lib/ConditionalInitFragment.js +1 -1
- package/lib/ConstPlugin.js +89 -59
- package/lib/ContextExclusionPlugin.js +5 -4
- package/lib/ContextModule.js +66 -51
- package/lib/ContextModuleFactory.js +51 -30
- package/lib/ContextReplacementPlugin.js +89 -34
- package/lib/CssModule.js +8 -4
- package/lib/DefinePlugin.js +209 -57
- package/lib/DelegatedModule.js +34 -23
- package/lib/DelegatedModuleFactoryPlugin.js +27 -24
- package/lib/DelegatedPlugin.js +4 -2
- package/lib/DependenciesBlock.js +0 -2
- package/lib/Dependency.js +37 -19
- package/lib/DependencyTemplate.js +2 -0
- package/lib/DependencyTemplates.js +5 -6
- package/lib/DllEntryPlugin.js +8 -4
- package/lib/DllModule.js +11 -12
- package/lib/DllModuleFactory.js +2 -2
- package/lib/DllPlugin.js +9 -6
- package/lib/DllReferencePlugin.js +60 -65
- package/lib/DotenvPlugin.js +462 -0
- package/lib/DynamicEntryPlugin.js +8 -8
- package/lib/EntryOptionPlugin.js +8 -6
- package/lib/EntryPlugin.js +5 -3
- package/lib/Entrypoint.js +19 -0
- package/lib/EnvironmentNotSupportAsyncWarning.js +0 -3
- package/lib/EnvironmentPlugin.js +26 -19
- package/lib/ErrorHelpers.js +6 -6
- package/lib/EvalDevToolModulePlugin.js +17 -14
- package/lib/EvalSourceMapDevToolPlugin.js +156 -142
- package/lib/ExportsInfo.js +180 -115
- package/lib/ExportsInfoApiPlugin.js +2 -2
- package/lib/ExternalModule.js +256 -102
- package/lib/ExternalModuleFactoryPlugin.js +66 -29
- package/lib/ExternalsPlugin.js +57 -2
- package/lib/FileSystemInfo.js +313 -247
- package/lib/FlagAllModulesAsUsedPlugin.js +2 -2
- package/lib/FlagDependencyExportsPlugin.js +29 -19
- package/lib/FlagDependencyUsagePlugin.js +9 -10
- package/lib/FlagEntryExportAsUsedPlugin.js +1 -1
- package/lib/Generator.js +43 -10
- package/lib/GraphHelpers.js +11 -3
- package/lib/HookWebpackError.js +35 -7
- package/lib/HotModuleReplacementPlugin.js +149 -108
- package/lib/HotUpdateChunk.js +0 -3
- package/lib/IgnoreErrorModuleFactory.js +2 -2
- package/lib/IgnorePlugin.js +16 -13
- package/lib/IgnoreWarningsPlugin.js +6 -4
- package/lib/InitFragment.js +41 -23
- package/lib/InvalidDependenciesModuleWarning.js +2 -3
- package/lib/JavascriptMetaInfoPlugin.js +2 -4
- package/lib/LibManifestPlugin.js +12 -13
- package/lib/LoaderOptionsPlugin.js +12 -14
- package/lib/LoaderTargetPlugin.js +5 -3
- package/lib/MainTemplate.js +18 -29
- package/lib/ManifestPlugin.js +235 -0
- package/lib/Module.js +138 -60
- package/lib/ModuleBuildError.js +4 -2
- package/lib/ModuleDependencyError.js +4 -3
- package/lib/ModuleDependencyWarning.js +4 -3
- package/lib/ModuleError.js +1 -1
- package/lib/ModuleFactory.js +10 -3
- package/lib/ModuleFilenameHelpers.js +63 -60
- package/lib/ModuleGraph.js +195 -70
- package/lib/ModuleGraphConnection.js +14 -20
- package/lib/ModuleInfoHeaderPlugin.js +15 -16
- package/lib/ModuleNotFoundError.js +1 -1
- package/lib/ModuleParseError.js +8 -4
- package/lib/ModuleSourceTypeConstants.js +189 -0
- package/lib/ModuleTemplate.js +7 -8
- package/lib/ModuleTypeConstants.js +37 -15
- package/lib/ModuleWarning.js +1 -1
- package/lib/MultiCompiler.js +64 -49
- package/lib/MultiStats.js +19 -14
- package/lib/MultiWatching.js +7 -11
- package/lib/NoEmitOnErrorsPlugin.js +5 -3
- package/lib/NodeStuffPlugin.js +438 -126
- package/lib/NormalModule.js +322 -201
- package/lib/NormalModuleFactory.js +230 -117
- package/lib/NormalModuleReplacementPlugin.js +37 -39
- package/lib/NullFactory.js +3 -2
- package/lib/OptimizationStages.js +1 -1
- package/lib/OptionsApply.js +1 -1
- package/lib/Parser.js +5 -3
- package/lib/PlatformPlugin.js +3 -1
- package/lib/PrefetchPlugin.js +6 -4
- package/lib/ProgressPlugin.js +48 -49
- package/lib/ProvidePlugin.js +7 -5
- package/lib/RawModule.js +26 -12
- package/lib/RecordIdsPlugin.js +88 -110
- package/lib/RequestShortener.js +3 -1
- package/lib/ResolverFactory.js +15 -14
- package/lib/RuntimeGlobals.js +216 -153
- package/lib/RuntimeModule.js +7 -6
- package/lib/RuntimePlugin.js +115 -62
- package/lib/RuntimeTemplate.js +248 -76
- package/lib/SelfModuleFactory.js +2 -2
- package/lib/SizeFormatHelpers.js +2 -2
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +17 -27
- package/lib/SourceMapDevToolPlugin.js +72 -59
- package/lib/Stats.js +2 -3
- package/lib/Template.js +31 -24
- package/lib/TemplatedPathPlugin.js +24 -21
- package/lib/UseStrictPlugin.js +1 -1
- package/lib/WarnCaseSensitiveModulesPlugin.js +36 -37
- package/lib/WarnDeprecatedOptionPlugin.js +7 -8
- package/lib/WarnNoModeSetPlugin.js +3 -1
- package/lib/WatchIgnorePlugin.js +11 -9
- package/lib/Watching.js +27 -29
- package/lib/WebpackError.js +10 -3
- package/lib/WebpackIsIncludedPlugin.js +4 -5
- package/lib/WebpackOptionsApply.js +263 -135
- package/lib/asset/AssetBytesGenerator.js +171 -0
- package/lib/asset/AssetBytesParser.js +37 -0
- package/lib/asset/AssetGenerator.js +285 -223
- package/lib/asset/AssetModulesPlugin.js +103 -41
- package/lib/asset/AssetParser.js +7 -3
- package/lib/asset/AssetSourceGenerator.js +41 -17
- package/lib/asset/RawDataUrlModule.js +17 -9
- package/lib/async-modules/AsyncModuleHelpers.js +52 -0
- package/lib/async-modules/AwaitDependenciesInitFragment.js +39 -24
- package/lib/async-modules/InferAsyncModulesPlugin.js +25 -26
- package/lib/buildChunkGraph.js +36 -17
- package/lib/cache/AddBuildDependenciesPlugin.js +5 -6
- package/lib/cache/IdleFileCachePlugin.js +22 -20
- package/lib/cache/MemoryCachePlugin.js +3 -3
- package/lib/cache/MemoryWithGcCachePlugin.js +17 -11
- package/lib/cache/PackFileCacheStrategy.js +198 -170
- package/lib/cache/ResolverCachePlugin.js +58 -48
- package/lib/cache/getLazyHashedEtag.js +5 -4
- package/lib/cli.js +197 -39
- package/lib/config/browserslistTargetHandler.js +110 -85
- package/lib/config/defaults.js +514 -113
- package/lib/config/normalization.js +91 -64
- package/lib/config/target.js +30 -18
- package/lib/container/ContainerEntryDependency.js +0 -1
- package/lib/container/ContainerEntryModule.js +16 -15
- package/lib/container/ContainerEntryModuleFactory.js +2 -2
- package/lib/container/ContainerPlugin.js +5 -6
- package/lib/container/ContainerReferencePlugin.js +27 -30
- package/lib/container/FallbackDependency.js +2 -1
- package/lib/container/FallbackModule.js +19 -14
- package/lib/container/FallbackModuleFactory.js +2 -2
- package/lib/container/HoistContainerReferencesPlugin.js +7 -7
- package/lib/container/ModuleFederationPlugin.js +4 -4
- package/lib/container/RemoteModule.js +14 -14
- package/lib/container/RemoteRuntimeModule.js +2 -2
- package/lib/container/options.js +9 -9
- package/lib/css/CssGenerator.js +366 -74
- package/lib/css/CssLoadingRuntimeModule.js +26 -16
- package/lib/css/CssMergeStyleSheetsRuntimeModule.js +56 -0
- package/lib/css/CssModulesPlugin.js +191 -142
- package/lib/css/CssParser.js +1756 -740
- package/lib/css/walkCssTokens.js +180 -67
- package/lib/debug/ProfilingPlugin.js +135 -51
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +29 -28
- package/lib/dependencies/AMDPlugin.js +18 -11
- package/lib/dependencies/AMDRequireArrayDependency.js +5 -4
- package/lib/dependencies/AMDRequireContextDependency.js +2 -1
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +35 -26
- package/lib/dependencies/AMDRuntimeModules.js +3 -1
- package/lib/dependencies/CachedConstDependency.js +24 -18
- package/lib/dependencies/CommonJsExportRequireDependency.js +31 -24
- package/lib/dependencies/CommonJsExportsDependency.js +2 -1
- package/lib/dependencies/CommonJsExportsParserPlugin.js +50 -36
- package/lib/dependencies/CommonJsFullRequireDependency.js +7 -13
- package/lib/dependencies/CommonJsImportsParserPlugin.js +146 -127
- package/lib/dependencies/CommonJsPlugin.js +29 -18
- package/lib/dependencies/CommonJsRequireContextDependency.js +4 -3
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +4 -4
- package/lib/dependencies/ConstDependency.js +2 -2
- package/lib/dependencies/ContextDependency.js +10 -5
- package/lib/dependencies/ContextDependencyHelpers.js +21 -13
- package/lib/dependencies/ContextDependencyTemplateAsId.js +10 -9
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +13 -10
- package/lib/dependencies/ContextElementDependency.js +23 -12
- package/lib/dependencies/CssIcssExportDependency.js +402 -22
- package/lib/dependencies/CssIcssImportDependency.js +116 -51
- package/lib/dependencies/CssIcssSymbolDependency.js +33 -35
- package/lib/dependencies/CssImportDependency.js +17 -14
- package/lib/dependencies/CssUrlDependency.js +8 -13
- package/lib/dependencies/DynamicExports.js +19 -19
- package/lib/dependencies/ExportsInfoDependency.js +13 -10
- package/lib/dependencies/ExternalModuleDependency.js +7 -7
- package/lib/dependencies/ExternalModuleInitFragment.js +3 -2
- package/lib/dependencies/ExternalModuleInitFragmentDependency.js +96 -0
- package/lib/dependencies/HarmonyAcceptDependency.js +96 -5
- package/lib/dependencies/HarmonyAcceptImportDependency.js +2 -5
- package/lib/dependencies/HarmonyCompatibilityDependency.js +0 -1
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +10 -30
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +19 -8
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +136 -99
- package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +152 -61
- package/lib/dependencies/HarmonyExportInitFragment.js +2 -2
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +2 -2
- package/lib/dependencies/HarmonyExports.js +5 -5
- package/lib/dependencies/HarmonyImportDependency.js +92 -45
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +201 -163
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +5 -6
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +69 -42
- package/lib/dependencies/HarmonyModulesPlugin.js +16 -11
- package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +15 -15
- package/lib/dependencies/ImportContextDependency.js +15 -1
- package/lib/dependencies/ImportDependency.js +25 -7
- package/lib/dependencies/ImportEagerDependency.js +7 -5
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +23 -13
- package/lib/dependencies/ImportMetaContextPlugin.js +2 -2
- package/lib/dependencies/ImportMetaPlugin.js +172 -20
- package/lib/dependencies/ImportParserPlugin.js +327 -49
- package/lib/dependencies/ImportPhase.js +121 -0
- package/lib/dependencies/ImportPlugin.js +3 -1
- package/lib/dependencies/ImportWeakDependency.js +7 -5
- package/lib/dependencies/JsonExportsDependency.js +54 -28
- package/lib/dependencies/LoaderDependency.js +0 -3
- package/lib/dependencies/LoaderImportDependency.js +0 -3
- package/lib/dependencies/LoaderPlugin.js +24 -25
- package/lib/dependencies/LocalModulesHelpers.js +4 -4
- package/lib/dependencies/ModuleDecoratorDependency.js +2 -4
- package/lib/dependencies/ModuleDependency.js +14 -13
- package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +1 -0
- package/lib/dependencies/ModuleHotAcceptDependency.js +1 -1
- package/lib/dependencies/NullDependency.js +2 -0
- package/lib/dependencies/ProvidedDependency.js +8 -10
- package/lib/dependencies/PureExpressionDependency.js +1 -2
- package/lib/dependencies/RequireContextDependency.js +2 -1
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +47 -44
- package/lib/dependencies/RequireContextPlugin.js +5 -2
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +3 -3
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +101 -99
- package/lib/dependencies/RequireEnsurePlugin.js +6 -6
- package/lib/dependencies/RequireIncludeDependency.js +2 -2
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +33 -34
- package/lib/dependencies/RequireIncludePlugin.js +1 -0
- package/lib/dependencies/RequireResolveContextDependency.js +1 -1
- package/lib/dependencies/RequireResolveDependency.js +3 -3
- package/lib/dependencies/RuntimeRequirementsDependency.js +3 -4
- package/lib/dependencies/StaticExportsDependency.js +3 -5
- package/lib/dependencies/SystemPlugin.js +4 -4
- package/lib/dependencies/URLContextDependency.js +65 -0
- package/lib/dependencies/URLDependency.js +3 -8
- package/lib/dependencies/URLPlugin.js +18 -159
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +3 -3
- package/lib/dependencies/WebAssemblyImportDependency.js +2 -2
- package/lib/dependencies/WebpackIsIncludedDependency.js +2 -3
- package/lib/dependencies/WorkerDependency.js +8 -6
- package/lib/dependencies/WorkerPlugin.js +131 -67
- package/lib/dependencies/getFunctionExpression.js +2 -2
- package/lib/dependencies/processExportInfo.js +4 -4
- package/lib/esm/ExportWebpackRequireRuntimeModule.js +1 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +232 -179
- package/lib/esm/ModuleChunkLoadingPlugin.js +112 -57
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +102 -28
- package/lib/formatLocation.js +2 -2
- package/lib/hmr/HotModuleReplacement.runtime.js +41 -29
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -1
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +43 -33
- package/lib/hmr/JavascriptHotModuleReplacementHelper.js +37 -0
- package/lib/hmr/LazyCompilationPlugin.js +67 -54
- package/lib/hmr/lazyCompilationBackend.js +23 -18
- package/lib/ids/ChunkModuleIdRangePlugin.js +14 -11
- package/lib/ids/DeterministicChunkIdsPlugin.js +32 -37
- package/lib/ids/DeterministicModuleIdsPlugin.js +52 -52
- package/lib/ids/HashedModuleIdsPlugin.js +15 -13
- package/lib/ids/IdHelpers.js +66 -49
- package/lib/ids/NamedChunkIdsPlugin.js +14 -17
- package/lib/ids/NamedModuleIdsPlugin.js +12 -14
- package/lib/ids/NaturalChunkIdsPlugin.js +6 -4
- package/lib/ids/NaturalModuleIdsPlugin.js +4 -3
- package/lib/ids/OccurrenceChunkIdsPlugin.js +7 -5
- package/lib/ids/OccurrenceModuleIdsPlugin.js +8 -7
- package/lib/ids/SyncModuleIdsPlugin.js +18 -13
- package/lib/index.js +54 -14
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +116 -119
- package/lib/javascript/BasicEvaluatedExpression.js +26 -18
- package/lib/javascript/ChunkFormatHelpers.js +70 -0
- package/lib/javascript/ChunkHelpers.js +17 -5
- package/lib/javascript/CommonJsChunkFormatPlugin.js +114 -141
- package/lib/javascript/EnableChunkLoadingPlugin.js +7 -4
- package/lib/javascript/JavascriptGenerator.js +122 -100
- package/lib/javascript/JavascriptModulesPlugin.js +332 -152
- package/lib/javascript/JavascriptParser.js +1488 -1052
- package/lib/javascript/JavascriptParserHelpers.js +48 -47
- package/lib/javascript/StartupHelpers.js +23 -22
- package/lib/json/JsonData.js +4 -4
- package/lib/json/JsonGenerator.js +66 -32
- package/lib/json/JsonModulesPlugin.js +16 -6
- package/lib/json/JsonParser.js +23 -8
- package/lib/library/AbstractLibraryPlugin.js +45 -10
- package/lib/library/AmdLibraryPlugin.js +7 -5
- package/lib/library/AssignLibraryPlugin.js +71 -17
- package/lib/library/EnableLibraryPlugin.js +51 -25
- package/lib/library/ExportPropertyLibraryPlugin.js +12 -18
- package/lib/library/JsonpLibraryPlugin.js +5 -2
- package/lib/library/ModuleLibraryPlugin.js +230 -18
- package/lib/library/SystemLibraryPlugin.js +29 -11
- package/lib/library/UmdLibraryPlugin.js +35 -32
- package/lib/logging/Logger.js +18 -15
- package/lib/logging/createConsoleLogger.js +27 -27
- package/lib/logging/runtime.js +11 -11
- package/lib/logging/truncateArgs.js +5 -5
- package/lib/node/CommonJsChunkLoadingPlugin.js +72 -75
- package/lib/node/NodeEnvironmentPlugin.js +9 -3
- package/lib/node/NodeTargetPlugin.js +9 -1
- package/lib/node/NodeTemplatePlugin.js +2 -2
- package/lib/node/NodeWatchFileSystem.js +4 -4
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +22 -38
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +10 -11
- package/lib/node/ReadFileCompileWasmPlugin.js +11 -14
- package/lib/node/RequireChunkLoadingRuntimeModule.js +22 -30
- package/lib/node/nodeConsole.js +12 -7
- package/lib/optimize/AggressiveMergingPlugin.js +46 -47
- package/lib/optimize/AggressiveSplittingPlugin.js +233 -238
- package/lib/optimize/ConcatenatedModule.js +620 -251
- package/lib/optimize/EnsureChunkConditionsPlugin.js +58 -58
- package/lib/optimize/FlagIncludedChunksPlugin.js +93 -96
- package/lib/optimize/InnerGraph.js +139 -124
- package/lib/optimize/InnerGraphPlugin.js +29 -24
- package/lib/optimize/LimitChunkCountPlugin.js +32 -8
- package/lib/optimize/MangleExportsPlugin.js +22 -22
- package/lib/optimize/MergeDuplicateChunksPlugin.js +80 -81
- package/lib/optimize/MinChunkSizePlugin.js +12 -7
- package/lib/optimize/ModuleConcatenationPlugin.js +92 -71
- package/lib/optimize/RealContentHashPlugin.js +58 -44
- package/lib/optimize/RemoveEmptyChunksPlugin.js +8 -5
- package/lib/optimize/RemoveParentModulesPlugin.js +7 -4
- package/lib/optimize/RuntimeChunkPlugin.js +22 -25
- package/lib/optimize/SideEffectsFlagPlugin.js +44 -26
- package/lib/optimize/SplitChunksPlugin.js +209 -158
- package/lib/performance/AssetsOverSizeLimitWarning.js +1 -1
- package/lib/performance/EntrypointsOverSizeLimitWarning.js +2 -2
- package/lib/performance/SizeLimitsPlugin.js +8 -5
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +5 -7
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +61 -64
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +3 -4
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +2 -2
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +2 -2
- package/lib/rules/BasicEffectRulePlugin.js +14 -5
- package/lib/rules/BasicMatcherRulePlugin.js +18 -7
- package/lib/rules/ObjectMatcherRulePlugin.js +17 -6
- package/lib/rules/RuleSetCompiler.js +73 -32
- package/lib/rules/UseEffectRulePlugin.js +61 -25
- package/lib/runtime/AsyncModuleRuntimeModule.js +74 -9
- package/lib/runtime/AutoPublicPathRuntimeModule.js +9 -4
- package/lib/runtime/BaseUriRuntimeModule.js +2 -2
- package/lib/runtime/CompatRuntimeModule.js +0 -1
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +1 -1
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +34 -35
- package/lib/runtime/GetMainFilenameRuntimeModule.js +1 -1
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -1
- package/lib/runtime/LoadScriptRuntimeModule.js +0 -2
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +248 -0
- package/lib/runtime/PublicPathRuntimeModule.js +2 -2
- package/lib/runtime/RuntimeIdRuntimeModule.js +2 -1
- package/lib/runtime/StartupChunkDependenciesPlugin.js +39 -42
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +10 -9
- package/lib/runtime/StartupEntrypointRuntimeModule.js +0 -1
- package/lib/runtime/SystemContextRuntimeModule.js +0 -2
- package/lib/runtime/ToBinaryRuntimeModule.js +64 -0
- package/lib/schemes/DataUriPlugin.js +9 -31
- package/lib/schemes/FileUriPlugin.js +11 -6
- package/lib/schemes/HttpUriPlugin.js +381 -261
- package/lib/schemes/VirtualUrlPlugin.js +222 -0
- package/lib/serialization/AggregateErrorSerializer.js +41 -0
- package/lib/serialization/BinaryMiddleware.js +51 -33
- package/lib/serialization/ErrorObjectSerializer.js +7 -2
- package/lib/serialization/FileMiddleware.js +101 -71
- package/lib/serialization/NullPrototypeObjectSerializer.js +5 -3
- package/lib/serialization/ObjectMiddleware.js +130 -54
- package/lib/serialization/PlainObjectSerializer.js +1 -1
- package/lib/serialization/Serializer.js +38 -20
- package/lib/serialization/SerializerMiddleware.js +121 -49
- package/lib/serialization/SingleItemMiddleware.js +9 -7
- package/lib/serialization/types.js +1 -1
- package/lib/sharing/ConsumeSharedModule.js +9 -9
- package/lib/sharing/ConsumeSharedPlugin.js +14 -14
- package/lib/sharing/ConsumeSharedRuntimeModule.js +11 -8
- package/lib/sharing/ProvideSharedModule.js +9 -11
- package/lib/sharing/ProvideSharedModuleFactory.js +5 -3
- package/lib/sharing/ProvideSharedPlugin.js +15 -10
- package/lib/sharing/SharePlugin.js +3 -4
- package/lib/sharing/ShareRuntimeModule.js +7 -6
- package/lib/sharing/resolveMatchedConfigs.js +27 -13
- package/lib/sharing/utils.js +37 -43
- package/lib/stats/DefaultStatsFactoryPlugin.js +455 -286
- package/lib/stats/DefaultStatsPresetPlugin.js +77 -46
- package/lib/stats/DefaultStatsPrinterPlugin.js +583 -419
- package/lib/stats/StatsFactory.js +75 -32
- package/lib/stats/StatsPrinter.js +71 -51
- package/lib/url/URLParserPlugin.js +264 -0
- package/lib/util/ArrayHelpers.js +6 -8
- package/lib/util/ArrayQueue.js +1 -1
- package/lib/util/AsyncQueue.js +11 -10
- package/lib/util/Hash.js +37 -5
- package/lib/util/IterableHelpers.js +4 -4
- package/lib/util/LazyBucketSortedSet.js +46 -27
- package/lib/util/LazySet.js +16 -10
- package/lib/util/MapHelpers.js +1 -1
- package/lib/util/ParallelismFactorCalculator.js +2 -2
- package/lib/util/Semaphore.js +3 -3
- package/lib/util/SetHelpers.js +6 -6
- package/lib/util/SortableSet.js +11 -9
- package/lib/util/StackedCacheMap.js +2 -2
- package/lib/util/StackedMap.js +3 -3
- package/lib/util/StringXor.js +2 -1
- package/lib/util/TupleQueue.js +11 -8
- package/lib/util/TupleSet.js +44 -19
- package/lib/util/URLAbsoluteSpecifier.js +3 -4
- package/lib/util/WeakTupleMap.js +56 -42
- package/lib/util/binarySearchBounds.js +4 -3
- package/lib/util/chainedImports.js +3 -1
- package/lib/util/cleverMerge.js +171 -107
- package/lib/util/comparators.js +265 -162
- package/lib/util/compileBooleanMatcher.js +120 -41
- package/lib/util/concatenate.js +20 -16
- package/lib/util/conventions.js +73 -74
- package/lib/util/create-schema-validation.js +8 -8
- package/lib/util/createHash.js +32 -135
- package/lib/util/dataURL.js +39 -0
- package/lib/util/deprecation.js +119 -116
- package/lib/util/deterministicGrouping.js +56 -47
- package/lib/util/extractSourceMap.js +319 -0
- package/lib/util/extractUrlAndGlobal.js +1 -1
- package/lib/util/findGraphRoots.js +19 -9
- package/lib/util/fs.js +169 -141
- package/lib/util/hash/BatchedHash.js +50 -10
- package/lib/util/hash/BulkUpdateHash.js +138 -0
- package/lib/util/hash/DebugHash.js +75 -0
- package/lib/util/hash/hash-digest.js +216 -0
- package/lib/util/hash/md4.js +2 -2
- package/lib/util/hash/wasm-hash.js +59 -17
- package/lib/util/identifier.js +124 -61
- package/lib/util/internalSerializables.js +4 -6
- package/lib/util/magicComment.js +9 -5
- package/lib/util/makeSerializable.js +2 -2
- package/lib/util/memoize.js +5 -2
- package/lib/util/objectToMap.js +3 -2
- package/lib/util/processAsyncTree.js +5 -5
- package/lib/util/propertyAccess.js +1 -1
- package/lib/util/propertyName.js +2 -3
- package/lib/util/registerExternalSerializer.js +16 -20
- package/lib/util/removeBOM.js +25 -0
- package/lib/util/runtime.js +72 -56
- package/lib/util/semver.js +44 -33
- package/lib/util/serialization.js +56 -56
- package/lib/util/smartGrouping.js +42 -27
- package/lib/util/source.js +5 -4
- package/lib/util/traverseDestructuringAssignmentProperties.js +45 -0
- package/lib/validateSchema.js +7 -9
- package/lib/wasm/EnableWasmLoadingPlugin.js +22 -12
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +9 -5
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +15 -3
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +28 -22
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +47 -57
- package/lib/wasm-async/AsyncWebAssemblyParser.js +2 -10
- package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +8 -4
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +23 -17
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +55 -57
- package/lib/wasm-sync/WebAssemblyGenerator.js +56 -41
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +6 -3
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +25 -10
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +11 -12
- package/lib/wasm-sync/WebAssemblyParser.js +10 -17
- package/lib/wasm-sync/WebAssemblyUtils.js +1 -1
- package/lib/web/FetchCompileAsyncWasmPlugin.js +4 -4
- package/lib/web/FetchCompileWasmPlugin.js +6 -8
- package/lib/web/JsonpChunkLoadingPlugin.js +74 -74
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +10 -26
- package/lib/web/JsonpTemplatePlugin.js +0 -1
- package/lib/webpack.js +107 -87
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +79 -75
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +38 -51
- package/lib/webworker/WebWorkerTemplatePlugin.js +1 -0
- package/module.d.ts +5 -0
- package/package.json +149 -129
- package/schemas/WebpackOptions.check.d.ts +1 -1
- package/schemas/WebpackOptions.check.js +2 -2
- package/schemas/WebpackOptions.json +543 -190
- package/schemas/plugins/BannerPlugin.check.d.ts +1 -1
- package/schemas/plugins/BannerPlugin.check.js +2 -2
- package/schemas/plugins/BannerPlugin.json +4 -0
- package/schemas/plugins/DllPlugin.check.d.ts +1 -1
- package/schemas/plugins/DllPlugin.check.js +1 -1
- package/schemas/plugins/DllReferencePlugin.check.d.ts +1 -1
- package/schemas/plugins/DllReferencePlugin.check.js +1 -1
- package/schemas/plugins/IgnorePlugin.check.d.ts +1 -1
- package/schemas/plugins/IgnorePlugin.check.js +1 -1
- package/schemas/plugins/IgnorePlugin.json +1 -1
- package/schemas/plugins/LoaderOptionsPlugin.check.d.ts +1 -1
- package/schemas/plugins/LoaderOptionsPlugin.check.js +1 -1
- package/schemas/plugins/{HashedModuleIdsPlugin.check.d.ts → ManifestPlugin.check.d.ts} +2 -2
- package/schemas/plugins/ManifestPlugin.check.js +6 -0
- package/schemas/plugins/ManifestPlugin.json +98 -0
- package/schemas/plugins/ProgressPlugin.check.d.ts +1 -1
- package/schemas/plugins/ProgressPlugin.check.js +1 -1
- package/schemas/plugins/ProgressPlugin.json +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.check.d.ts +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +2 -2
- package/schemas/plugins/SourceMapDevToolPlugin.json +23 -6
- package/schemas/plugins/WatchIgnorePlugin.check.d.ts +1 -1
- package/schemas/plugins/WatchIgnorePlugin.check.js +1 -1
- package/schemas/plugins/asset/AssetGeneratorOptions.check.d.ts +1 -1
- package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.d.ts +1 -1
- package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetParserOptions.check.d.ts +1 -1
- package/schemas/plugins/asset/AssetParserOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.d.ts +1 -1
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
- package/schemas/plugins/container/ContainerPlugin.check.d.ts +1 -1
- package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.check.d.ts +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +2 -2
- package/schemas/plugins/container/ContainerReferencePlugin.json +4 -1
- package/schemas/plugins/container/ExternalsType.check.d.ts +1 -1
- package/schemas/plugins/container/ExternalsType.check.js +2 -2
- package/schemas/plugins/container/ModuleFederationPlugin.check.d.ts +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +2 -2
- package/schemas/plugins/container/ModuleFederationPlugin.json +4 -1
- package/schemas/plugins/css/CssGeneratorOptions.check.d.ts +1 -1
- package/schemas/plugins/css/CssGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.d.ts +1 -1
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +2 -2
- package/schemas/plugins/css/CssModuleParserOptions.check.d.ts +1 -1
- package/schemas/plugins/css/CssModuleParserOptions.check.js +2 -2
- package/schemas/plugins/css/CssParserOptions.check.d.ts +1 -1
- package/schemas/plugins/css/CssParserOptions.check.js +2 -2
- package/schemas/plugins/debug/ProfilingPlugin.check.d.ts +1 -1
- package/schemas/plugins/debug/ProfilingPlugin.check.js +1 -1
- package/schemas/plugins/ids/HashedModuleIdsPlugin.check.d.ts +7 -0
- package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +6 -0
- package/schemas/plugins/{HashedModuleIdsPlugin.json → ids/HashedModuleIdsPlugin.json} +15 -2
- package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.d.ts +1 -1
- package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.js +1 -1
- package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.d.ts +1 -1
- package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.js +1 -1
- package/schemas/plugins/{css/CssGlobalParserOptions.check.d.ts → json/JsonModulesPluginGenerator.check.d.ts} +1 -1
- package/schemas/plugins/json/JsonModulesPluginGenerator.check.js +6 -0
- package/schemas/plugins/json/JsonModulesPluginGenerator.json +3 -0
- package/schemas/plugins/{css/CssGlobalGeneratorOptions.check.d.ts → json/JsonModulesPluginParser.check.d.ts} +1 -1
- package/schemas/plugins/json/JsonModulesPluginParser.check.js +6 -0
- package/schemas/plugins/json/JsonModulesPluginParser.json +3 -0
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.d.ts +1 -1
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.js +1 -1
- package/schemas/plugins/optimize/LimitChunkCountPlugin.check.d.ts +1 -1
- package/schemas/plugins/optimize/LimitChunkCountPlugin.check.js +1 -1
- package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.d.ts +1 -1
- package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.js +1 -1
- package/schemas/plugins/optimize/MinChunkSizePlugin.check.d.ts +1 -1
- package/schemas/plugins/optimize/MinChunkSizePlugin.check.js +1 -1
- package/schemas/plugins/schemes/HttpUriPlugin.check.d.ts +1 -1
- package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.d.ts +7 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +6 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +77 -0
- package/schemas/plugins/sharing/ConsumeSharedPlugin.check.d.ts +1 -1
- package/schemas/plugins/sharing/ConsumeSharedPlugin.check.js +1 -1
- package/schemas/plugins/sharing/ProvideSharedPlugin.check.d.ts +1 -1
- package/schemas/plugins/sharing/ProvideSharedPlugin.check.js +1 -1
- package/schemas/plugins/sharing/SharePlugin.check.d.ts +1 -1
- package/schemas/plugins/sharing/SharePlugin.check.js +1 -1
- package/types.d.ts +5115 -1863
- package/SECURITY.md +0 -9
- package/lib/ModuleSourceTypesConstants.js +0 -112
- package/lib/dependencies/CssLocalIdentifierDependency.js +0 -250
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +0 -111
- package/lib/library/ModernModuleLibraryPlugin.js +0 -144
- package/schemas/plugins/HashedModuleIdsPlugin.check.js +0 -6
- package/schemas/plugins/JsonModulesPluginParser.check.d.ts +0 -7
- package/schemas/plugins/JsonModulesPluginParser.check.js +0 -6
- package/schemas/plugins/JsonModulesPluginParser.json +0 -12
- package/schemas/plugins/css/CssAutoGeneratorOptions.check.d.ts +0 -7
- package/schemas/plugins/css/CssAutoGeneratorOptions.check.js +0 -6
- package/schemas/plugins/css/CssAutoGeneratorOptions.json +0 -3
- package/schemas/plugins/css/CssAutoParserOptions.check.d.ts +0 -7
- package/schemas/plugins/css/CssAutoParserOptions.check.js +0 -6
- package/schemas/plugins/css/CssAutoParserOptions.json +0 -3
- package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +0 -6
- package/schemas/plugins/css/CssGlobalGeneratorOptions.json +0 -3
- package/schemas/plugins/css/CssGlobalParserOptions.check.js +0 -6
- package/schemas/plugins/css/CssGlobalParserOptions.json +0 -3
|
@@ -9,10 +9,10 @@ const { getContext } = require("loader-runner");
|
|
|
9
9
|
const asyncLib = require("neo-async");
|
|
10
10
|
const {
|
|
11
11
|
AsyncSeriesBailHook,
|
|
12
|
-
|
|
12
|
+
HookMap,
|
|
13
13
|
SyncBailHook,
|
|
14
14
|
SyncHook,
|
|
15
|
-
|
|
15
|
+
SyncWaterfallHook
|
|
16
16
|
} = require("tapable");
|
|
17
17
|
const ChunkGraph = require("./ChunkGraph");
|
|
18
18
|
const Module = require("./Module");
|
|
@@ -34,9 +34,13 @@ const {
|
|
|
34
34
|
parseResourceWithoutFragment
|
|
35
35
|
} = require("./util/identifier");
|
|
36
36
|
|
|
37
|
+
/** @typedef {import("enhanced-resolve").ResolveContext} ResolveContext */
|
|
38
|
+
/** @typedef {import("enhanced-resolve").ResolveRequest} ResolveRequest */
|
|
37
39
|
/** @typedef {import("../declarations/WebpackOptions").ModuleOptionsNormalized} ModuleOptions */
|
|
38
40
|
/** @typedef {import("../declarations/WebpackOptions").RuleSetRule} RuleSetRule */
|
|
41
|
+
/** @typedef {import("./Compilation").FileSystemDependencies} FileSystemDependencies */
|
|
39
42
|
/** @typedef {import("./Generator")} Generator */
|
|
43
|
+
/** @typedef {import("./ModuleFactory").ModuleFactoryCallback} ModuleFactoryCallback */
|
|
40
44
|
/** @typedef {import("./ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
|
|
41
45
|
/** @typedef {import("./ModuleFactory").ModuleFactoryCreateDataContextInfo} ModuleFactoryCreateDataContextInfo */
|
|
42
46
|
/** @typedef {import("./ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */
|
|
@@ -46,13 +50,19 @@ const {
|
|
|
46
50
|
/** @typedef {import("./NormalModule").ParserOptions} ParserOptions */
|
|
47
51
|
/** @typedef {import("./Parser")} Parser */
|
|
48
52
|
/** @typedef {import("./ResolverFactory")} ResolverFactory */
|
|
49
|
-
/** @typedef {import("./ResolverFactory").ResolveContext} ResolveContext */
|
|
50
|
-
/** @typedef {import("./ResolverFactory").ResolveRequest} ResolveRequest */
|
|
51
53
|
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
|
52
54
|
/** @typedef {import("./dependencies/ModuleDependency")} ModuleDependency */
|
|
55
|
+
/** @typedef {import("./javascript/JavascriptParser").ImportAttributes} ImportAttributes */
|
|
56
|
+
/** @typedef {import("./rules/RuleSetCompiler").RuleSetRules} RuleSetRules */
|
|
53
57
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
|
58
|
+
/** @typedef {import("./util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */
|
|
54
59
|
|
|
55
|
-
/**
|
|
60
|
+
/**
|
|
61
|
+
* @template T
|
|
62
|
+
* @typedef {import("./Compiler").Callback<T>} Callback
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
/** @typedef {Pick<RuleSetRule, "type" | "sideEffects" | "parser" | "generator" | "resolve" | "layer" | "extractSourceMap">} ModuleSettings */
|
|
56
66
|
/** @typedef {Partial<NormalModuleCreateData & { settings: ModuleSettings }>} CreateData */
|
|
57
67
|
|
|
58
68
|
/**
|
|
@@ -61,13 +71,13 @@ const {
|
|
|
61
71
|
* @property {ModuleFactoryCreateData["resolveOptions"]} resolveOptions
|
|
62
72
|
* @property {string} context
|
|
63
73
|
* @property {string} request
|
|
64
|
-
* @property {
|
|
74
|
+
* @property {ImportAttributes | undefined} attributes
|
|
65
75
|
* @property {ModuleDependency[]} dependencies
|
|
66
76
|
* @property {string} dependencyType
|
|
67
77
|
* @property {CreateData} createData
|
|
68
|
-
* @property {
|
|
69
|
-
* @property {
|
|
70
|
-
* @property {
|
|
78
|
+
* @property {FileSystemDependencies} fileDependencies
|
|
79
|
+
* @property {FileSystemDependencies} missingDependencies
|
|
80
|
+
* @property {FileSystemDependencies} contextDependencies
|
|
71
81
|
* @property {Module=} ignoredModule
|
|
72
82
|
* @property {boolean} cacheable allow to use the unsafe cache
|
|
73
83
|
*/
|
|
@@ -81,7 +91,15 @@ const {
|
|
|
81
91
|
* @property {string=} context
|
|
82
92
|
*/
|
|
83
93
|
|
|
84
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
* @typedef {object} ResourceSchemeData
|
|
96
|
+
* @property {string=} mimetype mime type of the resource
|
|
97
|
+
* @property {string=} parameters additional parameters for the resource
|
|
98
|
+
* @property {"base64" | false=} encoding encoding of the resource
|
|
99
|
+
* @property {string=} encodedContent encoded content of the resource
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
/** @typedef {ResourceData & { data: ResourceSchemeData & Partial<ResolveRequest> }} ResourceDataWithData */
|
|
85
103
|
|
|
86
104
|
/**
|
|
87
105
|
* @typedef {object} ParsedLoaderRequest
|
|
@@ -89,13 +107,24 @@ const {
|
|
|
89
107
|
* @property {string|undefined} options options
|
|
90
108
|
*/
|
|
91
109
|
|
|
92
|
-
/**
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
*/
|
|
110
|
+
/** @typedef {import("./ModuleTypeConstants").JAVASCRIPT_MODULE_TYPE_AUTO} JAVASCRIPT_MODULE_TYPE_AUTO */
|
|
111
|
+
/** @typedef {import("./ModuleTypeConstants").JAVASCRIPT_MODULE_TYPE_DYNAMIC} JAVASCRIPT_MODULE_TYPE_DYNAMIC */
|
|
112
|
+
/** @typedef {import("./ModuleTypeConstants").JAVASCRIPT_MODULE_TYPE_ESM} JAVASCRIPT_MODULE_TYPE_ESM */
|
|
113
|
+
/** @typedef {import("./ModuleTypeConstants").JSON_MODULE_TYPE} JSON_MODULE_TYPE */
|
|
114
|
+
/** @typedef {import("./ModuleTypeConstants").ASSET_MODULE_TYPE} ASSET_MODULE_TYPE */
|
|
115
|
+
/** @typedef {import("./ModuleTypeConstants").ASSET_MODULE_TYPE_INLINE} ASSET_MODULE_TYPE_INLINE */
|
|
116
|
+
/** @typedef {import("./ModuleTypeConstants").ASSET_MODULE_TYPE_RESOURCE} ASSET_MODULE_TYPE_RESOURCE */
|
|
117
|
+
/** @typedef {import("./ModuleTypeConstants").ASSET_MODULE_TYPE_SOURCE} ASSET_MODULE_TYPE_SOURCE */
|
|
118
|
+
/** @typedef {import("./ModuleTypeConstants").ASSET_MODULE_TYPE_BYTES} ASSET_MODULE_TYPE_BYTES */
|
|
119
|
+
/** @typedef {import("./ModuleTypeConstants").WEBASSEMBLY_MODULE_TYPE_ASYNC} WEBASSEMBLY_MODULE_TYPE_ASYNC */
|
|
120
|
+
/** @typedef {import("./ModuleTypeConstants").WEBASSEMBLY_MODULE_TYPE_SYNC} WEBASSEMBLY_MODULE_TYPE_SYNC */
|
|
121
|
+
/** @typedef {import("./ModuleTypeConstants").CSS_MODULE_TYPE} CSS_MODULE_TYPE */
|
|
122
|
+
/** @typedef {import("./ModuleTypeConstants").CSS_MODULE_TYPE_GLOBAL} CSS_MODULE_TYPE_GLOBAL */
|
|
123
|
+
/** @typedef {import("./ModuleTypeConstants").CSS_MODULE_TYPE_MODULE} CSS_MODULE_TYPE_MODULE */
|
|
124
|
+
/** @typedef {import("./ModuleTypeConstants").CSS_MODULE_TYPE_AUTO} CSS_MODULE_TYPE_AUTO */
|
|
125
|
+
|
|
126
|
+
/** @typedef {JAVASCRIPT_MODULE_TYPE_AUTO | JAVASCRIPT_MODULE_TYPE_DYNAMIC | JAVASCRIPT_MODULE_TYPE_ESM | JSON_MODULE_TYPE | ASSET_MODULE_TYPE | ASSET_MODULE_TYPE_INLINE | ASSET_MODULE_TYPE_RESOURCE | ASSET_MODULE_TYPE_SOURCE | WEBASSEMBLY_MODULE_TYPE_ASYNC | WEBASSEMBLY_MODULE_TYPE_SYNC | CSS_MODULE_TYPE | CSS_MODULE_TYPE_GLOBAL | CSS_MODULE_TYPE_MODULE | CSS_MODULE_TYPE_AUTO} KnownNormalModuleTypes */
|
|
127
|
+
/** @typedef {KnownNormalModuleTypes | string} NormalModuleTypes */
|
|
99
128
|
|
|
100
129
|
const EMPTY_RESOLVE_OPTIONS = {};
|
|
101
130
|
/** @type {ParserOptions} */
|
|
@@ -112,7 +141,7 @@ const LEADING_DOT_EXTENSION_REGEX = /^[^.]/;
|
|
|
112
141
|
* @param {LoaderItem} data data
|
|
113
142
|
* @returns {string} ident
|
|
114
143
|
*/
|
|
115
|
-
const loaderToIdent = data => {
|
|
144
|
+
const loaderToIdent = (data) => {
|
|
116
145
|
if (!data.options) {
|
|
117
146
|
return data.loader;
|
|
118
147
|
}
|
|
@@ -146,7 +175,7 @@ const stringifyLoadersAndResource = (loaders, resource) => {
|
|
|
146
175
|
* @param {(err?: null | Error) => void} callback callback
|
|
147
176
|
* @returns {(err?: null | Error) => void} callback
|
|
148
177
|
*/
|
|
149
|
-
const needCalls = (times, callback) => err => {
|
|
178
|
+
const needCalls = (times, callback) => (err) => {
|
|
150
179
|
if (--times === 0) {
|
|
151
180
|
return callback(err);
|
|
152
181
|
}
|
|
@@ -186,20 +215,13 @@ const mergeGlobalOptions = (globalOptions, type, localOptions) => {
|
|
|
186
215
|
|
|
187
216
|
// TODO webpack 6 remove
|
|
188
217
|
/**
|
|
218
|
+
* @template {import("tapable").Hook<EXPECTED_ANY, EXPECTED_ANY>} T
|
|
189
219
|
* @param {string} name name
|
|
190
|
-
* @param {
|
|
220
|
+
* @param {T} hook hook
|
|
191
221
|
* @returns {string} result
|
|
192
222
|
*/
|
|
193
223
|
const deprecationChangedHookMessage = (name, hook) => {
|
|
194
|
-
const names = hook.taps
|
|
195
|
-
.map(
|
|
196
|
-
/**
|
|
197
|
-
* @param {TODO} tapped tapped
|
|
198
|
-
* @returns {string} name
|
|
199
|
-
*/
|
|
200
|
-
tapped => tapped.name
|
|
201
|
-
)
|
|
202
|
-
.join(", ");
|
|
224
|
+
const names = hook.taps.map((tapped) => tapped.name).join(", ");
|
|
203
225
|
|
|
204
226
|
return (
|
|
205
227
|
`NormalModuleFactory.${name} (${names}) is no longer a waterfall hook, but a bailing hook instead. ` +
|
|
@@ -222,16 +244,18 @@ const ruleSetCompiler = new RuleSetCompiler([
|
|
|
222
244
|
new BasicMatcherRulePlugin("issuer"),
|
|
223
245
|
new BasicMatcherRulePlugin("compiler"),
|
|
224
246
|
new BasicMatcherRulePlugin("issuerLayer"),
|
|
225
|
-
new ObjectMatcherRulePlugin("assert", "
|
|
247
|
+
new ObjectMatcherRulePlugin("assert", "attributes", (value) => {
|
|
226
248
|
if (value) {
|
|
227
|
-
return
|
|
249
|
+
return (
|
|
250
|
+
/** @type {ImportAttributes} */ (value)._isLegacyAssert !== undefined
|
|
251
|
+
);
|
|
228
252
|
}
|
|
229
253
|
|
|
230
254
|
return false;
|
|
231
255
|
}),
|
|
232
|
-
new ObjectMatcherRulePlugin("with", "
|
|
256
|
+
new ObjectMatcherRulePlugin("with", "attributes", (value) => {
|
|
233
257
|
if (value) {
|
|
234
|
-
return !(/** @type {
|
|
258
|
+
return !(/** @type {ImportAttributes} */ (value)._isLegacyAssert);
|
|
235
259
|
}
|
|
236
260
|
return false;
|
|
237
261
|
}),
|
|
@@ -242,9 +266,76 @@ const ruleSetCompiler = new RuleSetCompiler([
|
|
|
242
266
|
new BasicEffectRulePlugin("resolve"),
|
|
243
267
|
new BasicEffectRulePlugin("generator"),
|
|
244
268
|
new BasicEffectRulePlugin("layer"),
|
|
269
|
+
new BasicEffectRulePlugin("extractSourceMap"),
|
|
245
270
|
new UseEffectRulePlugin()
|
|
246
271
|
]);
|
|
247
272
|
|
|
273
|
+
/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
|
|
274
|
+
/** @typedef {import("../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
|
275
|
+
/** @typedef {import("./javascript/JavascriptGenerator")} JavascriptGenerator */
|
|
276
|
+
/** @typedef {import("../declarations/WebpackOptions").EmptyGeneratorOptions} EmptyGeneratorOptions */
|
|
277
|
+
|
|
278
|
+
/** @typedef {import("./json/JsonParser")} JsonParser */
|
|
279
|
+
/** @typedef {import("../declarations/WebpackOptions").JsonParserOptions} JsonParserOptions */
|
|
280
|
+
/** @typedef {import("./json/JsonGenerator")} JsonGenerator */
|
|
281
|
+
/** @typedef {import("../declarations/WebpackOptions").JsonGeneratorOptions} JsonGeneratorOptions */
|
|
282
|
+
|
|
283
|
+
/** @typedef {import("./asset/AssetParser")} AssetParser */
|
|
284
|
+
/** @typedef {import("./asset/AssetSourceParser")} AssetSourceParser */
|
|
285
|
+
/** @typedef {import("./asset/AssetBytesParser")} AssetBytesParser */
|
|
286
|
+
/** @typedef {import("../declarations/WebpackOptions").AssetParserOptions} AssetParserOptions */
|
|
287
|
+
/** @typedef {import("../declarations/WebpackOptions").EmptyParserOptions} EmptyParserOptions */
|
|
288
|
+
/** @typedef {import("./asset/AssetGenerator")} AssetGenerator */
|
|
289
|
+
/** @typedef {import("../declarations/WebpackOptions").AssetGeneratorOptions} AssetGeneratorOptions */
|
|
290
|
+
/** @typedef {import("../declarations/WebpackOptions").AssetInlineGeneratorOptions} AssetInlineGeneratorOptions */
|
|
291
|
+
/** @typedef {import("../declarations/WebpackOptions").AssetResourceGeneratorOptions} AssetResourceGeneratorOptions */
|
|
292
|
+
/** @typedef {import("./asset/AssetSourceGenerator")} AssetSourceGenerator */
|
|
293
|
+
/** @typedef {import("./asset/AssetBytesGenerator")} AssetBytesGenerator */
|
|
294
|
+
|
|
295
|
+
/** @typedef {import("./wasm-async/AsyncWebAssemblyParser")} AsyncWebAssemblyParser */
|
|
296
|
+
/** @typedef {import("./wasm-sync/WebAssemblyParser")} WebAssemblyParser */
|
|
297
|
+
|
|
298
|
+
/** @typedef {import("./css/CssParser")} CssParser */
|
|
299
|
+
/** @typedef {import("../declarations/WebpackOptions").CssParserOptions} CssParserOptions */
|
|
300
|
+
/** @typedef {import("../declarations/WebpackOptions").CssModuleParserOptions} CssModuleParserOptions */
|
|
301
|
+
/** @typedef {import("./css/CssGenerator")} CssGenerator */
|
|
302
|
+
/** @typedef {import("../declarations/WebpackOptions").CssGeneratorOptions} CssGeneratorOptions */
|
|
303
|
+
/** @typedef {import("../declarations/WebpackOptions").CssModuleGeneratorOptions} CssModuleGeneratorOptions */
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* @typedef {[
|
|
307
|
+
* [JAVASCRIPT_MODULE_TYPE_AUTO, JavascriptParser, JavascriptParserOptions, JavascriptGenerator, EmptyGeneratorOptions],
|
|
308
|
+
* [JAVASCRIPT_MODULE_TYPE_DYNAMIC, JavascriptParser, JavascriptParserOptions, JavascriptGenerator, EmptyGeneratorOptions],
|
|
309
|
+
* [JAVASCRIPT_MODULE_TYPE_ESM, JavascriptParser, JavascriptParserOptions, JavascriptGenerator, EmptyGeneratorOptions],
|
|
310
|
+
* [JSON_MODULE_TYPE, JsonParser, JsonParserOptions, JsonGenerator, JsonGeneratorOptions],
|
|
311
|
+
* [ASSET_MODULE_TYPE, AssetParser, AssetParserOptions, AssetGenerator, AssetGeneratorOptions],
|
|
312
|
+
* [ASSET_MODULE_TYPE_INLINE, AssetParser, EmptyParserOptions, AssetGenerator, AssetGeneratorOptions],
|
|
313
|
+
* [ASSET_MODULE_TYPE_RESOURCE, AssetParser, EmptyParserOptions, AssetGenerator, AssetGeneratorOptions],
|
|
314
|
+
* [ASSET_MODULE_TYPE_SOURCE, AssetSourceParser, EmptyParserOptions, AssetSourceGenerator, EmptyGeneratorOptions],
|
|
315
|
+
* [ASSET_MODULE_TYPE_BYTES, AssetBytesParser, EmptyParserOptions, AssetBytesGenerator, EmptyGeneratorOptions],
|
|
316
|
+
* [WEBASSEMBLY_MODULE_TYPE_ASYNC, AsyncWebAssemblyParser, EmptyParserOptions, Generator, EmptyParserOptions],
|
|
317
|
+
* [WEBASSEMBLY_MODULE_TYPE_SYNC, WebAssemblyParser, EmptyParserOptions, Generator, EmptyParserOptions],
|
|
318
|
+
* [CSS_MODULE_TYPE, CssParser, CssParserOptions, CssGenerator, CssGeneratorOptions],
|
|
319
|
+
* [CSS_MODULE_TYPE_AUTO, CssParser, CssModuleParserOptions, CssGenerator, CssModuleGeneratorOptions],
|
|
320
|
+
* [CSS_MODULE_TYPE_MODULE, CssParser, CssModuleParserOptions, CssGenerator, CssModuleGeneratorOptions],
|
|
321
|
+
* [CSS_MODULE_TYPE_GLOBAL, CssParser, CssModuleParserOptions, CssGenerator, CssModuleGeneratorOptions],
|
|
322
|
+
* [string, Parser, ParserOptions, Generator, GeneratorOptions],
|
|
323
|
+
* ]} ParsersAndGeneratorsByTypes
|
|
324
|
+
*/
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* @template {unknown[]} T
|
|
328
|
+
* @template {number[]} I
|
|
329
|
+
* @typedef {{ [K in keyof I]: K extends keyof I ? I[K] extends keyof T ? T[I[K]] : never : never }} ExtractTupleElements
|
|
330
|
+
*/
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* @template {unknown[]} T
|
|
334
|
+
* @template {number[]} A
|
|
335
|
+
* @template [R=void]
|
|
336
|
+
* @typedef {T extends [infer Head extends [string, ...unknown[]], ...infer Tail extends [string, ...unknown[]][]] ? Record<Head[0], SyncBailHook<ExtractTupleElements<Head, A>, R extends number ? Head[R] : R>> & RecordFactoryFromTuple<Tail, A, R> : unknown } RecordFactoryFromTuple
|
|
337
|
+
*/
|
|
338
|
+
|
|
248
339
|
class NormalModuleFactory extends ModuleFactory {
|
|
249
340
|
/**
|
|
250
341
|
* @param {object} param params
|
|
@@ -252,16 +343,14 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
252
343
|
* @param {InputFileSystem} param.fs file system
|
|
253
344
|
* @param {ResolverFactory} param.resolverFactory resolverFactory
|
|
254
345
|
* @param {ModuleOptions} param.options options
|
|
255
|
-
* @param {
|
|
256
|
-
* @param {boolean=} param.layers enable layers
|
|
346
|
+
* @param {AssociatedObjectForCache} param.associatedObjectForCache an object to which the cache will be attached
|
|
257
347
|
*/
|
|
258
348
|
constructor({
|
|
259
349
|
context,
|
|
260
350
|
fs,
|
|
261
351
|
resolverFactory,
|
|
262
352
|
options,
|
|
263
|
-
associatedObjectForCache
|
|
264
|
-
layers = false
|
|
353
|
+
associatedObjectForCache
|
|
265
354
|
}) {
|
|
266
355
|
super();
|
|
267
356
|
this.hooks = Object.freeze({
|
|
@@ -281,23 +370,23 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
281
370
|
beforeResolve: new AsyncSeriesBailHook(["resolveData"]),
|
|
282
371
|
/** @type {AsyncSeriesBailHook<[ResolveData], false | void>} */
|
|
283
372
|
afterResolve: new AsyncSeriesBailHook(["resolveData"]),
|
|
284
|
-
/** @type {AsyncSeriesBailHook<[
|
|
373
|
+
/** @type {AsyncSeriesBailHook<[CreateData, ResolveData], Module | void>} */
|
|
285
374
|
createModule: new AsyncSeriesBailHook(["createData", "resolveData"]),
|
|
286
|
-
/** @type {SyncWaterfallHook<[Module,
|
|
375
|
+
/** @type {SyncWaterfallHook<[Module, CreateData, ResolveData]>} */
|
|
287
376
|
module: new SyncWaterfallHook(["module", "createData", "resolveData"]),
|
|
288
|
-
/** @type {
|
|
377
|
+
/** @type {import("tapable").TypedHookMap<RecordFactoryFromTuple<ParsersAndGeneratorsByTypes, [2], 1>>} */
|
|
289
378
|
createParser: new HookMap(() => new SyncBailHook(["parserOptions"])),
|
|
290
|
-
/** @type {
|
|
379
|
+
/** @type {import("tapable").TypedHookMap<RecordFactoryFromTuple<ParsersAndGeneratorsByTypes, [1, 2]>>} */
|
|
291
380
|
parser: new HookMap(() => new SyncHook(["parser", "parserOptions"])),
|
|
292
|
-
/** @type {
|
|
381
|
+
/** @type {import("tapable").TypedHookMap<RecordFactoryFromTuple<ParsersAndGeneratorsByTypes, [4], 3>>} */
|
|
293
382
|
createGenerator: new HookMap(
|
|
294
383
|
() => new SyncBailHook(["generatorOptions"])
|
|
295
384
|
),
|
|
296
|
-
/** @type {
|
|
385
|
+
/** @type {import("tapable").TypedHookMap<RecordFactoryFromTuple<ParsersAndGeneratorsByTypes, [3, 4]>>} */
|
|
297
386
|
generator: new HookMap(
|
|
298
387
|
() => new SyncHook(["generator", "generatorOptions"])
|
|
299
388
|
),
|
|
300
|
-
/** @type {HookMap<SyncBailHook<[
|
|
389
|
+
/** @type {HookMap<SyncBailHook<[CreateData, ResolveData], Module | void>>} */
|
|
301
390
|
createModuleClass: new HookMap(
|
|
302
391
|
() => new SyncBailHook(["createData", "resolveData"])
|
|
303
392
|
)
|
|
@@ -305,23 +394,24 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
305
394
|
this.resolverFactory = resolverFactory;
|
|
306
395
|
this.ruleSet = ruleSetCompiler.compile([
|
|
307
396
|
{
|
|
308
|
-
rules: options.defaultRules
|
|
397
|
+
rules: /** @type {RuleSetRules} */ (options.defaultRules)
|
|
309
398
|
},
|
|
310
399
|
{
|
|
311
|
-
rules: options.rules
|
|
400
|
+
rules: /** @type {RuleSetRules} */ (options.rules)
|
|
312
401
|
}
|
|
313
402
|
]);
|
|
314
403
|
this.context = context || "";
|
|
315
404
|
this.fs = fs;
|
|
316
405
|
this._globalParserOptions = options.parser;
|
|
317
406
|
this._globalGeneratorOptions = options.generator;
|
|
318
|
-
/** @type {Map<string, WeakMap<
|
|
407
|
+
/** @type {Map<string, WeakMap<ParserOptions, Parser>>} */
|
|
319
408
|
this.parserCache = new Map();
|
|
320
|
-
/** @type {Map<string, WeakMap<
|
|
409
|
+
/** @type {Map<string, WeakMap<GeneratorOptions, Generator>>} */
|
|
321
410
|
this.generatorCache = new Map();
|
|
322
411
|
/** @type {Set<Module>} */
|
|
323
412
|
this._restoredUnsafeCacheEntries = new Set();
|
|
324
413
|
|
|
414
|
+
/** @type {(resource: string) => import("./util/identifier").ParsedResource} */
|
|
325
415
|
const cacheParseResource = parseResource.bindCache(
|
|
326
416
|
associatedObjectForCache
|
|
327
417
|
);
|
|
@@ -344,24 +434,26 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
344
434
|
// direct module
|
|
345
435
|
if (result instanceof Module) return callback(null, result);
|
|
346
436
|
|
|
347
|
-
if (typeof result === "object")
|
|
437
|
+
if (typeof result === "object") {
|
|
348
438
|
throw new Error(
|
|
349
439
|
`${deprecationChangedHookMessage(
|
|
350
440
|
"resolve",
|
|
351
441
|
this.hooks.resolve
|
|
352
442
|
)} Returning a Module object will result in this module used as result.`
|
|
353
443
|
);
|
|
444
|
+
}
|
|
354
445
|
|
|
355
446
|
this.hooks.afterResolve.callAsync(resolveData, (err, result) => {
|
|
356
447
|
if (err) return callback(err);
|
|
357
448
|
|
|
358
|
-
if (typeof result === "object")
|
|
449
|
+
if (typeof result === "object") {
|
|
359
450
|
throw new Error(
|
|
360
451
|
deprecationChangedHookMessage(
|
|
361
452
|
"afterResolve",
|
|
362
453
|
this.hooks.afterResolve
|
|
363
454
|
)
|
|
364
455
|
);
|
|
456
|
+
}
|
|
365
457
|
|
|
366
458
|
// Ignored
|
|
367
459
|
if (result === false) return callback();
|
|
@@ -420,7 +512,7 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
420
512
|
dependencies,
|
|
421
513
|
dependencyType,
|
|
422
514
|
request,
|
|
423
|
-
|
|
515
|
+
attributes,
|
|
424
516
|
resolveOptions,
|
|
425
517
|
fileDependencies,
|
|
426
518
|
missingDependencies,
|
|
@@ -448,20 +540,22 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
448
540
|
const matchResourceMatch = MATCH_RESOURCE_REGEX.exec(request);
|
|
449
541
|
if (matchResourceMatch) {
|
|
450
542
|
let matchResource = matchResourceMatch[1];
|
|
543
|
+
// Check if matchResource starts with ./ or ../
|
|
451
544
|
if (matchResource.charCodeAt(0) === 46) {
|
|
452
|
-
// 46
|
|
545
|
+
// 46 is "."
|
|
453
546
|
const secondChar = matchResource.charCodeAt(1);
|
|
454
547
|
if (
|
|
455
|
-
secondChar === 47 ||
|
|
456
|
-
(secondChar === 46 && matchResource.charCodeAt(2) === 47)
|
|
548
|
+
secondChar === 47 || // 47 is "/"
|
|
549
|
+
(secondChar === 46 && matchResource.charCodeAt(2) === 47) // "../"
|
|
457
550
|
) {
|
|
458
|
-
//
|
|
551
|
+
// Resolve relative path against context
|
|
459
552
|
matchResource = join(this.fs, context, matchResource);
|
|
460
553
|
}
|
|
461
554
|
}
|
|
555
|
+
|
|
462
556
|
matchResourceData = {
|
|
463
|
-
|
|
464
|
-
|
|
557
|
+
...cacheParseResource(matchResource),
|
|
558
|
+
resource: matchResource
|
|
465
559
|
};
|
|
466
560
|
requestWithoutMatchResource = request.slice(
|
|
467
561
|
matchResourceMatch[0].length
|
|
@@ -486,7 +580,7 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
486
580
|
)
|
|
487
581
|
.split(/!+/);
|
|
488
582
|
unresolvedResource = /** @type {string} */ (rawElements.pop());
|
|
489
|
-
elements = rawElements.map(el => {
|
|
583
|
+
elements = rawElements.map((el) => {
|
|
490
584
|
const { path, query } = cachedParseResourceWithoutFragment(el);
|
|
491
585
|
return {
|
|
492
586
|
loader: path,
|
|
@@ -516,7 +610,7 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
516
610
|
/** @type {undefined | LoaderItem[]} */
|
|
517
611
|
let loaders;
|
|
518
612
|
|
|
519
|
-
const continueCallback = needCalls(2, err => {
|
|
613
|
+
const continueCallback = needCalls(2, (err) => {
|
|
520
614
|
if (err) return callback(err);
|
|
521
615
|
|
|
522
616
|
// translate option idents
|
|
@@ -560,8 +654,11 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
560
654
|
|
|
561
655
|
/** @type {ModuleSettings} */
|
|
562
656
|
const settings = {};
|
|
657
|
+
/** @type {LoaderItem[]} */
|
|
563
658
|
const useLoadersPost = [];
|
|
659
|
+
/** @type {LoaderItem[]} */
|
|
564
660
|
const useLoaders = [];
|
|
661
|
+
/** @type {LoaderItem[]} */
|
|
565
662
|
const useLoadersPre = [];
|
|
566
663
|
|
|
567
664
|
// handle .webpack[] suffix
|
|
@@ -586,7 +683,7 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
586
683
|
resourceQuery: resourceDataForRules.query,
|
|
587
684
|
resourceFragment: resourceDataForRules.fragment,
|
|
588
685
|
scheme,
|
|
589
|
-
|
|
686
|
+
attributes,
|
|
590
687
|
mimetype: matchResourceData
|
|
591
688
|
? ""
|
|
592
689
|
: resourceData.data.mimetype || "",
|
|
@@ -620,16 +717,16 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
620
717
|
typeof r.value === "object" &&
|
|
621
718
|
r.value !== null &&
|
|
622
719
|
typeof settings[
|
|
623
|
-
/** @type {keyof ModuleSettings} */
|
|
720
|
+
/** @type {keyof ModuleSettings} */
|
|
721
|
+
(r.type)
|
|
624
722
|
] === "object" &&
|
|
625
723
|
settings[/** @type {keyof ModuleSettings} */ (r.type)] !== null
|
|
626
724
|
) {
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
r.value
|
|
630
|
-
);
|
|
725
|
+
const type = /** @type {keyof ModuleSettings} */ (r.type);
|
|
726
|
+
settings[type] = cachedCleverMerge(settings[type], r.value);
|
|
631
727
|
} else {
|
|
632
|
-
|
|
728
|
+
const type = /** @type {keyof ModuleSettings} */ (r.type);
|
|
729
|
+
settings[type] = r.value;
|
|
633
730
|
}
|
|
634
731
|
}
|
|
635
732
|
}
|
|
@@ -641,34 +738,37 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
641
738
|
/** @type {undefined | LoaderItem[]} */
|
|
642
739
|
let preLoaders;
|
|
643
740
|
|
|
644
|
-
const continueCallback = needCalls(3, err => {
|
|
741
|
+
const continueCallback = needCalls(3, (err) => {
|
|
645
742
|
if (err) {
|
|
646
743
|
return callback(err);
|
|
647
744
|
}
|
|
648
745
|
const allLoaders = /** @type {LoaderItem[]} */ (postLoaders);
|
|
649
746
|
if (matchResourceData === undefined) {
|
|
650
|
-
for (const loader of /** @type {LoaderItem[]} */ (loaders))
|
|
747
|
+
for (const loader of /** @type {LoaderItem[]} */ (loaders)) {
|
|
651
748
|
allLoaders.push(loader);
|
|
652
|
-
|
|
749
|
+
}
|
|
750
|
+
for (const loader of /** @type {LoaderItem[]} */ (
|
|
751
|
+
normalLoaders
|
|
752
|
+
)) {
|
|
653
753
|
allLoaders.push(loader);
|
|
754
|
+
}
|
|
654
755
|
} else {
|
|
655
|
-
for (const loader of /** @type {LoaderItem[]} */ (
|
|
756
|
+
for (const loader of /** @type {LoaderItem[]} */ (
|
|
757
|
+
normalLoaders
|
|
758
|
+
)) {
|
|
656
759
|
allLoaders.push(loader);
|
|
657
|
-
|
|
760
|
+
}
|
|
761
|
+
for (const loader of /** @type {LoaderItem[]} */ (loaders)) {
|
|
658
762
|
allLoaders.push(loader);
|
|
763
|
+
}
|
|
659
764
|
}
|
|
660
|
-
for (const loader of /** @type {LoaderItem[]} */ (preLoaders))
|
|
765
|
+
for (const loader of /** @type {LoaderItem[]} */ (preLoaders)) {
|
|
661
766
|
allLoaders.push(loader);
|
|
662
|
-
|
|
767
|
+
}
|
|
768
|
+
const type = /** @type {NormalModuleTypes} */ (settings.type);
|
|
663
769
|
const resolveOptions = settings.resolve;
|
|
664
770
|
const layer = settings.layer;
|
|
665
|
-
|
|
666
|
-
return callback(
|
|
667
|
-
new Error(
|
|
668
|
-
"'Rule.layer' is only allowed when 'experiments.layers' is enabled"
|
|
669
|
-
)
|
|
670
|
-
);
|
|
671
|
-
}
|
|
771
|
+
|
|
672
772
|
try {
|
|
673
773
|
Object.assign(data.createData, {
|
|
674
774
|
layer:
|
|
@@ -693,7 +793,8 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
693
793
|
parserOptions: settings.parser,
|
|
694
794
|
generator: this.getGenerator(type, settings.generator),
|
|
695
795
|
generatorOptions: settings.generator,
|
|
696
|
-
resolveOptions
|
|
796
|
+
resolveOptions,
|
|
797
|
+
extractSourceMap: settings.extractSourceMap || false
|
|
697
798
|
});
|
|
698
799
|
} catch (createDataErr) {
|
|
699
800
|
return callback(/** @type {Error} */ (createDataErr));
|
|
@@ -751,12 +852,12 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
751
852
|
/**
|
|
752
853
|
* @param {string} context context
|
|
753
854
|
*/
|
|
754
|
-
const defaultResolve = context => {
|
|
855
|
+
const defaultResolve = (context) => {
|
|
755
856
|
if (/^($|\?)/.test(unresolvedResource)) {
|
|
756
857
|
resourceData = {
|
|
858
|
+
...cacheParseResource(unresolvedResource),
|
|
757
859
|
resource: unresolvedResource,
|
|
758
|
-
data: {}
|
|
759
|
-
...cacheParseResource(unresolvedResource)
|
|
860
|
+
data: {}
|
|
760
861
|
};
|
|
761
862
|
continueCallback();
|
|
762
863
|
}
|
|
@@ -786,11 +887,11 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
786
887
|
/** @type {string} */
|
|
787
888
|
(_resolvedResource);
|
|
788
889
|
resourceData = {
|
|
890
|
+
...cacheParseResource(resolvedResource),
|
|
789
891
|
resource: resolvedResource,
|
|
790
892
|
data:
|
|
791
893
|
/** @type {ResolveRequest} */
|
|
792
|
-
(resolvedResourceResolveData)
|
|
793
|
-
...cacheParseResource(resolvedResource)
|
|
894
|
+
(resolvedResourceResolveData)
|
|
794
895
|
};
|
|
795
896
|
}
|
|
796
897
|
continueCallback();
|
|
@@ -811,7 +912,7 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
811
912
|
};
|
|
812
913
|
this.hooks.resolveForScheme
|
|
813
914
|
.for(scheme)
|
|
814
|
-
.callAsync(resourceData, data, err => {
|
|
915
|
+
.callAsync(resourceData, data, (err) => {
|
|
815
916
|
if (err) return continueCallback(err);
|
|
816
917
|
continueCallback();
|
|
817
918
|
});
|
|
@@ -837,7 +938,9 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
837
938
|
}
|
|
838
939
|
|
|
839
940
|
// resource without scheme and without path
|
|
840
|
-
else
|
|
941
|
+
else {
|
|
942
|
+
defaultResolve(context);
|
|
943
|
+
}
|
|
841
944
|
}
|
|
842
945
|
);
|
|
843
946
|
}
|
|
@@ -852,7 +955,7 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
852
955
|
|
|
853
956
|
/**
|
|
854
957
|
* @param {ModuleFactoryCreateData} data data object
|
|
855
|
-
* @param {
|
|
958
|
+
* @param {ModuleFactoryCallback} callback callback
|
|
856
959
|
* @returns {void}
|
|
857
960
|
*/
|
|
858
961
|
create(data, callback) {
|
|
@@ -861,20 +964,21 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
861
964
|
const resolveOptions = data.resolveOptions || EMPTY_RESOLVE_OPTIONS;
|
|
862
965
|
const dependency = dependencies[0];
|
|
863
966
|
const request = dependency.request;
|
|
864
|
-
const
|
|
967
|
+
const attributes =
|
|
968
|
+
/** @type {ModuleDependency & { attributes: ImportAttributes }} */
|
|
969
|
+
(dependency).attributes;
|
|
970
|
+
const dependencyType = dependency.category || "";
|
|
865
971
|
const contextInfo = data.contextInfo;
|
|
866
972
|
const fileDependencies = new LazySet();
|
|
867
973
|
const missingDependencies = new LazySet();
|
|
868
974
|
const contextDependencies = new LazySet();
|
|
869
|
-
const dependencyType =
|
|
870
|
-
(dependencies.length > 0 && dependencies[0].category) || "";
|
|
871
975
|
/** @type {ResolveData} */
|
|
872
976
|
const resolveData = {
|
|
873
977
|
contextInfo,
|
|
874
978
|
resolveOptions,
|
|
875
979
|
context,
|
|
876
980
|
request,
|
|
877
|
-
|
|
981
|
+
attributes,
|
|
878
982
|
dependencies,
|
|
879
983
|
dependencyType,
|
|
880
984
|
fileDependencies,
|
|
@@ -910,13 +1014,14 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
910
1014
|
return callback(null, factoryResult);
|
|
911
1015
|
}
|
|
912
1016
|
|
|
913
|
-
if (typeof result === "object")
|
|
1017
|
+
if (typeof result === "object") {
|
|
914
1018
|
throw new Error(
|
|
915
1019
|
deprecationChangedHookMessage(
|
|
916
1020
|
"beforeResolve",
|
|
917
1021
|
this.hooks.beforeResolve
|
|
918
1022
|
)
|
|
919
1023
|
);
|
|
1024
|
+
}
|
|
920
1025
|
|
|
921
1026
|
this.hooks.factorize.callAsync(resolveData, (err, module) => {
|
|
922
1027
|
if (err) {
|
|
@@ -989,16 +1094,16 @@ ${hints.join("\n\n")}`;
|
|
|
989
1094
|
|
|
990
1095
|
// Check if the extension is missing a leading dot (e.g. "js" instead of ".js")
|
|
991
1096
|
let appendResolveExtensionsHint = false;
|
|
992
|
-
const specifiedExtensions =
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
1097
|
+
const specifiedExtensions = [...resolver.options.extensions];
|
|
1098
|
+
const expectedExtensions = specifiedExtensions.map(
|
|
1099
|
+
(extension) => {
|
|
1100
|
+
if (LEADING_DOT_EXTENSION_REGEX.test(extension)) {
|
|
1101
|
+
appendResolveExtensionsHint = true;
|
|
1102
|
+
return `.${extension}`;
|
|
1103
|
+
}
|
|
1104
|
+
return extension;
|
|
999
1105
|
}
|
|
1000
|
-
|
|
1001
|
-
});
|
|
1106
|
+
);
|
|
1002
1107
|
if (appendResolveExtensionsHint) {
|
|
1003
1108
|
err.message += `\nDid you miss the leading dot in 'resolve.extensions'? Did you mean '${JSON.stringify(
|
|
1004
1109
|
expectedExtensions
|
|
@@ -1035,7 +1140,7 @@ ${hints.join("\n\n")}`;
|
|
|
1035
1140
|
) {
|
|
1036
1141
|
asyncLib.parallel(
|
|
1037
1142
|
[
|
|
1038
|
-
callback => {
|
|
1143
|
+
(callback) => {
|
|
1039
1144
|
if (!resolver.options.fullySpecified) return callback();
|
|
1040
1145
|
resolver
|
|
1041
1146
|
.withOptions({
|
|
@@ -1065,7 +1170,7 @@ Add the extension to the request.`
|
|
|
1065
1170
|
}
|
|
1066
1171
|
);
|
|
1067
1172
|
},
|
|
1068
|
-
callback => {
|
|
1173
|
+
(callback) => {
|
|
1069
1174
|
if (!resolver.options.enforceExtension) return callback();
|
|
1070
1175
|
resolver
|
|
1071
1176
|
.withOptions({
|
|
@@ -1104,7 +1209,7 @@ Including the extension in the request is no longer possible. Did you mean to en
|
|
|
1104
1209
|
}
|
|
1105
1210
|
);
|
|
1106
1211
|
},
|
|
1107
|
-
callback => {
|
|
1212
|
+
(callback) => {
|
|
1108
1213
|
if (
|
|
1109
1214
|
/^\.\.?\//.test(unresolvedResource) ||
|
|
1110
1215
|
resolver.options.preferRelative
|
|
@@ -1119,7 +1224,7 @@ Including the extension in the request is no longer possible. Did you mean to en
|
|
|
1119
1224
|
(err, resolvedResource) => {
|
|
1120
1225
|
if (err || !resolvedResource) return callback();
|
|
1121
1226
|
const moduleDirectories = resolver.options.modules
|
|
1122
|
-
.map(m => (Array.isArray(m) ? m.join(", ") : m))
|
|
1227
|
+
.map((m) => (Array.isArray(m) ? m.join(", ") : m))
|
|
1123
1228
|
.join(", ");
|
|
1124
1229
|
callback(
|
|
1125
1230
|
null,
|
|
@@ -1160,6 +1265,10 @@ If changing the source code is not an option there is also a resolve options cal
|
|
|
1160
1265
|
if (array.length === 0) return callback(null, array);
|
|
1161
1266
|
asyncLib.map(
|
|
1162
1267
|
array,
|
|
1268
|
+
/**
|
|
1269
|
+
* @param {LoaderItem} item item
|
|
1270
|
+
* @param {Callback<LoaderItem>} callback callback
|
|
1271
|
+
*/
|
|
1163
1272
|
(item, callback) => {
|
|
1164
1273
|
resolver.resolve(
|
|
1165
1274
|
contextInfo,
|
|
@@ -1177,7 +1286,7 @@ If changing the source code is not an option there is also a resolve options cal
|
|
|
1177
1286
|
context,
|
|
1178
1287
|
`${item.loader}-loader`,
|
|
1179
1288
|
resolveContext,
|
|
1180
|
-
err2 => {
|
|
1289
|
+
(err2) => {
|
|
1181
1290
|
if (!err2) {
|
|
1182
1291
|
err.message =
|
|
1183
1292
|
`${err.message}\n` +
|
|
@@ -1192,7 +1301,8 @@ If changing the source code is not an option there is also a resolve options cal
|
|
|
1192
1301
|
if (err) return callback(err);
|
|
1193
1302
|
|
|
1194
1303
|
const parsedResult = this._parseResourceWithoutFragment(
|
|
1195
|
-
/** @type {string} */
|
|
1304
|
+
/** @type {string} */
|
|
1305
|
+
(result)
|
|
1196
1306
|
);
|
|
1197
1307
|
|
|
1198
1308
|
const type = /\.mjs$/i.test(parsedResult.path)
|
|
@@ -1202,8 +1312,12 @@ If changing the source code is not an option there is also a resolve options cal
|
|
|
1202
1312
|
: /** @type {ResolveRequest} */
|
|
1203
1313
|
(resolveRequest).descriptionFileData === undefined
|
|
1204
1314
|
? undefined
|
|
1205
|
-
: /** @type {
|
|
1206
|
-
(
|
|
1315
|
+
: /** @type {string} */
|
|
1316
|
+
(
|
|
1317
|
+
/** @type {ResolveRequest} */
|
|
1318
|
+
(resolveRequest).descriptionFileData.type
|
|
1319
|
+
);
|
|
1320
|
+
/** @type {LoaderItem} */
|
|
1207
1321
|
const resolved = {
|
|
1208
1322
|
loader: parsedResult.path,
|
|
1209
1323
|
type,
|
|
@@ -1213,17 +1327,16 @@ If changing the source code is not an option there is also a resolve options cal
|
|
|
1213
1327
|
? parsedResult.query.slice(1)
|
|
1214
1328
|
: undefined
|
|
1215
1329
|
: item.options,
|
|
1216
|
-
ident:
|
|
1217
|
-
item.options === undefined
|
|
1218
|
-
? undefined
|
|
1219
|
-
: /** @type {string} */ (item.ident)
|
|
1330
|
+
ident: item.options === undefined ? undefined : item.ident
|
|
1220
1331
|
};
|
|
1221
1332
|
|
|
1222
|
-
return callback(null,
|
|
1333
|
+
return callback(null, resolved);
|
|
1223
1334
|
}
|
|
1224
1335
|
);
|
|
1225
1336
|
},
|
|
1226
|
-
|
|
1337
|
+
(err, value) => {
|
|
1338
|
+
callback(err, /** @type {(LoaderItem)[]} */ (value));
|
|
1339
|
+
}
|
|
1227
1340
|
);
|
|
1228
1341
|
}
|
|
1229
1342
|
|