MCPcopy
hub / github.com/ampproject/amphtml / getModuleGraph

Function getModuleGraph

build-system/tasks/dep-check.js:181–207  ·  view source on GitHub ↗

* @param {string} entryPointModule * @return {!Promise }

(entryPointModule)

Source from the content-addressed store, hash-verified

179 * @return {!Promise<ModuleDef>}
180 */
181async 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

Callers 1

depCheckFunction · 0.85

Calls 5

getEsbuildBabelPluginFunction · 0.85
logLocalDevFunction · 0.85
buildMethod · 0.45
createMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected