webpack 5.99.9 → 5.100.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/bin/webpack.js +8 -2
- package/hot/log.js +15 -15
- package/hot/poll.js +1 -0
- package/lib/APIPlugin.js +3 -3
- package/lib/AbstractMethodError.js +1 -0
- package/lib/AutomaticPrefetchPlugin.js +1 -0
- package/lib/BannerPlugin.js +1 -1
- package/lib/CaseSensitiveModulesWarning.js +4 -4
- package/lib/Chunk.js +6 -6
- package/lib/ChunkGraph.js +37 -31
- package/lib/ChunkGroup.js +4 -4
- package/lib/ChunkTemplate.js +1 -1
- package/lib/CleanPlugin.js +94 -17
- package/lib/CodeGenerationResults.js +1 -1
- package/lib/CompatibilityPlugin.js +5 -2
- package/lib/Compilation.js +67 -45
- package/lib/Compiler.js +46 -16
- package/lib/ConcatenationScope.js +15 -6
- package/lib/ConstPlugin.js +5 -3
- package/lib/ContextModule.js +16 -12
- package/lib/ContextModuleFactory.js +4 -3
- package/lib/ContextReplacementPlugin.js +4 -2
- package/lib/CssModule.js +2 -2
- package/lib/DefinePlugin.js +111 -3
- package/lib/DelegatedModuleFactoryPlugin.js +18 -18
- package/lib/Dependency.js +11 -4
- package/lib/DependencyTemplate.js +1 -0
- package/lib/DllEntryPlugin.js +3 -1
- package/lib/DllPlugin.js +4 -3
- package/lib/DllReferencePlugin.js +2 -2
- package/lib/DynamicEntryPlugin.js +1 -1
- package/lib/EntryOptionPlugin.js +5 -0
- package/lib/ErrorHelpers.js +4 -4
- package/lib/EvalDevToolModulePlugin.js +3 -3
- package/lib/EvalSourceMapDevToolPlugin.js +7 -7
- package/lib/ExportsInfo.js +48 -39
- package/lib/ExternalModule.js +15 -11
- package/lib/ExternalModuleFactoryPlugin.js +5 -2
- package/lib/FileSystemInfo.js +51 -36
- package/lib/FlagDependencyExportsPlugin.js +14 -7
- package/lib/FlagDependencyUsagePlugin.js +1 -1
- package/lib/Generator.js +14 -1
- package/lib/HookWebpackError.js +1 -0
- package/lib/HotModuleReplacementPlugin.js +77 -50
- package/lib/IgnorePlugin.js +5 -2
- package/lib/InvalidDependenciesModuleWarning.js +1 -1
- package/lib/JavascriptMetaInfoPlugin.js +0 -1
- package/lib/LibManifestPlugin.js +4 -2
- package/lib/LoaderOptionsPlugin.js +6 -4
- package/lib/MainTemplate.js +2 -2
- package/lib/Module.js +21 -6
- package/lib/ModuleFactory.js +1 -0
- package/lib/ModuleGraph.js +24 -2
- package/lib/ModuleGraphConnection.js +5 -5
- package/lib/ModuleInfoHeaderPlugin.js +2 -1
- package/lib/ModuleParseError.js +1 -0
- package/lib/ModuleSourceTypesConstants.js +12 -12
- package/lib/ModuleTemplate.js +1 -1
- package/lib/ModuleTypeConstants.js +21 -21
- package/lib/MultiCompiler.js +6 -6
- package/lib/NormalModule.js +31 -44
- package/lib/NormalModuleFactory.js +34 -20
- package/lib/NormalModuleReplacementPlugin.js +1 -1
- package/lib/NullFactory.js +1 -0
- package/lib/OptimizationStages.js +1 -1
- package/lib/Parser.js +1 -0
- package/lib/ProgressPlugin.js +12 -5
- package/lib/ProvidePlugin.js +5 -1
- package/lib/RawModule.js +14 -0
- package/lib/RecordIdsPlugin.js +3 -3
- package/lib/RuntimeGlobals.js +175 -155
- package/lib/RuntimeModule.js +1 -0
- package/lib/RuntimePlugin.js +33 -7
- package/lib/RuntimeTemplate.js +111 -11
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +15 -25
- package/lib/SourceMapDevToolPlugin.js +19 -17
- package/lib/Template.js +2 -2
- package/lib/TemplatedPathPlugin.js +1 -1
- package/lib/WarnDeprecatedOptionPlugin.js +7 -8
- package/lib/WatchIgnorePlugin.js +4 -3
- package/lib/WebpackIsIncludedPlugin.js +2 -1
- package/lib/WebpackOptionsApply.js +115 -27
- package/lib/asset/AssetGenerator.js +15 -11
- package/lib/asset/AssetModulesPlugin.js +19 -17
- package/lib/asset/AssetSourceGenerator.js +4 -4
- package/lib/asset/RawDataUrlModule.js +4 -2
- package/lib/async-modules/AwaitDependenciesInitFragment.js +1 -1
- package/lib/buildChunkGraph.js +6 -3
- package/lib/cache/AddBuildDependenciesPlugin.js +5 -6
- package/lib/cache/IdleFileCachePlugin.js +7 -4
- package/lib/cache/MemoryCachePlugin.js +1 -0
- package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
- package/lib/cache/PackFileCacheStrategy.js +26 -20
- package/lib/cache/ResolverCachePlugin.js +16 -8
- package/lib/cli.js +15 -10
- package/lib/config/browserslistTargetHandler.js +3 -3
- package/lib/config/defaults.js +25 -17
- package/lib/config/normalization.js +2 -1
- package/lib/config/target.js +6 -5
- package/lib/container/ContainerPlugin.js +1 -1
- package/lib/container/ContainerReferencePlugin.js +1 -1
- package/lib/container/FallbackModule.js +2 -1
- package/lib/container/HoistContainerReferencesPlugin.js +1 -1
- package/lib/container/ModuleFederationPlugin.js +2 -2
- package/lib/container/RemoteModule.js +1 -1
- package/lib/css/CssGenerator.js +9 -6
- package/lib/css/CssModulesPlugin.js +44 -31
- package/lib/css/CssParser.js +6 -4
- package/lib/css/walkCssTokens.js +33 -37
- package/lib/debug/ProfilingPlugin.js +6 -6
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +8 -8
- package/lib/dependencies/AMDPlugin.js +12 -8
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +28 -26
- package/lib/dependencies/CachedConstDependency.js +1 -5
- package/lib/dependencies/CommonJsExportRequireDependency.js +6 -4
- package/lib/dependencies/CommonJsExportsParserPlugin.js +22 -25
- package/lib/dependencies/CommonJsFullRequireDependency.js +1 -9
- package/lib/dependencies/CommonJsImportsParserPlugin.js +100 -114
- package/lib/dependencies/CommonJsPlugin.js +15 -16
- package/lib/dependencies/ContextDependencyHelpers.js +2 -1
- package/lib/dependencies/ContextDependencyTemplateAsId.js +1 -0
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +1 -0
- package/lib/dependencies/CssIcssExportDependency.js +1 -1
- package/lib/dependencies/CssLocalIdentifierDependency.js +2 -2
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
- package/lib/dependencies/DynamicExports.js +9 -9
- package/lib/dependencies/ExportsInfoDependency.js +1 -1
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +122 -101
- package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +95 -19
- package/lib/dependencies/HarmonyExportInitFragment.js +1 -1
- package/lib/dependencies/HarmonyImportDependency.js +11 -5
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +238 -162
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +4 -1
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +20 -9
- package/lib/dependencies/HarmonyModulesPlugin.js +23 -12
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -0
- package/lib/dependencies/ImportMetaContextPlugin.js +2 -1
- package/lib/dependencies/ImportMetaPlugin.js +2 -2
- package/lib/dependencies/ImportParserPlugin.js +40 -9
- package/lib/dependencies/ImportPlugin.js +3 -1
- package/lib/dependencies/LoaderPlugin.js +1 -0
- package/lib/dependencies/ModuleDependency.js +3 -1
- package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +1 -0
- package/lib/dependencies/RequireContextPlugin.js +3 -1
- package/lib/dependencies/RequireEnsurePlugin.js +6 -6
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +33 -34
- package/lib/dependencies/RequireIncludePlugin.js +1 -0
- package/lib/dependencies/RuntimeRequirementsDependency.js +1 -1
- package/lib/dependencies/SystemPlugin.js +1 -1
- package/lib/dependencies/URLContextDependency.js +65 -0
- package/lib/dependencies/URLPlugin.js +17 -157
- package/lib/dependencies/WorkerPlugin.js +23 -10
- package/lib/dependencies/processExportInfo.js +2 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +269 -185
- package/lib/esm/ModuleChunkLoadingPlugin.js +39 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +70 -3
- package/lib/hmr/HotModuleReplacement.runtime.js +0 -1
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -1
- package/lib/hmr/JavascriptHotModuleReplacementHelper.js +37 -0
- package/lib/hmr/LazyCompilationPlugin.js +4 -2
- package/lib/hmr/lazyCompilationBackend.js +4 -2
- package/lib/ids/ChunkModuleIdRangePlugin.js +6 -3
- package/lib/ids/DeterministicChunkIdsPlugin.js +30 -35
- package/lib/ids/DeterministicModuleIdsPlugin.js +4 -3
- package/lib/ids/HashedModuleIdsPlugin.js +5 -4
- package/lib/ids/IdHelpers.js +21 -17
- package/lib/ids/NamedChunkIdsPlugin.js +5 -5
- package/lib/ids/NamedModuleIdsPlugin.js +4 -4
- package/lib/ids/NaturalChunkIdsPlugin.js +2 -1
- package/lib/ids/NaturalModuleIdsPlugin.js +1 -1
- package/lib/ids/OccurrenceChunkIdsPlugin.js +3 -2
- package/lib/ids/OccurrenceModuleIdsPlugin.js +1 -1
- package/lib/ids/SyncModuleIdsPlugin.js +1 -1
- package/lib/index.js +13 -3
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +113 -119
- package/lib/javascript/BasicEvaluatedExpression.js +2 -1
- package/lib/javascript/ChunkHelpers.js +1 -0
- package/lib/javascript/CommonJsChunkFormatPlugin.js +121 -136
- package/lib/javascript/EnableChunkLoadingPlugin.js +6 -3
- package/lib/javascript/JavascriptGenerator.js +14 -2
- package/lib/javascript/JavascriptModulesPlugin.js +68 -27
- package/lib/javascript/JavascriptParser.js +117 -76
- package/lib/javascript/JavascriptParserHelpers.js +41 -41
- package/lib/javascript/StartupHelpers.js +17 -17
- package/lib/json/JsonGenerator.js +4 -2
- package/lib/json/JsonModulesPlugin.js +2 -2
- package/lib/json/JsonParser.js +1 -1
- package/lib/library/AbstractLibraryPlugin.js +6 -2
- package/lib/library/AssignLibraryPlugin.js +21 -6
- package/lib/library/EnableLibraryPlugin.js +23 -3
- package/lib/library/UmdLibraryPlugin.js +15 -6
- package/lib/logging/createConsoleLogger.js +3 -3
- package/lib/logging/runtime.js +9 -9
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +4 -22
- package/lib/node/RequireChunkLoadingRuntimeModule.js +4 -22
- package/lib/node/nodeConsole.js +4 -2
- package/lib/optimize/AggressiveMergingPlugin.js +45 -46
- package/lib/optimize/AggressiveSplittingPlugin.js +13 -12
- package/lib/optimize/ConcatenatedModule.js +227 -57
- package/lib/optimize/EnsureChunkConditionsPlugin.js +58 -58
- package/lib/optimize/FlagIncludedChunksPlugin.js +3 -1
- package/lib/optimize/InnerGraph.js +115 -112
- package/lib/optimize/InnerGraphPlugin.js +2 -2
- package/lib/optimize/LimitChunkCountPlugin.js +4 -2
- package/lib/optimize/MangleExportsPlugin.js +4 -3
- package/lib/optimize/MergeDuplicateChunksPlugin.js +80 -81
- package/lib/optimize/MinChunkSizePlugin.js +6 -3
- package/lib/optimize/ModuleConcatenationPlugin.js +31 -22
- package/lib/optimize/RealContentHashPlugin.js +26 -20
- package/lib/optimize/RemoveEmptyChunksPlugin.js +2 -1
- package/lib/optimize/RemoveParentModulesPlugin.js +1 -0
- package/lib/optimize/SideEffectsFlagPlugin.js +3 -2
- package/lib/optimize/SplitChunksPlugin.js +16 -13
- package/lib/rules/BasicEffectRulePlugin.js +4 -2
- package/lib/rules/BasicMatcherRulePlugin.js +3 -1
- package/lib/rules/ObjectMatcherRulePlugin.js +3 -1
- package/lib/rules/RuleSetCompiler.js +19 -5
- package/lib/rules/UseEffectRulePlugin.js +17 -9
- package/lib/runtime/AsyncModuleRuntimeModule.js +64 -9
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +1 -1
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +214 -0
- package/lib/runtime/RuntimeIdRuntimeModule.js +2 -1
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +8 -7
- package/lib/schemes/FileUriPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +27 -19
- package/lib/schemes/VirtualUrlPlugin.js +222 -0
- package/lib/serialization/AggregateErrorSerializer.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +5 -4
- package/lib/serialization/FileMiddleware.js +7 -4
- package/lib/serialization/ObjectMiddleware.js +14 -8
- package/lib/serialization/Serializer.js +5 -3
- package/lib/serialization/SerializerMiddleware.js +2 -0
- package/lib/sharing/ConsumeSharedModule.js +1 -1
- package/lib/sharing/ConsumeSharedPlugin.js +3 -3
- package/lib/sharing/ConsumeSharedRuntimeModule.js +2 -2
- package/lib/sharing/ProvideSharedModule.js +1 -1
- package/lib/sharing/ProvideSharedPlugin.js +3 -2
- package/lib/sharing/SharePlugin.js +2 -1
- package/lib/sharing/ShareRuntimeModule.js +3 -5
- package/lib/sharing/utils.js +34 -34
- package/lib/stats/DefaultStatsFactoryPlugin.js +49 -46
- package/lib/stats/DefaultStatsPresetPlugin.js +13 -13
- package/lib/stats/DefaultStatsPrinterPlugin.js +15 -9
- package/lib/stats/StatsFactory.js +6 -3
- package/lib/stats/StatsPrinter.js +6 -7
- package/lib/url/URLParserPlugin.js +266 -0
- package/lib/util/ArrayQueue.js +1 -1
- package/lib/util/AsyncQueue.js +1 -1
- package/lib/util/Hash.js +2 -0
- package/lib/util/IterableHelpers.js +1 -1
- package/lib/util/LazyBucketSortedSet.js +2 -1
- package/lib/util/LazySet.js +11 -6
- package/lib/util/ParallelismFactorCalculator.js +1 -1
- package/lib/util/SetHelpers.js +3 -3
- package/lib/util/SortableSet.js +2 -2
- package/lib/util/StackedCacheMap.js +3 -1
- package/lib/util/StackedMap.js +2 -2
- package/lib/util/StringXor.js +1 -0
- package/lib/util/TupleSet.js +1 -0
- package/lib/util/URLAbsoluteSpecifier.js +1 -1
- package/lib/util/cleverMerge.js +95 -58
- package/lib/util/comparators.js +154 -127
- package/lib/util/compileBooleanMatcher.js +8 -3
- package/lib/util/concatenate.js +8 -7
- package/lib/util/conventions.js +72 -73
- package/lib/util/create-schema-validation.js +2 -1
- package/lib/util/createHash.js +10 -4
- package/lib/util/deprecation.js +69 -66
- package/lib/util/deterministicGrouping.js +4 -2
- package/lib/util/extractUrlAndGlobal.js +1 -1
- package/lib/util/findGraphRoots.js +2 -2
- package/lib/util/fs.js +30 -23
- package/lib/util/hash/md4.js +2 -2
- package/lib/util/hash/wasm-hash.js +4 -2
- package/lib/util/identifier.js +13 -12
- package/lib/util/internalSerializables.js +2 -0
- package/lib/util/magicComment.js +5 -5
- package/lib/util/processAsyncTree.js +1 -1
- package/lib/util/propertyAccess.js +1 -1
- package/lib/util/propertyName.js +1 -1
- package/lib/util/registerExternalSerializer.js +1 -2
- package/lib/util/removeBOM.js +1 -1
- package/lib/util/runtime.js +29 -21
- package/lib/util/semver.js +1 -1
- package/lib/util/serialization.js +3 -0
- package/lib/util/source.js +3 -2
- package/lib/validateSchema.js +1 -0
- package/lib/wasm/EnableWasmLoadingPlugin.js +6 -3
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +4 -1
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +46 -49
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +2 -2
- package/lib/wasm-sync/WebAssemblyGenerator.js +2 -3
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +3 -2
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +3 -0
- package/lib/wasm-sync/WebAssemblyUtils.js +1 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +4 -22
- package/lib/webpack.js +4 -5
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +1 -0
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +6 -24
- package/lib/webworker/WebWorkerTemplatePlugin.js +1 -0
- package/package.json +119 -113
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +17 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.d.ts +7 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +6 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +77 -0
- package/types.d.ts +1243 -409
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
-
const eslintScope = require("eslint-scope");
|
|
9
|
-
const { SyncWaterfallHook, SyncHook, SyncBailHook } = require("tapable");
|
|
10
8
|
const vm = require("vm");
|
|
9
|
+
const eslintScope = require("eslint-scope");
|
|
10
|
+
const { SyncBailHook, SyncHook, SyncWaterfallHook } = require("tapable");
|
|
11
11
|
const {
|
|
12
|
+
CachedSource,
|
|
12
13
|
ConcatSource,
|
|
13
14
|
OriginalSource,
|
|
14
15
|
PrefixSource,
|
|
15
16
|
RawSource,
|
|
16
|
-
CachedSource,
|
|
17
17
|
ReplaceSource
|
|
18
18
|
} = require("webpack-sources");
|
|
19
19
|
const Compilation = require("../Compilation");
|
|
@@ -33,11 +33,11 @@ const { last, someInIterable } = require("../util/IterableHelpers");
|
|
|
33
33
|
const StringXor = require("../util/StringXor");
|
|
34
34
|
const { compareModulesByIdOrIdentifier } = require("../util/comparators");
|
|
35
35
|
const {
|
|
36
|
-
getPathInAst,
|
|
37
|
-
getAllReferences,
|
|
38
36
|
RESERVED_NAMES,
|
|
39
|
-
findNewName,
|
|
40
37
|
addScopeSymbols,
|
|
38
|
+
findNewName,
|
|
39
|
+
getAllReferences,
|
|
40
|
+
getPathInAst,
|
|
41
41
|
getUsedNamesInScopeInfo
|
|
42
42
|
} = require("../util/concatenate");
|
|
43
43
|
const createHash = require("../util/createHash");
|
|
@@ -95,8 +95,9 @@ const chunkHasRuntimeOrJs = (chunk, chunkGraph) => {
|
|
|
95
95
|
chunk,
|
|
96
96
|
WEBPACK_MODULE_TYPE_RUNTIME
|
|
97
97
|
)
|
|
98
|
-
)
|
|
98
|
+
) {
|
|
99
99
|
return true;
|
|
100
|
+
}
|
|
100
101
|
|
|
101
102
|
return Boolean(
|
|
102
103
|
chunkGraph.getChunkModulesIterableBySourceType(chunk, "javascript")
|
|
@@ -116,10 +117,10 @@ const printGeneratedCodeForStack = (module, code) => {
|
|
|
116
117
|
/**
|
|
117
118
|
* @param {string} line the line
|
|
118
119
|
* @param {number} i the index
|
|
119
|
-
* @param {string[]}
|
|
120
|
+
* @param {string[]} _lines the lines
|
|
120
121
|
* @returns {string} the line with line number
|
|
121
122
|
*/
|
|
122
|
-
(line, i,
|
|
123
|
+
(line, i, _lines) => {
|
|
123
124
|
const iStr = `${i + 1}`;
|
|
124
125
|
return `${" ".repeat(n - iStr.length)}${iStr} | ${line}`;
|
|
125
126
|
}
|
|
@@ -594,8 +595,9 @@ class JavascriptModulesPlugin {
|
|
|
594
595
|
if (codeGenResult.data !== undefined) {
|
|
595
596
|
const chunkInitFragments = codeGenResult.data.get("chunkInitFragments");
|
|
596
597
|
if (chunkInitFragments) {
|
|
597
|
-
for (const i of chunkInitFragments)
|
|
598
|
+
for (const i of chunkInitFragments) {
|
|
598
599
|
renderContext.chunkInitFragments.push(i);
|
|
600
|
+
}
|
|
599
601
|
}
|
|
600
602
|
}
|
|
601
603
|
const moduleSourcePostContent = tryRunOrWebpackError(
|
|
@@ -636,18 +638,20 @@ class JavascriptModulesPlugin {
|
|
|
636
638
|
} else {
|
|
637
639
|
const factorySource = new ConcatSource();
|
|
638
640
|
const args = [];
|
|
639
|
-
if (needExports || needRequire || needModule)
|
|
641
|
+
if (needExports || needRequire || needModule) {
|
|
640
642
|
args.push(
|
|
641
643
|
needModule
|
|
642
644
|
? module.moduleArgument
|
|
643
645
|
: `__unused_webpack_${module.moduleArgument}`
|
|
644
646
|
);
|
|
645
|
-
|
|
647
|
+
}
|
|
648
|
+
if (needExports || needRequire) {
|
|
646
649
|
args.push(
|
|
647
650
|
needExports
|
|
648
651
|
? module.exportsArgument
|
|
649
652
|
: `__unused_webpack_${module.exportsArgument}`
|
|
650
653
|
);
|
|
654
|
+
}
|
|
651
655
|
if (needRequire) args.push(RuntimeGlobals.require);
|
|
652
656
|
if (!needThisAsExports && runtimeTemplate.supportsArrowFunction()) {
|
|
653
657
|
factorySource.add(`/***/ ((${args.join(", ")}) => {\n\n`);
|
|
@@ -704,7 +708,7 @@ class JavascriptModulesPlugin {
|
|
|
704
708
|
"javascript",
|
|
705
709
|
compareModulesByIdOrIdentifier(chunkGraph)
|
|
706
710
|
);
|
|
707
|
-
const allModules = modules ?
|
|
711
|
+
const allModules = modules ? [...modules] : [];
|
|
708
712
|
let strictHeader;
|
|
709
713
|
let allStrict = renderContext.strictMode;
|
|
710
714
|
if (
|
|
@@ -777,13 +781,14 @@ class JavascriptModulesPlugin {
|
|
|
777
781
|
const bootstrap = this.renderBootstrap(renderContext, hooks);
|
|
778
782
|
const useSourceMap = hooks.useSourceMap.call(chunk, renderContext);
|
|
779
783
|
|
|
780
|
-
|
|
781
|
-
|
|
784
|
+
/** @type {Module[]} */
|
|
785
|
+
const allModules = [
|
|
786
|
+
...(chunkGraph.getOrderedChunkModulesIterableBySourceType(
|
|
782
787
|
chunk,
|
|
783
788
|
"javascript",
|
|
784
789
|
compareModulesByIdOrIdentifier(chunkGraph)
|
|
785
|
-
) || []
|
|
786
|
-
|
|
790
|
+
) || [])
|
|
791
|
+
];
|
|
787
792
|
|
|
788
793
|
const hasEntryModules = chunkGraph.getNumberOfEntryModules(chunk) > 0;
|
|
789
794
|
/** @type {Set<Module> | undefined} */
|
|
@@ -964,12 +969,13 @@ class JavascriptModulesPlugin {
|
|
|
964
969
|
footer = "\n";
|
|
965
970
|
}
|
|
966
971
|
if (exports) {
|
|
967
|
-
if (m !== lastInlinedModule)
|
|
972
|
+
if (m !== lastInlinedModule) {
|
|
968
973
|
startupSource.add(`var ${m.exportsArgument} = {};\n`);
|
|
969
|
-
else if (m.exportsArgument !== RuntimeGlobals.exports)
|
|
974
|
+
} else if (m.exportsArgument !== RuntimeGlobals.exports) {
|
|
970
975
|
startupSource.add(
|
|
971
976
|
`var ${m.exportsArgument} = ${RuntimeGlobals.exports};\n`
|
|
972
977
|
);
|
|
978
|
+
}
|
|
973
979
|
}
|
|
974
980
|
startupSource.add(renderedModule);
|
|
975
981
|
startupSource.add(footer);
|
|
@@ -1013,7 +1019,7 @@ class JavascriptModulesPlugin {
|
|
|
1013
1019
|
toSource(bootstrap.beforeStartup, "webpack/before-startup"),
|
|
1014
1020
|
"\n",
|
|
1015
1021
|
hooks.renderStartup.call(
|
|
1016
|
-
toSource(bootstrap.startup
|
|
1022
|
+
toSource([...bootstrap.startup, ""], "webpack/startup"),
|
|
1017
1023
|
lastEntryModule,
|
|
1018
1024
|
{
|
|
1019
1025
|
...renderContext,
|
|
@@ -1162,6 +1168,16 @@ class JavascriptModulesPlugin {
|
|
|
1162
1168
|
buf.push("");
|
|
1163
1169
|
}
|
|
1164
1170
|
|
|
1171
|
+
if (runtimeRequirements.has(RuntimeGlobals.makeDeferredNamespaceObject)) {
|
|
1172
|
+
// in order to optimize of DeferredNamespaceObject, we remove all proxy handlers after the module initialize
|
|
1173
|
+
// (see MakeDeferredNamespaceObjectRuntimeModule)
|
|
1174
|
+
// This requires all deferred imports to a module can get the module export object before the module
|
|
1175
|
+
// is evaluated.
|
|
1176
|
+
buf.push("// The deferred module cache");
|
|
1177
|
+
buf.push("var __webpack_module_deferred_exports__ = {};");
|
|
1178
|
+
buf.push("");
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1165
1181
|
if (useRequire) {
|
|
1166
1182
|
buf.push("// The require function");
|
|
1167
1183
|
buf.push(`function ${RuntimeGlobals.require}(moduleId) {`);
|
|
@@ -1431,6 +1447,9 @@ class JavascriptModulesPlugin {
|
|
|
1431
1447
|
const needModuleLoaded = runtimeRequirements.has(
|
|
1432
1448
|
RuntimeGlobals.moduleLoaded
|
|
1433
1449
|
);
|
|
1450
|
+
const needModuleDefer = runtimeRequirements.has(
|
|
1451
|
+
RuntimeGlobals.makeDeferredNamespaceObject
|
|
1452
|
+
);
|
|
1434
1453
|
const content = Template.asString([
|
|
1435
1454
|
"// Check if module is in cache",
|
|
1436
1455
|
"var cachedModule = __webpack_module_cache__[moduleId];",
|
|
@@ -1447,7 +1466,9 @@ class JavascriptModulesPlugin {
|
|
|
1447
1466
|
Template.indent([
|
|
1448
1467
|
needModuleId ? "id: moduleId," : "// no module.id needed",
|
|
1449
1468
|
needModuleLoaded ? "loaded: false," : "// no module.loaded needed",
|
|
1450
|
-
|
|
1469
|
+
needModuleDefer
|
|
1470
|
+
? "exports: __webpack_module_deferred_exports__[moduleId] || {}"
|
|
1471
|
+
: "exports: {}"
|
|
1451
1472
|
]),
|
|
1452
1473
|
"};",
|
|
1453
1474
|
"",
|
|
@@ -1456,7 +1477,13 @@ class JavascriptModulesPlugin {
|
|
|
1456
1477
|
"// Execute the module function",
|
|
1457
1478
|
"var threw = true;",
|
|
1458
1479
|
"try {",
|
|
1459
|
-
Template.indent([
|
|
1480
|
+
Template.indent([
|
|
1481
|
+
moduleExecution,
|
|
1482
|
+
"threw = false;",
|
|
1483
|
+
...(needModuleDefer
|
|
1484
|
+
? ["delete __webpack_module_deferred_exports__[moduleId];"]
|
|
1485
|
+
: [])
|
|
1486
|
+
]),
|
|
1460
1487
|
"} finally {",
|
|
1461
1488
|
Template.indent([
|
|
1462
1489
|
"if(threw) delete __webpack_module_cache__[moduleId];"
|
|
@@ -1467,14 +1494,27 @@ class JavascriptModulesPlugin {
|
|
|
1467
1494
|
? Template.asString([
|
|
1468
1495
|
"// Execute the module function",
|
|
1469
1496
|
"try {",
|
|
1470
|
-
Template.indent(
|
|
1497
|
+
Template.indent(
|
|
1498
|
+
needModuleDefer
|
|
1499
|
+
? [
|
|
1500
|
+
moduleExecution,
|
|
1501
|
+
"delete __webpack_module_deferred_exports__[moduleId];"
|
|
1502
|
+
]
|
|
1503
|
+
: moduleExecution
|
|
1504
|
+
),
|
|
1471
1505
|
"} catch(e) {",
|
|
1472
1506
|
Template.indent(["module.error = e;", "throw e;"]),
|
|
1473
1507
|
"}"
|
|
1474
1508
|
])
|
|
1475
1509
|
: Template.asString([
|
|
1476
1510
|
"// Execute the module function",
|
|
1477
|
-
moduleExecution
|
|
1511
|
+
moduleExecution,
|
|
1512
|
+
...(needModuleDefer
|
|
1513
|
+
? [
|
|
1514
|
+
"// delete __webpack_module_deferred_exports__[module];",
|
|
1515
|
+
"// skipped because strictModuleErrorHandling is not enabled."
|
|
1516
|
+
]
|
|
1517
|
+
: [])
|
|
1478
1518
|
]),
|
|
1479
1519
|
needModuleLoaded
|
|
1480
1520
|
? Template.asString([
|
|
@@ -1619,9 +1659,10 @@ class JavascriptModulesPlugin {
|
|
|
1619
1659
|
|
|
1620
1660
|
if (allUsedNames.has(name) || usedNames.has(name)) {
|
|
1621
1661
|
const references = getAllReferences(variable);
|
|
1622
|
-
const allIdentifiers = new Set(
|
|
1623
|
-
references.map(r => r.identifier)
|
|
1624
|
-
|
|
1662
|
+
const allIdentifiers = new Set([
|
|
1663
|
+
...references.map(r => r.identifier),
|
|
1664
|
+
...variable.identifiers
|
|
1665
|
+
]);
|
|
1625
1666
|
for (const ref of references) {
|
|
1626
1667
|
addScopeSymbols(
|
|
1627
1668
|
ref.from,
|