MCPcopy
hub / github.com/webpack/webpack / getUsedName

Method getUsedName

lib/ExportsInfo.js:1484–1510  ·  view source on GitHub ↗

* Returns used name. May return InlinedUsedName when the export is inlined to a primitive. * @param {string | undefined} fallbackName fallback name for used exports with no name * @param {RuntimeSpec} runtime check usage for this runtime only * @returns {string | InlinedUsedName | false} used

(fallbackName, runtime)

Source from the content-addressed store, hash-verified

1482 * @returns {string | InlinedUsedName | false} used name
1483 */
1484 getUsedName(fallbackName, runtime) {
1485 if (this._hasUseInRuntimeInfo) {
1486 if (this._globalUsed !== undefined) {
1487 if (this._globalUsed === UsageState.Unused) return false;
1488 } else {
1489 if (this._usedInRuntime === undefined) return false;
1490 if (typeof runtime === "string") {
1491 if (!this._usedInRuntime.has(runtime)) {
1492 return false;
1493 }
1494 } else if (runtime !== undefined) {
1495 // Unused unless at least one runtime in the set is used; loop avoids
1496 // allocating an array from the runtime set on this hot path.
1497 let anyUsed = false;
1498 for (const r of runtime) {
1499 if (this._usedInRuntime.has(r)) {
1500 anyUsed = true;
1501 break;
1502 }
1503 }
1504 if (!anyUsed) return false;
1505 }
1506 }
1507 }
1508 if (this._usedName !== null) return this._usedName;
1509 return /** @type {string | false} */ (this.name || fallbackName);
1510 }
1511
1512 /**
1513 * Checks whether this export info has used name.

Callers 15

exportFromImportMethod · 0.45
getUsedNameMethod · 0.45
hasInlinedUsedNameMethod · 0.45
generateModuleRemappingFunction · 0.45
renderStartupMethod · 0.45
renderMethod · 0.45
getFinalBindingFunction · 0.45
codeGenerationMethod · 0.45
generateImportObjectFunction · 0.45

Calls 1

hasMethod · 0.45

Tested by

no test coverage detected