MCPcopy
hub / github.com/webpack/webpack / getReferencedExports

Method getReferencedExports

lib/dependencies/ImportDependency.js:97–128  ·  view source on GitHub ↗

* Returns list of exports referenced by this dependency * @param {ModuleGraph} moduleGraph module graph * @param {RuntimeSpec} runtime the runtime for which the module is analysed * @returns {ReferencedExports} referenced exports

(moduleGraph, runtime)

Source from the content-addressed store, hash-verified

95 * @returns {ReferencedExports} referenced exports
96 */
97 getReferencedExports(moduleGraph, runtime) {
98 if (!this.referencedExports) return Dependency.EXPORTS_OBJECT_REFERENCED;
99 /** @type {ReferencedExports} */
100 const refs = [];
101 for (const referencedExport of this.referencedExports) {
102 if (referencedExport[0] === "default") {
103 const selfModule =
104 /** @type {Module} */
105 (moduleGraph.getParentModule(this));
106 const importedModule =
107 /** @type {Module} */
108 (moduleGraph.getModule(this));
109 const exportsType = importedModule.getExportsType(
110 moduleGraph,
111 /** @type {BuildMeta} */
112 (selfModule.buildMeta).strictHarmonyModule
113 );
114 if (
115 exportsType === "default-only" ||
116 exportsType === "default-with-named"
117 ) {
118 return Dependency.EXPORTS_OBJECT_REFERENCED;
119 }
120 }
121 refs.push({
122 name: referencedExport,
123 canMangle: false,
124 canInline: false
125 });
126 }
127 return refs;
128 }
129
130 /**
131 * Serializes this instance into the provided serializer context.

Callers

nothing calls this directly

Calls 4

getParentModuleMethod · 0.80
getModuleMethod · 0.45
getExportsTypeMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected