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
@@ -5,12 +5,20 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
const {
|
9
|
+
JAVASCRIPT_MODULE_TYPE_AUTO,
|
10
|
+
JAVASCRIPT_MODULE_TYPE_ESM
|
11
|
+
} = require("../ModuleTypeConstants");
|
8
12
|
const ContextElementDependency = require("./ContextElementDependency");
|
9
13
|
const ImportMetaContextDependency = require("./ImportMetaContextDependency");
|
10
14
|
const ImportMetaContextDependencyParserPlugin = require("./ImportMetaContextDependencyParserPlugin");
|
11
15
|
|
16
|
+
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
12
17
|
/** @typedef {import("../../declarations/WebpackOptions").ResolveOptions} ResolveOptions */
|
13
18
|
/** @typedef {import("../Compiler")} Compiler */
|
19
|
+
/** @typedef {import("../javascript/JavascriptParser")} Parser */
|
20
|
+
|
21
|
+
const PLUGIN_NAME = "ImportMetaContextPlugin";
|
14
22
|
|
15
23
|
class ImportMetaContextPlugin {
|
16
24
|
/**
|
@@ -20,7 +28,7 @@ class ImportMetaContextPlugin {
|
|
20
28
|
*/
|
21
29
|
apply(compiler) {
|
22
30
|
compiler.hooks.compilation.tap(
|
23
|
-
|
31
|
+
PLUGIN_NAME,
|
24
32
|
(compilation, { contextModuleFactory, normalModuleFactory }) => {
|
25
33
|
compilation.dependencyFactories.set(
|
26
34
|
ImportMetaContextDependency,
|
@@ -35,6 +43,11 @@ class ImportMetaContextPlugin {
|
|
35
43
|
normalModuleFactory
|
36
44
|
);
|
37
45
|
|
46
|
+
/**
|
47
|
+
* @param {Parser} parser parser parser
|
48
|
+
* @param {JavascriptParserOptions} parserOptions parserOptions
|
49
|
+
* @returns {void}
|
50
|
+
*/
|
38
51
|
const handler = (parser, parserOptions) => {
|
39
52
|
if (
|
40
53
|
parserOptions.importMetaContext !== undefined &&
|
@@ -46,11 +59,11 @@ class ImportMetaContextPlugin {
|
|
46
59
|
};
|
47
60
|
|
48
61
|
normalModuleFactory.hooks.parser
|
49
|
-
.for(
|
50
|
-
.tap(
|
62
|
+
.for(JAVASCRIPT_MODULE_TYPE_AUTO)
|
63
|
+
.tap(PLUGIN_NAME, handler);
|
51
64
|
normalModuleFactory.hooks.parser
|
52
|
-
.for(
|
53
|
-
.tap(
|
65
|
+
.for(JAVASCRIPT_MODULE_TYPE_ESM)
|
66
|
+
.tap(PLUGIN_NAME, handler);
|
54
67
|
}
|
55
68
|
);
|
56
69
|
}
|
@@ -9,7 +9,13 @@ const makeSerializable = require("../util/makeSerializable");
|
|
9
9
|
const ModuleDependency = require("./ModuleDependency");
|
10
10
|
const ModuleDependencyTemplateAsId = require("./ModuleDependencyTemplateAsId");
|
11
11
|
|
12
|
+
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
13
|
+
|
12
14
|
class ImportMetaHotAcceptDependency extends ModuleDependency {
|
15
|
+
/**
|
16
|
+
* @param {string} request the request string
|
17
|
+
* @param {Range} range location in source code
|
18
|
+
*/
|
13
19
|
constructor(request, range) {
|
14
20
|
super(request);
|
15
21
|
this.range = range;
|
@@ -9,7 +9,13 @@ const makeSerializable = require("../util/makeSerializable");
|
|
9
9
|
const ModuleDependency = require("./ModuleDependency");
|
10
10
|
const ModuleDependencyTemplateAsId = require("./ModuleDependencyTemplateAsId");
|
11
11
|
|
12
|
+
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
13
|
+
|
12
14
|
class ImportMetaHotDeclineDependency extends ModuleDependency {
|
15
|
+
/**
|
16
|
+
* @param {string} request the request string
|
17
|
+
* @param {Range} range location in source code
|
18
|
+
*/
|
13
19
|
constructor(request, range) {
|
14
20
|
super(request);
|
15
21
|
|
@@ -7,6 +7,10 @@
|
|
7
7
|
|
8
8
|
const { pathToFileURL } = require("url");
|
9
9
|
const ModuleDependencyWarning = require("../ModuleDependencyWarning");
|
10
|
+
const {
|
11
|
+
JAVASCRIPT_MODULE_TYPE_AUTO,
|
12
|
+
JAVASCRIPT_MODULE_TYPE_ESM
|
13
|
+
} = require("../ModuleTypeConstants");
|
10
14
|
const Template = require("../Template");
|
11
15
|
const BasicEvaluatedExpression = require("../javascript/BasicEvaluatedExpression");
|
12
16
|
const {
|
@@ -22,20 +26,24 @@ const ConstDependency = require("./ConstDependency");
|
|
22
26
|
/** @typedef {import("estree").MemberExpression} MemberExpression */
|
23
27
|
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
24
28
|
/** @typedef {import("../Compiler")} Compiler */
|
29
|
+
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
25
30
|
/** @typedef {import("../NormalModule")} NormalModule */
|
26
31
|
/** @typedef {import("../javascript/JavascriptParser")} Parser */
|
32
|
+
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
27
33
|
|
28
34
|
const getCriticalDependencyWarning = memoize(() =>
|
29
35
|
require("./CriticalDependencyWarning")
|
30
36
|
);
|
31
37
|
|
38
|
+
const PLUGIN_NAME = "ImportMetaPlugin";
|
39
|
+
|
32
40
|
class ImportMetaPlugin {
|
33
41
|
/**
|
34
42
|
* @param {Compiler} compiler compiler
|
35
43
|
*/
|
36
44
|
apply(compiler) {
|
37
45
|
compiler.hooks.compilation.tap(
|
38
|
-
|
46
|
+
PLUGIN_NAME,
|
39
47
|
(compilation, { normalModuleFactory }) => {
|
40
48
|
/**
|
41
49
|
* @param {NormalModule} module module
|
@@ -56,12 +64,12 @@ class ImportMetaPlugin {
|
|
56
64
|
|
57
65
|
parser.hooks.expression
|
58
66
|
.for("import.meta")
|
59
|
-
.tap(
|
67
|
+
.tap(PLUGIN_NAME, metaProperty => {
|
60
68
|
const dep = new ConstDependency(
|
61
|
-
importMetaName,
|
62
|
-
metaProperty.range
|
69
|
+
/** @type {string} */ (importMetaName),
|
70
|
+
/** @type {Range} */ (metaProperty.range)
|
63
71
|
);
|
64
|
-
dep.loc = metaProperty.loc;
|
72
|
+
dep.loc = /** @type {DependencyLocation} */ (metaProperty.loc);
|
65
73
|
parser.state.module.addPresentationalDependency(dep);
|
66
74
|
return true;
|
67
75
|
});
|
@@ -69,38 +77,88 @@ class ImportMetaPlugin {
|
|
69
77
|
}
|
70
78
|
|
71
79
|
/// import.meta direct ///
|
80
|
+
const webpackVersion = parseInt(
|
81
|
+
require("../../package.json").version,
|
82
|
+
10
|
83
|
+
);
|
84
|
+
const importMetaUrl = () =>
|
85
|
+
JSON.stringify(getUrl(parser.state.module));
|
86
|
+
const importMetaWebpackVersion = () => JSON.stringify(webpackVersion);
|
87
|
+
/**
|
88
|
+
* @param {string[]} members members
|
89
|
+
* @returns {string} error message
|
90
|
+
*/
|
91
|
+
const importMetaUnknownProperty = members =>
|
92
|
+
`${Template.toNormalComment(
|
93
|
+
"unsupported import.meta." + members.join(".")
|
94
|
+
)} undefined${propertyAccess(members, 1)}`;
|
72
95
|
parser.hooks.typeof
|
73
96
|
.for("import.meta")
|
74
97
|
.tap(
|
75
|
-
|
98
|
+
PLUGIN_NAME,
|
76
99
|
toConstantDependency(parser, JSON.stringify("object"))
|
77
100
|
);
|
78
101
|
parser.hooks.expression
|
79
102
|
.for("import.meta")
|
80
|
-
.tap(
|
81
|
-
const
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
103
|
+
.tap(PLUGIN_NAME, metaProperty => {
|
104
|
+
const referencedPropertiesInDestructuring =
|
105
|
+
parser.destructuringAssignmentPropertiesFor(metaProperty);
|
106
|
+
if (!referencedPropertiesInDestructuring) {
|
107
|
+
const CriticalDependencyWarning =
|
108
|
+
getCriticalDependencyWarning();
|
109
|
+
parser.state.module.addWarning(
|
110
|
+
new ModuleDependencyWarning(
|
111
|
+
parser.state.module,
|
112
|
+
new CriticalDependencyWarning(
|
113
|
+
"Accessing import.meta directly is unsupported (only property access or destructuring is supported)"
|
114
|
+
),
|
115
|
+
/** @type {DependencyLocation} */ (metaProperty.loc)
|
116
|
+
)
|
117
|
+
);
|
118
|
+
const dep = new ConstDependency(
|
119
|
+
`${
|
120
|
+
parser.isAsiPosition(
|
121
|
+
/** @type {Range} */ (metaProperty.range)[0]
|
122
|
+
)
|
123
|
+
? ";"
|
124
|
+
: ""
|
125
|
+
}({})`,
|
126
|
+
/** @type {Range} */ (metaProperty.range)
|
127
|
+
);
|
128
|
+
dep.loc = /** @type {DependencyLocation} */ (metaProperty.loc);
|
129
|
+
parser.state.module.addPresentationalDependency(dep);
|
130
|
+
return true;
|
131
|
+
}
|
132
|
+
|
133
|
+
let str = "";
|
134
|
+
for (const prop of referencedPropertiesInDestructuring) {
|
135
|
+
switch (prop) {
|
136
|
+
case "url":
|
137
|
+
str += `url: ${importMetaUrl()},`;
|
138
|
+
break;
|
139
|
+
case "webpack":
|
140
|
+
str += `webpack: ${importMetaWebpackVersion()},`;
|
141
|
+
break;
|
142
|
+
default:
|
143
|
+
str += `[${JSON.stringify(
|
144
|
+
prop
|
145
|
+
)}]: ${importMetaUnknownProperty([prop])},`;
|
146
|
+
break;
|
147
|
+
}
|
148
|
+
}
|
91
149
|
const dep = new ConstDependency(
|
92
|
-
|
93
|
-
metaProperty.range
|
150
|
+
`({${str}})`,
|
151
|
+
/** @type {Range} */ (metaProperty.range)
|
94
152
|
);
|
95
|
-
dep.loc = metaProperty.loc;
|
153
|
+
dep.loc = /** @type {DependencyLocation} */ (metaProperty.loc);
|
96
154
|
parser.state.module.addPresentationalDependency(dep);
|
97
155
|
return true;
|
98
156
|
});
|
99
157
|
parser.hooks.evaluateTypeof
|
100
158
|
.for("import.meta")
|
101
|
-
.tap(
|
159
|
+
.tap(PLUGIN_NAME, evaluateToString("object"));
|
102
160
|
parser.hooks.evaluateIdentifier.for("import.meta").tap(
|
103
|
-
|
161
|
+
PLUGIN_NAME,
|
104
162
|
evaluateToIdentifier("import.meta", "import.meta", () => [], true)
|
105
163
|
);
|
106
164
|
|
@@ -108,72 +166,66 @@ class ImportMetaPlugin {
|
|
108
166
|
parser.hooks.typeof
|
109
167
|
.for("import.meta.url")
|
110
168
|
.tap(
|
111
|
-
|
169
|
+
PLUGIN_NAME,
|
112
170
|
toConstantDependency(parser, JSON.stringify("string"))
|
113
171
|
);
|
114
172
|
parser.hooks.expression
|
115
173
|
.for("import.meta.url")
|
116
|
-
.tap(
|
174
|
+
.tap(PLUGIN_NAME, expr => {
|
117
175
|
const dep = new ConstDependency(
|
118
|
-
|
119
|
-
expr.range
|
176
|
+
importMetaUrl(),
|
177
|
+
/** @type {Range} */ (expr.range)
|
120
178
|
);
|
121
|
-
dep.loc = expr.loc;
|
179
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
122
180
|
parser.state.module.addPresentationalDependency(dep);
|
123
181
|
return true;
|
124
182
|
});
|
125
183
|
parser.hooks.evaluateTypeof
|
126
184
|
.for("import.meta.url")
|
127
|
-
.tap(
|
185
|
+
.tap(PLUGIN_NAME, evaluateToString("string"));
|
128
186
|
parser.hooks.evaluateIdentifier
|
129
187
|
.for("import.meta.url")
|
130
|
-
.tap(
|
188
|
+
.tap(PLUGIN_NAME, expr => {
|
131
189
|
return new BasicEvaluatedExpression()
|
132
190
|
.setString(getUrl(parser.state.module))
|
133
|
-
.setRange(expr.range);
|
191
|
+
.setRange(/** @type {Range} */ (expr.range));
|
134
192
|
});
|
135
193
|
|
136
194
|
/// import.meta.webpack ///
|
137
|
-
const webpackVersion = parseInt(
|
138
|
-
require("../../package.json").version,
|
139
|
-
10
|
140
|
-
);
|
141
195
|
parser.hooks.typeof
|
142
196
|
.for("import.meta.webpack")
|
143
197
|
.tap(
|
144
|
-
|
198
|
+
PLUGIN_NAME,
|
145
199
|
toConstantDependency(parser, JSON.stringify("number"))
|
146
200
|
);
|
147
201
|
parser.hooks.expression
|
148
202
|
.for("import.meta.webpack")
|
149
203
|
.tap(
|
150
|
-
|
151
|
-
toConstantDependency(parser,
|
204
|
+
PLUGIN_NAME,
|
205
|
+
toConstantDependency(parser, importMetaWebpackVersion())
|
152
206
|
);
|
153
207
|
parser.hooks.evaluateTypeof
|
154
208
|
.for("import.meta.webpack")
|
155
|
-
.tap(
|
209
|
+
.tap(PLUGIN_NAME, evaluateToString("number"));
|
156
210
|
parser.hooks.evaluateIdentifier
|
157
211
|
.for("import.meta.webpack")
|
158
|
-
.tap(
|
212
|
+
.tap(PLUGIN_NAME, evaluateToNumber(webpackVersion));
|
159
213
|
|
160
214
|
/// Unknown properties ///
|
161
215
|
parser.hooks.unhandledExpressionMemberChain
|
162
216
|
.for("import.meta")
|
163
|
-
.tap(
|
217
|
+
.tap(PLUGIN_NAME, (expr, members) => {
|
164
218
|
const dep = new ConstDependency(
|
165
|
-
|
166
|
-
|
167
|
-
)} undefined${propertyAccess(members, 1)}`,
|
168
|
-
expr.range
|
219
|
+
importMetaUnknownProperty(members),
|
220
|
+
/** @type {Range} */ (expr.range)
|
169
221
|
);
|
170
|
-
dep.loc = expr.loc;
|
222
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
171
223
|
parser.state.module.addPresentationalDependency(dep);
|
172
224
|
return true;
|
173
225
|
});
|
174
226
|
parser.hooks.evaluate
|
175
227
|
.for("MemberExpression")
|
176
|
-
.tap(
|
228
|
+
.tap(PLUGIN_NAME, expression => {
|
177
229
|
const expr = /** @type {MemberExpression} */ (expression);
|
178
230
|
if (
|
179
231
|
expr.object.type === "MetaProperty" &&
|
@@ -184,17 +236,17 @@ class ImportMetaPlugin {
|
|
184
236
|
) {
|
185
237
|
return new BasicEvaluatedExpression()
|
186
238
|
.setUndefined()
|
187
|
-
.setRange(expr.range);
|
239
|
+
.setRange(/** @type {Range} */ (expr.range));
|
188
240
|
}
|
189
241
|
});
|
190
242
|
};
|
191
243
|
|
192
244
|
normalModuleFactory.hooks.parser
|
193
|
-
.for(
|
194
|
-
.tap(
|
245
|
+
.for(JAVASCRIPT_MODULE_TYPE_AUTO)
|
246
|
+
.tap(PLUGIN_NAME, parserHandler);
|
195
247
|
normalModuleFactory.hooks.parser
|
196
|
-
.for(
|
197
|
-
.tap(
|
248
|
+
.for(JAVASCRIPT_MODULE_TYPE_ESM)
|
249
|
+
.tap(PLUGIN_NAME, parserHandler);
|
198
250
|
}
|
199
251
|
);
|
200
252
|
}
|
@@ -17,6 +17,10 @@ const ImportWeakDependency = require("./ImportWeakDependency");
|
|
17
17
|
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
18
18
|
/** @typedef {import("../ChunkGroup").RawChunkGroupOptions} RawChunkGroupOptions */
|
19
19
|
/** @typedef {import("../ContextModule").ContextMode} ContextMode */
|
20
|
+
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
21
|
+
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
22
|
+
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
23
|
+
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
20
24
|
|
21
25
|
class ImportParserPlugin {
|
22
26
|
/**
|
@@ -26,13 +30,23 @@ class ImportParserPlugin {
|
|
26
30
|
this.options = options;
|
27
31
|
}
|
28
32
|
|
33
|
+
/**
|
34
|
+
* @param {JavascriptParser} parser the parser
|
35
|
+
* @returns {void}
|
36
|
+
*/
|
29
37
|
apply(parser) {
|
38
|
+
/**
|
39
|
+
* @template T
|
40
|
+
* @param {Iterable<T>} enumerable enumerable
|
41
|
+
* @returns {T[][]} array of array
|
42
|
+
*/
|
43
|
+
const exportsFromEnumerable = enumerable =>
|
44
|
+
Array.from(enumerable, e => [e]);
|
30
45
|
parser.hooks.importCall.tap("ImportParserPlugin", expr => {
|
31
46
|
const param = parser.evaluateExpression(expr.source);
|
32
47
|
|
33
48
|
let chunkName = null;
|
34
|
-
/** @type {ContextMode} */
|
35
|
-
let mode = this.options.dynamicImportMode;
|
49
|
+
let mode = /** @type {ContextMode} */ (this.options.dynamicImportMode);
|
36
50
|
let include = null;
|
37
51
|
let exclude = null;
|
38
52
|
/** @type {string[][] | null} */
|
@@ -40,7 +54,11 @@ class ImportParserPlugin {
|
|
40
54
|
/** @type {RawChunkGroupOptions} */
|
41
55
|
const groupOptions = {};
|
42
56
|
|
43
|
-
const {
|
57
|
+
const {
|
58
|
+
dynamicImportPreload,
|
59
|
+
dynamicImportPrefetch,
|
60
|
+
dynamicImportFetchPriority
|
61
|
+
} = this.options;
|
44
62
|
if (dynamicImportPreload !== undefined && dynamicImportPreload !== false)
|
45
63
|
groupOptions.preloadOrder =
|
46
64
|
dynamicImportPreload === true ? 0 : dynamicImportPreload;
|
@@ -50,9 +68,14 @@ class ImportParserPlugin {
|
|
50
68
|
)
|
51
69
|
groupOptions.prefetchOrder =
|
52
70
|
dynamicImportPrefetch === true ? 0 : dynamicImportPrefetch;
|
71
|
+
if (
|
72
|
+
dynamicImportFetchPriority !== undefined &&
|
73
|
+
dynamicImportFetchPriority !== false
|
74
|
+
)
|
75
|
+
groupOptions.fetchPriority = dynamicImportFetchPriority;
|
53
76
|
|
54
77
|
const { options: importOptions, errors: commentErrors } =
|
55
|
-
parser.parseCommentOptions(expr.range);
|
78
|
+
parser.parseCommentOptions(/** @type {Range} */ (expr.range));
|
56
79
|
|
57
80
|
if (commentErrors) {
|
58
81
|
for (const e of commentErrors) {
|
@@ -72,7 +95,7 @@ class ImportParserPlugin {
|
|
72
95
|
parser.state.module.addWarning(
|
73
96
|
new UnsupportedFeatureWarning(
|
74
97
|
`\`webpackIgnore\` expected a boolean, but received: ${importOptions.webpackIgnore}.`,
|
75
|
-
expr.loc
|
98
|
+
/** @type {DependencyLocation} */ (expr.loc)
|
76
99
|
)
|
77
100
|
);
|
78
101
|
} else {
|
@@ -87,7 +110,7 @@ class ImportParserPlugin {
|
|
87
110
|
parser.state.module.addWarning(
|
88
111
|
new UnsupportedFeatureWarning(
|
89
112
|
`\`webpackChunkName\` expected a string, but received: ${importOptions.webpackChunkName}.`,
|
90
|
-
expr.loc
|
113
|
+
/** @type {DependencyLocation} */ (expr.loc)
|
91
114
|
)
|
92
115
|
);
|
93
116
|
} else {
|
@@ -99,7 +122,7 @@ class ImportParserPlugin {
|
|
99
122
|
parser.state.module.addWarning(
|
100
123
|
new UnsupportedFeatureWarning(
|
101
124
|
`\`webpackMode\` expected a string, but received: ${importOptions.webpackMode}.`,
|
102
|
-
expr.loc
|
125
|
+
/** @type {DependencyLocation} */ (expr.loc)
|
103
126
|
)
|
104
127
|
);
|
105
128
|
} else {
|
@@ -115,7 +138,7 @@ class ImportParserPlugin {
|
|
115
138
|
parser.state.module.addWarning(
|
116
139
|
new UnsupportedFeatureWarning(
|
117
140
|
`\`webpackPrefetch\` expected true or a number, but received: ${importOptions.webpackPrefetch}.`,
|
118
|
-
expr.loc
|
141
|
+
/** @type {DependencyLocation} */ (expr.loc)
|
119
142
|
)
|
120
143
|
);
|
121
144
|
}
|
@@ -129,7 +152,22 @@ class ImportParserPlugin {
|
|
129
152
|
parser.state.module.addWarning(
|
130
153
|
new UnsupportedFeatureWarning(
|
131
154
|
`\`webpackPreload\` expected true or a number, but received: ${importOptions.webpackPreload}.`,
|
132
|
-
expr.loc
|
155
|
+
/** @type {DependencyLocation} */ (expr.loc)
|
156
|
+
)
|
157
|
+
);
|
158
|
+
}
|
159
|
+
}
|
160
|
+
if (importOptions.webpackFetchPriority !== undefined) {
|
161
|
+
if (
|
162
|
+
typeof importOptions.webpackFetchPriority === "string" &&
|
163
|
+
["high", "low", "auto"].includes(importOptions.webpackFetchPriority)
|
164
|
+
) {
|
165
|
+
groupOptions.fetchPriority = importOptions.webpackFetchPriority;
|
166
|
+
} else {
|
167
|
+
parser.state.module.addWarning(
|
168
|
+
new UnsupportedFeatureWarning(
|
169
|
+
`\`webpackFetchPriority\` expected true or "low", "high" or "auto", but received: ${importOptions.webpackFetchPriority}.`,
|
170
|
+
/** @type {DependencyLocation} */ (expr.loc)
|
133
171
|
)
|
134
172
|
);
|
135
173
|
}
|
@@ -142,7 +180,7 @@ class ImportParserPlugin {
|
|
142
180
|
parser.state.module.addWarning(
|
143
181
|
new UnsupportedFeatureWarning(
|
144
182
|
`\`webpackInclude\` expected a regular expression, but received: ${importOptions.webpackInclude}.`,
|
145
|
-
expr.loc
|
183
|
+
/** @type {DependencyLocation} */ (expr.loc)
|
146
184
|
)
|
147
185
|
);
|
148
186
|
} else {
|
@@ -157,7 +195,7 @@ class ImportParserPlugin {
|
|
157
195
|
parser.state.module.addWarning(
|
158
196
|
new UnsupportedFeatureWarning(
|
159
197
|
`\`webpackExclude\` expected a regular expression, but received: ${importOptions.webpackExclude}.`,
|
160
|
-
expr.loc
|
198
|
+
/** @type {DependencyLocation} */ (expr.loc)
|
161
199
|
)
|
162
200
|
);
|
163
201
|
} else {
|
@@ -169,7 +207,7 @@ class ImportParserPlugin {
|
|
169
207
|
!(
|
170
208
|
typeof importOptions.webpackExports === "string" ||
|
171
209
|
(Array.isArray(importOptions.webpackExports) &&
|
172
|
-
importOptions.webpackExports.every(
|
210
|
+
/** @type {string[]} */ (importOptions.webpackExports).every(
|
173
211
|
item => typeof item === "string"
|
174
212
|
))
|
175
213
|
)
|
@@ -177,14 +215,14 @@ class ImportParserPlugin {
|
|
177
215
|
parser.state.module.addWarning(
|
178
216
|
new UnsupportedFeatureWarning(
|
179
217
|
`\`webpackExports\` expected a string or an array of strings, but received: ${importOptions.webpackExports}.`,
|
180
|
-
expr.loc
|
218
|
+
/** @type {DependencyLocation} */ (expr.loc)
|
181
219
|
)
|
182
220
|
);
|
183
221
|
} else {
|
184
222
|
if (typeof importOptions.webpackExports === "string") {
|
185
223
|
exports = [[importOptions.webpackExports]];
|
186
224
|
} else {
|
187
|
-
exports =
|
225
|
+
exports = exportsFromEnumerable(importOptions.webpackExports);
|
188
226
|
}
|
189
227
|
}
|
190
228
|
}
|
@@ -199,24 +237,38 @@ class ImportParserPlugin {
|
|
199
237
|
parser.state.module.addWarning(
|
200
238
|
new UnsupportedFeatureWarning(
|
201
239
|
`\`webpackMode\` expected 'lazy', 'lazy-once', 'eager' or 'weak', but received: ${mode}.`,
|
202
|
-
expr.loc
|
240
|
+
/** @type {DependencyLocation} */ (expr.loc)
|
203
241
|
)
|
204
242
|
);
|
205
243
|
mode = "lazy";
|
206
244
|
}
|
207
245
|
|
246
|
+
const referencedPropertiesInDestructuring =
|
247
|
+
parser.destructuringAssignmentPropertiesFor(expr);
|
248
|
+
if (referencedPropertiesInDestructuring) {
|
249
|
+
if (exports) {
|
250
|
+
parser.state.module.addWarning(
|
251
|
+
new UnsupportedFeatureWarning(
|
252
|
+
`\`webpackExports\` could not be used with destructuring assignment.`,
|
253
|
+
/** @type {DependencyLocation} */ (expr.loc)
|
254
|
+
)
|
255
|
+
);
|
256
|
+
}
|
257
|
+
exports = exportsFromEnumerable(referencedPropertiesInDestructuring);
|
258
|
+
}
|
259
|
+
|
208
260
|
if (param.isString()) {
|
209
261
|
if (mode === "eager") {
|
210
262
|
const dep = new ImportEagerDependency(
|
211
|
-
param.string,
|
212
|
-
expr.range,
|
263
|
+
/** @type {string} */ (param.string),
|
264
|
+
/** @type {Range} */ (expr.range),
|
213
265
|
exports
|
214
266
|
);
|
215
267
|
parser.state.current.addDependency(dep);
|
216
268
|
} else if (mode === "weak") {
|
217
269
|
const dep = new ImportWeakDependency(
|
218
|
-
param.string,
|
219
|
-
expr.range,
|
270
|
+
/** @type {string} */ (param.string),
|
271
|
+
/** @type {Range} */ (expr.range),
|
220
272
|
exports
|
221
273
|
);
|
222
274
|
parser.state.current.addDependency(dep);
|
@@ -226,11 +278,15 @@ class ImportParserPlugin {
|
|
226
278
|
...groupOptions,
|
227
279
|
name: chunkName
|
228
280
|
},
|
229
|
-
expr.loc,
|
281
|
+
/** @type {DependencyLocation} */ (expr.loc),
|
230
282
|
param.string
|
231
283
|
);
|
232
|
-
const dep = new ImportDependency(
|
233
|
-
|
284
|
+
const dep = new ImportDependency(
|
285
|
+
/** @type {string} */ (param.string),
|
286
|
+
/** @type {Range} */ (expr.range),
|
287
|
+
exports
|
288
|
+
);
|
289
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
234
290
|
depBlock.addDependency(dep);
|
235
291
|
parser.state.current.addBlock(depBlock);
|
236
292
|
}
|
@@ -241,7 +297,7 @@ class ImportParserPlugin {
|
|
241
297
|
}
|
242
298
|
const dep = ContextDependencyHelpers.create(
|
243
299
|
ImportContextDependency,
|
244
|
-
expr.range,
|
300
|
+
/** @type {Range} */ (expr.range),
|
245
301
|
param,
|
246
302
|
expr,
|
247
303
|
this.options,
|
@@ -251,7 +307,9 @@ class ImportParserPlugin {
|
|
251
307
|
include,
|
252
308
|
exclude,
|
253
309
|
mode,
|
254
|
-
namespaceObject:
|
310
|
+
namespaceObject: /** @type {BuildMeta} */ (
|
311
|
+
parser.state.module.buildMeta
|
312
|
+
).strictHarmonyModule
|
255
313
|
? "strict"
|
256
314
|
: true,
|
257
315
|
typePrefix: "import()",
|
@@ -261,7 +319,7 @@ class ImportParserPlugin {
|
|
261
319
|
parser
|
262
320
|
);
|
263
321
|
if (!dep) return;
|
264
|
-
dep.loc = expr.loc;
|
322
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
265
323
|
dep.optional = !!parser.scope.inTry;
|
266
324
|
parser.state.current.addDependency(dep);
|
267
325
|
return true;
|
@@ -5,13 +5,22 @@
|
|
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 ImportContextDependency = require("./ImportContextDependency");
|
9
14
|
const ImportDependency = require("./ImportDependency");
|
10
15
|
const ImportEagerDependency = require("./ImportEagerDependency");
|
11
16
|
const ImportParserPlugin = require("./ImportParserPlugin");
|
12
17
|
const ImportWeakDependency = require("./ImportWeakDependency");
|
13
18
|
|
19
|
+
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
14
20
|
/** @typedef {import("../Compiler")} Compiler */
|
21
|
+
/** @typedef {import("../javascript/JavascriptParser")} Parser */
|
22
|
+
|
23
|
+
const PLUGIN_NAME = "ImportPlugin";
|
15
24
|
|
16
25
|
class ImportPlugin {
|
17
26
|
/**
|
@@ -21,7 +30,7 @@ class ImportPlugin {
|
|
21
30
|
*/
|
22
31
|
apply(compiler) {
|
23
32
|
compiler.hooks.compilation.tap(
|
24
|
-
|
33
|
+
PLUGIN_NAME,
|
25
34
|
(compilation, { contextModuleFactory, normalModuleFactory }) => {
|
26
35
|
compilation.dependencyFactories.set(
|
27
36
|
ImportDependency,
|
@@ -59,6 +68,11 @@ class ImportPlugin {
|
|
59
68
|
new ImportContextDependency.Template()
|
60
69
|
);
|
61
70
|
|
71
|
+
/**
|
72
|
+
* @param {Parser} parser parser parser
|
73
|
+
* @param {JavascriptParserOptions} parserOptions parserOptions
|
74
|
+
* @returns {void}
|
75
|
+
*/
|
62
76
|
const handler = (parser, parserOptions) => {
|
63
77
|
if (parserOptions.import !== undefined && !parserOptions.import)
|
64
78
|
return;
|
@@ -67,14 +81,14 @@ class ImportPlugin {
|
|
67
81
|
};
|
68
82
|
|
69
83
|
normalModuleFactory.hooks.parser
|
70
|
-
.for(
|
71
|
-
.tap(
|
84
|
+
.for(JAVASCRIPT_MODULE_TYPE_AUTO)
|
85
|
+
.tap(PLUGIN_NAME, handler);
|
72
86
|
normalModuleFactory.hooks.parser
|
73
|
-
.for(
|
74
|
-
.tap(
|
87
|
+
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC)
|
88
|
+
.tap(PLUGIN_NAME, handler);
|
75
89
|
normalModuleFactory.hooks.parser
|
76
|
-
.for(
|
77
|
-
.tap(
|
90
|
+
.for(JAVASCRIPT_MODULE_TYPE_ESM)
|
91
|
+
.tap(PLUGIN_NAME, handler);
|
78
92
|
}
|
79
93
|
);
|
80
94
|
}
|