(platform: string, bundleEntry: string)
| 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 | }); |
no test coverage detected
searching dependent graphs…