MCPcopy
hub / github.com/webpack/webpack / hasInlinedUsedName

Method hasInlinedUsedName

lib/ExportsInfo.js:859–894  ·  view source on GitHub ↗

* Checks whether `getUsedName(name, runtime)` would return an `InlinedUsedName`, * without allocating intermediate used-name arrays (hot path for connection conditions). * @param {ExportInfoName[]} name the export name path * @param {RuntimeSpec} runtime check usage for this runtime only * @

(name, runtime)

Source from the content-addressed store, hash-verified

857 * @returns {boolean} true when the used name resolves to an inlined value
858 */
859 hasInlinedUsedName(name, runtime) {
860 if (name.length === 0) return false;
861 /** @type {ExportsInfo} */
862 let exportsInfo = this;
863 const last = name.length - 1;
864 for (let i = 0; ; i++) {
865 // follow redirects for the fast-path flag; InlinedUsedName can only
866 // exist on a level whose (redirected) exportsInfo is marked
867 let hasInlined = false;
868 /** @type {ExportsInfo | undefined} */
869 let e = exportsInfo;
870 while (e !== undefined) {
871 if (e._hasInlinedExports) {
872 hasInlined = true;
873 break;
874 }
875 e = e._redirectTo;
876 }
877 if (!hasInlined && i === last) return false;
878 const info = exportsInfo.getReadOnlyExportInfo(name[i]);
879 if (hasInlined) {
880 const x = info.getUsedName(name[i], runtime);
881 if (x === false) return false;
882 if (x instanceof InlinedUsedName) return true;
883 if (i === last) return false;
884 }
885 if (
886 info.exportsInfo &&
887 info.getUsed(runtime) === UsageState.OnlyPropertiesUsed
888 ) {
889 exportsInfo = info.exportsInfo;
890 continue;
891 }
892 return false;
893 }
894 }
895
896 /**
897 * Updates the hash with the data contributed by this instance.

Callers 1

isExportInlinedFunction · 0.80

Calls 3

getReadOnlyExportInfoMethod · 0.45
getUsedNameMethod · 0.45
getUsedMethod · 0.45

Tested by

no test coverage detected