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
|
@@ -21,7 +21,11 @@ const { getEntryRuntime, mergeRuntimeOwned } = require("./util/runtime");
|
|
|
21
21
|
/** @typedef {import("./Module")} Module */
|
|
22
22
|
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
|
23
23
|
|
|
24
|
-
const {
|
|
24
|
+
const {
|
|
25
|
+
NO_EXPORTS_REFERENCED,
|
|
26
|
+
EXPORTS_OBJECT_REFERENCED,
|
|
27
|
+
EXPORTS_OBJECT_REFERENCED_MANGLEABLE
|
|
28
|
+
} = Dependency;
|
|
25
29
|
|
|
26
30
|
const PLUGIN_NAME = "FlagDependencyUsagePlugin";
|
|
27
31
|
const PLUGIN_LOGGER_NAME = `webpack.${PLUGIN_NAME}`;
|
|
@@ -30,10 +34,13 @@ class FlagDependencyUsagePlugin {
|
|
|
30
34
|
/**
|
|
31
35
|
* Creates an instance of FlagDependencyUsagePlugin.
|
|
32
36
|
* @param {boolean} global do a global analysis instead of per runtime
|
|
37
|
+
* @param {boolean=} mangleEscapingNamespaces keep exports mangleable when a module's namespace object escapes
|
|
33
38
|
*/
|
|
34
|
-
constructor(global) {
|
|
39
|
+
constructor(global, mangleEscapingNamespaces = false) {
|
|
35
40
|
/** @type {boolean} */
|
|
36
41
|
this.global = global;
|
|
42
|
+
/** @type {boolean} */
|
|
43
|
+
this.mangleEscapingNamespaces = mangleEscapingNamespaces;
|
|
37
44
|
}
|
|
38
45
|
|
|
39
46
|
/**
|
|
@@ -75,6 +82,42 @@ class FlagDependencyUsagePlugin {
|
|
|
75
82
|
forceSideEffects
|
|
76
83
|
) => {
|
|
77
84
|
const exportsInfo = moduleGraph.getExportsInfo(module);
|
|
85
|
+
if (usedExports === EXPORTS_OBJECT_REFERENCED_MANGLEABLE) {
|
|
86
|
+
// The whole namespace object escapes via a reference that codegen
|
|
87
|
+
// can materialize as a decoupled namespace object. When all exports
|
|
88
|
+
// are statically known we keep them mangleable instead of marking
|
|
89
|
+
// them used-in-unknown-way.
|
|
90
|
+
if (
|
|
91
|
+
this.mangleEscapingNamespaces &&
|
|
92
|
+
module.buildMeta &&
|
|
93
|
+
module.buildMeta.exportsType === "namespace" &&
|
|
94
|
+
exportsInfo.otherExportsInfo.provided === false
|
|
95
|
+
) {
|
|
96
|
+
let changed = exportsInfo.setAllKnownExportsUsed(runtime);
|
|
97
|
+
// The whole namespace object is observed as a value, so the
|
|
98
|
+
// module must stay a real ES module namespace at runtime
|
|
99
|
+
// (keep __esModule / the namespace object, i.e. `r()`).
|
|
100
|
+
if (
|
|
101
|
+
exportsInfo
|
|
102
|
+
.getExportInfo("__esModule")
|
|
103
|
+
.setUsed(UsageState.Used, runtime)
|
|
104
|
+
) {
|
|
105
|
+
changed = true;
|
|
106
|
+
}
|
|
107
|
+
// Exports must keep a real binding (not be inlined) so member
|
|
108
|
+
// access on the namespace has ES namespace semantics, e.g.
|
|
109
|
+
// `delete ns.x` hits a non-configurable property and throws.
|
|
110
|
+
for (const exportInfo of exportsInfo.ownedExports) {
|
|
111
|
+
exportInfo.canInlineUse = false;
|
|
112
|
+
}
|
|
113
|
+
if (changed) {
|
|
114
|
+
queue.enqueue(module, runtime);
|
|
115
|
+
}
|
|
116
|
+
} else if (exportsInfo.setUsedInUnknownWay(runtime)) {
|
|
117
|
+
queue.enqueue(module, runtime);
|
|
118
|
+
}
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
78
121
|
if (usedExports.length > 0) {
|
|
79
122
|
if (!module.buildMeta || !module.buildMeta.exportsType) {
|
|
80
123
|
if (exportsInfo.setUsedWithoutInfo(runtime)) {
|
|
@@ -86,11 +129,13 @@ class FlagDependencyUsagePlugin {
|
|
|
86
129
|
/** @type {string[]} */
|
|
87
130
|
let usedExport;
|
|
88
131
|
let canMangle = true;
|
|
132
|
+
let canInline = true;
|
|
89
133
|
if (Array.isArray(usedExportInfo)) {
|
|
90
134
|
usedExport = usedExportInfo;
|
|
91
135
|
} else {
|
|
92
136
|
usedExport = usedExportInfo.name;
|
|
93
137
|
canMangle = usedExportInfo.canMangle !== false;
|
|
138
|
+
canInline = usedExportInfo.canInline !== false;
|
|
94
139
|
}
|
|
95
140
|
if (usedExport.length === 0) {
|
|
96
141
|
if (exportsInfo.setUsedInUnknownWay(runtime)) {
|
|
@@ -105,6 +150,12 @@ class FlagDependencyUsagePlugin {
|
|
|
105
150
|
if (canMangle === false) {
|
|
106
151
|
exportInfo.canMangleUse = false;
|
|
107
152
|
}
|
|
153
|
+
|
|
154
|
+
if (exportInfo.canInlineUse === undefined) {
|
|
155
|
+
exportInfo.canInlineUse = canInline;
|
|
156
|
+
} else if (!canInline) {
|
|
157
|
+
exportInfo.canInlineUse = false;
|
|
158
|
+
}
|
|
108
159
|
const lastOne = i === usedExport.length - 1;
|
|
109
160
|
if (!lastOne) {
|
|
110
161
|
const nestedInfo = exportInfo.getNestedExportsInfo();
|
|
@@ -175,6 +226,11 @@ class FlagDependencyUsagePlugin {
|
|
|
175
226
|
/** @typedef {Map<string, string[] | ReferencedExport>} ExportMaps */
|
|
176
227
|
/** @type {Map<Module, ReferencedExports | ExportMaps>} */
|
|
177
228
|
const map = new Map();
|
|
229
|
+
// Modules whose whole namespace object escapes in a mangleable way.
|
|
230
|
+
// Tracked separately so specific member references are still merged
|
|
231
|
+
// (and marked used) instead of being dropped by the escape marker.
|
|
232
|
+
/** @type {Set<Module>} */
|
|
233
|
+
const mangleableEscapeModules = new Set();
|
|
178
234
|
|
|
179
235
|
/** @type {ArrayQueue<DependenciesBlock>} */
|
|
180
236
|
const queue = new ArrayQueue();
|
|
@@ -213,10 +269,27 @@ class FlagDependencyUsagePlugin {
|
|
|
213
269
|
}
|
|
214
270
|
const referencedExports =
|
|
215
271
|
compilation.getDependencyReferencedExports(dep, runtime);
|
|
272
|
+
// The non-mangleable whole-object reference is the most
|
|
273
|
+
// conservative result and always wins.
|
|
274
|
+
if (referencedExports === EXPORTS_OBJECT_REFERENCED) {
|
|
275
|
+
map.set(module, EXPORTS_OBJECT_REFERENCED);
|
|
276
|
+
mangleableEscapeModules.delete(module);
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
// A mangleable whole-object escape keeps the module's exports
|
|
280
|
+
// mangleable (applied after the merge). Unlike the conservative
|
|
281
|
+
// marker it must not drop specific member references: those still
|
|
282
|
+
// need their own (possibly non-existent) export marked used so
|
|
283
|
+
// they render as a qualified access, not a bare `undefined`.
|
|
284
|
+
if (
|
|
285
|
+
referencedExports === EXPORTS_OBJECT_REFERENCED_MANGLEABLE
|
|
286
|
+
) {
|
|
287
|
+
mangleableEscapeModules.add(module);
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
216
290
|
if (
|
|
217
291
|
oldReferencedExports === undefined ||
|
|
218
|
-
oldReferencedExports === NO_EXPORTS_REFERENCED
|
|
219
|
-
referencedExports === EXPORTS_OBJECT_REFERENCED
|
|
292
|
+
oldReferencedExports === NO_EXPORTS_REFERENCED
|
|
220
293
|
) {
|
|
221
294
|
map.set(module, referencedExports);
|
|
222
295
|
} else if (
|
|
@@ -258,7 +331,8 @@ class FlagDependencyUsagePlugin {
|
|
|
258
331
|
} else {
|
|
259
332
|
exportsMap.set(key, {
|
|
260
333
|
name: item.name,
|
|
261
|
-
canMangle: item.canMangle && oldItem.canMangle
|
|
334
|
+
canMangle: item.canMangle && oldItem.canMangle,
|
|
335
|
+
canInline: item.canInline && oldItem.canInline
|
|
262
336
|
});
|
|
263
337
|
}
|
|
264
338
|
}
|
|
@@ -284,6 +358,14 @@ class FlagDependencyUsagePlugin {
|
|
|
284
358
|
);
|
|
285
359
|
}
|
|
286
360
|
}
|
|
361
|
+
for (const module of mangleableEscapeModules) {
|
|
362
|
+
processReferencedModule(
|
|
363
|
+
module,
|
|
364
|
+
EXPORTS_OBJECT_REFERENCED_MANGLEABLE,
|
|
365
|
+
runtime,
|
|
366
|
+
forceSideEffects
|
|
367
|
+
);
|
|
368
|
+
}
|
|
287
369
|
};
|
|
288
370
|
|
|
289
371
|
logger.time("initialize exports usage");
|
|
@@ -18,7 +18,9 @@ class FlagEntryExportAsUsedPlugin {
|
|
|
18
18
|
* @param {string} explanation explanation for the reason
|
|
19
19
|
*/
|
|
20
20
|
constructor(nsObjectUsed, explanation) {
|
|
21
|
+
/** @type {boolean} */
|
|
21
22
|
this.nsObjectUsed = nsObjectUsed;
|
|
23
|
+
/** @type {string} */
|
|
22
24
|
this.explanation = explanation;
|
|
23
25
|
}
|
|
24
26
|
|
package/lib/Generator.js
CHANGED
|
@@ -79,6 +79,13 @@ class Generator {
|
|
|
79
79
|
throw new AbstractMethodError();
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
/**
|
|
83
|
+
* @returns {boolean} whether getTypes() depends on the module's incoming connections
|
|
84
|
+
*/
|
|
85
|
+
getTypesDependOnIncomingConnections() {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
|
|
82
89
|
/* istanbul ignore next */
|
|
83
90
|
/**
|
|
84
91
|
* Returns the estimated size for the requested source type.
|
|
@@ -156,6 +163,7 @@ class ByTypeGenerator extends Generator {
|
|
|
156
163
|
constructor(map) {
|
|
157
164
|
super();
|
|
158
165
|
this.map = map;
|
|
166
|
+
/** @type {SourceTypes} */
|
|
159
167
|
this._types = /** @type {SourceTypes} */ (new Set(Object.keys(map)));
|
|
160
168
|
/** @type {GenerateErrorFn | undefined} */
|
|
161
169
|
this.generateError = generateError.bind(this);
|
|
@@ -56,6 +56,7 @@ const {
|
|
|
56
56
|
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
|
|
57
57
|
/** @typedef {import("./Module")} Module */
|
|
58
58
|
/** @typedef {import("./Module").BuildInfo} BuildInfo */
|
|
59
|
+
/** @typedef {import("./css/CssModule").CssModuleBuildMeta} CssModuleBuildMeta */
|
|
59
60
|
/** @typedef {import("./RuntimeModule")} RuntimeModule */
|
|
60
61
|
/** @typedef {import("./javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
|
|
61
62
|
/** @typedef {import("./javascript/JavascriptParserHelpers").Range} Range */
|
|
@@ -80,7 +81,7 @@ const {
|
|
|
80
81
|
/** @typedef {Set<ChunkId>} ChunkIds */
|
|
81
82
|
/** @typedef {Set<Module>} ModuleSet */
|
|
82
83
|
|
|
83
|
-
/** @typedef {{ updatedChunkIds: ChunkIds, removedChunkIds: ChunkIds, removedModules: ModuleSet, filename: string, assetInfo: AssetInfo }} HotUpdateMainContentByRuntimeItem */
|
|
84
|
+
/** @typedef {{ updatedChunkIds: ChunkIds, removedChunkIds: ChunkIds, removedModules: ModuleSet, forceLoadChunkIds: ChunkIds, filename: string, assetInfo: AssetInfo }} HotUpdateMainContentByRuntimeItem */
|
|
84
85
|
/** @typedef {Map<string, HotUpdateMainContentByRuntimeItem>} HotUpdateMainContentByRuntime */
|
|
85
86
|
|
|
86
87
|
/** @type {WeakMap<JavascriptParser, HMRJavascriptParserHooks>} */
|
|
@@ -167,10 +168,10 @@ class HotModuleReplacementPlugin {
|
|
|
167
168
|
/** @type {Range} */ (param.range)
|
|
168
169
|
);
|
|
169
170
|
dep.optional = true;
|
|
170
|
-
dep.
|
|
171
|
-
/** @type {DependencyLocation} */ (expr.loc)
|
|
171
|
+
dep.setLocWithIndex(
|
|
172
|
+
/** @type {DependencyLocation} */ (expr.loc),
|
|
173
|
+
idx
|
|
172
174
|
);
|
|
173
|
-
dep.loc.index = idx;
|
|
174
175
|
module.addDependency(dep);
|
|
175
176
|
requests.push(request);
|
|
176
177
|
}
|
|
@@ -224,8 +225,10 @@ class HotModuleReplacementPlugin {
|
|
|
224
225
|
/** @type {Range} */ (param.range)
|
|
225
226
|
);
|
|
226
227
|
dep.optional = true;
|
|
227
|
-
dep.
|
|
228
|
-
|
|
228
|
+
dep.setLocWithIndex(
|
|
229
|
+
/** @type {DependencyLocation} */ (expr.loc),
|
|
230
|
+
idx
|
|
231
|
+
);
|
|
229
232
|
module.addDependency(dep);
|
|
230
233
|
}
|
|
231
234
|
}
|
|
@@ -403,7 +406,8 @@ class HotModuleReplacementPlugin {
|
|
|
403
406
|
for (const innerModule of m.modules) {
|
|
404
407
|
if (
|
|
405
408
|
innerModule.buildMeta &&
|
|
406
|
-
innerModule.buildMeta
|
|
409
|
+
/** @type {CssModuleBuildMeta} */ (innerModule.buildMeta)
|
|
410
|
+
.needIdInConcatenation
|
|
407
411
|
) {
|
|
408
412
|
const innerId = chunkGraph.getModuleId(innerModule);
|
|
409
413
|
if (innerId !== null) {
|
|
@@ -573,6 +577,8 @@ class HotModuleReplacementPlugin {
|
|
|
573
577
|
removedChunkIds: new Set(),
|
|
574
578
|
/** @type {ModuleSet} */
|
|
575
579
|
removedModules: new Set(),
|
|
580
|
+
/** @type {ChunkIds} */
|
|
581
|
+
forceLoadChunkIds: new Set(),
|
|
576
582
|
filename,
|
|
577
583
|
assetInfo
|
|
578
584
|
}
|
|
@@ -699,30 +705,43 @@ class HotModuleReplacementPlugin {
|
|
|
699
705
|
}
|
|
700
706
|
} else {
|
|
701
707
|
// module is no longer in this runtime combination
|
|
702
|
-
// We (incorrectly) assume that it's not in an overlapping runtime combination
|
|
703
|
-
// and dispose it from the main runtimes the chunk was removed from
|
|
704
708
|
forEachRuntime(removedFromRuntime, (runtime) => {
|
|
705
|
-
// If the module is still used in this runtime, do not dispose it
|
|
706
|
-
// This could create a bad runtime state where the module is still loaded,
|
|
707
|
-
// but no chunk which contains it. This means we don't receive further HMR updates
|
|
708
|
-
// to this module and that's bad.
|
|
709
|
-
// TODO force load one of the chunks which contains the module
|
|
710
|
-
for (const moduleRuntime of runtimes) {
|
|
711
|
-
if (typeof moduleRuntime === "string") {
|
|
712
|
-
if (moduleRuntime === runtime) return;
|
|
713
|
-
} else if (
|
|
714
|
-
moduleRuntime !== undefined &&
|
|
715
|
-
moduleRuntime.has(/** @type {string} */ (runtime))
|
|
716
|
-
) {
|
|
717
|
-
return;
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
709
|
const item =
|
|
721
710
|
/** @type {HotUpdateMainContentByRuntimeItem} */ (
|
|
722
711
|
hotUpdateMainContentByRuntime.get(
|
|
723
712
|
/** @type {string} */ (runtime)
|
|
724
713
|
)
|
|
725
714
|
);
|
|
715
|
+
// Module still in this runtime via another chunk: force-load one so
|
|
716
|
+
// it keeps an installed owner instead of being disposed (lost updates).
|
|
717
|
+
const stillInRuntime = [...runtimes].some(
|
|
718
|
+
(moduleRuntime) =>
|
|
719
|
+
typeof moduleRuntime === "string"
|
|
720
|
+
? moduleRuntime === runtime
|
|
721
|
+
: moduleRuntime !== undefined &&
|
|
722
|
+
moduleRuntime.has(/** @type {string} */ (runtime))
|
|
723
|
+
);
|
|
724
|
+
if (stillInRuntime) {
|
|
725
|
+
for (const moduleChunk of chunkGraph.getModuleChunksIterable(
|
|
726
|
+
module
|
|
727
|
+
)) {
|
|
728
|
+
const chunkRuntime = moduleChunk.runtime;
|
|
729
|
+
const inRuntime =
|
|
730
|
+
typeof chunkRuntime === "string"
|
|
731
|
+
? chunkRuntime === runtime
|
|
732
|
+
: chunkRuntime !== undefined &&
|
|
733
|
+
chunkRuntime.has(
|
|
734
|
+
/** @type {string} */ (runtime)
|
|
735
|
+
);
|
|
736
|
+
if (inRuntime) {
|
|
737
|
+
item.forceLoadChunkIds.add(
|
|
738
|
+
/** @type {ChunkId} */ (moduleChunk.id)
|
|
739
|
+
);
|
|
740
|
+
break;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
726
745
|
item.removedModules.add(module);
|
|
727
746
|
});
|
|
728
747
|
}
|
|
@@ -820,6 +839,7 @@ class HotModuleReplacementPlugin {
|
|
|
820
839
|
removedChunkIds,
|
|
821
840
|
removedModules,
|
|
822
841
|
updatedChunkIds,
|
|
842
|
+
forceLoadChunkIds,
|
|
823
843
|
filename,
|
|
824
844
|
assetInfo
|
|
825
845
|
} of hotUpdateMainContentByRuntime.values()) {
|
|
@@ -828,7 +848,8 @@ class HotModuleReplacementPlugin {
|
|
|
828
848
|
old &&
|
|
829
849
|
(!isSubset(old.removedChunkIds, removedChunkIds) ||
|
|
830
850
|
!isSubset(old.removedModules, removedModules) ||
|
|
831
|
-
!isSubset(old.updatedChunkIds, updatedChunkIds)
|
|
851
|
+
!isSubset(old.updatedChunkIds, updatedChunkIds) ||
|
|
852
|
+
!isSubset(old.forceLoadChunkIds, forceLoadChunkIds))
|
|
832
853
|
) {
|
|
833
854
|
compilation.warnings.push(
|
|
834
855
|
new WebpackError(`HotModuleReplacementPlugin
|
|
@@ -845,20 +866,30 @@ To fix this, make sure to include [runtime] in the output.hotUpdateMainFilename
|
|
|
845
866
|
for (const chunkId of updatedChunkIds) {
|
|
846
867
|
old.updatedChunkIds.add(chunkId);
|
|
847
868
|
}
|
|
869
|
+
for (const chunkId of forceLoadChunkIds) {
|
|
870
|
+
old.forceLoadChunkIds.add(chunkId);
|
|
871
|
+
}
|
|
848
872
|
continue;
|
|
849
873
|
}
|
|
850
874
|
hotUpdateMainContentByFilename.set(filename, {
|
|
851
875
|
removedChunkIds,
|
|
852
876
|
removedModules,
|
|
853
877
|
updatedChunkIds,
|
|
878
|
+
forceLoadChunkIds,
|
|
854
879
|
assetInfo
|
|
855
880
|
});
|
|
856
881
|
}
|
|
857
882
|
for (const [
|
|
858
883
|
filename,
|
|
859
|
-
{
|
|
884
|
+
{
|
|
885
|
+
removedChunkIds,
|
|
886
|
+
removedModules,
|
|
887
|
+
updatedChunkIds,
|
|
888
|
+
forceLoadChunkIds,
|
|
889
|
+
assetInfo
|
|
890
|
+
}
|
|
860
891
|
] of hotUpdateMainContentByFilename) {
|
|
861
|
-
/** @type {{ c: ChunkId[], r: ChunkId[], m: ModuleId[], css?: { r: ChunkId[] } }} */
|
|
892
|
+
/** @type {{ c: ChunkId[], r: ChunkId[], m: ModuleId[], f?: ChunkId[], css?: { r: ChunkId[] } }} */
|
|
862
893
|
const hotUpdateMainJson = {
|
|
863
894
|
c: [...updatedChunkIds],
|
|
864
895
|
r: [...removedChunkIds],
|
|
@@ -875,6 +906,12 @@ To fix this, make sure to include [runtime] in the output.hotUpdateMainFilename
|
|
|
875
906
|
]
|
|
876
907
|
};
|
|
877
908
|
|
|
909
|
+
// Chunks the client must load so a module whose only loaded chunk
|
|
910
|
+
// left a runtime keeps an installed owner (see force-load branch).
|
|
911
|
+
if (forceLoadChunkIds.size > 0) {
|
|
912
|
+
hotUpdateMainJson.f = [...forceLoadChunkIds];
|
|
913
|
+
}
|
|
914
|
+
|
|
878
915
|
// Build CSS removed chunks list (chunks in updatedChunkIds that no longer have CSS)
|
|
879
916
|
/** @type {ChunkId[]} */
|
|
880
917
|
const cssRemovedChunkIds = [];
|
|
@@ -938,7 +975,7 @@ To fix this, make sure to include [runtime] in the output.hotUpdateMainFilename
|
|
|
938
975
|
applyImportMetaHot(parser);
|
|
939
976
|
});
|
|
940
977
|
normalModuleFactory.hooks.module.tap(PLUGIN_NAME, (module) => {
|
|
941
|
-
module.hot = true;
|
|
978
|
+
if (module instanceof NormalModule) module.hot = true;
|
|
942
979
|
return module;
|
|
943
980
|
});
|
|
944
981
|
|
package/lib/IgnorePlugin.js
CHANGED
package/lib/InitFragment.js
CHANGED
|
@@ -67,10 +67,15 @@ class InitFragment {
|
|
|
67
67
|
* @param {string | Source=} endContent the source code that will be included at the end of the module
|
|
68
68
|
*/
|
|
69
69
|
constructor(content, stage, position, key, endContent) {
|
|
70
|
+
/** @type {string | Source | undefined} */
|
|
70
71
|
this.content = content;
|
|
72
|
+
/** @type {number} */
|
|
71
73
|
this.stage = stage;
|
|
74
|
+
/** @type {number} */
|
|
72
75
|
this.position = position;
|
|
76
|
+
/** @type {string | undefined} */
|
|
73
77
|
this.key = key;
|
|
78
|
+
/** @type {string | Source | undefined} */
|
|
74
79
|
this.endContent = endContent;
|
|
75
80
|
}
|
|
76
81
|
|
|
@@ -10,10 +10,11 @@ const {
|
|
|
10
10
|
JAVASCRIPT_MODULE_TYPE_DYNAMIC,
|
|
11
11
|
JAVASCRIPT_MODULE_TYPE_ESM
|
|
12
12
|
} = require("./ModuleTypeConstants");
|
|
13
|
-
const
|
|
13
|
+
const { getInnerGraphUtils } = require("./optimize/InnerGraph");
|
|
14
14
|
|
|
15
15
|
/** @typedef {import("./Compiler")} Compiler */
|
|
16
16
|
/** @typedef {import("./Module").BuildInfo} BuildInfo */
|
|
17
|
+
/** @typedef {import("./javascript/JavascriptModule").JavascriptModuleBuildInfo} JavascriptModuleBuildInfo */
|
|
17
18
|
/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
|
|
18
19
|
|
|
19
20
|
const PLUGIN_NAME = "JavascriptMetaInfoPlugin";
|
|
@@ -28,6 +29,7 @@ class JavascriptMetaInfoPlugin {
|
|
|
28
29
|
compiler.hooks.compilation.tap(
|
|
29
30
|
PLUGIN_NAME,
|
|
30
31
|
(compilation, { normalModuleFactory }) => {
|
|
32
|
+
const innerGraph = getInnerGraphUtils(compilation);
|
|
31
33
|
/**
|
|
32
34
|
* Handles the hook callback for this code path.
|
|
33
35
|
* @param {JavascriptParser} parser the parser
|
|
@@ -36,14 +38,14 @@ class JavascriptMetaInfoPlugin {
|
|
|
36
38
|
const handler = (parser) => {
|
|
37
39
|
parser.hooks.call.for("eval").tap(PLUGIN_NAME, () => {
|
|
38
40
|
const buildInfo =
|
|
39
|
-
/** @type {
|
|
41
|
+
/** @type {JavascriptModuleBuildInfo} */
|
|
40
42
|
(parser.state.module.buildInfo);
|
|
41
43
|
buildInfo.moduleConcatenationBailout = "eval()";
|
|
42
|
-
const currentSymbol =
|
|
44
|
+
const currentSymbol = innerGraph.getTopLevelSymbol(parser.state);
|
|
43
45
|
if (currentSymbol) {
|
|
44
|
-
|
|
46
|
+
innerGraph.addUsage(parser.state, null, currentSymbol);
|
|
45
47
|
} else {
|
|
46
|
-
|
|
48
|
+
innerGraph.bailout(parser.state);
|
|
47
49
|
}
|
|
48
50
|
});
|
|
49
51
|
parser.hooks.finish.tap(PLUGIN_NAME, () => {
|