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
|
@@ -17,6 +17,7 @@ const {
|
|
|
17
17
|
|
|
18
18
|
/** @typedef {import("../Compiler")} Compiler */
|
|
19
19
|
/** @typedef {import("../ChunkGraph").EntryModuleWithChunkGroup} EntryModuleWithChunkGroup */
|
|
20
|
+
/** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
|
|
20
21
|
|
|
21
22
|
const PLUGIN_NAME = "ArrayPushCallbackChunkFormatPlugin";
|
|
22
23
|
|
|
@@ -89,7 +90,9 @@ class ArrayPushCallbackChunkFormatPlugin {
|
|
|
89
90
|
runtime.add(
|
|
90
91
|
Template.renderRuntimeModules(runtimeModules, {
|
|
91
92
|
...renderContext,
|
|
92
|
-
codeGenerationResults:
|
|
93
|
+
codeGenerationResults:
|
|
94
|
+
/** @type {CodeGenerationResults} */
|
|
95
|
+
(compilation.codeGenerationResults)
|
|
93
96
|
})
|
|
94
97
|
);
|
|
95
98
|
}
|
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
/** @typedef {import("estree").Node} Node */
|
|
9
9
|
/** @typedef {import("./JavascriptParser").Range} Range */
|
|
10
10
|
/** @typedef {import("./JavascriptParser").VariableInfo} VariableInfo */
|
|
11
|
+
/** @typedef {import("./JavascriptParser").Members} Members */
|
|
12
|
+
/** @typedef {import("./JavascriptParser").MembersOptionals} MembersOptionals */
|
|
13
|
+
/** @typedef {import("./JavascriptParser").MemberRanges} MemberRanges */
|
|
11
14
|
|
|
12
15
|
const TypeUnknown = 0;
|
|
13
16
|
const TypeUndefined = 1;
|
|
@@ -24,6 +27,10 @@ const TypeWrapped = 11;
|
|
|
24
27
|
const TypeTemplateString = 12;
|
|
25
28
|
const TypeBigInt = 13;
|
|
26
29
|
|
|
30
|
+
/** @typedef {() => Members} GetMembers */
|
|
31
|
+
/** @typedef {() => MembersOptionals} GetMembersOptionals */
|
|
32
|
+
/** @typedef {() => MemberRanges} GetMemberRanges */
|
|
33
|
+
|
|
27
34
|
class BasicEvaluatedExpression {
|
|
28
35
|
constructor() {
|
|
29
36
|
this.type = TypeUnknown;
|
|
@@ -67,11 +74,11 @@ class BasicEvaluatedExpression {
|
|
|
67
74
|
this.identifier = undefined;
|
|
68
75
|
/** @type {string | VariableInfo | undefined} */
|
|
69
76
|
this.rootInfo = undefined;
|
|
70
|
-
/** @type {
|
|
77
|
+
/** @type {GetMembers | undefined} */
|
|
71
78
|
this.getMembers = undefined;
|
|
72
|
-
/** @type {
|
|
79
|
+
/** @type {GetMembersOptionals | undefined} */
|
|
73
80
|
this.getMembersOptionals = undefined;
|
|
74
|
-
/** @type {
|
|
81
|
+
/** @type {GetMemberRanges | undefined} */
|
|
75
82
|
this.getMemberRanges = undefined;
|
|
76
83
|
/** @type {Node | undefined} */
|
|
77
84
|
this.expression = undefined;
|
|
@@ -388,9 +395,9 @@ class BasicEvaluatedExpression {
|
|
|
388
395
|
* Set's the value of this expression to a particular identifier and its members.
|
|
389
396
|
* @param {string | VariableInfo} identifier identifier to set
|
|
390
397
|
* @param {string | VariableInfo} rootInfo root info
|
|
391
|
-
* @param {
|
|
392
|
-
* @param {
|
|
393
|
-
* @param {
|
|
398
|
+
* @param {GetMembers} getMembers members
|
|
399
|
+
* @param {GetMembersOptionals=} getMembersOptionals optional members
|
|
400
|
+
* @param {GetMemberRanges=} getMemberRanges ranges of progressively increasing sub-expressions
|
|
394
401
|
* @returns {this} this
|
|
395
402
|
*/
|
|
396
403
|
setIdentifier(
|
|
@@ -18,7 +18,7 @@ const { updateHashForEntryStartup } = require("./StartupHelpers");
|
|
|
18
18
|
* Gets information about a chunk including its entries and runtime chunk
|
|
19
19
|
* @param {Chunk} chunk The chunk to get information for
|
|
20
20
|
* @param {ChunkGraph} chunkGraph The chunk graph containing the chunk
|
|
21
|
-
* @returns {{entries:
|
|
21
|
+
* @returns {{ entries: [Module, Entrypoint | undefined][], runtimeChunk: Chunk | null }} Object containing chunk entries and runtime chunk
|
|
22
22
|
*/
|
|
23
23
|
function getChunkInfo(chunk, chunkGraph) {
|
|
24
24
|
const entries = [
|
|
@@ -21,7 +21,6 @@ const { generateEntryStartup } = require("./StartupHelpers");
|
|
|
21
21
|
|
|
22
22
|
/** @typedef {import("../Chunk")} Chunk */
|
|
23
23
|
/** @typedef {import("../Compiler")} Compiler */
|
|
24
|
-
/** @typedef {import("../Entrypoint")} Entrypoint */
|
|
25
24
|
|
|
26
25
|
const PLUGIN_NAME = "CommonJsChunkFormatPlugin";
|
|
27
26
|
|
|
@@ -13,17 +13,16 @@ const { JS_TYPES } = require("../ModuleSourceTypesConstants");
|
|
|
13
13
|
const HarmonyCompatibilityDependency = require("../dependencies/HarmonyCompatibilityDependency");
|
|
14
14
|
|
|
15
15
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
16
|
+
/** @typedef {import("../Compilation").DependencyConstructor} DependencyConstructor */
|
|
16
17
|
/** @typedef {import("../DependenciesBlock")} DependenciesBlock */
|
|
17
18
|
/** @typedef {import("../Dependency")} Dependency */
|
|
18
19
|
/** @typedef {import("../DependencyTemplate")} DependencyTemplate */
|
|
19
20
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
|
20
|
-
/** @typedef {import("../DependencyTemplates")} DependencyTemplates */
|
|
21
21
|
/** @typedef {import("../Generator").GenerateContext} GenerateContext */
|
|
22
22
|
/** @typedef {import("../Module")} Module */
|
|
23
23
|
/** @typedef {import("../Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
|
|
24
24
|
/** @typedef {import("../Module").SourceTypes} SourceTypes */
|
|
25
25
|
/** @typedef {import("../NormalModule")} NormalModule */
|
|
26
|
-
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
|
27
26
|
|
|
28
27
|
const DEFAULT_SOURCE = {
|
|
29
28
|
source() {
|
|
@@ -213,7 +212,7 @@ class JavascriptGenerator extends Generator {
|
|
|
213
212
|
*/
|
|
214
213
|
sourceDependency(module, dependency, initFragments, source, generateContext) {
|
|
215
214
|
const constructor =
|
|
216
|
-
/** @type {
|
|
215
|
+
/** @type {DependencyConstructor} */
|
|
217
216
|
(dependency.constructor);
|
|
218
217
|
const template = generateContext.dependencyTemplates.get(constructor);
|
|
219
218
|
if (!template) {
|
|
@@ -52,8 +52,7 @@ const JavascriptParser = require("./JavascriptParser");
|
|
|
52
52
|
/** @typedef {import("eslint-scope").Variable} Variable */
|
|
53
53
|
/** @typedef {import("estree").Program} Program */
|
|
54
54
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
55
|
-
/** @typedef {import("
|
|
56
|
-
/** @typedef {import("../../declarations/WebpackOptions").Output} OutputOptions */
|
|
55
|
+
/** @typedef {import("../config/defaults").OutputNormalizedWithDefaults} OutputOptions */
|
|
57
56
|
/** @typedef {import("../Chunk")} Chunk */
|
|
58
57
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
|
59
58
|
/** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
|
|
@@ -445,7 +444,6 @@ class JavascriptModulesPlugin {
|
|
|
445
444
|
compilation.hooks.contentHash.tap(PLUGIN_NAME, (chunk) => {
|
|
446
445
|
const {
|
|
447
446
|
chunkGraph,
|
|
448
|
-
codeGenerationResults,
|
|
449
447
|
moduleGraph,
|
|
450
448
|
runtimeTemplate,
|
|
451
449
|
outputOptions: {
|
|
@@ -455,7 +453,10 @@ class JavascriptModulesPlugin {
|
|
|
455
453
|
hashFunction
|
|
456
454
|
}
|
|
457
455
|
} = compilation;
|
|
458
|
-
const
|
|
456
|
+
const codeGenerationResults =
|
|
457
|
+
/** @type {CodeGenerationResults} */
|
|
458
|
+
(compilation.codeGenerationResults);
|
|
459
|
+
const hash = createHash(hashFunction);
|
|
459
460
|
if (hashSalt) hash.update(hashSalt);
|
|
460
461
|
if (chunk.hasRuntime()) {
|
|
461
462
|
this.updateHashWithBootstrap(
|
|
@@ -591,11 +592,11 @@ class JavascriptModulesPlugin {
|
|
|
591
592
|
if (chunk.filenameTemplate) {
|
|
592
593
|
return chunk.filenameTemplate;
|
|
593
594
|
} else if (chunk instanceof HotUpdateChunk) {
|
|
594
|
-
return
|
|
595
|
+
return outputOptions.hotUpdateChunkFilename;
|
|
595
596
|
} else if (chunk.canBeInitial()) {
|
|
596
|
-
return
|
|
597
|
+
return outputOptions.filename;
|
|
597
598
|
}
|
|
598
|
-
return
|
|
599
|
+
return outputOptions.chunkFilename;
|
|
599
600
|
}
|
|
600
601
|
|
|
601
602
|
/**
|
|
@@ -1356,6 +1357,16 @@ class JavascriptModulesPlugin {
|
|
|
1356
1357
|
"// This entry module used 'module' so it can't be inlined"
|
|
1357
1358
|
);
|
|
1358
1359
|
}
|
|
1360
|
+
if (
|
|
1361
|
+
result.allowInlineStartup &&
|
|
1362
|
+
entryRuntimeRequirements.has(RuntimeGlobals.thisAsExports)
|
|
1363
|
+
) {
|
|
1364
|
+
buf2.push(
|
|
1365
|
+
"// This entry module used `this` as exports so it can't be inlined"
|
|
1366
|
+
);
|
|
1367
|
+
result.allowInlineStartup = false;
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1359
1370
|
if (chunks.length > 0) {
|
|
1360
1371
|
buf2.push(
|
|
1361
1372
|
`${i === 0 ? `var ${RuntimeGlobals.exports} = ` : ""}${
|
|
@@ -1374,21 +1385,33 @@ class JavascriptModulesPlugin {
|
|
|
1374
1385
|
);
|
|
1375
1386
|
} else {
|
|
1376
1387
|
if (i === 0) buf2.push(`var ${RuntimeGlobals.exports} = {};`);
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
);
|
|
1389
|
-
|
|
1390
|
-
|
|
1388
|
+
const needThisAsExports = entryRuntimeRequirements.has(
|
|
1389
|
+
RuntimeGlobals.thisAsExports
|
|
1390
|
+
);
|
|
1391
|
+
|
|
1392
|
+
/** @type {string[]} */
|
|
1393
|
+
const args = [];
|
|
1394
|
+
if (
|
|
1395
|
+
requireScopeUsed ||
|
|
1396
|
+
entryRuntimeRequirements.has(RuntimeGlobals.exports)
|
|
1397
|
+
) {
|
|
1398
|
+
const exportsArg = i === 0 ? RuntimeGlobals.exports : "{}";
|
|
1399
|
+
args.push("0", exportsArg);
|
|
1400
|
+
if (requireScopeUsed) {
|
|
1401
|
+
args.push(RuntimeGlobals.require);
|
|
1402
|
+
}
|
|
1391
1403
|
}
|
|
1404
|
+
buf2.push(
|
|
1405
|
+
Template.asString(
|
|
1406
|
+
(() => {
|
|
1407
|
+
if (needThisAsExports) {
|
|
1408
|
+
const comma = args.length ? "," : "";
|
|
1409
|
+
return `__webpack_modules__[${moduleIdExpr}].call(${RuntimeGlobals.exports}${comma}${args.join(",")});`;
|
|
1410
|
+
}
|
|
1411
|
+
return `__webpack_modules__[${moduleIdExpr}](${args.join(",")});`;
|
|
1412
|
+
})()
|
|
1413
|
+
)
|
|
1414
|
+
);
|
|
1392
1415
|
}
|
|
1393
1416
|
}
|
|
1394
1417
|
if (runtimeRequirements.has(RuntimeGlobals.onChunksLoaded)) {
|