webpack 5.101.3 → 5.102.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.
- 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 +35 -25
- package/lib/ChunkGroup.js +8 -10
- package/lib/ChunkTemplate.js +1 -1
- package/lib/CleanPlugin.js +3 -3
- package/lib/CodeGenerationResults.js +2 -1
- package/lib/CompatibilityPlugin.js +29 -12
- package/lib/Compilation.js +204 -185
- 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 +22 -20
- package/lib/ContextModuleFactory.js +30 -11
- package/lib/ContextReplacementPlugin.js +38 -15
- package/lib/DefinePlugin.js +4 -8
- package/lib/DelegatedModule.js +7 -11
- package/lib/DependenciesBlock.js +0 -2
- package/lib/Dependency.js +9 -11
- package/lib/DependencyTemplates.js +1 -3
- 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 +96 -78
- 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 +41 -24
- 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 +145 -88
- package/lib/NormalModuleFactory.js +59 -40
- 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 +12 -11
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +2 -2
- package/lib/SourceMapDevToolPlugin.js +6 -11
- 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 +166 -0
- package/lib/asset/AssetBytesParser.js +37 -0
- package/lib/asset/AssetGenerator.js +20 -34
- 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/config/defaults.js +155 -21
- package/lib/config/normalization.js +18 -3
- 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 +11 -13
- package/lib/css/CssParser.js +3 -3
- package/lib/css/walkCssTokens.js +1 -1
- 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 +3 -4
- 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 +30 -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/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 +2 -1
- 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 +3 -9
- 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/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 +44 -21
- package/lib/javascript/JavascriptParser.js +119 -54
- 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 +0 -1
- 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/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/NullPrototypeObjectSerializer.js +5 -3
- package/lib/serialization/ObjectMiddleware.js +30 -19
- 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 +178 -94
- 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/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 +0 -1
- 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/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 -1
- 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 -4
- 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 +12 -12
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +77 -93
- 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/schemes/VirtualUrlPlugin.json +3 -3
- package/types.d.ts +1129 -530
- package/SECURITY.md +0 -9
|
@@ -34,6 +34,8 @@ const {
|
|
|
34
34
|
parseResourceWithoutFragment
|
|
35
35
|
} = require("./util/identifier");
|
|
36
36
|
|
|
37
|
+
/** @typedef {import("enhanced-resolve").ResolveContext} ResolveContext */
|
|
38
|
+
/** @typedef {import("enhanced-resolve").ResolveRequest} ResolveRequest */
|
|
37
39
|
/** @typedef {import("../declarations/WebpackOptions").ModuleOptionsNormalized} ModuleOptions */
|
|
38
40
|
/** @typedef {import("../declarations/WebpackOptions").RuleSetRule} RuleSetRule */
|
|
39
41
|
/** @typedef {import("./Generator")} Generator */
|
|
@@ -47,8 +49,6 @@ const {
|
|
|
47
49
|
/** @typedef {import("./NormalModule").ParserOptions} ParserOptions */
|
|
48
50
|
/** @typedef {import("./Parser")} Parser */
|
|
49
51
|
/** @typedef {import("./ResolverFactory")} ResolverFactory */
|
|
50
|
-
/** @typedef {import("./ResolverFactory").ResolveContext} ResolveContext */
|
|
51
|
-
/** @typedef {import("./ResolverFactory").ResolveRequest} ResolveRequest */
|
|
52
52
|
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
|
53
53
|
/** @typedef {import("./dependencies/ModuleDependency")} ModuleDependency */
|
|
54
54
|
/** @typedef {import("./javascript/JavascriptParser").ImportAttributes} ImportAttributes */
|
|
@@ -56,7 +56,12 @@ const {
|
|
|
56
56
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
|
57
57
|
/** @typedef {import("./util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */
|
|
58
58
|
|
|
59
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* @template T
|
|
61
|
+
* @typedef {import("./Compiler").Callback<T>} Callback
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
/** @typedef {Pick<RuleSetRule, 'type' | 'sideEffects' | 'parser' | 'generator' | 'resolve' | 'layer' | 'extractSourceMap'>} ModuleSettings */
|
|
60
65
|
/** @typedef {Partial<NormalModuleCreateData & { settings: ModuleSettings }>} CreateData */
|
|
61
66
|
|
|
62
67
|
/**
|
|
@@ -65,7 +70,7 @@ const {
|
|
|
65
70
|
* @property {ModuleFactoryCreateData["resolveOptions"]} resolveOptions
|
|
66
71
|
* @property {string} context
|
|
67
72
|
* @property {string} request
|
|
68
|
-
* @property {ImportAttributes | undefined}
|
|
73
|
+
* @property {ImportAttributes | undefined} attributes
|
|
69
74
|
* @property {ModuleDependency[]} dependencies
|
|
70
75
|
* @property {string} dependencyType
|
|
71
76
|
* @property {CreateData} createData
|
|
@@ -101,13 +106,23 @@ const {
|
|
|
101
106
|
* @property {string|undefined} options options
|
|
102
107
|
*/
|
|
103
108
|
|
|
104
|
-
/**
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
*/
|
|
109
|
+
/** @typedef {import("./ModuleTypeConstants").JAVASCRIPT_MODULE_TYPE_AUTO} JAVASCRIPT_MODULE_TYPE_AUTO */
|
|
110
|
+
/** @typedef {import("./ModuleTypeConstants").JAVASCRIPT_MODULE_TYPE_DYNAMIC} JAVASCRIPT_MODULE_TYPE_DYNAMIC */
|
|
111
|
+
/** @typedef {import("./ModuleTypeConstants").JAVASCRIPT_MODULE_TYPE_ESM} JAVASCRIPT_MODULE_TYPE_ESM */
|
|
112
|
+
/** @typedef {import("./ModuleTypeConstants").JSON_MODULE_TYPE} JSON_MODULE_TYPE */
|
|
113
|
+
/** @typedef {import("./ModuleTypeConstants").ASSET_MODULE_TYPE} ASSET_MODULE_TYPE */
|
|
114
|
+
/** @typedef {import("./ModuleTypeConstants").ASSET_MODULE_TYPE_INLINE} ASSET_MODULE_TYPE_INLINE */
|
|
115
|
+
/** @typedef {import("./ModuleTypeConstants").ASSET_MODULE_TYPE_RESOURCE} ASSET_MODULE_TYPE_RESOURCE */
|
|
116
|
+
/** @typedef {import("./ModuleTypeConstants").ASSET_MODULE_TYPE_SOURCE} ASSET_MODULE_TYPE_SOURCE */
|
|
117
|
+
/** @typedef {import("./ModuleTypeConstants").WEBASSEMBLY_MODULE_TYPE_ASYNC} WEBASSEMBLY_MODULE_TYPE_ASYNC */
|
|
118
|
+
/** @typedef {import("./ModuleTypeConstants").WEBASSEMBLY_MODULE_TYPE_SYNC} WEBASSEMBLY_MODULE_TYPE_SYNC */
|
|
119
|
+
/** @typedef {import("./ModuleTypeConstants").CSS_MODULE_TYPE} CSS_MODULE_TYPE */
|
|
120
|
+
/** @typedef {import("./ModuleTypeConstants").CSS_MODULE_TYPE_GLOBAL} CSS_MODULE_TYPE_GLOBAL */
|
|
121
|
+
/** @typedef {import("./ModuleTypeConstants").CSS_MODULE_TYPE_MODULE} CSS_MODULE_TYPE_MODULE */
|
|
122
|
+
/** @typedef {import("./ModuleTypeConstants").CSS_MODULE_TYPE_AUTO} CSS_MODULE_TYPE_AUTO */
|
|
123
|
+
|
|
124
|
+
/** @typedef {JAVASCRIPT_MODULE_TYPE_AUTO | JAVASCRIPT_MODULE_TYPE_DYNAMIC | JAVASCRIPT_MODULE_TYPE_ESM | JSON_MODULE_TYPE | ASSET_MODULE_TYPE | ASSET_MODULE_TYPE_INLINE | ASSET_MODULE_TYPE_RESOURCE | ASSET_MODULE_TYPE_SOURCE | WEBASSEMBLY_MODULE_TYPE_ASYNC | WEBASSEMBLY_MODULE_TYPE_SYNC | CSS_MODULE_TYPE | CSS_MODULE_TYPE_GLOBAL | CSS_MODULE_TYPE_MODULE | CSS_MODULE_TYPE_AUTO} KnownNormalModuleTypes */
|
|
125
|
+
/** @typedef {KnownNormalModuleTypes | string} NormalModuleTypes */
|
|
111
126
|
|
|
112
127
|
const EMPTY_RESOLVE_OPTIONS = {};
|
|
113
128
|
/** @type {ParserOptions} */
|
|
@@ -227,7 +242,7 @@ const ruleSetCompiler = new RuleSetCompiler([
|
|
|
227
242
|
new BasicMatcherRulePlugin("issuer"),
|
|
228
243
|
new BasicMatcherRulePlugin("compiler"),
|
|
229
244
|
new BasicMatcherRulePlugin("issuerLayer"),
|
|
230
|
-
new ObjectMatcherRulePlugin("assert", "
|
|
245
|
+
new ObjectMatcherRulePlugin("assert", "attributes", (value) => {
|
|
231
246
|
if (value) {
|
|
232
247
|
return (
|
|
233
248
|
/** @type {ImportAttributes} */ (value)._isLegacyAssert !== undefined
|
|
@@ -236,7 +251,7 @@ const ruleSetCompiler = new RuleSetCompiler([
|
|
|
236
251
|
|
|
237
252
|
return false;
|
|
238
253
|
}),
|
|
239
|
-
new ObjectMatcherRulePlugin("with", "
|
|
254
|
+
new ObjectMatcherRulePlugin("with", "attributes", (value) => {
|
|
240
255
|
if (value) {
|
|
241
256
|
return !(/** @type {ImportAttributes} */ (value)._isLegacyAssert);
|
|
242
257
|
}
|
|
@@ -249,6 +264,7 @@ const ruleSetCompiler = new RuleSetCompiler([
|
|
|
249
264
|
new BasicEffectRulePlugin("resolve"),
|
|
250
265
|
new BasicEffectRulePlugin("generator"),
|
|
251
266
|
new BasicEffectRulePlugin("layer"),
|
|
267
|
+
new BasicEffectRulePlugin("extractSourceMap"),
|
|
252
268
|
new UseEffectRulePlugin()
|
|
253
269
|
]);
|
|
254
270
|
|
|
@@ -260,15 +276,13 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
260
276
|
* @param {ResolverFactory} param.resolverFactory resolverFactory
|
|
261
277
|
* @param {ModuleOptions} param.options options
|
|
262
278
|
* @param {AssociatedObjectForCache} param.associatedObjectForCache an object to which the cache will be attached
|
|
263
|
-
* @param {boolean=} param.layers enable layers
|
|
264
279
|
*/
|
|
265
280
|
constructor({
|
|
266
281
|
context,
|
|
267
282
|
fs,
|
|
268
283
|
resolverFactory,
|
|
269
284
|
options,
|
|
270
|
-
associatedObjectForCache
|
|
271
|
-
layers = false
|
|
285
|
+
associatedObjectForCache
|
|
272
286
|
}) {
|
|
273
287
|
super();
|
|
274
288
|
this.hooks = Object.freeze({
|
|
@@ -294,13 +308,13 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
294
308
|
module: new SyncWaterfallHook(["module", "createData", "resolveData"]),
|
|
295
309
|
/** @type {HookMap<SyncBailHook<[ParserOptions], Parser | void>>} */
|
|
296
310
|
createParser: new HookMap(() => new SyncBailHook(["parserOptions"])),
|
|
297
|
-
/** @type {HookMap<SyncBailHook<[
|
|
311
|
+
/** @type {HookMap<SyncBailHook<[EXPECTED_ANY, ParserOptions], void>>} */
|
|
298
312
|
parser: new HookMap(() => new SyncHook(["parser", "parserOptions"])),
|
|
299
313
|
/** @type {HookMap<SyncBailHook<[GeneratorOptions], Generator | void>>} */
|
|
300
314
|
createGenerator: new HookMap(
|
|
301
315
|
() => new SyncBailHook(["generatorOptions"])
|
|
302
316
|
),
|
|
303
|
-
/** @type {HookMap<SyncBailHook<[
|
|
317
|
+
/** @type {HookMap<SyncBailHook<[EXPECTED_ANY, GeneratorOptions], void>>} */
|
|
304
318
|
generator: new HookMap(
|
|
305
319
|
() => new SyncHook(["generator", "generatorOptions"])
|
|
306
320
|
),
|
|
@@ -430,7 +444,7 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
430
444
|
dependencies,
|
|
431
445
|
dependencyType,
|
|
432
446
|
request,
|
|
433
|
-
|
|
447
|
+
attributes,
|
|
434
448
|
resolveOptions,
|
|
435
449
|
fileDependencies,
|
|
436
450
|
missingDependencies,
|
|
@@ -601,7 +615,7 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
601
615
|
resourceQuery: resourceDataForRules.query,
|
|
602
616
|
resourceFragment: resourceDataForRules.fragment,
|
|
603
617
|
scheme,
|
|
604
|
-
|
|
618
|
+
attributes,
|
|
605
619
|
mimetype: matchResourceData
|
|
606
620
|
? ""
|
|
607
621
|
: resourceData.data.mimetype || "",
|
|
@@ -683,16 +697,10 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
683
697
|
for (const loader of /** @type {LoaderItem[]} */ (preLoaders)) {
|
|
684
698
|
allLoaders.push(loader);
|
|
685
699
|
}
|
|
686
|
-
const type = /** @type {
|
|
700
|
+
const type = /** @type {NormalModuleTypes} */ (settings.type);
|
|
687
701
|
const resolveOptions = settings.resolve;
|
|
688
702
|
const layer = settings.layer;
|
|
689
|
-
|
|
690
|
-
return callback(
|
|
691
|
-
new Error(
|
|
692
|
-
"'Rule.layer' is only allowed when 'experiments.layers' is enabled"
|
|
693
|
-
)
|
|
694
|
-
);
|
|
695
|
-
}
|
|
703
|
+
|
|
696
704
|
try {
|
|
697
705
|
Object.assign(data.createData, {
|
|
698
706
|
layer:
|
|
@@ -717,7 +725,8 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
717
725
|
parserOptions: settings.parser,
|
|
718
726
|
generator: this.getGenerator(type, settings.generator),
|
|
719
727
|
generatorOptions: settings.generator,
|
|
720
|
-
resolveOptions
|
|
728
|
+
resolveOptions,
|
|
729
|
+
extractSourceMap: settings.extractSourceMap || false
|
|
721
730
|
});
|
|
722
731
|
} catch (createDataErr) {
|
|
723
732
|
return callback(/** @type {Error} */ (createDataErr));
|
|
@@ -887,7 +896,9 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
887
896
|
const resolveOptions = data.resolveOptions || EMPTY_RESOLVE_OPTIONS;
|
|
888
897
|
const dependency = dependencies[0];
|
|
889
898
|
const request = dependency.request;
|
|
890
|
-
const
|
|
899
|
+
const attributes =
|
|
900
|
+
/** @type {ModuleDependency & { attributes: ImportAttributes }} */
|
|
901
|
+
(dependency).attributes;
|
|
891
902
|
const dependencyType = dependency.category || "";
|
|
892
903
|
const contextInfo = data.contextInfo;
|
|
893
904
|
const fileDependencies = new LazySet();
|
|
@@ -899,7 +910,7 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
899
910
|
resolveOptions,
|
|
900
911
|
context,
|
|
901
912
|
request,
|
|
902
|
-
|
|
913
|
+
attributes,
|
|
903
914
|
dependencies,
|
|
904
915
|
dependencyType,
|
|
905
916
|
fileDependencies,
|
|
@@ -1186,6 +1197,10 @@ If changing the source code is not an option there is also a resolve options cal
|
|
|
1186
1197
|
if (array.length === 0) return callback(null, array);
|
|
1187
1198
|
asyncLib.map(
|
|
1188
1199
|
array,
|
|
1200
|
+
/**
|
|
1201
|
+
* @param {LoaderItem} item item
|
|
1202
|
+
* @param {Callback<LoaderItem>} callback callback
|
|
1203
|
+
*/
|
|
1189
1204
|
(item, callback) => {
|
|
1190
1205
|
resolver.resolve(
|
|
1191
1206
|
contextInfo,
|
|
@@ -1218,7 +1233,8 @@ If changing the source code is not an option there is also a resolve options cal
|
|
|
1218
1233
|
if (err) return callback(err);
|
|
1219
1234
|
|
|
1220
1235
|
const parsedResult = this._parseResourceWithoutFragment(
|
|
1221
|
-
/** @type {string} */
|
|
1236
|
+
/** @type {string} */
|
|
1237
|
+
(result)
|
|
1222
1238
|
);
|
|
1223
1239
|
|
|
1224
1240
|
const type = /\.mjs$/i.test(parsedResult.path)
|
|
@@ -1228,8 +1244,12 @@ If changing the source code is not an option there is also a resolve options cal
|
|
|
1228
1244
|
: /** @type {ResolveRequest} */
|
|
1229
1245
|
(resolveRequest).descriptionFileData === undefined
|
|
1230
1246
|
? undefined
|
|
1231
|
-
: /** @type {
|
|
1232
|
-
(
|
|
1247
|
+
: /** @type {string} */
|
|
1248
|
+
(
|
|
1249
|
+
/** @type {ResolveRequest} */
|
|
1250
|
+
(resolveRequest).descriptionFileData.type
|
|
1251
|
+
);
|
|
1252
|
+
/** @type {LoaderItem} */
|
|
1233
1253
|
const resolved = {
|
|
1234
1254
|
loader: parsedResult.path,
|
|
1235
1255
|
type,
|
|
@@ -1239,17 +1259,16 @@ If changing the source code is not an option there is also a resolve options cal
|
|
|
1239
1259
|
? parsedResult.query.slice(1)
|
|
1240
1260
|
: undefined
|
|
1241
1261
|
: item.options,
|
|
1242
|
-
ident:
|
|
1243
|
-
item.options === undefined
|
|
1244
|
-
? undefined
|
|
1245
|
-
: /** @type {string} */ (item.ident)
|
|
1262
|
+
ident: item.options === undefined ? undefined : item.ident
|
|
1246
1263
|
};
|
|
1247
1264
|
|
|
1248
|
-
return callback(null,
|
|
1265
|
+
return callback(null, resolved);
|
|
1249
1266
|
}
|
|
1250
1267
|
);
|
|
1251
1268
|
},
|
|
1252
|
-
|
|
1269
|
+
(err, value) => {
|
|
1270
|
+
callback(err, /** @type {(LoaderItem)[]} */ (value));
|
|
1271
|
+
}
|
|
1253
1272
|
);
|
|
1254
1273
|
}
|
|
1255
1274
|
|
package/lib/OptionsApply.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
-
/** @typedef {import("
|
|
8
|
+
/** @typedef {import("./config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */
|
|
9
9
|
/** @typedef {import("./Compiler")} Compiler */
|
|
10
10
|
|
|
11
11
|
class OptionsApply {
|
package/lib/Parser.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
-
/** @typedef {import("
|
|
8
|
+
/** @typedef {import("./config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */
|
|
9
9
|
/** @typedef {import("./Compilation")} Compilation */
|
|
10
10
|
/** @typedef {import("./NormalModule")} NormalModule */
|
|
11
11
|
|
package/lib/ProgressPlugin.js
CHANGED
|
@@ -16,9 +16,7 @@ const { contextify } = require("./util/identifier");
|
|
|
16
16
|
* @template T, R, AdditionalOptions
|
|
17
17
|
* @typedef {import("tapable").Hook<T, R, AdditionalOptions>} Hook
|
|
18
18
|
*/
|
|
19
|
-
/** @typedef {import("../declarations/plugins/ProgressPlugin").HandlerFunction} HandlerFunction */
|
|
20
19
|
/** @typedef {import("../declarations/plugins/ProgressPlugin").ProgressPluginArgument} ProgressPluginArgument */
|
|
21
|
-
/** @typedef {import("../declarations/plugins/ProgressPlugin").ProgressPluginOptions} ProgressPluginOptions */
|
|
22
20
|
/** @typedef {import("./Compilation").FactorizeModuleOptions} FactorizeModuleOptions */
|
|
23
21
|
/** @typedef {import("./Dependency")} Dependency */
|
|
24
22
|
/** @typedef {import("./Entrypoint").EntryOptions} EntryOptions */
|
|
@@ -54,20 +52,18 @@ const validate = createSchemaValidation(
|
|
|
54
52
|
*/
|
|
55
53
|
const median3 = (a, b, c) => a + b + c - Math.max(a, b, c) - Math.min(a, b, c);
|
|
56
54
|
|
|
55
|
+
/** @typedef {(percentage: number, msg: string, ...args: string[]) => void} HandlerFn */
|
|
56
|
+
|
|
57
57
|
/**
|
|
58
58
|
* @param {boolean | null | undefined} profile need profile
|
|
59
59
|
* @param {Logger} logger logger
|
|
60
|
-
* @returns {
|
|
60
|
+
* @returns {HandlerFn} default handler
|
|
61
61
|
*/
|
|
62
62
|
const createDefaultHandler = (profile, logger) => {
|
|
63
63
|
/** @type {{ value: string | undefined, time: number }[]} */
|
|
64
64
|
const lastStateInfo = [];
|
|
65
65
|
|
|
66
|
-
/**
|
|
67
|
-
* @param {number} percentage percentage
|
|
68
|
-
* @param {string} msg message
|
|
69
|
-
* @param {...string} args additional arguments
|
|
70
|
-
*/
|
|
66
|
+
/** @type {HandlerFn} */
|
|
71
67
|
const defaultHandler = (percentage, msg, ...args) => {
|
|
72
68
|
if (profile) {
|
|
73
69
|
if (percentage === 0) {
|
|
@@ -199,7 +195,7 @@ class ProgressPlugin {
|
|
|
199
195
|
|
|
200
196
|
/**
|
|
201
197
|
* @param {MultiCompiler} compiler webpack multi-compiler
|
|
202
|
-
* @param {
|
|
198
|
+
* @param {HandlerFn} handler function that executes for every progress step
|
|
203
199
|
* @returns {void}
|
|
204
200
|
*/
|
|
205
201
|
_applyOnMultiCompiler(compiler, handler) {
|
|
@@ -218,7 +214,7 @@ class ProgressPlugin {
|
|
|
218
214
|
|
|
219
215
|
/**
|
|
220
216
|
* @param {Compiler} compiler webpack compiler
|
|
221
|
-
* @param {
|
|
217
|
+
* @param {HandlerFn} handler function that executes for every progress step
|
|
222
218
|
* @returns {void}
|
|
223
219
|
*/
|
|
224
220
|
_applyOnCompiler(compiler, handler) {
|
package/lib/ProvidePlugin.js
CHANGED
|
@@ -59,13 +59,11 @@ class ProvidePlugin {
|
|
|
59
59
|
*/
|
|
60
60
|
const handler = (parser, parserOptions) => {
|
|
61
61
|
for (const name of Object.keys(definitions)) {
|
|
62
|
-
const request =
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
: [definitions[name]])
|
|
68
|
-
]);
|
|
62
|
+
const request = [
|
|
63
|
+
...(Array.isArray(definitions[name])
|
|
64
|
+
? definitions[name]
|
|
65
|
+
: [definitions[name]])
|
|
66
|
+
];
|
|
69
67
|
const splittedName = name.split(".");
|
|
70
68
|
if (splittedName.length > 0) {
|
|
71
69
|
for (const [i, _] of splittedName.slice(1).entries()) {
|
package/lib/RawModule.js
CHANGED
|
@@ -11,12 +11,9 @@ const { JS_TYPES } = require("./ModuleSourceTypesConstants");
|
|
|
11
11
|
const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("./ModuleTypeConstants");
|
|
12
12
|
const makeSerializable = require("./util/makeSerializable");
|
|
13
13
|
|
|
14
|
-
/** @typedef {import("
|
|
15
|
-
/** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
|
|
16
|
-
/** @typedef {import("./ChunkGraph")} ChunkGraph */
|
|
14
|
+
/** @typedef {import("./config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */
|
|
17
15
|
/** @typedef {import("./Compilation")} Compilation */
|
|
18
16
|
/** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
|
|
19
|
-
/** @typedef {import("./DependencyTemplates")} DependencyTemplates */
|
|
20
17
|
/** @typedef {import("./Generator").SourceTypes} SourceTypes */
|
|
21
18
|
/** @typedef {import("./Module").BuildCallback} BuildCallback */
|
|
22
19
|
/** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */
|
|
@@ -28,8 +25,6 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
28
25
|
/** @typedef {import("./ModuleGraphConnection").ConnectionState} ConnectionState */
|
|
29
26
|
/** @typedef {import("./RequestShortener")} RequestShortener */
|
|
30
27
|
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
|
31
|
-
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
|
32
|
-
/** @typedef {import("./WebpackError")} WebpackError */
|
|
33
28
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
34
29
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
35
30
|
/** @typedef {import("./util/Hash")} Hash */
|
package/lib/RecordIdsPlugin.js
CHANGED
|
@@ -36,6 +36,8 @@ const identifierUtils = require("./util/identifier");
|
|
|
36
36
|
* @property {boolean=} portableIds true, when ids need to be portable
|
|
37
37
|
*/
|
|
38
38
|
|
|
39
|
+
/** @typedef {Set<number>} UsedIds */
|
|
40
|
+
|
|
39
41
|
const PLUGIN_NAME = "RecordIdsPlugin";
|
|
40
42
|
|
|
41
43
|
class RecordIdsPlugin {
|
|
@@ -75,7 +77,7 @@ class RecordIdsPlugin {
|
|
|
75
77
|
const chunkGraph = compilation.chunkGraph;
|
|
76
78
|
if (!records.modules) records.modules = {};
|
|
77
79
|
if (!records.modules.byIdentifier) records.modules.byIdentifier = {};
|
|
78
|
-
/** @type {
|
|
80
|
+
/** @type {UsedIds} */
|
|
79
81
|
const usedIds = new Set();
|
|
80
82
|
for (const module of modules) {
|
|
81
83
|
const moduleId = chunkGraph.getModuleId(module);
|
|
@@ -90,7 +92,7 @@ class RecordIdsPlugin {
|
|
|
90
92
|
if (!records.modules) return;
|
|
91
93
|
if (records.modules.byIdentifier) {
|
|
92
94
|
const chunkGraph = compilation.chunkGraph;
|
|
93
|
-
/** @type {
|
|
95
|
+
/** @type {UsedIds} */
|
|
94
96
|
const usedIds = new Set();
|
|
95
97
|
for (const module of modules) {
|
|
96
98
|
const moduleId = chunkGraph.getModuleId(module);
|
|
@@ -108,12 +110,14 @@ class RecordIdsPlugin {
|
|
|
108
110
|
}
|
|
109
111
|
});
|
|
110
112
|
|
|
113
|
+
/** @typedef {string[]} ChunkSources */
|
|
114
|
+
|
|
111
115
|
/**
|
|
112
116
|
* @param {Chunk} chunk the chunk
|
|
113
|
-
* @returns {
|
|
117
|
+
* @returns {ChunkSources} sources of the chunk
|
|
114
118
|
*/
|
|
115
119
|
const getChunkSources = (chunk) => {
|
|
116
|
-
/** @type {
|
|
120
|
+
/** @type {ChunkSources} */
|
|
117
121
|
const sources = [];
|
|
118
122
|
for (const chunkGroup of chunk.groupsIterable) {
|
|
119
123
|
const index = chunkGroup.chunks.indexOf(chunk);
|
|
@@ -156,7 +160,7 @@ class RecordIdsPlugin {
|
|
|
156
160
|
if (!records.chunks) records.chunks = {};
|
|
157
161
|
if (!records.chunks.byName) records.chunks.byName = {};
|
|
158
162
|
if (!records.chunks.bySource) records.chunks.bySource = {};
|
|
159
|
-
/** @type {
|
|
163
|
+
/** @type {UsedIds} */
|
|
160
164
|
const usedIds = new Set();
|
|
161
165
|
for (const chunk of chunks) {
|
|
162
166
|
if (typeof chunk.id !== "number") continue;
|
|
@@ -172,7 +176,7 @@ class RecordIdsPlugin {
|
|
|
172
176
|
});
|
|
173
177
|
compilation.hooks.reviveChunks.tap(PLUGIN_NAME, (chunks, records) => {
|
|
174
178
|
if (!records.chunks) return;
|
|
175
|
-
/** @type {
|
|
179
|
+
/** @type {UsedIds} */
|
|
176
180
|
const usedIds = new Set();
|
|
177
181
|
if (records.chunks.byName) {
|
|
178
182
|
for (const chunk of chunks) {
|
package/lib/ResolverFactory.js
CHANGED
|
@@ -13,9 +13,7 @@ const {
|
|
|
13
13
|
resolveByProperty
|
|
14
14
|
} = require("./util/cleverMerge");
|
|
15
15
|
|
|
16
|
-
/** @typedef {import("enhanced-resolve").ResolveContext} ResolveContext */
|
|
17
16
|
/** @typedef {import("enhanced-resolve").ResolveOptions} ResolveOptions */
|
|
18
|
-
/** @typedef {import("enhanced-resolve").ResolveRequest} ResolveRequest */
|
|
19
17
|
/** @typedef {import("enhanced-resolve").Resolver} Resolver */
|
|
20
18
|
/** @typedef {import("../declarations/WebpackOptions").ResolveOptions} WebpackResolveOptions */
|
|
21
19
|
/** @typedef {import("../declarations/WebpackOptions").ResolvePluginInstance} ResolvePluginInstance */
|
package/lib/RuntimeGlobals.js
CHANGED
|
@@ -416,6 +416,11 @@ module.exports.systemContext = "__webpack_require__.y";
|
|
|
416
416
|
*/
|
|
417
417
|
module.exports.thisAsExports = "top-level-this-exports";
|
|
418
418
|
|
|
419
|
+
/**
|
|
420
|
+
* to binary helper, convert base64 to Uint8Array
|
|
421
|
+
*/
|
|
422
|
+
module.exports.toBinary = "__webpack_require__.tb";
|
|
423
|
+
|
|
419
424
|
/**
|
|
420
425
|
* the uncaught error handler for the webpack runtime
|
|
421
426
|
*/
|
package/lib/RuntimeModule.js
CHANGED
|
@@ -11,8 +11,7 @@ const Module = require("./Module");
|
|
|
11
11
|
const { RUNTIME_TYPES } = require("./ModuleSourceTypesConstants");
|
|
12
12
|
const { WEBPACK_MODULE_TYPE_RUNTIME } = require("./ModuleTypeConstants");
|
|
13
13
|
|
|
14
|
-
/** @typedef {import("
|
|
15
|
-
/** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
|
|
14
|
+
/** @typedef {import("./config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */
|
|
16
15
|
/** @typedef {import("./Chunk")} Chunk */
|
|
17
16
|
/** @typedef {import("./ChunkGraph")} ChunkGraph */
|
|
18
17
|
/** @typedef {import("./Compilation")} Compilation */
|
|
@@ -25,7 +24,6 @@ const { WEBPACK_MODULE_TYPE_RUNTIME } = require("./ModuleTypeConstants");
|
|
|
25
24
|
/** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
|
|
26
25
|
/** @typedef {import("./RequestShortener")} RequestShortener */
|
|
27
26
|
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
|
28
|
-
/** @typedef {import("./WebpackError")} WebpackError */
|
|
29
27
|
/** @typedef {import("./util/Hash")} Hash */
|
|
30
28
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
|
31
29
|
|
package/lib/RuntimePlugin.js
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
8
|
const RuntimeGlobals = require("./RuntimeGlobals");
|
|
9
|
-
const { getChunkFilenameTemplate } = require("./css/CssModulesPlugin");
|
|
10
9
|
const RuntimeRequirementsDependency = require("./dependencies/RuntimeRequirementsDependency");
|
|
11
10
|
const JavascriptModulesPlugin = require("./javascript/JavascriptModulesPlugin");
|
|
12
11
|
const AsyncModuleRuntimeModule = require("./runtime/AsyncModuleRuntimeModule");
|
|
@@ -33,16 +32,14 @@ const PublicPathRuntimeModule = require("./runtime/PublicPathRuntimeModule");
|
|
|
33
32
|
const RelativeUrlRuntimeModule = require("./runtime/RelativeUrlRuntimeModule");
|
|
34
33
|
const RuntimeIdRuntimeModule = require("./runtime/RuntimeIdRuntimeModule");
|
|
35
34
|
const SystemContextRuntimeModule = require("./runtime/SystemContextRuntimeModule");
|
|
35
|
+
const ToBinaryRuntimeModule = require("./runtime/ToBinaryRuntimeModule");
|
|
36
36
|
const ShareRuntimeModule = require("./sharing/ShareRuntimeModule");
|
|
37
37
|
const StringXor = require("./util/StringXor");
|
|
38
38
|
const memoize = require("./util/memoize");
|
|
39
39
|
|
|
40
40
|
/** @typedef {import("../declarations/WebpackOptions").LibraryOptions} LibraryOptions */
|
|
41
|
-
/** @typedef {import("../declarations/WebpackOptions").OutputNormalized} OutputNormalized */
|
|
42
41
|
/** @typedef {import("./Chunk")} Chunk */
|
|
43
42
|
/** @typedef {import("./Compiler")} Compiler */
|
|
44
|
-
/** @typedef {import("./Module")} Module */
|
|
45
|
-
/** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */
|
|
46
43
|
|
|
47
44
|
const getJavascriptModulesPlugin = memoize(() =>
|
|
48
45
|
require("./javascript/JavascriptModulesPlugin")
|
|
@@ -310,12 +307,10 @@ class RuntimePlugin {
|
|
|
310
307
|
RuntimeGlobals.getChunkScriptFilename,
|
|
311
308
|
(chunk) =>
|
|
312
309
|
getJavascriptModulesPlugin().chunkHasJs(chunk, chunkGraph) &&
|
|
313
|
-
|
|
314
|
-
chunk.
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
: compilation.outputOptions.chunkFilename)
|
|
318
|
-
),
|
|
310
|
+
(chunk.filenameTemplate ||
|
|
311
|
+
(chunk.canBeInitial()
|
|
312
|
+
? compilation.outputOptions.filename
|
|
313
|
+
: compilation.outputOptions.chunkFilename)),
|
|
319
314
|
set.has(RuntimeGlobals.hmrDownloadUpdateHandlers)
|
|
320
315
|
)
|
|
321
316
|
);
|
|
@@ -338,9 +333,17 @@ class RuntimePlugin {
|
|
|
338
333
|
"css",
|
|
339
334
|
"css",
|
|
340
335
|
RuntimeGlobals.getChunkCssFilename,
|
|
341
|
-
(chunk) =>
|
|
342
|
-
getCssModulesPlugin()
|
|
343
|
-
|
|
336
|
+
(chunk) => {
|
|
337
|
+
const cssModulePlugin = getCssModulesPlugin();
|
|
338
|
+
|
|
339
|
+
return (
|
|
340
|
+
cssModulePlugin.chunkHasCss(chunk, chunkGraph) &&
|
|
341
|
+
cssModulePlugin.getChunkFilenameTemplate(
|
|
342
|
+
chunk,
|
|
343
|
+
compilation.outputOptions
|
|
344
|
+
)
|
|
345
|
+
);
|
|
346
|
+
},
|
|
344
347
|
set.has(RuntimeGlobals.hmrDownloadUpdateHandlers)
|
|
345
348
|
)
|
|
346
349
|
);
|
|
@@ -351,8 +354,7 @@ class RuntimePlugin {
|
|
|
351
354
|
.tap(PLUGIN_NAME, (chunk, set) => {
|
|
352
355
|
if (
|
|
353
356
|
/\[(full)?hash(:\d+)?\]/.test(
|
|
354
|
-
|
|
355
|
-
(compilation.outputOptions.hotUpdateChunkFilename)
|
|
357
|
+
compilation.outputOptions.hotUpdateChunkFilename
|
|
356
358
|
)
|
|
357
359
|
) {
|
|
358
360
|
set.add(RuntimeGlobals.getFullHash);
|
|
@@ -363,9 +365,7 @@ class RuntimePlugin {
|
|
|
363
365
|
"javascript",
|
|
364
366
|
"javascript update",
|
|
365
367
|
RuntimeGlobals.getChunkUpdateScriptFilename,
|
|
366
|
-
(_chunk) =>
|
|
367
|
-
/** @type {NonNullable<OutputNormalized["hotUpdateChunkFilename"]>} */
|
|
368
|
-
(compilation.outputOptions.hotUpdateChunkFilename),
|
|
368
|
+
(_chunk) => compilation.outputOptions.hotUpdateChunkFilename,
|
|
369
369
|
true
|
|
370
370
|
)
|
|
371
371
|
);
|
|
@@ -376,8 +376,7 @@ class RuntimePlugin {
|
|
|
376
376
|
.tap(PLUGIN_NAME, (chunk, set) => {
|
|
377
377
|
if (
|
|
378
378
|
/\[(full)?hash(:\d+)?\]/.test(
|
|
379
|
-
|
|
380
|
-
(compilation.outputOptions.hotUpdateMainFilename)
|
|
379
|
+
compilation.outputOptions.hotUpdateMainFilename
|
|
381
380
|
)
|
|
382
381
|
) {
|
|
383
382
|
set.add(RuntimeGlobals.getFullHash);
|
|
@@ -387,8 +386,7 @@ class RuntimePlugin {
|
|
|
387
386
|
new GetMainFilenameRuntimeModule(
|
|
388
387
|
"update manifest",
|
|
389
388
|
RuntimeGlobals.getUpdateManifestFilename,
|
|
390
|
-
|
|
391
|
-
(compilation.outputOptions.hotUpdateMainFilename)
|
|
389
|
+
compilation.outputOptions.hotUpdateMainFilename
|
|
392
390
|
)
|
|
393
391
|
);
|
|
394
392
|
return true;
|
|
@@ -492,6 +490,12 @@ class RuntimePlugin {
|
|
|
492
490
|
compilation.addRuntimeModule(chunk, new NonceRuntimeModule());
|
|
493
491
|
return true;
|
|
494
492
|
});
|
|
493
|
+
compilation.hooks.runtimeRequirementInTree
|
|
494
|
+
.for(RuntimeGlobals.toBinary)
|
|
495
|
+
.tap(PLUGIN_NAME, (chunk) => {
|
|
496
|
+
compilation.addRuntimeModule(chunk, new ToBinaryRuntimeModule());
|
|
497
|
+
return true;
|
|
498
|
+
});
|
|
495
499
|
// TODO webpack 6: remove CompatRuntimeModule
|
|
496
500
|
compilation.hooks.additionalTreeRuntimeRequirements.tap(
|
|
497
501
|
PLUGIN_NAME,
|
package/lib/RuntimeTemplate.js
CHANGED
|
@@ -20,13 +20,10 @@ const compileBooleanMatcher = require("./util/compileBooleanMatcher");
|
|
|
20
20
|
const propertyAccess = require("./util/propertyAccess");
|
|
21
21
|
const { forEachRuntime, subtractRuntime } = require("./util/runtime");
|
|
22
22
|
|
|
23
|
-
/** @typedef {import("
|
|
24
|
-
/** @typedef {import("../declarations/WebpackOptions").OutputNormalized} OutputOptions */
|
|
23
|
+
/** @typedef {import("./config/defaults").OutputNormalizedWithDefaults} OutputOptions */
|
|
25
24
|
/** @typedef {import("./AsyncDependenciesBlock")} AsyncDependenciesBlock */
|
|
26
25
|
/** @typedef {import("./Chunk")} Chunk */
|
|
27
26
|
/** @typedef {import("./ChunkGraph")} ChunkGraph */
|
|
28
|
-
/** @typedef {import("./CodeGenerationResults")} CodeGenerationResults */
|
|
29
|
-
/** @typedef {import("./CodeGenerationResults").CodeGenerationResult} CodeGenerationResult */
|
|
30
27
|
/** @typedef {import("./Compilation")} Compilation */
|
|
31
28
|
/** @typedef {import("./Dependency")} Dependency */
|
|
32
29
|
/** @typedef {import("./Module")} Module */
|
|
@@ -97,10 +94,7 @@ class RuntimeTemplate {
|
|
|
97
94
|
this.globalObject =
|
|
98
95
|
/** @type {string} */
|
|
99
96
|
(getGlobalObject(outputOptions.globalObject));
|
|
100
|
-
this.contentHashReplacement = "X".repeat(
|
|
101
|
-
/** @type {NonNullable<OutputOptions["hashDigestLength"]>} */
|
|
102
|
-
(outputOptions.hashDigestLength)
|
|
103
|
-
);
|
|
97
|
+
this.contentHashReplacement = "X".repeat(outputOptions.hashDigestLength);
|
|
104
98
|
}
|
|
105
99
|
|
|
106
100
|
isIIFE() {
|
|
@@ -113,7 +107,7 @@ class RuntimeTemplate {
|
|
|
113
107
|
|
|
114
108
|
isNeutralPlatform() {
|
|
115
109
|
return (
|
|
116
|
-
!this.
|
|
110
|
+
!this.compilation.compiler.platform.web &&
|
|
117
111
|
!this.compilation.compiler.platform.node
|
|
118
112
|
);
|
|
119
113
|
}
|
|
@@ -172,6 +166,13 @@ class RuntimeTemplate {
|
|
|
172
166
|
: `"${mod}"`;
|
|
173
167
|
}
|
|
174
168
|
|
|
169
|
+
/**
|
|
170
|
+
* @returns {"const" | "var"} return `const` when it is supported, otherwise `var`
|
|
171
|
+
*/
|
|
172
|
+
renderConst() {
|
|
173
|
+
return this.supportsConst() ? "const" : "var";
|
|
174
|
+
}
|
|
175
|
+
|
|
175
176
|
/**
|
|
176
177
|
* @param {string} returnValue return value
|
|
177
178
|
* @param {string} args arguments
|
|
@@ -195,7 +196,7 @@ class RuntimeTemplate {
|
|
|
195
196
|
}
|
|
196
197
|
|
|
197
198
|
/**
|
|
198
|
-
* @param {
|
|
199
|
+
* @param {(string | { expr: string })[]} args args
|
|
199
200
|
* @returns {string} result expression
|
|
200
201
|
*/
|
|
201
202
|
concatenation(...args) {
|
|
@@ -244,7 +245,7 @@ class RuntimeTemplate {
|
|
|
244
245
|
}
|
|
245
246
|
|
|
246
247
|
/**
|
|
247
|
-
* @param {
|
|
248
|
+
* @param {(string | { expr: string })[]} args args (len >= 2)
|
|
248
249
|
* @returns {string} result expression
|
|
249
250
|
* @private
|
|
250
251
|
*/
|