MCPcopy
hub / github.com/webpack/webpack / getFinalName

Function getFinalName

lib/optimize/ConcatenatedModule.js:734–799  ·  view source on GitHub ↗
(
	moduleGraph,
	info,
	exportName,
	moduleToInfoMap,
	runtime,
	requestShortener,
	runtimeTemplate,
	neededNamespaceObjects,
	asCall,
	depDeferred,
	callContext,
	strictHarmonyModule,
	asiSafe
)

Source from the content-addressed store, hash-verified

732 * @returns {string} the final name
733 */
734const getFinalName = (
735 moduleGraph,
736 info,
737 exportName,
738 moduleToInfoMap,
739 runtime,
740 requestShortener,
741 runtimeTemplate,
742 neededNamespaceObjects,
743 asCall,
744 depDeferred,
745 callContext,
746 strictHarmonyModule,
747 asiSafe
748) => {
749 const binding = getFinalBinding(
750 moduleGraph,
751 info,
752 exportName,
753 moduleToInfoMap,
754 runtime,
755 requestShortener,
756 runtimeTemplate,
757 neededNamespaceObjects,
758 asCall,
759 depDeferred,
760 strictHarmonyModule,
761 asiSafe
762 );
763 {
764 const { ids, comment } = binding;
765 /** @type {string} */
766 let reference;
767 /** @type {boolean} */
768 let isPropertyAccess;
769 if ("rawName" in binding) {
770 reference = `${binding.rawName}${comment || ""}${propertyAccess(ids)}`;
771 isPropertyAccess = ids.length > 0;
772 } else {
773 const { info, name: exportId } = binding;
774 const name = info.internalNames.get(exportId);
775 if (!name) {
776 throw new Error(
777 `The export "${exportId}" in "${info.module.readableIdentifier(
778 requestShortener
779 )}" has no internal name (existing names: ${
780 Array.from(
781 info.internalNames,
782 ([name, symbol]) => `${name}: ${symbol}`
783 ).join(", ") || "none"
784 })`
785 );
786 }
787 reference = `${name}${comment || ""}${propertyAccess(ids)}`;
788 isPropertyAccess = ids.length > 1;
789 }
790 if (isPropertyAccess && asCall && callContext === false) {
791 return asiSafe

Callers 1

codeGenerationMethod · 0.85

Calls 4

getFinalBindingFunction · 0.85
propertyAccessFunction · 0.85
getMethod · 0.45
readableIdentifierMethod · 0.45

Tested by

no test coverage detected