* @param {string} entryPointModule * @return {!Promise }
(entryPointModule)
| 179 | * @return {!Promise<ModuleDef>} |
| 180 | */ |
| 181 | async function getModuleGraph(entryPointModule) { |
| 182 | const plugin = getEsbuildBabelPlugin('unminified', /* enableCache */ true); |
| 183 | const result = await esbuild.build({ |
| 184 | stdin: { |
| 185 | contents: entryPointModule, |
| 186 | resolveDir: '.', |
| 187 | }, |
| 188 | bundle: true, |
| 189 | write: false, |
| 190 | metafile: true, |
| 191 | plugins: [plugin], |
| 192 | }); |
| 193 | |
| 194 | const entryPoints = result.metafile?.inputs || []; |
| 195 | const moduleGraph = Object.create(null); |
| 196 | moduleGraph.name = entryPointModule; |
| 197 | moduleGraph.deps = []; |
| 198 | |
| 199 | for (const entryPoint in entryPoints) { |
| 200 | moduleGraph.deps.push({ |
| 201 | name: entryPoint, |
| 202 | deps: entryPoints[entryPoint].imports.map((dep) => dep.path), |
| 203 | }); |
| 204 | } |
| 205 | logLocalDev('Extracted module graph'); |
| 206 | return moduleGraph; |
| 207 | } |
| 208 | |
| 209 | /** |
| 210 | * @param {string} extensionFolder |
no test coverage detected