MCPcopy Create free account
hub / github.com/ptmt/react-native-macos / getDependencies

Function getDependencies

local-cli/server/util/attachHMRServer.js:52–135  ·  view source on GitHub ↗
(platform: string, bundleEntry: string)

Source from the content-addressed store, hash-verified

50 // - The shallow dependencies each file on the dependency list has
51 // - Inverse shallow dependencies map
52 function getDependencies(platform: string, bundleEntry: string): Promise<{
53 dependenciesCache: Array<string>,
54 dependenciesModulesCache: {[mixed]: Module},
55 shallowDependencies: {[string]: Array<Module>},
56 inverseDependenciesCache: mixed,
57 resolutionResponse: ResolutionResponse<Module, *>,
58 }> {
59 return packagerServer.getDependencies({
60 dev: true,
61 entryFile: bundleEntry,
62 hot: true,
63 minify: false,
64 platform: platform,
65 recursive: true,
66 }).then(response => {
67 /* $FlowFixMe: getModuleId might be null */
68 const {getModuleId}: {getModuleId: () => number} = response;
69
70 // for each dependency builds the object:
71 // `{path: '/a/b/c.js', deps: ['modA', 'modB', ...]}`
72 return Promise.all(response.dependencies.map((dep: Module) => {
73 return dep.getName().then(depName => {
74 if (dep.isAsset() || dep.isJSON()) {
75 return Promise.resolve({path: dep.path, deps: []});
76 }
77 return packagerServer.getShallowDependencies({
78 dev: true,
79 entryFile: dep.path,
80 hot: true,
81 minify: false,
82 platform: platform,
83 recursive: true,
84 }).then(deps => {
85 return {
86 path: dep.path,
87 name: depName,
88 deps,
89 };
90 });
91 });
92 }))
93 .then((deps: Array<{path: string, name?: string, deps: Array<Module>}>) => {
94 // list with all the dependencies' filenames the bundle entry has
95 const dependenciesCache = response.dependencies.map(dep => dep.path);
96
97 // map from module name to path
98 const moduleToFilenameCache = Object.create(null);
99 deps.forEach(dep => {
100 /* $FlowFixMe: `name` could be null, but `deps` would be as well. */
101 moduleToFilenameCache[dep.name] = dep.path;
102 });
103
104 // map that indicates the shallow dependency each file included on the
105 // bundle has
106 const shallowDependencies = Object.create(null);
107 deps.forEach(dep => {
108 shallowDependencies[dep.path] = dep.deps;
109 });

Callers 1

attachHMRServerFunction · 0.70

Calls 10

getInverseDependenciesFunction · 0.85
fromMethod · 0.80
getNameMethod · 0.65
resolveMethod · 0.65
createMethod · 0.65
thenMethod · 0.45
getDependenciesMethod · 0.45
isAssetMethod · 0.45
isJSONMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…