From 3bd962a6d7f61239c020e2dbbeb7341e5b842dd1 Mon Sep 17 00:00:00 2001
From: WXL <wl_5969728@163.com>
Date: 星期二, 21 四月 2026 11:46:41 +0800
Subject: [PATCH] 推送
---
node_modules/webpack/lib/dependencies/HarmonyExportImportedSpecifierDependency.js | 70 ++++++++++++++++++++++++++++++-----
1 files changed, 60 insertions(+), 10 deletions(-)
diff --git a/node_modules/webpack/lib/dependencies/HarmonyExportImportedSpecifierDependency.js b/node_modules/webpack/lib/dependencies/HarmonyExportImportedSpecifierDependency.js
index b7e6026..d7d9af7 100644
--- a/node_modules/webpack/lib/dependencies/HarmonyExportImportedSpecifierDependency.js
+++ b/node_modules/webpack/lib/dependencies/HarmonyExportImportedSpecifierDependency.js
@@ -18,8 +18,7 @@
const { countIterable } = require("../util/IterableHelpers");
const { combine, first } = require("../util/SetHelpers");
const makeSerializable = require("../util/makeSerializable");
-const propertyAccess = require("../util/propertyAccess");
-const { propertyName } = require("../util/propertyName");
+const { propertyAccess, propertyName } = require("../util/property");
const {
filterRuntime,
getRuntimeKey,
@@ -58,16 +57,20 @@
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
/** @typedef {import("./HarmonyImportDependency").Ids} Ids */
/** @typedef {import("./HarmonyImportDependency").ExportPresenceMode} ExportPresenceMode */
+/** @typedef {import("./HarmonyExportInitFragment").ExportMap} ExportMap */
/** @typedef {import("../dependencies/ImportPhase").ImportPhaseType} ImportPhaseType */
-/** @typedef {"missing"|"unused"|"empty-star"|"reexport-dynamic-default"|"reexport-named-default"|"reexport-namespace-object"|"reexport-fake-namespace-object"|"reexport-undefined"|"normal-reexport"|"dynamic-reexport"} ExportModeType */
+/** @typedef {"missing" | "unused" | "empty-star" | "reexport-dynamic-default" | "reexport-named-default" | "reexport-namespace-object" | "reexport-fake-namespace-object" | "reexport-undefined" | "normal-reexport" | "dynamic-reexport"} ExportModeType */
const { ExportPresenceModes } = HarmonyImportDependency;
-const idsSymbol = Symbol("HarmonyExportImportedSpecifierDependency.ids");
+const idsSymbol = /** @type {symbol} */ (
+ Symbol("HarmonyExportImportedSpecifierDependency.ids")
+);
class NormalReexportItem {
/**
+ * Creates an instance of NormalReexportItem.
* @param {string} name export name
* @param {Ids} ids reexported ids from other module
* @param {ExportInfo} exportInfo export info from other module
@@ -88,6 +91,7 @@
class ExportMode {
/**
+ * Creates an instance of ExportMode.
* @param {ExportModeType} type type of the mode
*/
constructor(type) {
@@ -125,6 +129,7 @@
/** @typedef {number[]} DependencyIndices */
/**
+ * Determine export assignments.
* @param {ModuleGraph} moduleGraph module graph
* @param {HarmonyExportImportedSpecifierDependency[]} dependencies dependencies
* @param {HarmonyExportImportedSpecifierDependency=} additionalDependency additional dependency
@@ -168,6 +173,7 @@
};
/**
+ * Finds dependency for name.
* @param {object} options options
* @param {ExportInfoName[]} options.names names
* @param {DependencyIndices} options.dependencyIndices dependency indices
@@ -197,6 +203,7 @@
};
/**
+ * Returns the export mode.
* @param {ModuleGraph} moduleGraph the module graph
* @param {HarmonyExportImportedSpecifierDependency} dep the dependency
* @param {string} runtimeKey the runtime key
@@ -264,6 +271,7 @@
// reexporting with a fixed name
if (name) {
+ /** @type {ExportMode} */
let mode;
const exportInfo = exportsInfo.getReadOnlyExportInfo(name);
@@ -370,6 +378,7 @@
class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
/**
+ * Creates an instance of HarmonyExportImportedSpecifierDependency.
* @param {string} request the request string
* @param {number} sourceOrder the order in the original source file
* @param {Ids} ids the requested export name of the imported module
@@ -404,6 +413,7 @@
}
/**
+ * Could affect referencing module.
* @returns {boolean | TRANSITIVE} true, when changes to the referenced module could affect the referencing module; TRANSITIVE, when changes to the referenced module could affect referencing modules of the referencing module
*/
couldAffectReferencingModule() {
@@ -411,16 +421,28 @@
}
// TODO webpack 6 remove
+ /**
+ * Returns id.
+ * @deprecated
+ */
get id() {
throw new Error("id was renamed to ids and type changed to string[]");
}
// TODO webpack 6 remove
+ /**
+ * Returns id.
+ * @deprecated
+ */
getId() {
throw new Error("id was renamed to ids and type changed to string[]");
}
// TODO webpack 6 remove
+ /**
+ * Updates id.
+ * @deprecated
+ */
setId() {
throw new Error("id was renamed to ids and type changed to string[]");
}
@@ -430,6 +452,7 @@
}
/**
+ * Returns the imported id.
* @param {ModuleGraph} moduleGraph the module graph
* @returns {Ids} the imported id
*/
@@ -438,6 +461,7 @@
}
/**
+ * Updates ids using the provided module graph.
* @param {ModuleGraph} moduleGraph the module graph
* @param {Ids} ids the imported ids
* @returns {void}
@@ -447,6 +471,7 @@
}
/**
+ * Returns the export mode.
* @param {ModuleGraph} moduleGraph the module graph
* @param {RuntimeSpec} runtime the runtime
* @returns {ExportMode} the export mode
@@ -460,11 +485,12 @@
}
/**
+ * Gets star reexports.
* @param {ModuleGraph} moduleGraph the module graph
* @param {RuntimeSpec} runtime the runtime
* @param {ExportsInfo} exportsInfo exports info about the current module (optional)
* @param {Module} importedModule the imported module (optional)
- * @returns {{exports?: Exports, checked?: Checked, ignoredExports: IgnoredExports, hidden?: Hidden}} information
+ * @returns {{ exports?: Exports, checked?: Checked, ignoredExports: IgnoredExports, hidden?: Hidden }} information
*/
getStarReexports(
moduleGraph,
@@ -480,8 +506,10 @@
const noExtraImports =
exportsInfo.otherExportsInfo.getUsed(runtime) === UsageState.Unused;
+ /** @type {IgnoredExports} */
const ignoredExports = new Set(["default", ...this.activeExports]);
+ /** @type {Hidden | undefined} */
let hiddenExports;
const otherStarExports =
this._discoverActiveExportsFromOtherStarExports(moduleGraph);
@@ -546,6 +574,7 @@
}
/**
+ * Returns function to determine if the connection is active.
* @param {ModuleGraph} moduleGraph module graph
* @returns {null | false | GetConditionFn} function to determine if the connection is active
*/
@@ -557,6 +586,7 @@
}
/**
+ * Gets module evaluation side effects state.
* @param {ModuleGraph} moduleGraph the module graph
* @returns {ConnectionState} how this dependency connects the module to referencing modules
*/
@@ -638,6 +668,7 @@
}
/**
+ * Discover active exports from other star exports.
* @param {ModuleGraph} moduleGraph the module graph
* @returns {{ names: ExportInfoName[], namesSlice: number, dependencyIndices: DependencyIndices, dependencyIndex: number } | undefined} exported names and their origin dependency
*/
@@ -816,6 +847,7 @@
}
/**
+ * Get effective export presence level.
* @param {ModuleGraph} moduleGraph module graph
* @returns {ExportPresenceMode} effective mode
*/
@@ -830,7 +862,7 @@
}
/**
- * Returns warnings
+ * Returns warnings.
* @param {ModuleGraph} moduleGraph module graph
* @returns {WebpackError[] | null | undefined} warnings
*/
@@ -843,7 +875,7 @@
}
/**
- * Returns errors
+ * Returns errors.
* @param {ModuleGraph} moduleGraph module graph
* @returns {WebpackError[] | null | undefined} errors
*/
@@ -856,6 +888,7 @@
}
/**
+ * Returns errors.
* @param {ModuleGraph} moduleGraph module graph
* @returns {WebpackError[] | undefined} errors
*/
@@ -942,6 +975,7 @@
}
/**
+ * Serializes this instance into the provided serializer context.
* @param {ObjectSerializerContext} context context
*/
serialize(context) {
@@ -959,6 +993,7 @@
}
/**
+ * Restores this instance from the provided deserializer context.
* @param {ObjectDeserializerContext} context context
*/
deserialize(context) {
@@ -985,6 +1020,7 @@
HarmonyImportDependency.Template
) {
/**
+ * Applies the plugin by registering its hooks on the compiler.
* @param {Dependency} dependency the dependency for which the template should be applied
* @param {ReplaceSource} source the current replace source which can be modified
* @param {DependencyTemplateContext} templateContext the context object
@@ -1028,6 +1064,7 @@
}
/**
+ * Add export fragments.
* @param {InitFragment<GenerateContext>[]} initFragments target array for init fragments
* @param {HarmonyExportImportedSpecifierDependency} dep dependency
* @param {ExportMode} mode the export mode
@@ -1251,9 +1288,11 @@
}
content += "__WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = ";
- content += runtimeTemplate.supportsArrowFunction()
- ? `() => ${importVar}[__WEBPACK_IMPORT_KEY__]`
- : `function(key) { return ${importVar}[key]; }.bind(0, __WEBPACK_IMPORT_KEY__)`;
+ content +=
+ runtimeTemplate.supportsArrowFunction() &&
+ runtimeTemplate.supportsConst()
+ ? `() => ${importVar}[__WEBPACK_IMPORT_KEY__]`
+ : `function(key) { return ${importVar}[key]; }.bind(0, __WEBPACK_IMPORT_KEY__)`;
runtimeRequirements.add(RuntimeGlobals.exports);
runtimeRequirements.add(RuntimeGlobals.definePropertyGetters);
@@ -1277,6 +1316,7 @@
}
/**
+ * Gets reexport fragment.
* @param {Module} module the current module
* @param {string} comment comment
* @param {UsedName} key key
@@ -1298,6 +1338,7 @@
runtimeRequirements.add(RuntimeGlobals.exports);
runtimeRequirements.add(RuntimeGlobals.definePropertyGetters);
+ /** @type {ExportMap} */
const map = new Map();
map.set(key, `/* ${comment} */ ${returnValue}`);
@@ -1305,6 +1346,7 @@
}
/**
+ * Gets reexport fake namespace object fragments.
* @param {Module} module module
* @param {UsedName} key key
* @param {string} name name
@@ -1323,6 +1365,7 @@
runtimeRequirements.add(RuntimeGlobals.definePropertyGetters);
runtimeRequirements.add(RuntimeGlobals.createFakeNamespaceObject);
+ /** @type {ExportMap} */
const map = new Map();
map.set(
key,
@@ -1343,6 +1386,7 @@
}
/**
+ * Gets reexport deferred namespace object fragments.
* @param {Module} module module
* @param {ChunkGraph} chunkGraph chunkGraph
* @param {UsedName} key key
@@ -1363,6 +1407,7 @@
runtimeRequirements.add(RuntimeGlobals.definePropertyGetters);
runtimeRequirements.add(RuntimeGlobals.makeDeferredNamespaceObject);
+ /** @type {ExportMap} */
const map = new Map();
const moduleId = JSON.stringify(chunkGraph.getModuleId(module));
const mode = getMakeDeferredNamespaceModeFromExportsType(exportsType);
@@ -1383,6 +1428,7 @@
}
/**
+ * Gets conditional reexport statement.
* @param {Module} module module
* @param {string} key key
* @param {string} name name
@@ -1418,6 +1464,7 @@
}
/**
+ * Returns value.
* @param {string} name name
* @param {null | false | string | string[]} valueKey value key
* @returns {string | undefined} value
@@ -1446,6 +1493,7 @@
}
/**
+ * Processes the provided dep.
* @param {HarmonyExportImportedSpecifierDependency} dep dependency
* @returns {void}
*/
@@ -1458,6 +1506,7 @@
}
/**
+ * Serializes this instance into the provided serializer context.
* @param {ObjectSerializerContext} context context
*/
serialize({ write, setCircularReference }) {
@@ -1466,6 +1515,7 @@
}
/**
+ * Restores this instance from the provided deserializer context.
* @param {ObjectDeserializerContext} context context
*/
deserialize({ read, setCircularReference }) {
--
Gitblit v1.9.3