MCPcopy Index your code
hub / github.com/getsentry/XcodeBuildMCP / importResourceModule

Function importResourceModule

src/core/manifest/import-resource-module.ts:24–54  ·  view source on GitHub ↗
(moduleId: string)

Source from the content-addressed store, hash-verified

22 * @returns Imported resource module with handler
23 */
24export async function importResourceModule(moduleId: string): Promise<ImportedResourceModule> {
25 const cached = moduleCache.get(moduleId);
26 if (cached) {
27 return cached;
28 }
29
30 const packageRoot = getPackageRoot();
31 const modulePath = path.join(packageRoot, 'build', `${moduleId}.js`);
32 const moduleUrl = pathToFileURL(modulePath).href;
33
34 let mod: Record<string, unknown>;
35 try {
36 mod = (await import(moduleUrl)) as Record<string, unknown>;
37 } catch (err) {
38 throw new Error(`Failed to import resource module '${moduleId}': ${err}`);
39 }
40
41 if (typeof mod.handler !== 'function') {
42 throw new Error(
43 `Resource module '${moduleId}' does not export the required shape. ` +
44 `Expected a named export: export const handler = ...`,
45 );
46 }
47
48 const result: ImportedResourceModule = {
49 handler: mod.handler as ImportedResourceModule['handler'],
50 };
51
52 moduleCache.set(moduleId, result);
53 return result;
54}
55
56/**
57 * Reset module cache (for tests).

Callers 1

loadResourcesFunction · 0.90

Calls 2

getPackageRootFunction · 0.90
getMethod · 0.80

Tested by

no test coverage detected