webpack 5.101.3 → 5.102.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 +21 -26
- package/lib/APIPlugin.js +30 -36
- package/lib/AsyncDependenciesBlock.js +1 -4
- package/lib/BannerPlugin.js +0 -1
- package/lib/Cache.js +7 -6
- package/lib/CacheFacade.js +0 -1
- package/lib/Chunk.js +49 -31
- package/lib/ChunkGraph.js +37 -27
- package/lib/ChunkGroup.js +8 -10
- package/lib/ChunkTemplate.js +1 -1
- package/lib/CleanPlugin.js +3 -3
- package/lib/CodeGenerationResults.js +3 -2
- package/lib/CompatibilityPlugin.js +29 -12
- package/lib/Compilation.js +209 -196
- package/lib/Compiler.js +36 -35
- package/lib/ConcatenationScope.js +6 -1
- package/lib/ConditionalInitFragment.js +1 -1
- package/lib/ConstPlugin.js +6 -5
- package/lib/ContextExclusionPlugin.js +0 -1
- package/lib/ContextModule.js +25 -21
- package/lib/ContextModuleFactory.js +30 -11
- package/lib/ContextReplacementPlugin.js +38 -15
- package/lib/DefinePlugin.js +5 -9
- package/lib/DelegatedModule.js +7 -11
- package/lib/DependenciesBlock.js +0 -2
- package/lib/Dependency.js +9 -11
- package/lib/DependencyTemplates.js +2 -4
- package/lib/DllModule.js +1 -7
- package/lib/DllReferencePlugin.js +2 -4
- package/lib/DynamicEntryPlugin.js +0 -2
- package/lib/EntryOptionPlugin.js +0 -5
- package/lib/EnvironmentNotSupportAsyncWarning.js +0 -3
- package/lib/EvalDevToolModulePlugin.js +4 -3
- package/lib/EvalSourceMapDevToolPlugin.js +3 -4
- package/lib/ExportsInfo.js +50 -49
- package/lib/ExternalModule.js +84 -52
- package/lib/ExternalModuleFactoryPlugin.js +27 -7
- package/lib/ExternalsPlugin.js +24 -17
- package/lib/FileSystemInfo.js +105 -90
- package/lib/FlagDependencyUsagePlugin.js +3 -4
- package/lib/Generator.js +2 -13
- package/lib/GraphHelpers.js +0 -3
- package/lib/HookWebpackError.js +0 -2
- package/lib/HotModuleReplacementPlugin.js +22 -24
- package/lib/HotUpdateChunk.js +0 -3
- package/lib/IgnorePlugin.js +5 -2
- package/lib/InitFragment.js +41 -29
- package/lib/InvalidDependenciesModuleWarning.js +0 -1
- package/lib/LibManifestPlugin.js +4 -6
- package/lib/LoaderOptionsPlugin.js +1 -10
- package/lib/MainTemplate.js +8 -19
- package/lib/Module.js +32 -20
- package/lib/ModuleFactory.js +1 -1
- package/lib/ModuleFilenameHelpers.js +42 -25
- package/lib/ModuleGraph.js +30 -16
- package/lib/ModuleInfoHeaderPlugin.js +0 -1
- package/lib/ModuleTemplate.js +0 -2
- package/lib/ModuleTypeConstants.js +11 -1
- package/lib/MultiCompiler.js +23 -15
- package/lib/MultiWatching.js +6 -10
- package/lib/NodeStuffPlugin.js +2 -10
- package/lib/NormalModule.js +146 -89
- package/lib/NormalModuleFactory.js +132 -42
- package/lib/OptionsApply.js +1 -1
- package/lib/Parser.js +1 -1
- package/lib/ProgressPlugin.js +6 -10
- package/lib/ProvidePlugin.js +5 -7
- package/lib/RawModule.js +1 -6
- package/lib/RecordIdsPlugin.js +10 -6
- package/lib/ResolverFactory.js +0 -2
- package/lib/RuntimeGlobals.js +5 -0
- package/lib/RuntimeModule.js +1 -3
- package/lib/RuntimePlugin.js +26 -22
- package/lib/RuntimeTemplate.js +22 -12
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +2 -2
- package/lib/SourceMapDevToolPlugin.js +11 -18
- package/lib/Stats.js +0 -1
- package/lib/Template.js +6 -11
- package/lib/TemplatedPathPlugin.js +2 -1
- package/lib/WatchIgnorePlugin.js +2 -3
- package/lib/Watching.js +15 -15
- package/lib/WebpackIsIncludedPlugin.js +0 -2
- package/lib/WebpackOptionsApply.js +74 -107
- package/lib/asset/AssetBytesGenerator.js +167 -0
- package/lib/asset/AssetBytesParser.js +37 -0
- package/lib/asset/AssetGenerator.js +22 -37
- package/lib/asset/AssetModulesPlugin.js +34 -16
- package/lib/asset/AssetParser.js +7 -3
- package/lib/asset/AssetSourceGenerator.js +1 -1
- package/lib/asset/RawDataUrlModule.js +3 -2
- package/lib/async-modules/AsyncModuleHelpers.js +6 -4
- package/lib/buildChunkGraph.js +0 -1
- package/lib/cache/MemoryCachePlugin.js +0 -2
- package/lib/cache/MemoryWithGcCachePlugin.js +0 -2
- package/lib/cache/PackFileCacheStrategy.js +14 -1
- package/lib/cache/ResolverCachePlugin.js +9 -15
- package/lib/cache/getLazyHashedEtag.js +1 -1
- package/lib/config/browserslistTargetHandler.js +77 -76
- package/lib/config/defaults.js +162 -23
- package/lib/config/normalization.js +18 -3
- package/lib/config/target.js +1 -1
- package/lib/container/ContainerEntryDependency.js +0 -1
- package/lib/container/ContainerEntryModule.js +3 -7
- package/lib/container/ContainerPlugin.js +1 -2
- package/lib/container/ContainerReferencePlugin.js +0 -1
- package/lib/container/FallbackDependency.js +2 -1
- package/lib/container/FallbackModule.js +6 -7
- package/lib/container/ModuleFederationPlugin.js +0 -1
- package/lib/container/RemoteModule.js +8 -8
- package/lib/container/RemoteRuntimeModule.js +2 -2
- package/lib/css/CssGenerator.js +3 -6
- package/lib/css/CssLoadingRuntimeModule.js +6 -9
- package/lib/css/CssModulesPlugin.js +13 -19
- package/lib/css/CssParser.js +3 -3
- package/lib/css/walkCssTokens.js +2 -2
- package/lib/debug/ProfilingPlugin.js +35 -8
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +12 -17
- package/lib/dependencies/AMDPlugin.js +2 -2
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -2
- package/lib/dependencies/CachedConstDependency.js +0 -4
- package/lib/dependencies/CommonJsExportRequireDependency.js +20 -14
- package/lib/dependencies/CommonJsExportsDependency.js +2 -1
- package/lib/dependencies/CommonJsExportsParserPlugin.js +20 -5
- package/lib/dependencies/CommonJsFullRequireDependency.js +6 -4
- package/lib/dependencies/CommonJsImportsParserPlugin.js +16 -7
- package/lib/dependencies/CommonJsRequireContextDependency.js +1 -1
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +4 -4
- package/lib/dependencies/ConstDependency.js +2 -2
- package/lib/dependencies/ContextDependency.js +9 -4
- package/lib/dependencies/ContextDependencyHelpers.js +2 -2
- package/lib/dependencies/ContextDependencyTemplateAsId.js +9 -9
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +9 -9
- package/lib/dependencies/ContextElementDependency.js +22 -11
- package/lib/dependencies/CssIcssImportDependency.js +0 -2
- package/lib/dependencies/CssIcssSymbolDependency.js +2 -2
- package/lib/dependencies/CssImportDependency.js +0 -8
- package/lib/dependencies/CssLocalIdentifierDependency.js +4 -7
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -2
- package/lib/dependencies/CssUrlDependency.js +0 -6
- package/lib/dependencies/ExportsInfoDependency.js +7 -9
- package/lib/dependencies/ExternalModuleDependency.js +0 -3
- package/lib/dependencies/ExternalModuleInitFragment.js +1 -1
- package/lib/dependencies/HarmonyAcceptDependency.js +1 -1
- package/lib/dependencies/HarmonyAcceptImportDependency.js +0 -4
- package/lib/dependencies/HarmonyCompatibilityDependency.js +0 -1
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +0 -14
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +3 -3
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +4 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +29 -35
- package/lib/dependencies/HarmonyImportDependency.js +33 -14
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +20 -23
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +0 -4
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +46 -31
- package/lib/dependencies/HarmonyModulesPlugin.js +3 -3
- package/lib/dependencies/ImportContextDependency.js +13 -0
- package/lib/dependencies/ImportDependency.js +18 -6
- package/lib/dependencies/ImportEagerDependency.js +2 -3
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +8 -5
- package/lib/dependencies/ImportMetaContextPlugin.js +0 -1
- package/lib/dependencies/ImportMetaPlugin.js +3 -2
- package/lib/dependencies/ImportParserPlugin.js +288 -45
- package/lib/dependencies/ImportWeakDependency.js +2 -3
- package/lib/dependencies/JsonExportsDependency.js +0 -1
- package/lib/dependencies/LoaderDependency.js +0 -3
- package/lib/dependencies/LoaderImportDependency.js +0 -3
- package/lib/dependencies/LoaderPlugin.js +11 -5
- package/lib/dependencies/ModuleDecoratorDependency.js +2 -4
- package/lib/dependencies/ModuleDependency.js +3 -9
- package/lib/dependencies/NullDependency.js +2 -0
- package/lib/dependencies/ProvidedDependency.js +6 -8
- package/lib/dependencies/PureExpressionDependency.js +0 -1
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +0 -1
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +1 -2
- package/lib/dependencies/RequireIncludeDependency.js +2 -2
- package/lib/dependencies/RequireResolveDependency.js +2 -2
- package/lib/dependencies/RuntimeRequirementsDependency.js +2 -3
- package/lib/dependencies/StaticExportsDependency.js +3 -5
- package/lib/dependencies/URLDependency.js +2 -7
- package/lib/dependencies/URLPlugin.js +1 -2
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +2 -2
- package/lib/dependencies/WebAssemblyImportDependency.js +2 -2
- package/lib/dependencies/WebpackIsIncludedDependency.js +2 -3
- package/lib/dependencies/WorkerDependency.js +2 -3
- package/lib/dependencies/WorkerPlugin.js +4 -12
- package/lib/dependencies/processExportInfo.js +2 -3
- package/lib/esm/ModuleChunkFormatPlugin.js +0 -3
- package/lib/esm/ModuleChunkLoadingPlugin.js +2 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +7 -7
- package/lib/hmr/LazyCompilationPlugin.js +6 -4
- package/lib/hmr/lazyCompilationBackend.js +13 -10
- package/lib/ids/DeterministicChunkIdsPlugin.js +0 -1
- package/lib/ids/HashedModuleIdsPlugin.js +5 -7
- package/lib/ids/IdHelpers.js +1 -1
- package/lib/ids/NamedChunkIdsPlugin.js +1 -6
- package/lib/ids/NamedModuleIdsPlugin.js +1 -5
- package/lib/ids/NaturalChunkIdsPlugin.js +0 -1
- package/lib/ids/NaturalModuleIdsPlugin.js +0 -1
- package/lib/ids/OccurrenceChunkIdsPlugin.js +0 -1
- package/lib/ids/OccurrenceModuleIdsPlugin.js +0 -1
- package/lib/ids/SyncModuleIdsPlugin.js +4 -3
- package/lib/index.js +8 -7
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +4 -1
- package/lib/javascript/BasicEvaluatedExpression.js +13 -6
- package/lib/javascript/ChunkFormatHelpers.js +1 -1
- package/lib/javascript/CommonJsChunkFormatPlugin.js +0 -1
- package/lib/javascript/JavascriptGenerator.js +2 -3
- package/lib/javascript/JavascriptModulesPlugin.js +46 -24
- package/lib/javascript/JavascriptParser.js +120 -55
- package/lib/javascript/JavascriptParserHelpers.js +2 -2
- package/lib/javascript/StartupHelpers.js +2 -4
- package/lib/json/JsonData.js +1 -1
- package/lib/json/JsonGenerator.js +4 -5
- package/lib/json/JsonModulesPlugin.js +0 -3
- package/lib/json/JsonParser.js +4 -2
- package/lib/library/AbstractLibraryPlugin.js +2 -2
- package/lib/library/AmdLibraryPlugin.js +0 -1
- package/lib/library/AssignLibraryPlugin.js +23 -12
- package/lib/library/EnableLibraryPlugin.js +7 -11
- package/lib/library/ExportPropertyLibraryPlugin.js +8 -20
- package/lib/library/JsonpLibraryPlugin.js +5 -2
- package/lib/library/ModuleLibraryPlugin.js +88 -43
- package/lib/library/SystemLibraryPlugin.js +15 -6
- package/lib/library/UmdLibraryPlugin.js +12 -18
- package/lib/logging/Logger.js +12 -10
- package/lib/logging/createConsoleLogger.js +15 -14
- package/lib/logging/truncateArgs.js +1 -1
- package/lib/node/CommonJsChunkLoadingPlugin.js +2 -1
- package/lib/node/NodeWatchFileSystem.js +4 -4
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -2
- package/lib/node/RequireChunkLoadingRuntimeModule.js +5 -2
- package/lib/node/nodeConsole.js +2 -2
- package/lib/optimize/AggressiveSplittingPlugin.js +2 -0
- package/lib/optimize/ConcatenatedModule.js +142 -100
- package/lib/optimize/InnerGraph.js +17 -11
- package/lib/optimize/InnerGraphPlugin.js +0 -3
- package/lib/optimize/ModuleConcatenationPlugin.js +3 -4
- package/lib/optimize/RealContentHashPlugin.js +5 -3
- package/lib/optimize/RuntimeChunkPlugin.js +0 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +3 -10
- package/lib/optimize/SplitChunksPlugin.js +46 -40
- package/lib/performance/SizeLimitsPlugin.js +2 -1
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +5 -7
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +0 -2
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +0 -1
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +2 -2
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +2 -2
- package/lib/rules/BasicMatcherRulePlugin.js +0 -2
- package/lib/rules/ObjectMatcherRulePlugin.js +0 -1
- package/lib/rules/RuleSetCompiler.js +8 -6
- package/lib/runtime/BaseUriRuntimeModule.js +2 -2
- package/lib/runtime/CompatRuntimeModule.js +0 -1
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +8 -9
- package/lib/runtime/LoadScriptRuntimeModule.js +0 -2
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +1 -1
- package/lib/runtime/PublicPathRuntimeModule.js +2 -2
- 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 +2 -28
- package/lib/schemes/FileUriPlugin.js +5 -2
- package/lib/schemes/HttpUriPlugin.js +4 -2
- package/lib/schemes/VirtualUrlPlugin.js +11 -11
- package/lib/serialization/FileMiddleware.js +1 -1
- package/lib/serialization/NullPrototypeObjectSerializer.js +5 -3
- package/lib/serialization/ObjectMiddleware.js +31 -20
- package/lib/serialization/SerializerMiddleware.js +1 -3
- package/lib/serialization/types.js +1 -1
- package/lib/sharing/ConsumeSharedModule.js +3 -5
- package/lib/sharing/ConsumeSharedPlugin.js +2 -4
- package/lib/sharing/ConsumeSharedRuntimeModule.js +9 -6
- package/lib/sharing/ProvideSharedModule.js +3 -7
- package/lib/sharing/SharePlugin.js +0 -2
- package/lib/sharing/ShareRuntimeModule.js +4 -1
- package/lib/sharing/resolveMatchedConfigs.js +14 -6
- package/lib/sharing/utils.js +0 -6
- package/lib/stats/DefaultStatsFactoryPlugin.js +179 -95
- package/lib/stats/DefaultStatsPresetPlugin.js +15 -9
- package/lib/stats/DefaultStatsPrinterPlugin.js +77 -113
- package/lib/stats/StatsFactory.js +14 -11
- package/lib/url/URLParserPlugin.js +2 -4
- package/lib/util/ArrayHelpers.js +4 -4
- package/lib/util/AsyncQueue.js +1 -0
- package/lib/util/Hash.js +35 -5
- package/lib/util/LazySet.js +2 -2
- package/lib/util/StackedCacheMap.js +0 -2
- package/lib/util/TupleSet.js +9 -4
- package/lib/util/URLAbsoluteSpecifier.js +0 -1
- package/lib/util/WeakTupleMap.js +1 -1
- package/lib/util/chainedImports.js +3 -1
- package/lib/util/cleverMerge.js +15 -18
- package/lib/util/comparators.js +2 -4
- package/lib/util/compileBooleanMatcher.js +11 -9
- package/lib/util/concatenate.js +1 -2
- package/lib/util/create-schema-validation.js +1 -2
- package/lib/util/createHash.js +85 -15
- package/lib/util/dataURL.js +39 -0
- package/lib/util/deprecation.js +29 -31
- package/lib/util/deterministicGrouping.js +34 -30
- package/lib/util/extractSourceMap.js +319 -0
- package/lib/util/findGraphRoots.js +15 -5
- package/lib/util/fs.js +29 -8
- package/lib/util/hash/BatchedHash.js +47 -8
- package/lib/util/hash/wasm-hash.js +53 -13
- package/lib/util/semver.js +9 -8
- package/lib/util/smartGrouping.js +41 -26
- package/lib/util/traverseDestructuringAssignmentProperties.js +45 -0
- package/lib/wasm/EnableWasmLoadingPlugin.js +3 -2
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +5 -1
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +2 -13
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +2 -9
- package/lib/wasm-async/AsyncWebAssemblyParser.js +2 -10
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +6 -4
- package/lib/wasm-sync/WebAssemblyGenerator.js +1 -3
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -4
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -7
- package/lib/wasm-sync/WebAssemblyParser.js +1 -13
- package/lib/web/JsonpChunkLoadingPlugin.js +2 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -1
- package/lib/web/JsonpTemplatePlugin.js +0 -1
- package/lib/webpack.js +21 -8
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +2 -1
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
- package/package.json +21 -21
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +93 -96
- package/schemas/plugins/BannerPlugin.check.js +1 -1
- package/schemas/plugins/BannerPlugin.json +4 -0
- package/schemas/plugins/IgnorePlugin.json +1 -1
- package/schemas/plugins/ProgressPlugin.json +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.json +5 -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/schemes/VirtualUrlPlugin.json +3 -3
- package/types.d.ts +1699 -706
- package/SECURITY.md +0 -9
- package/schemas/plugins/HashedModuleIdsPlugin.check.d.ts +0 -7
- package/schemas/plugins/HashedModuleIdsPlugin.check.js +0 -6
package/lib/config/defaults.js
CHANGED
|
@@ -9,8 +9,10 @@ const fs = require("fs");
|
|
|
9
9
|
const path = require("path");
|
|
10
10
|
const {
|
|
11
11
|
ASSET_MODULE_TYPE,
|
|
12
|
+
ASSET_MODULE_TYPE_BYTES,
|
|
12
13
|
ASSET_MODULE_TYPE_INLINE,
|
|
13
14
|
ASSET_MODULE_TYPE_RESOURCE,
|
|
15
|
+
ASSET_MODULE_TYPE_SOURCE,
|
|
14
16
|
CSS_MODULE_TYPE,
|
|
15
17
|
CSS_MODULE_TYPE_AUTO,
|
|
16
18
|
CSS_MODULE_TYPE_GLOBAL,
|
|
@@ -30,14 +32,11 @@ const {
|
|
|
30
32
|
getTargetsProperties
|
|
31
33
|
} = require("./target");
|
|
32
34
|
|
|
33
|
-
/** @typedef {import("../../declarations/WebpackOptions").CacheOptions} CacheOptions */
|
|
34
35
|
/** @typedef {import("../../declarations/WebpackOptions").CacheOptionsNormalized} CacheOptionsNormalized */
|
|
35
36
|
/** @typedef {import("../../declarations/WebpackOptions").Context} Context */
|
|
36
37
|
/** @typedef {import("../../declarations/WebpackOptions").CssGeneratorOptions} CssGeneratorOptions */
|
|
37
|
-
/** @typedef {import("../../declarations/WebpackOptions").CssParserOptions} CssParserOptions */
|
|
38
38
|
/** @typedef {import("../../declarations/WebpackOptions").EntryDescription} EntryDescription */
|
|
39
39
|
/** @typedef {import("../../declarations/WebpackOptions").EntryNormalized} Entry */
|
|
40
|
-
/** @typedef {import("../../declarations/WebpackOptions").EntryStaticNormalized} EntryStaticNormalized */
|
|
41
40
|
/** @typedef {import("../../declarations/WebpackOptions").Environment} Environment */
|
|
42
41
|
/** @typedef {import("../../declarations/WebpackOptions").Experiments} Experiments */
|
|
43
42
|
/** @typedef {import("../../declarations/WebpackOptions").ExperimentsNormalized} ExperimentsNormalized */
|
|
@@ -50,13 +49,12 @@ const {
|
|
|
50
49
|
/** @typedef {import("../../declarations/WebpackOptions").JsonGeneratorOptions} JsonGeneratorOptions */
|
|
51
50
|
/** @typedef {import("../../declarations/WebpackOptions").Library} Library */
|
|
52
51
|
/** @typedef {import("../../declarations/WebpackOptions").LibraryName} LibraryName */
|
|
53
|
-
/** @typedef {import("../../declarations/WebpackOptions").LibraryOptions} LibraryOptions */
|
|
54
52
|
/** @typedef {import("../../declarations/WebpackOptions").LibraryType} LibraryType */
|
|
55
53
|
/** @typedef {import("../../declarations/WebpackOptions").Loader} Loader */
|
|
56
54
|
/** @typedef {import("../../declarations/WebpackOptions").Mode} Mode */
|
|
57
55
|
/** @typedef {import("../../declarations/WebpackOptions").ModuleOptionsNormalized} ModuleOptions */
|
|
58
56
|
/** @typedef {import("../../declarations/WebpackOptions").Node} WebpackNode */
|
|
59
|
-
/** @typedef {import("../../declarations/WebpackOptions").
|
|
57
|
+
/** @typedef {import("../../declarations/WebpackOptions").OptimizationNormalized} Optimization */
|
|
60
58
|
/** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksOptions} OptimizationSplitChunksOptions */
|
|
61
59
|
/** @typedef {import("../../declarations/WebpackOptions").OutputNormalized} Output */
|
|
62
60
|
/** @typedef {import("../../declarations/WebpackOptions").ParserOptionsByModuleTypeKnown} ParserOptionsByModuleTypeKnown */
|
|
@@ -64,14 +62,149 @@ const {
|
|
|
64
62
|
/** @typedef {import("../../declarations/WebpackOptions").ResolveOptions} ResolveOptions */
|
|
65
63
|
/** @typedef {import("../../declarations/WebpackOptions").RuleSetRules} RuleSetRules */
|
|
66
64
|
/** @typedef {import("../../declarations/WebpackOptions").SnapshotOptions} SnapshotOptions */
|
|
67
|
-
/** @typedef {import("../../declarations/WebpackOptions").Target} Target */
|
|
68
|
-
/** @typedef {import("../../declarations/WebpackOptions").WebpackOptions} WebpackOptions */
|
|
69
65
|
/** @typedef {import("../../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptionsNormalized */
|
|
70
|
-
/** @typedef {import("../Compiler")} Compiler */
|
|
71
66
|
/** @typedef {import("../Module")} Module */
|
|
72
67
|
/** @typedef {import("./target").PlatformTargetProperties} PlatformTargetProperties */
|
|
73
68
|
/** @typedef {import("./target").TargetProperties} TargetProperties */
|
|
74
69
|
|
|
70
|
+
/**
|
|
71
|
+
* @template T
|
|
72
|
+
* @typedef {{ [P in keyof T]-?: T[P] extends object ? RecursiveNonNullable<NonNullable<T[P]>> : NonNullable<T[P]> }} RecursiveNonNullable
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @typedef {Output & {
|
|
77
|
+
* uniqueName: NonNullable<Output["uniqueName"]>,
|
|
78
|
+
* filename: NonNullable<Output["filename"]>,
|
|
79
|
+
* cssFilename: NonNullable<Output["cssFilename"]>,
|
|
80
|
+
* chunkFilename: NonNullable<Output["chunkFilename"]>,
|
|
81
|
+
* cssChunkFilename: NonNullable<Output["cssChunkFilename"]>,
|
|
82
|
+
* hotUpdateChunkFilename: NonNullable<Output["hotUpdateChunkFilename"]>,
|
|
83
|
+
* hotUpdateGlobal: NonNullable<Output["hotUpdateGlobal"]>,
|
|
84
|
+
* assetModuleFilename: NonNullable<Output["assetModuleFilename"]>,
|
|
85
|
+
* webassemblyModuleFilename: NonNullable<Output["webassemblyModuleFilename"]>
|
|
86
|
+
* sourceMapFilename: NonNullable<Output["sourceMapFilename"]>,
|
|
87
|
+
* hotUpdateMainFilename: NonNullable<Output["hotUpdateMainFilename"]>,
|
|
88
|
+
* devtoolNamespace: NonNullable<Output["devtoolNamespace"]>,
|
|
89
|
+
* publicPath: NonNullable<Output["publicPath"]>
|
|
90
|
+
* workerPublicPath: NonNullable<Output["workerPublicPath"]>
|
|
91
|
+
* workerWasmLoading: NonNullable<Output["workerWasmLoading"]>
|
|
92
|
+
* workerChunkLoading: NonNullable<Output["workerChunkLoading"]>
|
|
93
|
+
* chunkFormat: NonNullable<Output["chunkFormat"]>,
|
|
94
|
+
* module: NonNullable<Output["module"]>,
|
|
95
|
+
* asyncChunks: NonNullable<Output["asyncChunks"]>,
|
|
96
|
+
* charset: NonNullable<Output["charset"]>,
|
|
97
|
+
* iife: NonNullable<Output["iife"]>,
|
|
98
|
+
* globalObject: NonNullable<Output["globalObject"]>,
|
|
99
|
+
* scriptType: NonNullable<Output["scriptType"]>,
|
|
100
|
+
* path: NonNullable<Output["path"]>,
|
|
101
|
+
* pathinfo: NonNullable<Output["pathinfo"]>,
|
|
102
|
+
* hashFunction: NonNullable<Output["hashFunction"]>,
|
|
103
|
+
* hashDigest: NonNullable<Output["hashDigest"]>,
|
|
104
|
+
* hashDigestLength: NonNullable<Output["hashDigestLength"]>,
|
|
105
|
+
* chunkLoadTimeout: NonNullable<Output["chunkLoadTimeout"]>,
|
|
106
|
+
* chunkLoading: NonNullable<Output["chunkLoading"]>,
|
|
107
|
+
* chunkLoadingGlobal: NonNullable<Output["chunkLoadingGlobal"]>,
|
|
108
|
+
* compareBeforeEmit: NonNullable<Output["compareBeforeEmit"]>,
|
|
109
|
+
* strictModuleErrorHandling: NonNullable<Output["strictModuleErrorHandling"]>,
|
|
110
|
+
* strictModuleExceptionHandling: NonNullable<Output["strictModuleExceptionHandling"]>,
|
|
111
|
+
* importFunctionName: NonNullable<Output["importFunctionName"]>,
|
|
112
|
+
* importMetaName: NonNullable<Output["importMetaName"]>,
|
|
113
|
+
* environment: RecursiveNonNullable<Output["environment"]>,
|
|
114
|
+
* crossOriginLoading: NonNullable<Output["crossOriginLoading"]>,
|
|
115
|
+
* wasmLoading: NonNullable<Output["wasmLoading"]>,
|
|
116
|
+
* }} OutputNormalizedWithDefaults
|
|
117
|
+
*/
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* @typedef {SnapshotOptions & {
|
|
121
|
+
* managedPaths: NonNullable<SnapshotOptions["managedPaths"]>,
|
|
122
|
+
* unmanagedPaths: NonNullable<SnapshotOptions["unmanagedPaths"]>,
|
|
123
|
+
* immutablePaths: NonNullable<SnapshotOptions["immutablePaths"]>,
|
|
124
|
+
* resolveBuildDependencies: NonNullable<SnapshotOptions["resolveBuildDependencies"]>,
|
|
125
|
+
* buildDependencies: NonNullable<SnapshotOptions["buildDependencies"]>,
|
|
126
|
+
* module: NonNullable<SnapshotOptions["module"]>,
|
|
127
|
+
* resolve: NonNullable<SnapshotOptions["resolve"]>,
|
|
128
|
+
* }} SnapshotNormalizedWithDefaults
|
|
129
|
+
*/
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* @typedef {Optimization & {
|
|
133
|
+
* runtimeChunk: NonNullable<Optimization["runtimeChunk"]>,
|
|
134
|
+
* splitChunks: NonNullable<Optimization["splitChunks"]>,
|
|
135
|
+
* mergeDuplicateChunks: NonNullable<Optimization["mergeDuplicateChunks"]>,
|
|
136
|
+
* removeAvailableModules: NonNullable<Optimization["removeAvailableModules"]>,
|
|
137
|
+
* removeEmptyChunks: NonNullable<Optimization["removeEmptyChunks"]>,
|
|
138
|
+
* flagIncludedChunks: NonNullable<Optimization["flagIncludedChunks"]>,
|
|
139
|
+
* moduleIds: NonNullable<Optimization["moduleIds"]>,
|
|
140
|
+
* chunkIds: NonNullable<Optimization["chunkIds"]>,
|
|
141
|
+
* sideEffects: NonNullable<Optimization["sideEffects"]>,
|
|
142
|
+
* providedExports: NonNullable<Optimization["providedExports"]>,
|
|
143
|
+
* usedExports: NonNullable<Optimization["usedExports"]>,
|
|
144
|
+
* mangleExports: NonNullable<Optimization["mangleExports"]>,
|
|
145
|
+
* innerGraph: NonNullable<Optimization["innerGraph"]>,
|
|
146
|
+
* concatenateModules: NonNullable<Optimization["concatenateModules"]>,
|
|
147
|
+
* avoidEntryIife: NonNullable<Optimization["avoidEntryIife"]>,
|
|
148
|
+
* emitOnErrors: NonNullable<Optimization["emitOnErrors"]>,
|
|
149
|
+
* checkWasmTypes: NonNullable<Optimization["checkWasmTypes"]>,
|
|
150
|
+
* mangleWasmImports: NonNullable<Optimization["mangleWasmImports"]>,
|
|
151
|
+
* portableRecords: NonNullable<Optimization["portableRecords"]>,
|
|
152
|
+
* realContentHash: NonNullable<Optimization["realContentHash"]>,
|
|
153
|
+
* minimize: NonNullable<Optimization["minimize"]>,
|
|
154
|
+
* minimizer: NonNullable<Exclude<Optimization["minimizer"], "...">>,
|
|
155
|
+
* nodeEnv: NonNullable<Optimization["nodeEnv"]>,
|
|
156
|
+
* }} OptimizationNormalizedWithDefaults
|
|
157
|
+
*/
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* @typedef {ExternalsPresets & {
|
|
161
|
+
* web: NonNullable<ExternalsPresets["web"]>,
|
|
162
|
+
* node: NonNullable<ExternalsPresets["node"]>,
|
|
163
|
+
* nwjs: NonNullable<ExternalsPresets["nwjs"]>,
|
|
164
|
+
* electron: NonNullable<ExternalsPresets["electron"]>,
|
|
165
|
+
* electronMain: NonNullable<ExternalsPresets["electronMain"]>,
|
|
166
|
+
* electronPreload: NonNullable<ExternalsPresets["electronPreload"]>,
|
|
167
|
+
* electronRenderer: NonNullable<ExternalsPresets["electronRenderer"]>,
|
|
168
|
+
* }} ExternalsPresetsNormalizedWithDefaults
|
|
169
|
+
*/
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* @typedef {InfrastructureLogging & {
|
|
173
|
+
* stream: NonNullable<InfrastructureLogging["stream"]>,
|
|
174
|
+
* level: NonNullable<InfrastructureLogging["level"]>,
|
|
175
|
+
* debug: NonNullable<InfrastructureLogging["debug"]>,
|
|
176
|
+
* colors: NonNullable<InfrastructureLogging["colors"]>,
|
|
177
|
+
* appendOnly: NonNullable<InfrastructureLogging["appendOnly"]>,
|
|
178
|
+
* }} InfrastructureLoggingNormalizedWithDefaults
|
|
179
|
+
*/
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* @typedef {WebpackOptionsNormalized
|
|
183
|
+
* & { context: NonNullable<WebpackOptionsNormalized["context"]> }
|
|
184
|
+
* & { infrastructureLogging: InfrastructureLoggingNormalizedWithDefaults }
|
|
185
|
+
* } WebpackOptionsNormalizedWithBaseDefaults
|
|
186
|
+
*/
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* @typedef {WebpackOptionsNormalizedWithBaseDefaults
|
|
190
|
+
* & { target: NonNullable<WebpackOptionsNormalized["target"]> }
|
|
191
|
+
* & { output: OutputNormalizedWithDefaults }
|
|
192
|
+
* & { optimization: OptimizationNormalizedWithDefaults }
|
|
193
|
+
* & { devtool: NonNullable<WebpackOptionsNormalized["devtool"]> }
|
|
194
|
+
* & { stats: NonNullable<WebpackOptionsNormalized["stats"]> }
|
|
195
|
+
* & { node: NonNullable<WebpackOptionsNormalized["node"]> }
|
|
196
|
+
* & { profile: NonNullable<WebpackOptionsNormalized["profile"]> }
|
|
197
|
+
* & { parallelism: NonNullable<WebpackOptionsNormalized["parallelism"]> }
|
|
198
|
+
* & { snapshot: SnapshotNormalizedWithDefaults }
|
|
199
|
+
* & { externalsPresets: ExternalsPresetsNormalizedWithDefaults }
|
|
200
|
+
* & { externalsType: NonNullable<WebpackOptionsNormalized["externalsType"]> }
|
|
201
|
+
* & { watch: NonNullable<WebpackOptionsNormalized["watch"]> }
|
|
202
|
+
* & { performance: NonNullable<WebpackOptionsNormalized["performance"]> }
|
|
203
|
+
* & { recordsInputPath: NonNullable<WebpackOptionsNormalized["recordsInputPath"]> }
|
|
204
|
+
* & { recordsOutputPath: NonNullable<WebpackOptionsNormalized["recordsOutputPath"]>
|
|
205
|
+
* }} WebpackOptionsNormalizedWithDefaults
|
|
206
|
+
*/
|
|
207
|
+
|
|
75
208
|
/**
|
|
76
209
|
* @typedef {object} ResolvedOptions
|
|
77
210
|
* @property {PlatformTargetProperties | false} platform - platform target properties
|
|
@@ -140,9 +273,9 @@ const A = (obj, prop, factory) => {
|
|
|
140
273
|
newArray = value.slice(0, i);
|
|
141
274
|
obj[prop] = /** @type {T[P]} */ (/** @type {unknown} */ (newArray));
|
|
142
275
|
}
|
|
143
|
-
const items =
|
|
144
|
-
/** @type {
|
|
145
|
-
|
|
276
|
+
const items =
|
|
277
|
+
/** @type {EXPECTED_ANY[]} */
|
|
278
|
+
(/** @type {unknown} */ (factory()));
|
|
146
279
|
if (items !== undefined) {
|
|
147
280
|
for (const item of items) {
|
|
148
281
|
newArray.push(item);
|
|
@@ -383,20 +516,12 @@ const applyExperimentsDefaults = (
|
|
|
383
516
|
D(experiments, "syncWebAssembly", false);
|
|
384
517
|
D(experiments, "asyncWebAssembly", experiments.futureDefaults);
|
|
385
518
|
D(experiments, "outputModule", false);
|
|
386
|
-
D(experiments, "layers", false);
|
|
387
519
|
D(experiments, "lazyCompilation", undefined);
|
|
388
520
|
D(experiments, "buildHttp", undefined);
|
|
389
521
|
D(experiments, "cacheUnaffected", experiments.futureDefaults);
|
|
390
522
|
D(experiments, "deferImport", false);
|
|
391
523
|
F(experiments, "css", () => (experiments.futureDefaults ? true : undefined));
|
|
392
524
|
|
|
393
|
-
// TODO webpack 6: remove this. topLevelAwait should be enabled by default
|
|
394
|
-
let shouldEnableTopLevelAwait = true;
|
|
395
|
-
if (typeof experiments.topLevelAwait === "boolean") {
|
|
396
|
-
shouldEnableTopLevelAwait = experiments.topLevelAwait;
|
|
397
|
-
}
|
|
398
|
-
D(experiments, "topLevelAwait", shouldEnableTopLevelAwait);
|
|
399
|
-
|
|
400
525
|
if (typeof experiments.buildHttp === "object") {
|
|
401
526
|
D(experiments.buildHttp, "frozen", production);
|
|
402
527
|
D(experiments.buildHttp, "upgrade", false);
|
|
@@ -556,6 +681,7 @@ const applySnapshotDefaults = (snapshot, { production, futureDefaults }) => {
|
|
|
556
681
|
F(snapshot, "module", () =>
|
|
557
682
|
production ? { timestamp: true, hash: true } : { timestamp: true }
|
|
558
683
|
);
|
|
684
|
+
F(snapshot, "contextModule", () => ({ timestamp: true }));
|
|
559
685
|
F(snapshot, "resolve", () =>
|
|
560
686
|
production ? { timestamp: true, hash: true } : { timestamp: true }
|
|
561
687
|
);
|
|
@@ -931,12 +1057,20 @@ const applyModuleDefaults = (
|
|
|
931
1057
|
]
|
|
932
1058
|
},
|
|
933
1059
|
{
|
|
934
|
-
|
|
1060
|
+
with: { type: JSON_MODULE_TYPE },
|
|
935
1061
|
type: JSON_MODULE_TYPE
|
|
936
1062
|
},
|
|
937
1063
|
{
|
|
938
|
-
|
|
1064
|
+
assert: { type: JSON_MODULE_TYPE },
|
|
939
1065
|
type: JSON_MODULE_TYPE
|
|
1066
|
+
},
|
|
1067
|
+
{
|
|
1068
|
+
with: { type: "text" },
|
|
1069
|
+
type: ASSET_MODULE_TYPE_SOURCE
|
|
1070
|
+
},
|
|
1071
|
+
{
|
|
1072
|
+
with: { type: "bytes" },
|
|
1073
|
+
type: ASSET_MODULE_TYPE_BYTES
|
|
940
1074
|
}
|
|
941
1075
|
);
|
|
942
1076
|
return rules;
|
|
@@ -1192,8 +1326,13 @@ const applyOutputDefaults = (
|
|
|
1192
1326
|
if (tp.importScripts) return "array-push";
|
|
1193
1327
|
throw new Error(
|
|
1194
1328
|
"For the selected environment is no default script chunk format available:\n" +
|
|
1195
|
-
|
|
1196
|
-
|
|
1329
|
+
`${
|
|
1330
|
+
tp.module
|
|
1331
|
+
? "Module ('module') can be chosen when ES modules are available (please set 'experiments.outputModule' and 'output.module' to `true`)"
|
|
1332
|
+
: ""
|
|
1333
|
+
}\n` +
|
|
1334
|
+
"JSONP Array push ('array-push') can be chosen when 'document' or 'importScripts' is available.\n" +
|
|
1335
|
+
`CommonJs exports ('commonjs') can be chosen when 'require' or node builtins are available.\n${
|
|
1197
1336
|
helpMessage
|
|
1198
1337
|
}`
|
|
1199
1338
|
);
|
|
@@ -15,13 +15,13 @@ const util = require("util");
|
|
|
15
15
|
/** @typedef {import("../../declarations/WebpackOptions").LibraryName} LibraryName */
|
|
16
16
|
/** @typedef {import("../../declarations/WebpackOptions").LibraryOptions} LibraryOptions */
|
|
17
17
|
/** @typedef {import("../../declarations/WebpackOptions").ModuleOptionsNormalized} ModuleOptionsNormalized */
|
|
18
|
+
/** @typedef {import("../../declarations/WebpackOptions").OptimizationNormalized} OptimizationNormalized */
|
|
18
19
|
/** @typedef {import("../../declarations/WebpackOptions").OptimizationRuntimeChunk} OptimizationRuntimeChunk */
|
|
19
20
|
/** @typedef {import("../../declarations/WebpackOptions").OptimizationRuntimeChunkNormalized} OptimizationRuntimeChunkNormalized */
|
|
20
21
|
/** @typedef {import("../../declarations/WebpackOptions").OutputNormalized} OutputNormalized */
|
|
21
|
-
/** @typedef {import("../../declarations/WebpackOptions").
|
|
22
|
+
/** @typedef {import("../../declarations/WebpackOptions").PluginsNormalized} PluginsNormalized */
|
|
22
23
|
/** @typedef {import("../../declarations/WebpackOptions").WebpackOptions} WebpackOptions */
|
|
23
24
|
/** @typedef {import("../../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptionsNormalized */
|
|
24
|
-
/** @typedef {import("../Entrypoint")} Entrypoint */
|
|
25
25
|
/** @typedef {import("../WebpackError")} WebpackError */
|
|
26
26
|
|
|
27
27
|
const handledDeprecatedNoEmitOnErrors = util.deprecate(
|
|
@@ -287,6 +287,12 @@ const getNormalizedWebpackOptions = (config) => ({
|
|
|
287
287
|
cacheGroups: cloneObject(splitChunks.cacheGroups)
|
|
288
288
|
}
|
|
289
289
|
),
|
|
290
|
+
minimizer:
|
|
291
|
+
optimization.minimizer !== undefined
|
|
292
|
+
? /** @type {OptimizationNormalized["minimizer"]} */ (
|
|
293
|
+
nestedArray(optimization.minimizer, (p) => p.filter(Boolean))
|
|
294
|
+
)
|
|
295
|
+
: optimization.minimizer,
|
|
290
296
|
emitOnErrors:
|
|
291
297
|
optimization.noEmitOnErrors !== undefined
|
|
292
298
|
? handledDeprecatedNoEmitOnErrors(
|
|
@@ -410,7 +416,9 @@ const getNormalizedWebpackOptions = (config) => ({
|
|
|
410
416
|
...performance
|
|
411
417
|
};
|
|
412
418
|
}),
|
|
413
|
-
plugins: /** @type {
|
|
419
|
+
plugins: /** @type {PluginsNormalized} */ (
|
|
420
|
+
nestedArray(config.plugins, (p) => p.filter(Boolean))
|
|
421
|
+
),
|
|
414
422
|
profile: config.profile,
|
|
415
423
|
recordsInputPath:
|
|
416
424
|
config.recordsInputPath !== undefined
|
|
@@ -448,6 +456,13 @@ const getNormalizedWebpackOptions = (config) => ({
|
|
|
448
456
|
timestamp: module.timestamp,
|
|
449
457
|
hash: module.hash
|
|
450
458
|
})),
|
|
459
|
+
contextModule: optionalNestedConfig(
|
|
460
|
+
snapshot.contextModule,
|
|
461
|
+
(contextModule) => ({
|
|
462
|
+
timestamp: contextModule.timestamp,
|
|
463
|
+
hash: contextModule.hash
|
|
464
|
+
})
|
|
465
|
+
),
|
|
451
466
|
immutablePaths: optionalNestedArray(snapshot.immutablePaths, (p) => [...p]),
|
|
452
467
|
managedPaths: optionalNestedArray(snapshot.managedPaths, (p) => [...p]),
|
|
453
468
|
unmanagedPaths: optionalNestedArray(snapshot.unmanagedPaths, (p) => [...p])
|
package/lib/config/target.js
CHANGED
|
@@ -16,7 +16,7 @@ const getBrowserslistTargetHandler = memoize(() =>
|
|
|
16
16
|
* @returns {string} default target
|
|
17
17
|
*/
|
|
18
18
|
const getDefaultTarget = (context) => {
|
|
19
|
-
const browsers = getBrowserslistTargetHandler().load(
|
|
19
|
+
const browsers = getBrowserslistTargetHandler().load(undefined, context);
|
|
20
20
|
return browsers ? "browserslist" : "web";
|
|
21
21
|
};
|
|
22
22
|
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
const Dependency = require("../Dependency");
|
|
9
9
|
const makeSerializable = require("../util/makeSerializable");
|
|
10
10
|
|
|
11
|
-
/** @typedef {import("./ContainerEntryModule").ExposeOptions} ExposeOptions */
|
|
12
11
|
/** @typedef {import("./ContainerEntryModule").ExposesList} ExposesList */
|
|
13
12
|
|
|
14
13
|
class ContainerEntryDependency extends Dependency {
|
|
@@ -16,25 +16,21 @@ const StaticExportsDependency = require("../dependencies/StaticExportsDependency
|
|
|
16
16
|
const makeSerializable = require("../util/makeSerializable");
|
|
17
17
|
const ContainerExposedDependency = require("./ContainerExposedDependency");
|
|
18
18
|
|
|
19
|
-
/** @typedef {import("
|
|
20
|
-
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
|
21
|
-
/** @typedef {import("../ChunkGroup")} ChunkGroup */
|
|
19
|
+
/** @typedef {import("../config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */
|
|
22
20
|
/** @typedef {import("../Compilation")} Compilation */
|
|
23
21
|
/** @typedef {import("../Module").BuildCallback} BuildCallback */
|
|
24
22
|
/** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
|
|
25
23
|
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
|
|
26
24
|
/** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */
|
|
25
|
+
/** @typedef {import("../Module").LibIdent} LibIdent */
|
|
27
26
|
/** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */
|
|
28
27
|
/** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */
|
|
29
28
|
/** @typedef {import("../Module").SourceTypes} SourceTypes */
|
|
30
29
|
/** @typedef {import("../RequestShortener")} RequestShortener */
|
|
31
30
|
/** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
|
32
|
-
/** @typedef {import("../WebpackError")} WebpackError */
|
|
33
31
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
34
32
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
35
|
-
/** @typedef {import("../util/Hash")} Hash */
|
|
36
33
|
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
|
|
37
|
-
/** @typedef {import("./ContainerEntryDependency")} ContainerEntryDependency */
|
|
38
34
|
|
|
39
35
|
/**
|
|
40
36
|
* @typedef {object} ExposeOptions
|
|
@@ -83,7 +79,7 @@ class ContainerEntryModule extends Module {
|
|
|
83
79
|
|
|
84
80
|
/**
|
|
85
81
|
* @param {LibIdentOptions} options options
|
|
86
|
-
* @returns {
|
|
82
|
+
* @returns {LibIdent | null} an identifier for library inclusion
|
|
87
83
|
*/
|
|
88
84
|
libIdent(options) {
|
|
89
85
|
return `${this.layer ? `(${this.layer})/` : ""}webpack/container/entry/${
|
|
@@ -14,7 +14,6 @@ const { parseOptions } = require("./options");
|
|
|
14
14
|
|
|
15
15
|
/** @typedef {import("../../declarations/plugins/container/ContainerPlugin").ContainerPluginOptions} ContainerPluginOptions */
|
|
16
16
|
/** @typedef {import("../Compiler")} Compiler */
|
|
17
|
-
/** @typedef {import("./ContainerEntryModule").ExposeOptions} ExposeOptions */
|
|
18
17
|
/** @typedef {import("./ContainerEntryModule").ExposesList} ExposesList */
|
|
19
18
|
|
|
20
19
|
const getModuleFederationPlugin = memoize(() =>
|
|
@@ -83,7 +82,7 @@ class ContainerPlugin {
|
|
|
83
82
|
const dep = new ContainerEntryDependency(name, exposes, shareScope);
|
|
84
83
|
dep.loc = { name };
|
|
85
84
|
compilation.addEntry(
|
|
86
|
-
|
|
85
|
+
compilation.options.context,
|
|
87
86
|
dep,
|
|
88
87
|
{
|
|
89
88
|
name,
|
|
@@ -17,7 +17,6 @@ const RemoteToExternalDependency = require("./RemoteToExternalDependency");
|
|
|
17
17
|
const { parseOptions } = require("./options");
|
|
18
18
|
|
|
19
19
|
/** @typedef {import("../../declarations/plugins/container/ContainerReferencePlugin").ContainerReferencePluginOptions} ContainerReferencePluginOptions */
|
|
20
|
-
/** @typedef {import("../../declarations/plugins/container/ContainerReferencePlugin").RemotesConfig} RemotesConfig */
|
|
21
20
|
/** @typedef {import("../Compiler")} Compiler */
|
|
22
21
|
|
|
23
22
|
const validate = createSchemaValidation(
|
|
@@ -8,12 +8,13 @@
|
|
|
8
8
|
const Dependency = require("../Dependency");
|
|
9
9
|
const makeSerializable = require("../util/makeSerializable");
|
|
10
10
|
|
|
11
|
+
/** @typedef {import("./RemoteModule").ExternalRequests} ExternalRequests */
|
|
11
12
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
12
13
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
13
14
|
|
|
14
15
|
class FallbackDependency extends Dependency {
|
|
15
16
|
/**
|
|
16
|
-
* @param {
|
|
17
|
+
* @param {ExternalRequests} requests requests
|
|
17
18
|
*/
|
|
18
19
|
constructor(requests) {
|
|
19
20
|
super();
|
|
@@ -14,31 +14,30 @@ const Template = require("../Template");
|
|
|
14
14
|
const makeSerializable = require("../util/makeSerializable");
|
|
15
15
|
const FallbackItemDependency = require("./FallbackItemDependency");
|
|
16
16
|
|
|
17
|
-
/** @typedef {import("
|
|
17
|
+
/** @typedef {import("../config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */
|
|
18
18
|
/** @typedef {import("../Chunk")} Chunk */
|
|
19
|
-
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
|
20
|
-
/** @typedef {import("../ChunkGroup")} ChunkGroup */
|
|
21
19
|
/** @typedef {import("../Compilation")} Compilation */
|
|
22
20
|
/** @typedef {import("../Module").BuildCallback} BuildCallback */
|
|
23
21
|
/** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
|
|
24
22
|
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
|
|
25
23
|
/** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */
|
|
24
|
+
/** @typedef {import("../Module").LibIdent} LibIdent */
|
|
25
|
+
/** @typedef {import("../Module").NameForCondition} NameForCondition */
|
|
26
26
|
/** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */
|
|
27
27
|
/** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */
|
|
28
28
|
/** @typedef {import("../Module").SourceTypes} SourceTypes */
|
|
29
29
|
/** @typedef {import("../RequestShortener")} RequestShortener */
|
|
30
30
|
/** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
|
31
|
-
/** @typedef {import("../WebpackError")} WebpackError */
|
|
32
31
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
33
32
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
34
|
-
/** @typedef {import("../util/Hash")} Hash */
|
|
35
33
|
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
|
|
34
|
+
/** @typedef {import("./RemoteModule").ExternalRequests} ExternalRequests */
|
|
36
35
|
|
|
37
36
|
const RUNTIME_REQUIREMENTS = new Set([RuntimeGlobals.module]);
|
|
38
37
|
|
|
39
38
|
class FallbackModule extends Module {
|
|
40
39
|
/**
|
|
41
|
-
* @param {
|
|
40
|
+
* @param {ExternalRequests} requests list of requests to choose one
|
|
42
41
|
*/
|
|
43
42
|
constructor(requests) {
|
|
44
43
|
super(WEBPACK_MODULE_TYPE_FALLBACK);
|
|
@@ -63,7 +62,7 @@ class FallbackModule extends Module {
|
|
|
63
62
|
|
|
64
63
|
/**
|
|
65
64
|
* @param {LibIdentOptions} options options
|
|
66
|
-
* @returns {
|
|
65
|
+
* @returns {LibIdent | null} an identifier for library inclusion
|
|
67
66
|
*/
|
|
68
67
|
libIdent(options) {
|
|
69
68
|
return `${this.layer ? `(${this.layer})/` : ""}webpack/container/fallback/${
|
|
@@ -16,7 +16,6 @@ const HoistContainerReferences = require("./HoistContainerReferencesPlugin");
|
|
|
16
16
|
|
|
17
17
|
/** @typedef {import("../../declarations/plugins/container/ModuleFederationPlugin").ExternalsType} ExternalsType */
|
|
18
18
|
/** @typedef {import("../../declarations/plugins/container/ModuleFederationPlugin").ModuleFederationPluginOptions} ModuleFederationPluginOptions */
|
|
19
|
-
/** @typedef {import("../../declarations/plugins/container/ModuleFederationPlugin").Shared} Shared */
|
|
20
19
|
/** @typedef {import("../Compiler")} Compiler */
|
|
21
20
|
/** @typedef {import("../Dependency")} Dependency */
|
|
22
21
|
|
|
@@ -16,31 +16,31 @@ const makeSerializable = require("../util/makeSerializable");
|
|
|
16
16
|
const FallbackDependency = require("./FallbackDependency");
|
|
17
17
|
const RemoteToExternalDependency = require("./RemoteToExternalDependency");
|
|
18
18
|
|
|
19
|
-
/** @typedef {import("
|
|
20
|
-
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
|
21
|
-
/** @typedef {import("../ChunkGroup")} ChunkGroup */
|
|
19
|
+
/** @typedef {import("../config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */
|
|
22
20
|
/** @typedef {import("../Compilation")} Compilation */
|
|
23
21
|
/** @typedef {import("../Module").BuildCallback} BuildCallback */
|
|
24
22
|
/** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
|
|
25
23
|
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
|
|
26
24
|
/** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */
|
|
25
|
+
/** @typedef {import("../Module").LibIdent} LibIdent */
|
|
26
|
+
/** @typedef {import("../Module").NameForCondition} NameForCondition */
|
|
27
27
|
/** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */
|
|
28
28
|
/** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */
|
|
29
29
|
/** @typedef {import("../Module").SourceTypes} SourceTypes */
|
|
30
30
|
/** @typedef {import("../RequestShortener")} RequestShortener */
|
|
31
31
|
/** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
|
32
|
-
/** @typedef {import("../WebpackError")} WebpackError */
|
|
33
32
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
34
33
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
35
|
-
/** @typedef {import("../util/Hash")} Hash */
|
|
36
34
|
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
|
|
37
35
|
|
|
38
36
|
const RUNTIME_REQUIREMENTS = new Set([RuntimeGlobals.module]);
|
|
39
37
|
|
|
38
|
+
/** @typedef {string[]} ExternalRequests */
|
|
39
|
+
|
|
40
40
|
class RemoteModule extends Module {
|
|
41
41
|
/**
|
|
42
42
|
* @param {string} request request string
|
|
43
|
-
* @param {
|
|
43
|
+
* @param {ExternalRequests} externalRequests list of external requests to containers
|
|
44
44
|
* @param {string} internalRequest name of exposed module in container
|
|
45
45
|
* @param {string} shareScope the used share scope name
|
|
46
46
|
*/
|
|
@@ -72,7 +72,7 @@ class RemoteModule extends Module {
|
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
74
|
* @param {LibIdentOptions} options options
|
|
75
|
-
* @returns {
|
|
75
|
+
* @returns {LibIdent | null} an identifier for library inclusion
|
|
76
76
|
*/
|
|
77
77
|
libIdent(options) {
|
|
78
78
|
return `${this.layer ? `(${this.layer})/` : ""}webpack/container/remote/${
|
|
@@ -131,7 +131,7 @@ class RemoteModule extends Module {
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
/**
|
|
134
|
-
* @returns {
|
|
134
|
+
* @returns {NameForCondition | null} absolute path which should be used for condition matching (usually the resource path)
|
|
135
135
|
*/
|
|
136
136
|
nameForCondition() {
|
|
137
137
|
return this.request;
|
|
@@ -28,9 +28,9 @@ class RemoteRuntimeModule extends RuntimeModule {
|
|
|
28
28
|
const compilation = /** @type {Compilation} */ (this.compilation);
|
|
29
29
|
const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph);
|
|
30
30
|
const { runtimeTemplate, moduleGraph } = compilation;
|
|
31
|
-
/** @type {Record<ChunkId,
|
|
31
|
+
/** @type {Record<ChunkId, ModuleId[]>} */
|
|
32
32
|
const chunkToRemotesMapping = {};
|
|
33
|
-
/** @type {Record<ModuleId, [string, string,
|
|
33
|
+
/** @type {Record<ModuleId, [string, string, ModuleId]>} */
|
|
34
34
|
const idToExternalAndNameMapping = {};
|
|
35
35
|
for (const chunk of /** @type {Chunk} */ (
|
|
36
36
|
this.chunk
|
package/lib/css/CssGenerator.js
CHANGED
|
@@ -24,6 +24,7 @@ const memoize = require("../util/memoize");
|
|
|
24
24
|
/** @typedef {import("../../declarations/WebpackOptions").CssAutoGeneratorOptions} CssAutoGeneratorOptions */
|
|
25
25
|
/** @typedef {import("../../declarations/WebpackOptions").CssGlobalGeneratorOptions} CssGlobalGeneratorOptions */
|
|
26
26
|
/** @typedef {import("../../declarations/WebpackOptions").CssModuleGeneratorOptions} CssModuleGeneratorOptions */
|
|
27
|
+
/** @typedef {import("../Compilation").DependencyConstructor} DependencyConstructor */
|
|
27
28
|
/** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
|
|
28
29
|
/** @typedef {import("../Dependency")} Dependency */
|
|
29
30
|
/** @typedef {import("../DependencyTemplate").CssData} CssData */
|
|
@@ -124,7 +125,7 @@ class CssGenerator extends Generator {
|
|
|
124
125
|
*/
|
|
125
126
|
const handleDependency = (dependency) => {
|
|
126
127
|
const constructor =
|
|
127
|
-
/** @type {
|
|
128
|
+
/** @type {DependencyConstructor} */
|
|
128
129
|
(dependency.constructor);
|
|
129
130
|
const template = generateContext.dependencyTemplates.get(constructor);
|
|
130
131
|
if (!template) {
|
|
@@ -170,11 +171,7 @@ class CssGenerator extends Generator {
|
|
|
170
171
|
usedIdentifiers.add(identifier);
|
|
171
172
|
generateContext.concatenationScope.registerExport(name, identifier);
|
|
172
173
|
source.add(
|
|
173
|
-
`${
|
|
174
|
-
generateContext.runtimeTemplate.supportsConst()
|
|
175
|
-
? "const"
|
|
176
|
-
: "var"
|
|
177
|
-
} ${identifier} = ${JSON.stringify(v)};\n`
|
|
174
|
+
`${generateContext.runtimeTemplate.renderConst()} ${identifier} = ${JSON.stringify(v)};\n`
|
|
178
175
|
);
|
|
179
176
|
}
|
|
180
177
|
return source;
|
|
@@ -13,10 +13,9 @@ const Template = require("../Template");
|
|
|
13
13
|
const compileBooleanMatcher = require("../util/compileBooleanMatcher");
|
|
14
14
|
const { chunkHasCss } = require("./CssModulesPlugin");
|
|
15
15
|
|
|
16
|
-
/** @typedef {import("../../declarations/WebpackOptions").Environment} Environment */
|
|
17
16
|
/** @typedef {import("../Chunk")} Chunk */
|
|
17
|
+
/** @typedef {import("../Chunk").ChunkId} ChunkId */
|
|
18
18
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
|
19
|
-
/** @typedef {import("../Compilation").RuntimeRequirementsContext} RuntimeRequirementsContext */
|
|
20
19
|
/** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
|
|
21
20
|
|
|
22
21
|
/**
|
|
@@ -80,7 +79,7 @@ class CssLoadingRuntimeModule extends RuntimeModule {
|
|
|
80
79
|
} = compilation;
|
|
81
80
|
const fn = RuntimeGlobals.ensureChunkHandlers;
|
|
82
81
|
const conditionMap = chunkGraph.getChunkConditionMap(
|
|
83
|
-
|
|
82
|
+
chunk,
|
|
84
83
|
/**
|
|
85
84
|
* @param {Chunk} chunk the chunk
|
|
86
85
|
* @param {ChunkGraph} chunkGraph the chunk graph
|
|
@@ -98,11 +97,11 @@ class CssLoadingRuntimeModule extends RuntimeModule {
|
|
|
98
97
|
const withHmr = _runtimeRequirements.has(
|
|
99
98
|
RuntimeGlobals.hmrDownloadUpdateHandlers
|
|
100
99
|
);
|
|
101
|
-
/** @type {Set<
|
|
100
|
+
/** @type {Set<ChunkId>} */
|
|
102
101
|
const initialChunkIds = new Set();
|
|
103
|
-
for (const c of
|
|
102
|
+
for (const c of chunk.getAllInitialChunks()) {
|
|
104
103
|
if (chunkHasCss(c, chunkGraph)) {
|
|
105
|
-
initialChunkIds.add(c.id);
|
|
104
|
+
initialChunkIds.add(/** @type {ChunkId} */ (c.id));
|
|
106
105
|
}
|
|
107
106
|
}
|
|
108
107
|
|
|
@@ -110,9 +109,7 @@ class CssLoadingRuntimeModule extends RuntimeModule {
|
|
|
110
109
|
return null;
|
|
111
110
|
}
|
|
112
111
|
|
|
113
|
-
const environment =
|
|
114
|
-
/** @type {Environment} */
|
|
115
|
-
(compilation.outputOptions.environment);
|
|
112
|
+
const environment = compilation.outputOptions.environment;
|
|
116
113
|
const isNeutralPlatform = runtimeTemplate.isNeutralPlatform();
|
|
117
114
|
const withPrefetch =
|
|
118
115
|
this._runtimeRequirements.has(RuntimeGlobals.prefetchChunkHandlers) &&
|