MCPcopy Index your code
hub / github.com/ptmt/react-native-macos / createGraphHelpers

Function createGraphHelpers

packager/src/ModuleGraph/Graph.js:103–172  ·  view source on GitHub ↗
(loadQueue, skip)

Source from the content-addressed store, hash-verified

101};
102
103function createGraphHelpers(loadQueue, skip) {
104 const modules = new Map([[null, createParentModule()]]);
105
106 function collect(
107 path = null,
108 serialized = {entryModules: [], modules: []},
109 seen = new Set(),
110 ) {
111 const module = modules.get(path);
112 if (module == null || seen.has(path)) {
113 return serialized;
114 }
115
116 const {dependencies} = module;
117 if (path === null) {
118 serialized.entryModules =
119 dependencies.map(dep => nullthrows(modules.get(dep.path)));
120 } else {
121 serialized.modules.push(module);
122 seen.add(path);
123 }
124
125 for (const dependency of dependencies) {
126 collect(dependency.path, serialized, seen);
127 }
128
129 return serialized;
130 }
131
132 function loadModule(id, parent, parentDepIndex) {
133 loadQueue.push(
134 {id, parent},
135 (error, file, dependencyIDs) =>
136 onFileLoaded(error, file, dependencyIDs, id, parent, parentDepIndex),
137 );
138 }
139
140 function onFileLoaded(
141 error,
142 file,
143 dependencyIDs,
144 id,
145 parent,
146 parentDependencyIndex,
147 ) {
148 if (error) {
149 return;
150 }
151
152 const {path} = nullthrows(file);
153 dependencyIDs = nullthrows(dependencyIDs);
154
155 const parentModule = modules.get(parent);
156 invariant(parentModule, 'Invalid parent module: ' + String(parent));
157 parentModule.dependencies[parentDependencyIndex] = {id, path};
158
159 if ((!skip || !skip.has(path)) && !modules.has(path)) {
160 const module = {

Callers 1

GraphFunction · 0.85

Calls 1

createParentModuleFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…