webpack 5.107.1 → 5.108.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/hot/dev-server.js +2 -0
- package/lib/APIPlugin.js +8 -4
- package/lib/CacheFacade.js +7 -0
- package/lib/Chunk.js +4 -0
- package/lib/ChunkGraph.js +30 -9
- package/lib/CircularModulesPlugin.js +190 -0
- package/lib/CleanPlugin.js +2 -1
- package/lib/Compilation.js +396 -65
- package/lib/Compiler.js +52 -14
- package/lib/ConcatenationScope.js +10 -3
- package/lib/ContextExclusionPlugin.js +1 -0
- package/lib/ContextModule.js +92 -47
- package/lib/ContextModuleFactory.js +45 -38
- package/lib/ContextReplacementPlugin.js +4 -0
- package/lib/DefinePlugin.js +89 -15
- package/lib/Dependency.js +111 -7
- package/lib/EntryOptionPlugin.js +39 -2
- package/lib/EntryPlugin.js +2 -0
- package/lib/ExportsInfo.js +314 -73
- package/lib/ExternalModule.js +82 -34
- package/lib/ExternalModuleFactoryPlugin.js +1 -0
- package/lib/ExternalsPlugin.js +1 -0
- package/lib/FileSystemInfo.js +173 -23
- package/lib/FlagAllModulesAsUsedPlugin.js +1 -5
- package/lib/FlagDependencyExportsPlugin.js +23 -0
- package/lib/FlagDependencyUsagePlugin.js +87 -5
- package/lib/FlagEntryExportAsUsedPlugin.js +2 -0
- package/lib/Generator.js +8 -0
- package/lib/HotModuleReplacementPlugin.js +65 -28
- package/lib/IgnorePlugin.js +1 -0
- package/lib/InitFragment.js +5 -0
- package/lib/JavascriptMetaInfoPlugin.js +7 -5
- package/lib/LazyBarrel.js +361 -0
- package/lib/LoaderTargetPlugin.js +1 -0
- package/lib/Module.js +21 -42
- package/lib/ModuleGraph.js +3 -2
- package/lib/ModuleProfile.js +27 -1
- package/lib/ModuleTemplate.js +2 -0
- package/lib/MultiCompiler.js +16 -0
- package/lib/MultiStats.js +1 -0
- package/lib/MultiWatching.js +2 -0
- package/lib/NodeStuffPlugin.js +22 -17
- package/lib/NormalModule.js +557 -77
- package/lib/NormalModuleReplacementPlugin.js +2 -0
- package/lib/PrefetchPlugin.js +2 -0
- package/lib/ProgressPlugin.js +9 -1
- package/lib/ProvidePlugin.js +1 -0
- package/lib/RawModule.js +20 -16
- package/lib/RecordIdsPlugin.js +1 -0
- package/lib/RuntimeGlobals.js +5 -0
- package/lib/RuntimePlugin.js +58 -26
- package/lib/RuntimeTemplate.js +278 -21
- package/lib/SelfModuleFactory.js +1 -0
- package/lib/SourceMapDevToolPlugin.js +105 -30
- package/lib/Stats.js +1 -0
- package/lib/Template.js +8 -2
- package/lib/TemplatedPathPlugin.js +473 -131
- package/lib/WarnCaseSensitiveModulesPlugin.js +1 -0
- package/lib/WarnDeprecatedOptionPlugin.js +4 -0
- package/lib/WarnNoModeSetPlugin.js +1 -0
- package/lib/WatchIgnorePlugin.js +1 -0
- package/lib/Watching.js +9 -0
- package/lib/WebpackOptionsApply.js +50 -5
- package/lib/asset/AssetBytesGenerator.js +11 -3
- package/lib/asset/AssetGenerator.js +47 -22
- package/lib/asset/AssetModule.js +47 -0
- package/lib/asset/AssetModulesPlugin.js +14 -14
- package/lib/asset/AssetParser.js +2 -2
- package/lib/asset/AssetSourceGenerator.js +8 -0
- package/lib/asset/RawDataUrlModule.js +12 -13
- package/lib/buildChunkGraph.js +88 -9
- package/lib/bun/BunTargetPlugin.js +48 -0
- package/lib/cache/AddBuildDependenciesPlugin.js +1 -0
- package/lib/cache/AddManagedPathsPlugin.js +3 -0
- package/lib/cache/IdleFileCachePlugin.js +4 -0
- package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
- package/lib/cache/PackFileCacheStrategy.js +1 -0
- package/lib/cache/ResolverCachePlugin.js +2 -0
- package/lib/cache/getLazyHashedEtag.js +9 -2
- package/lib/cache/mergeEtags.js +2 -0
- package/lib/cli.js +109 -19
- package/lib/config/browserslistTargetHandler.js +99 -0
- package/lib/config/defaults.js +147 -7
- package/lib/config/defineConfig.js +31 -0
- package/lib/config/normalization.js +5 -0
- package/lib/config/target.js +181 -2
- package/lib/container/ContainerEntryModule.js +15 -14
- package/lib/container/ContainerExposedDependency.js +2 -2
- package/lib/container/ContainerReferencePlugin.js +1 -1
- package/lib/container/FallbackDependency.js +5 -7
- package/lib/container/FallbackModule.js +10 -9
- package/lib/container/RemoteModule.js +20 -10
- package/lib/container/RemoteRuntimeModule.js +14 -12
- package/lib/css/CssGenerator.js +353 -327
- package/lib/css/CssInjectStyleRuntimeModule.js +36 -8
- package/lib/css/CssLoadingRuntimeModule.js +118 -47
- package/lib/css/CssModule.js +52 -23
- package/lib/css/CssModulesPlugin.js +107 -124
- package/lib/css/CssParser.js +2759 -2205
- package/lib/css/syntax.js +2859 -0
- package/lib/debug/ProfilingPlugin.js +2 -0
- package/lib/deno/DenoTargetPlugin.js +47 -0
- package/lib/dependencies/AMDDefineDependency.js +22 -17
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +1 -0
- package/lib/dependencies/AMDRequireArrayDependency.js +7 -11
- package/lib/dependencies/AMDRequireContextDependency.js +7 -11
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -0
- package/lib/dependencies/AMDRequireDependency.js +24 -20
- package/lib/dependencies/CachedConstDependency.js +3 -0
- package/lib/dependencies/CommonJsDependencyHelpers.js +1 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +79 -31
- package/lib/dependencies/CommonJsExportsDependency.js +21 -16
- package/lib/dependencies/CommonJsExportsParserPlugin.js +230 -7
- package/lib/dependencies/CommonJsFullRequireDependency.js +27 -19
- package/lib/dependencies/CommonJsImportsParserPlugin.js +51 -16
- package/lib/dependencies/CommonJsPlugin.js +1 -1
- package/lib/dependencies/CommonJsRequireContextDependency.js +10 -13
- package/lib/dependencies/CommonJsRequireDependency.js +42 -11
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +22 -14
- package/lib/dependencies/ConstDependency.js +16 -11
- package/lib/dependencies/ContextDependency.js +4 -0
- package/lib/dependencies/ContextDependencyTemplateAsId.js +1 -1
- package/lib/dependencies/ContextElementDependency.js +23 -14
- package/lib/dependencies/CreateRequireParserPlugin.js +1 -0
- package/lib/dependencies/CreateScriptUrlDependency.js +5 -7
- package/lib/dependencies/CriticalDependencyWarning.js +1 -0
- package/lib/dependencies/CssIcssExportDependency.js +512 -574
- package/lib/dependencies/CssIcssImportDependency.js +9 -9
- package/lib/dependencies/CssIcssSymbolDependency.js +22 -15
- package/lib/dependencies/CssImportDependency.js +25 -1
- package/lib/dependencies/CssUrlDependency.js +23 -14
- package/lib/dependencies/DllEntryDependency.js +9 -13
- package/lib/dependencies/ExportBindingInitFragment.js +164 -0
- package/lib/dependencies/ExportsInfoDependency.js +12 -12
- package/lib/dependencies/ExternalModuleDependency.js +8 -5
- package/lib/dependencies/ExternalModuleInitFragment.js +7 -5
- package/lib/dependencies/ExternalModuleInitFragmentDependency.js +13 -10
- package/lib/dependencies/HarmonyAcceptDependency.js +11 -11
- package/lib/dependencies/HarmonyAcceptImportDependency.js +1 -0
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +47 -22
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +28 -2
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +46 -22
- package/lib/dependencies/HarmonyExportExpressionDependency.js +107 -30
- package/lib/dependencies/HarmonyExportHeaderDependency.js +7 -9
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +109 -31
- package/lib/dependencies/HarmonyExportInitFragment.js +22 -20
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +83 -18
- package/lib/dependencies/HarmonyExports.js +4 -1
- package/lib/dependencies/HarmonyImportDependency.js +24 -0
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +110 -74
- package/lib/dependencies/HarmonyImportGuard.js +254 -0
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +18 -1
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +118 -14
- package/lib/dependencies/HarmonyLinkingError.js +1 -0
- package/lib/dependencies/HarmonyModulesPlugin.js +1 -0
- package/lib/dependencies/{HtmlScriptSrcDependency.js → HtmlEntryDependency.js} +267 -154
- package/lib/dependencies/HtmlInlineHtmlDependency.js +107 -0
- package/lib/dependencies/HtmlInlineScriptDependency.js +20 -27
- package/lib/dependencies/HtmlInlineStyleDependency.js +62 -11
- package/lib/dependencies/HtmlSourceDependency.js +18 -0
- package/lib/dependencies/ImportContextDependency.js +5 -9
- package/lib/dependencies/ImportDependency.js +44 -2
- package/lib/dependencies/ImportMetaHotAcceptDependency.js +1 -0
- package/lib/dependencies/ImportMetaHotDeclineDependency.js +1 -0
- package/lib/dependencies/ImportMetaPlugin.js +74 -30
- package/lib/dependencies/ImportParserPlugin.js +19 -0
- package/lib/dependencies/ImportWeakDependency.js +1 -0
- package/lib/dependencies/JsonExportsDependency.js +9 -9
- package/lib/dependencies/LoaderImportDependency.js +1 -0
- package/lib/dependencies/LocalModule.js +11 -12
- package/lib/dependencies/LocalModuleDependency.js +11 -13
- package/lib/dependencies/ModuleDecoratorDependency.js +9 -9
- package/lib/dependencies/ModuleDependency.js +7 -0
- package/lib/dependencies/ModuleHotAcceptDependency.js +1 -0
- package/lib/dependencies/ModuleHotDeclineDependency.js +1 -0
- package/lib/dependencies/ModuleInitFragmentDependency.js +15 -11
- package/lib/dependencies/ProvidedDependency.js +31 -27
- package/lib/dependencies/PureExpressionDependency.js +7 -9
- package/lib/dependencies/RequireEnsureDependency.js +12 -13
- package/lib/dependencies/RequireHeaderDependency.js +3 -4
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +3 -0
- package/lib/dependencies/RequireResolveContextDependency.js +7 -11
- package/lib/dependencies/RequireResolveDependency.js +1 -0
- package/lib/dependencies/RequireResolveHeaderDependency.js +3 -5
- package/lib/dependencies/RuntimeRequirementsDependency.js +6 -7
- package/lib/dependencies/StaticExportsDependency.js +10 -10
- package/lib/dependencies/SystemPlugin.js +2 -0
- package/lib/dependencies/URLContextDependency.js +5 -7
- package/lib/dependencies/URLDependency.js +14 -16
- package/lib/dependencies/UnsupportedDependency.js +8 -13
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +11 -16
- package/lib/dependencies/WebAssemblyImportDependency.js +14 -16
- package/lib/dependencies/WebpackIsIncludedDependency.js +1 -0
- package/lib/dependencies/WorkerDependency.js +19 -8
- package/lib/dependencies/WorkerPlugin.js +40 -10
- package/lib/dependencies/processExportInfo.js +13 -11
- package/lib/dll/DelegatedModule.js +29 -15
- package/lib/dll/DelegatedModuleFactoryPlugin.js +1 -0
- package/lib/dll/DelegatedPlugin.js +1 -0
- package/lib/dll/DllEntryPlugin.js +3 -0
- package/lib/dll/DllModule.js +3 -2
- package/lib/dll/DllPlugin.js +16 -0
- package/lib/dll/DllReferencePlugin.js +3 -0
- package/lib/dll/LibManifestPlugin.js +1 -0
- package/lib/electron/ElectronTargetPlugin.js +22 -4
- package/lib/errors/ConcurrentCompilationError.js +1 -0
- package/lib/errors/HookWebpackError.js +11 -13
- package/lib/errors/IgnoreErrorModuleFactory.js +1 -0
- package/lib/errors/InvalidDependenciesModuleWarning.js +2 -0
- package/lib/errors/JSONParseError.js +9 -8
- package/lib/errors/ModuleBuildError.js +16 -13
- package/lib/errors/ModuleDependencyError.js +8 -1
- package/lib/errors/ModuleDependencyWarning.js +8 -1
- package/lib/errors/ModuleError.js +5 -11
- package/lib/errors/ModuleHashingError.js +4 -0
- package/lib/errors/ModuleNotFoundError.js +3 -0
- package/lib/errors/ModuleParseError.js +5 -11
- package/lib/errors/ModuleRestoreError.js +2 -0
- package/lib/errors/ModuleStoreError.js +3 -0
- package/lib/errors/ModuleWarning.js +7 -11
- package/lib/errors/NodeStuffInWebError.js +1 -0
- package/lib/errors/NonErrorEmittedError.js +2 -0
- package/lib/errors/UnhandledSchemeError.js +1 -0
- package/lib/esm/ModuleChunkLoadingPlugin.js +0 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +28 -23
- package/lib/hmr/HotModuleReplacement.runtime.js +175 -30
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +7 -0
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +173 -26
- package/lib/hmr/LazyCompilationPlugin.js +134 -6
- package/lib/html/HtmlGenerator.js +292 -50
- package/lib/html/HtmlModule.js +40 -0
- package/lib/html/HtmlModulesPlugin.js +287 -60
- package/lib/html/HtmlParser.js +1108 -1099
- package/lib/html/{walkHtmlTokens.js → syntax.js} +4701 -212
- package/lib/ids/IdHelpers.js +4 -2
- package/lib/index.js +19 -0
- package/lib/javascript/BasicEvaluatedExpression.js +1 -0
- package/lib/javascript/EnableChunkLoadingPlugin.js +1 -0
- package/lib/javascript/JavascriptGenerator.js +6 -2
- package/lib/javascript/JavascriptModule.js +54 -0
- package/lib/javascript/JavascriptModulesPlugin.js +257 -102
- package/lib/javascript/JavascriptParser.js +286 -159
- package/lib/json/JsonModule.js +40 -0
- package/lib/json/JsonModulesPlugin.js +7 -0
- package/lib/json/JsonParser.js +4 -2
- package/lib/library/AssignLibraryPlugin.js +5 -3
- package/lib/library/ExportPropertyLibraryPlugin.js +1 -0
- package/lib/library/FalseIIFEUmdWarning.js +1 -0
- package/lib/library/ModuleLibraryPlugin.js +54 -29
- package/lib/library/SystemLibraryPlugin.js +3 -3
- package/lib/node/NodeTargetPlugin.js +1 -0
- package/lib/node/NodeWatchFileSystem.js +38 -22
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +10 -9
- package/lib/node/RequireChunkLoadingRuntimeModule.js +18 -16
- package/lib/optimize/ConcatenatedModule.js +397 -78
- package/lib/optimize/ConstExportsPlugin.js +211 -0
- package/lib/optimize/InlineExports.js +178 -0
- package/lib/optimize/InnerGraph.js +372 -275
- package/lib/optimize/InnerGraphPlugin.js +196 -99
- package/lib/optimize/ModuleConcatenationPlugin.js +56 -25
- package/lib/optimize/RealContentHashPlugin.js +14 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +234 -64
- package/lib/runtime/AsyncModuleRuntimeModule.js +32 -30
- package/lib/runtime/AutoPublicPathRuntimeModule.js +11 -5
- package/lib/runtime/CompatGetDefaultExportRuntimeModule.js +1 -1
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +6 -4
- package/lib/runtime/DefinePropertyGettersRuntimeModule.js +33 -4
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +82 -3
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -1
- package/lib/runtime/HasOwnPropertyRuntimeModule.js +1 -1
- package/lib/runtime/LoadScriptRuntimeModule.js +18 -13
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +39 -26
- package/lib/runtime/MakeNamespaceObjectRuntimeModule.js +1 -1
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +4 -4
- package/lib/runtime/RelativeUrlRuntimeModule.js +3 -2
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -1
- package/lib/runtime/StartupEntrypointRuntimeModule.js +4 -3
- package/lib/runtime/WorkerRuntimeModule.js +33 -0
- package/lib/schemes/HttpUriPlugin.js +3 -2
- package/lib/serialization/AggregateErrorSerializer.js +7 -6
- package/lib/serialization/ArraySerializer.js +4 -8
- package/lib/serialization/BinaryMiddleware.js +538 -468
- package/lib/serialization/DateObjectSerializer.js +2 -2
- package/lib/serialization/ErrorObjectSerializer.js +7 -6
- package/lib/serialization/MapObjectSerializer.js +5 -9
- package/lib/serialization/NullPrototypeObjectSerializer.js +7 -9
- package/lib/serialization/ObjectMiddleware.js +50 -13
- package/lib/serialization/PlainObjectSerializer.js +9 -8
- package/lib/serialization/RegExpObjectSerializer.js +2 -2
- package/lib/serialization/Serializer.js +1 -0
- package/lib/serialization/SetObjectSerializer.js +4 -8
- package/lib/sharing/ConsumeSharedModule.js +6 -7
- package/lib/sharing/ConsumeSharedPlugin.js +1 -0
- package/lib/sharing/ConsumeSharedRuntimeModule.js +46 -41
- package/lib/sharing/ProvideSharedDependency.js +30 -15
- package/lib/sharing/ProvideSharedModule.js +30 -11
- package/lib/sharing/ProvideSharedPlugin.js +4 -2
- package/lib/sharing/SharePlugin.js +3 -0
- package/lib/sharing/ShareRuntimeModule.js +18 -16
- package/lib/sharing/resolveMatchedConfigs.js +2 -1
- package/lib/sharing/utils.js +1 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +4 -6
- package/lib/stats/DefaultStatsPrinterPlugin.js +14 -14
- package/lib/stats/StatsFactory.js +11 -9
- package/lib/stats/StatsPrinter.js +9 -2
- package/lib/url/URLParserPlugin.js +5 -2
- package/lib/util/AsyncQueue.js +10 -0
- package/lib/util/LazyBucketSortedSet.js +5 -0
- package/lib/util/LazySet.js +6 -4
- package/lib/util/LocConverter.js +11 -1
- package/lib/util/Semaphore.js +1 -0
- package/lib/util/SourceProcessor.js +106 -0
- package/lib/util/TupleSet.js +1 -0
- package/lib/util/WeakTupleMap.js +27 -1
- package/lib/util/chainedImports.js +3 -3
- package/lib/util/comparators.js +2 -2
- package/lib/util/concatenate.js +31 -7
- package/lib/util/createHash.js +0 -1
- package/lib/util/deterministicGrouping.js +19 -12
- package/lib/util/extractSourceMap.js +1 -1
- package/lib/util/findGraphRoots.js +2 -0
- package/lib/util/fs.js +16 -6
- package/lib/util/hash/DebugHash.js +1 -0
- package/lib/util/hash/hash-digest.js +24 -15
- package/lib/util/identifier.js +7 -0
- package/lib/util/internalSerializables.js +11 -2
- package/lib/util/magicComment.js +42 -0
- package/lib/util/makeSerializable.js +1 -0
- package/lib/util/nonNumericOnlyHash.js +30 -1
- package/lib/util/property.js +7 -1
- package/lib/util/publicPathPlaceholder.js +64 -0
- package/lib/util/registerExternalSerializer.js +4 -4
- package/lib/wasm-async/AsyncWasmModule.js +77 -0
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +1 -1
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +1 -96
- package/lib/wasm-async/AsyncWebAssemblyParser.js +1 -1
- package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +1 -1
- package/lib/wasm-sync/SyncWasmModule.js +39 -0
- package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +1 -0
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +6 -3
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +2 -1
- package/lib/wasm-sync/WebAssemblyGenerator.js +1 -0
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +2 -0
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +10 -0
- package/lib/wasm-sync/WebAssemblyParser.js +7 -3
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +45 -39
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +11 -10
- package/package.json +36 -28
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +212 -3
- package/schemas/plugins/HtmlGeneratorOptions.check.js +1 -1
- package/schemas/plugins/HtmlParserOptions.check.d.ts +7 -0
- package/schemas/plugins/HtmlParserOptions.check.js +6 -0
- package/schemas/plugins/HtmlParserOptions.json +3 -0
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssParserOptions.check.js +1 -1
- package/types.d.ts +1592 -314
- package/lib/css/walkCssTokens.js +0 -2020
- package/lib/util/AppendOnlyStackedSet.js +0 -93
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
const NormalModule = require("../NormalModule");
|
|
8
|
+
const makeSerializable = require("../util/makeSerializable");
|
|
9
|
+
|
|
10
|
+
/** @typedef {import("../NormalModule").NormalModuleBuildInfo} NormalModuleBuildInfo */
|
|
11
|
+
/** @typedef {import("../NormalModule").NormalModuleCreateData} NormalModuleCreateData */
|
|
12
|
+
/** @typedef {import("./JsonData")} JsonData */
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Defines the build info properties specific to json modules.
|
|
16
|
+
* @typedef {object} KnownJsonModuleBuildInfo
|
|
17
|
+
* @property {JsonData=} jsonData
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/** @typedef {NormalModuleBuildInfo & KnownJsonModuleBuildInfo} JsonModuleBuildInfo */
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Module class for `json` modules. JSON-specific properties should live here instead of `NormalModule`.
|
|
24
|
+
*/
|
|
25
|
+
class JsonModule extends NormalModule {
|
|
26
|
+
/**
|
|
27
|
+
* @param {NormalModuleCreateData} options options object
|
|
28
|
+
*/
|
|
29
|
+
constructor(options) {
|
|
30
|
+
super(options);
|
|
31
|
+
|
|
32
|
+
// Redeclared with the json specific shape
|
|
33
|
+
/** @type {JsonModuleBuildInfo | undefined} */
|
|
34
|
+
this.buildInfo = undefined;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
makeSerializable(JsonModule, "webpack/lib/json/JsonModule");
|
|
39
|
+
|
|
40
|
+
module.exports = JsonModule;
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
const { JSON_MODULE_TYPE } = require("../ModuleTypeConstants");
|
|
9
9
|
const JsonGenerator = require("./JsonGenerator");
|
|
10
|
+
const JsonModule = require("./JsonModule");
|
|
10
11
|
const JsonParser = require("./JsonParser");
|
|
11
12
|
|
|
12
13
|
/** @typedef {import("../Compiler")} Compiler */
|
|
@@ -27,6 +28,12 @@ class JsonModulesPlugin {
|
|
|
27
28
|
compiler.hooks.compilation.tap(
|
|
28
29
|
PLUGIN_NAME,
|
|
29
30
|
(compilation, { normalModuleFactory }) => {
|
|
31
|
+
normalModuleFactory.hooks.createModuleClass
|
|
32
|
+
.for(JSON_MODULE_TYPE)
|
|
33
|
+
.tap(
|
|
34
|
+
PLUGIN_NAME,
|
|
35
|
+
(createData, _resolveData) => new JsonModule(createData)
|
|
36
|
+
);
|
|
30
37
|
normalModuleFactory.hooks.createParser
|
|
31
38
|
.for(JSON_MODULE_TYPE)
|
|
32
39
|
.tap(PLUGIN_NAME, (parserOptions) => {
|
package/lib/json/JsonParser.js
CHANGED
|
@@ -11,7 +11,7 @@ const parseJson = require("../util/parseJson");
|
|
|
11
11
|
const JsonData = require("./JsonData");
|
|
12
12
|
|
|
13
13
|
/** @typedef {import("../../declarations/WebpackOptions").JsonParserOptions} JsonParserOptions */
|
|
14
|
-
/** @typedef {import("
|
|
14
|
+
/** @typedef {import("./JsonModule").JsonModuleBuildInfo} JsonModuleBuildInfo */
|
|
15
15
|
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
|
16
16
|
/** @typedef {import("../Parser").ParserState} ParserState */
|
|
17
17
|
/** @typedef {import("../Parser").PreparsedAst} PreparsedAst */
|
|
@@ -55,7 +55,9 @@ class JsonParser extends Parser {
|
|
|
55
55
|
? source
|
|
56
56
|
: parseFn(source[0] === "\uFEFF" ? source.slice(1) : source);
|
|
57
57
|
const jsonData = new JsonData(/** @type {Buffer | JsonValue} */ (data));
|
|
58
|
-
const buildInfo = /** @type {
|
|
58
|
+
const buildInfo = /** @type {JsonModuleBuildInfo} */ (
|
|
59
|
+
state.module.buildInfo
|
|
60
|
+
);
|
|
59
61
|
buildInfo.jsonData = jsonData;
|
|
60
62
|
buildInfo.strict = true;
|
|
61
63
|
const buildMeta = /** @type {BuildMeta} */ (state.module.buildMeta);
|
|
@@ -189,6 +189,7 @@ class AssignLibraryPlugin extends AbstractLibraryPlugin {
|
|
|
189
189
|
);
|
|
190
190
|
exportsInfo.setUsed(UsageState.Used, runtime);
|
|
191
191
|
exportsInfo.canMangleUse = false;
|
|
192
|
+
exportsInfo.canInlineUse = false;
|
|
192
193
|
} else {
|
|
193
194
|
const exportsInfo = moduleGraph.getExportsInfo(module);
|
|
194
195
|
exportsInfo.setUsedInUnknownWay(runtime);
|
|
@@ -331,6 +332,7 @@ class AssignLibraryPlugin extends AbstractLibraryPlugin {
|
|
|
331
332
|
Array.isArray(options.export) ? options.export : [options.export]
|
|
332
333
|
)
|
|
333
334
|
: "";
|
|
335
|
+
const cst = compilation.runtimeTemplate.renderConst();
|
|
334
336
|
const result = new ConcatSource(source);
|
|
335
337
|
if (staticExports) {
|
|
336
338
|
const exportsInfo = moduleGraph.getExportsInfo(module);
|
|
@@ -360,7 +362,7 @@ class AssignLibraryPlugin extends AbstractLibraryPlugin {
|
|
|
360
362
|
let exports = RuntimeGlobals.exports;
|
|
361
363
|
if (exportAccess) {
|
|
362
364
|
result.add(
|
|
363
|
-
|
|
365
|
+
`${cst} __webpack_exports_export__ = ${RuntimeGlobals.exports}${exportAccess};\n`
|
|
364
366
|
);
|
|
365
367
|
|
|
366
368
|
exports = "__webpack_exports_export__";
|
|
@@ -386,7 +388,7 @@ class AssignLibraryPlugin extends AbstractLibraryPlugin {
|
|
|
386
388
|
);
|
|
387
389
|
} else if (options.name ? this.named === "copy" : this.unnamed === "copy") {
|
|
388
390
|
result.add(
|
|
389
|
-
|
|
391
|
+
`${cst} __webpack_export_target__ = ${accessWithInit(
|
|
390
392
|
fullNameResolved,
|
|
391
393
|
this._getPrefix(compilation).length,
|
|
392
394
|
true
|
|
@@ -396,7 +398,7 @@ class AssignLibraryPlugin extends AbstractLibraryPlugin {
|
|
|
396
398
|
let exports = RuntimeGlobals.exports;
|
|
397
399
|
if (exportAccess) {
|
|
398
400
|
result.add(
|
|
399
|
-
|
|
401
|
+
`${cst} __webpack_exports_export__ = ${RuntimeGlobals.exports}${exportAccess};\n`
|
|
400
402
|
);
|
|
401
403
|
|
|
402
404
|
exports = "__webpack_exports_export__";
|
|
@@ -85,6 +85,7 @@ class ExportPropertyLibraryPlugin extends AbstractLibraryPlugin {
|
|
|
85
85
|
);
|
|
86
86
|
exportsInfo.setUsed(UsageState.Used, runtime);
|
|
87
87
|
exportsInfo.canMangleUse = false;
|
|
88
|
+
exportsInfo.canInlineUse = false;
|
|
88
89
|
} else {
|
|
89
90
|
const exportsInfo = moduleGraph.getExportsInfo(module);
|
|
90
91
|
exportsInfo.setUsedInUnknownWay(runtime);
|
|
@@ -12,6 +12,7 @@ class FalseIIFEUmdWarning extends WebpackError {
|
|
|
12
12
|
super();
|
|
13
13
|
/** @type {string} */
|
|
14
14
|
this.name = "FalseIIFEUmdWarning";
|
|
15
|
+
/** @type {string} */
|
|
15
16
|
this.message =
|
|
16
17
|
"Configuration:\nSetting 'output.iife' to 'false' is incompatible with 'output.library.type' set to 'umd'. This configuration may cause unexpected behavior, as UMD libraries are expected to use an IIFE (Immediately Invoked Function Expression) to support various module formats. Consider setting 'output.iife' to 'true' or choosing a different 'library.type' to ensure compatibility.\nLearn more: https://webpack.js.org/configuration/output/";
|
|
17
18
|
}
|
|
@@ -13,6 +13,7 @@ const Template = require("../Template");
|
|
|
13
13
|
const HarmonyExportImportedSpecifierDependency = require("../dependencies/HarmonyExportImportedSpecifierDependency");
|
|
14
14
|
const JavascriptModulesPlugin = require("../javascript/JavascriptModulesPlugin");
|
|
15
15
|
const ConcatenatedModule = require("../optimize/ConcatenatedModule");
|
|
16
|
+
const { InlinedUsedName } = require("../optimize/InlineExports");
|
|
16
17
|
const { propertyAccess } = require("../util/property");
|
|
17
18
|
const { getEntryRuntime, getRuntimeKey } = require("../util/runtime");
|
|
18
19
|
const AbstractLibraryPlugin = require("./AbstractLibraryPlugin");
|
|
@@ -31,6 +32,7 @@ const AbstractLibraryPlugin = require("./AbstractLibraryPlugin");
|
|
|
31
32
|
/** @typedef {import("../javascript/JavascriptModulesPlugin").ModuleRenderContext} ModuleRenderContext */
|
|
32
33
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
|
33
34
|
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
|
35
|
+
/** @typedef {import("../javascript/JavascriptModule").JavascriptModuleBuildMeta} JavascriptModuleBuildMeta */
|
|
34
36
|
|
|
35
37
|
/**
|
|
36
38
|
* Defines the shared type used by this module.
|
|
@@ -111,24 +113,15 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
|
111
113
|
|
|
112
114
|
// `ModuleLibraryPlugin` stashes the on-demand exports source via
|
|
113
115
|
// `onDemandExportsGeneration` and only re-emits it when the
|
|
114
|
-
// module is wrapped in an IIFE/factory. When
|
|
115
|
-
//
|
|
116
|
+
// module is wrapped in an IIFE/factory. When the entry is
|
|
117
|
+
// inlined directly, the stashed source — and the
|
|
116
118
|
// `definePropertyGetters` / `requireScope` runtime helpers it
|
|
117
119
|
// pulled in — never make it into the output. Drop those helpers
|
|
118
|
-
// from the chunk's set
|
|
119
|
-
// clean.
|
|
120
|
+
// from the chunk's set so the bundle stays clean.
|
|
120
121
|
compilation.hooks.additionalChunkRuntimeRequirements.tap(
|
|
121
122
|
PLUGIN_NAME,
|
|
122
123
|
(chunk, set, { chunkGraph, codeGenerationResults }) => {
|
|
123
124
|
if (!set.has(RuntimeGlobals.definePropertyGetters)) return;
|
|
124
|
-
|
|
125
|
-
// Only handle the simple "single concatenated entry"
|
|
126
|
-
// shape. Anything else (additional modules, multiple
|
|
127
|
-
// entries, sibling runtime chunks, or chunk-level
|
|
128
|
-
// requirements that disable inline startup) forces the
|
|
129
|
-
// module through factory/IIFE rendering, which re-emits
|
|
130
|
-
// the source.
|
|
131
|
-
if (chunkGraph.getNumberOfChunkModules(chunk) !== 1) return;
|
|
132
125
|
if (chunkGraph.getNumberOfEntryModules(chunk) !== 1) return;
|
|
133
126
|
if (chunkGraph.hasChunkEntryDependentChunks(chunk)) return;
|
|
134
127
|
if (
|
|
@@ -140,8 +133,6 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
|
140
133
|
) {
|
|
141
134
|
return;
|
|
142
135
|
}
|
|
143
|
-
// Anyone tapping `inlineInRuntimeBailout` may force factory
|
|
144
|
-
// rendering at render time, so conservatively bail out.
|
|
145
136
|
if (javascriptHooks.inlineInRuntimeBailout.isUsed()) return;
|
|
146
137
|
|
|
147
138
|
const [module] = chunkGraph.getChunkEntryModulesIterable(chunk);
|
|
@@ -153,14 +144,6 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
|
153
144
|
) {
|
|
154
145
|
return;
|
|
155
146
|
}
|
|
156
|
-
// If the generated source references any
|
|
157
|
-
// `__webpack_require__.<helper>` (the on-demand `.d(...)`
|
|
158
|
-
// is stashed, but `.r(__webpack_exports__)` from the ESM
|
|
159
|
-
// compat flag, namespace objects, deferred externals, ...
|
|
160
|
-
// stay in the result) the helpers and the require scope
|
|
161
|
-
// they live in are still needed. The dot in the substring
|
|
162
|
-
// avoids matching the bare `"__webpack_require__"` string
|
|
163
|
-
// literals that some test fixtures include.
|
|
164
147
|
const codeGenResult = codeGenerationResults.get(
|
|
165
148
|
module,
|
|
166
149
|
chunk.runtime
|
|
@@ -174,9 +157,34 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
|
174
157
|
return;
|
|
175
158
|
}
|
|
176
159
|
|
|
160
|
+
// Check whether any other module in the chunk still needs
|
|
161
|
+
// the helpers we want to remove.
|
|
162
|
+
let otherNeedsDefine = false;
|
|
163
|
+
let otherNeedsExports = false;
|
|
164
|
+
let otherNeedsRequireScope = false;
|
|
165
|
+
for (const m of chunkGraph.getChunkModulesIterable(chunk)) {
|
|
166
|
+
if (m === module) continue;
|
|
167
|
+
const requirements = chunkGraph.getModuleRuntimeRequirements(
|
|
168
|
+
m,
|
|
169
|
+
chunk.runtime
|
|
170
|
+
);
|
|
171
|
+
if (!requirements) continue;
|
|
172
|
+
if (requirements.has(RuntimeGlobals.definePropertyGetters)) {
|
|
173
|
+
otherNeedsDefine = true;
|
|
174
|
+
}
|
|
175
|
+
if (requirements.has(RuntimeGlobals.exports)) {
|
|
176
|
+
otherNeedsExports = true;
|
|
177
|
+
}
|
|
178
|
+
if (requirements.has(RuntimeGlobals.requireScope)) {
|
|
179
|
+
otherNeedsRequireScope = true;
|
|
180
|
+
}
|
|
181
|
+
if (otherNeedsDefine) break;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (otherNeedsDefine) return;
|
|
177
185
|
set.delete(RuntimeGlobals.definePropertyGetters);
|
|
178
|
-
set.delete(RuntimeGlobals.exports);
|
|
179
|
-
set.delete(RuntimeGlobals.requireScope);
|
|
186
|
+
if (!otherNeedsExports) set.delete(RuntimeGlobals.exports);
|
|
187
|
+
if (!otherNeedsRequireScope) set.delete(RuntimeGlobals.requireScope);
|
|
180
188
|
}
|
|
181
189
|
);
|
|
182
190
|
});
|
|
@@ -202,18 +210,24 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
|
202
210
|
);
|
|
203
211
|
exportsInfo.setUsed(UsageState.Used, runtime);
|
|
204
212
|
exportsInfo.canMangleUse = false;
|
|
213
|
+
exportsInfo.canInlineUse = false;
|
|
205
214
|
} else {
|
|
206
215
|
const exportsInfo = moduleGraph.getExportsInfo(module);
|
|
207
216
|
|
|
208
217
|
if (
|
|
209
218
|
// If the entry module is commonjs, its exports cannot be mangled
|
|
210
|
-
(module.buildMeta &&
|
|
219
|
+
(module.buildMeta &&
|
|
220
|
+
/** @type {JavascriptModuleBuildMeta} */ (module.buildMeta)
|
|
221
|
+
.treatAsCommonJs) ||
|
|
211
222
|
// The entry module provides unknown exports
|
|
212
223
|
exportsInfo._otherExportsInfo.provided === null
|
|
213
224
|
) {
|
|
214
225
|
exportsInfo.setUsedInUnknownWay(runtime);
|
|
215
226
|
} else {
|
|
216
227
|
exportsInfo.setAllKnownExportsUsed(runtime);
|
|
228
|
+
for (const exportInfo of exportsInfo.ownedExports) {
|
|
229
|
+
exportInfo.canInlineUse = false;
|
|
230
|
+
}
|
|
217
231
|
}
|
|
218
232
|
}
|
|
219
233
|
moduleGraph.addExtraReason(module, "used as library export");
|
|
@@ -259,7 +273,7 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
|
259
273
|
const result = new ConcatSource(source);
|
|
260
274
|
/** @type {Set<string>} */
|
|
261
275
|
const moduleRequests = new Set();
|
|
262
|
-
/** @type {Map<string, string>} */
|
|
276
|
+
/** @type {Map<string, string | InlinedUsedName>} */
|
|
263
277
|
const unknownProvidedExports = new Map();
|
|
264
278
|
|
|
265
279
|
/**
|
|
@@ -301,7 +315,9 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
|
301
315
|
continue;
|
|
302
316
|
}
|
|
303
317
|
const originalName = exportInfo.name;
|
|
304
|
-
const usedName =
|
|
318
|
+
const usedName =
|
|
319
|
+
/** @type {string | InlinedUsedName | false} */
|
|
320
|
+
(exportInfo.getUsedName(originalName, runtime));
|
|
305
321
|
|
|
306
322
|
if (!alreadyRenderedExports.has(originalName) && usedName) {
|
|
307
323
|
unknownProvidedExports.set(originalName, usedName);
|
|
@@ -321,7 +337,13 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
|
321
337
|
for (const [origin, used] of unknownProvidedExports) {
|
|
322
338
|
exports.push([
|
|
323
339
|
origin,
|
|
324
|
-
|
|
340
|
+
used instanceof InlinedUsedName
|
|
341
|
+
? used.render(
|
|
342
|
+
Template.toNormalComment(
|
|
343
|
+
`inlined export ${propertyAccess([origin])}`
|
|
344
|
+
)
|
|
345
|
+
)
|
|
346
|
+
: `${RuntimeGlobals.exports}${propertyAccess([used])}`
|
|
325
347
|
]);
|
|
326
348
|
}
|
|
327
349
|
|
|
@@ -379,7 +401,9 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
|
379
401
|
const isAsync = moduleGraph.isAsync(module);
|
|
380
402
|
|
|
381
403
|
const treatAsCommonJs =
|
|
382
|
-
module.buildMeta &&
|
|
404
|
+
module.buildMeta &&
|
|
405
|
+
/** @type {JavascriptModuleBuildMeta} */ (module.buildMeta)
|
|
406
|
+
.treatAsCommonJs;
|
|
383
407
|
const skipRenderDefaultExport = Boolean(treatAsCommonJs);
|
|
384
408
|
|
|
385
409
|
const moduleExportsInfo = moduleGraph.getExportsInfo(module);
|
|
@@ -424,6 +448,7 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
|
424
448
|
}
|
|
425
449
|
}
|
|
426
450
|
|
|
451
|
+
// The exports of entry module are never inlined
|
|
427
452
|
const usedName =
|
|
428
453
|
/** @type {string} */
|
|
429
454
|
(exportInfo.getUsedName(originalName, chunk.runtime));
|
|
@@ -141,9 +141,9 @@ class SystemLibraryPlugin extends AbstractLibraryPlugin {
|
|
|
141
141
|
/** @type {ExportInfoName[]} */
|
|
142
142
|
const handledNames = [];
|
|
143
143
|
for (const exportInfo of exportsInfo.orderedExports) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
chunk.runtime
|
|
144
|
+
// The exports of `ExternalModule` are never inlined
|
|
145
|
+
const used = /** @type {string | false} */ (
|
|
146
|
+
exportInfo.getUsedName(undefined, chunk.runtime)
|
|
147
147
|
);
|
|
148
148
|
if (used) {
|
|
149
149
|
if (otherUnused || used !== exportInfo.name) {
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
const util = require("util");
|
|
9
9
|
const Watchpack = require("watchpack");
|
|
10
10
|
|
|
11
|
+
/** @typedef {InstanceType<import("watchpack")>} Watchpack */
|
|
11
12
|
/** @typedef {import("watchpack").TimeInfoEntries} TimeInfoEntries */
|
|
12
13
|
/** @typedef {import("watchpack").WatchOptions} WatchOptions */
|
|
13
14
|
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
|
|
@@ -82,6 +83,41 @@ class NodeWatchFileSystem {
|
|
|
82
83
|
}
|
|
83
84
|
return { fileTimeInfoEntries, contextTimeInfoEntries };
|
|
84
85
|
};
|
|
86
|
+
const directoriesSet =
|
|
87
|
+
directories instanceof Set ? directories : new Set(directories);
|
|
88
|
+
|
|
89
|
+
// Watchpack reports a watched directory (a context dependency) in
|
|
90
|
+
// `changes` whenever its contents change, alongside the individual
|
|
91
|
+
// file events. The default `fs.purge(dir)` matches cache keys by
|
|
92
|
+
// prefix, so it would wipe the stat cache of every file inside the
|
|
93
|
+
// directory even though only file-level events actually invalidate
|
|
94
|
+
// file stats. For directories we explicitly watch, purge only the
|
|
95
|
+
// directory's own entry (`{ exact: true }`, enhanced-resolve >=
|
|
96
|
+
// 5.22.0); file-level events in the same aggregated batch still
|
|
97
|
+
// handle file stats and the parent readdir invalidation.
|
|
98
|
+
/**
|
|
99
|
+
* @param {Changes | null | undefined} changes changes set
|
|
100
|
+
* @param {Removals | null | undefined} removals removals set
|
|
101
|
+
*/
|
|
102
|
+
const purgeChanges = (changes, removals) => {
|
|
103
|
+
const fs = this.inputFileSystem;
|
|
104
|
+
if (!fs || !fs.purge) return;
|
|
105
|
+
if (changes) {
|
|
106
|
+
for (const item of changes) {
|
|
107
|
+
if (directoriesSet.has(item)) {
|
|
108
|
+
fs.purge(item, { exact: true });
|
|
109
|
+
} else {
|
|
110
|
+
fs.purge(item);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (removals) {
|
|
115
|
+
for (const item of removals) {
|
|
116
|
+
fs.purge(item);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
85
121
|
this.watcher.once(
|
|
86
122
|
"aggregated",
|
|
87
123
|
/**
|
|
@@ -94,15 +130,7 @@ class NodeWatchFileSystem {
|
|
|
94
130
|
/** @type {Watchpack} */
|
|
95
131
|
(this.watcher).pause();
|
|
96
132
|
|
|
97
|
-
|
|
98
|
-
if (fs && fs.purge) {
|
|
99
|
-
for (const item of changes) {
|
|
100
|
-
fs.purge(item);
|
|
101
|
-
}
|
|
102
|
-
for (const item of removals) {
|
|
103
|
-
fs.purge(item);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
133
|
+
purgeChanges(changes, removals);
|
|
106
134
|
const { fileTimeInfoEntries, contextTimeInfoEntries } = fetchTimeInfo();
|
|
107
135
|
callback(
|
|
108
136
|
null,
|
|
@@ -172,19 +200,7 @@ class NodeWatchFileSystem {
|
|
|
172
200
|
getInfo: () => {
|
|
173
201
|
const removals = this.watcher && this.watcher.aggregatedRemovals;
|
|
174
202
|
const changes = this.watcher && this.watcher.aggregatedChanges;
|
|
175
|
-
|
|
176
|
-
if (fs && fs.purge) {
|
|
177
|
-
if (removals) {
|
|
178
|
-
for (const item of removals) {
|
|
179
|
-
fs.purge(item);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
if (changes) {
|
|
183
|
-
for (const item of changes) {
|
|
184
|
-
fs.purge(item);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
203
|
+
purgeChanges(changes, removals);
|
|
188
204
|
const { fileTimeInfoEntries, contextTimeInfoEntries } = fetchTimeInfo();
|
|
189
205
|
return {
|
|
190
206
|
changes,
|
|
@@ -102,6 +102,11 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
102
102
|
const stateExpression = withHmr
|
|
103
103
|
? `${RuntimeGlobals.hmrRuntimeStatePrefix}_readFileVm`
|
|
104
104
|
: undefined;
|
|
105
|
+
const installedChunksObject = `{\n${Template.indent(
|
|
106
|
+
Array.from(initialChunkIds, (id) => `${JSON.stringify(id)}: 0`).join(
|
|
107
|
+
",\n"
|
|
108
|
+
)
|
|
109
|
+
)}\n}`;
|
|
105
110
|
|
|
106
111
|
return Template.asString([
|
|
107
112
|
withBaseURI
|
|
@@ -111,14 +116,10 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
111
116
|
"// object to store loaded chunks",
|
|
112
117
|
'// "0" means "already loaded", Promise means loading',
|
|
113
118
|
`var installedChunks = ${
|
|
114
|
-
stateExpression
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
",\n"
|
|
119
|
-
)
|
|
120
|
-
),
|
|
121
|
-
"};",
|
|
119
|
+
stateExpression
|
|
120
|
+
? runtimeTemplate.assignOr(stateExpression, installedChunksObject)
|
|
121
|
+
: installedChunksObject
|
|
122
|
+
};`,
|
|
122
123
|
"",
|
|
123
124
|
withOnChunkLoad
|
|
124
125
|
? `${
|
|
@@ -237,7 +238,7 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
237
238
|
`if(${RuntimeGlobals.hasOwnProperty}(updatedModules, moduleId)) {`,
|
|
238
239
|
Template.indent([
|
|
239
240
|
"currentUpdate[moduleId] = updatedModules[moduleId];",
|
|
240
|
-
"
|
|
241
|
+
`${runtimeTemplate.optionalChaining("updatedModulesList", "push(moduleId)")};`
|
|
241
242
|
]),
|
|
242
243
|
"}"
|
|
243
244
|
]),
|
|
@@ -103,6 +103,12 @@ class RequireChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
103
103
|
? `${RuntimeGlobals.hmrRuntimeStatePrefix}_require`
|
|
104
104
|
: undefined;
|
|
105
105
|
|
|
106
|
+
const cst = runtimeTemplate.renderConst();
|
|
107
|
+
const installedChunksObject = `{\n${Template.indent(
|
|
108
|
+
Array.from(initialChunkIds, (id) => `${JSON.stringify(id)}: 1`).join(
|
|
109
|
+
",\n"
|
|
110
|
+
)
|
|
111
|
+
)}\n}`;
|
|
106
112
|
return Template.asString([
|
|
107
113
|
withBaseURI
|
|
108
114
|
? this._generateBaseUri(chunk, rootOutputDir, runtimeTemplate)
|
|
@@ -110,15 +116,11 @@ class RequireChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
110
116
|
"",
|
|
111
117
|
"// object to store loaded chunks",
|
|
112
118
|
'// "1" means "loaded", otherwise not loaded yet',
|
|
113
|
-
|
|
114
|
-
stateExpression
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
",\n"
|
|
119
|
-
)
|
|
120
|
-
),
|
|
121
|
-
"};",
|
|
119
|
+
`${cst} installedChunks = ${
|
|
120
|
+
stateExpression
|
|
121
|
+
? runtimeTemplate.assignOr(stateExpression, installedChunksObject)
|
|
122
|
+
: installedChunksObject
|
|
123
|
+
};`,
|
|
122
124
|
"",
|
|
123
125
|
withOnChunkLoad
|
|
124
126
|
? `${
|
|
@@ -130,8 +132,8 @@ class RequireChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
130
132
|
: "// no on chunks loaded",
|
|
131
133
|
"",
|
|
132
134
|
withLoading || withExternalInstallChunk
|
|
133
|
-
?
|
|
134
|
-
|
|
135
|
+
? `${cst} installChunk = ${runtimeTemplate.basicFunction("chunk", [
|
|
136
|
+
`${cst} moreModules = chunk.modules, chunkIds = chunk.ids, runtime = chunk.runtime;`,
|
|
135
137
|
"for(var moduleId in moreModules) {",
|
|
136
138
|
Template.indent([
|
|
137
139
|
`if(${RuntimeGlobals.hasOwnProperty}(moreModules, moduleId)) {`,
|
|
@@ -164,7 +166,7 @@ class RequireChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
164
166
|
Template.indent([
|
|
165
167
|
// The require function loads and runs a chunk. When the chunk is being run,
|
|
166
168
|
// it can call __webpack_require__.C to directly complete installed.
|
|
167
|
-
|
|
169
|
+
`${cst} installedChunk = require(${JSON.stringify(
|
|
168
170
|
rootOutputDir
|
|
169
171
|
)} + ${
|
|
170
172
|
RuntimeGlobals.getChunkScriptFilename
|
|
@@ -194,17 +196,17 @@ class RequireChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
194
196
|
? Template.asString([
|
|
195
197
|
"function loadUpdateChunk(chunkId, updatedModulesList) {",
|
|
196
198
|
Template.indent([
|
|
197
|
-
|
|
199
|
+
`${cst} update = require(${JSON.stringify(rootOutputDir)} + ${
|
|
198
200
|
RuntimeGlobals.getChunkUpdateScriptFilename
|
|
199
201
|
}(chunkId));`,
|
|
200
|
-
|
|
201
|
-
|
|
202
|
+
`${cst} updatedModules = update.modules;`,
|
|
203
|
+
`${cst} runtime = update.runtime;`,
|
|
202
204
|
"for(var moduleId in updatedModules) {",
|
|
203
205
|
Template.indent([
|
|
204
206
|
`if(${RuntimeGlobals.hasOwnProperty}(updatedModules, moduleId)) {`,
|
|
205
207
|
Template.indent([
|
|
206
208
|
"currentUpdate[moduleId] = updatedModules[moduleId];",
|
|
207
|
-
"
|
|
209
|
+
`${runtimeTemplate.optionalChaining("updatedModulesList", "push(moduleId)")};`
|
|
208
210
|
]),
|
|
209
211
|
"}"
|
|
210
212
|
]),
|