MCPcopy
hub / github.com/webpack/webpack / getUsedDependencies

Function getUsedDependencies

lib/wasm-sync/WebAssemblyUtils.js:31–65  ·  view source on GitHub ↗
(moduleGraph, module, mangle)

Source from the content-addressed store, hash-verified

29 * @returns {UsedWasmDependency[]} used dependencies and (mangled) name
30 */
31const getUsedDependencies = (moduleGraph, module, mangle) => {
32 /** @type {UsedWasmDependency[]} */
33 const array = [];
34 let importIndex = 0;
35 for (const dep of module.dependencies) {
36 if (dep instanceof WebAssemblyImportDependency) {
37 if (
38 dep.description.type === "GlobalType" ||
39 moduleGraph.getModule(dep) === null
40 ) {
41 continue;
42 }
43
44 const exportName = dep.name;
45 // TODO add the following 3 lines when removing of ModuleExport is possible
46 // const importedModule = moduleGraph.getModule(dep);
47 // const usedName = importedModule && moduleGraph.getExportsInfo(importedModule).getUsedName(exportName, runtime);
48 // if (usedName !== false) {
49 if (mangle) {
50 array.push({
51 dependency: dep,
52 name: Template.numberToIdentifier(importIndex++),
53 module: MANGLED_MODULE
54 });
55 } else {
56 array.push({
57 dependency: dep,
58 name: exportName,
59 module: dep.request
60 });
61 }
62 }
63 }
64 return array;
65};
66
67module.exports.MANGLED_MODULE = MANGLED_MODULE;
68module.exports.getUsedDependencies = getUsedDependencies;

Callers

nothing calls this directly

Calls 3

numberToIdentifierMethod · 0.80
getModuleMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected