MCPcopy Create free account
hub / github.com/observablehq/framework / findModule

Function findModule

src/javascript/module.ts:223–229  ·  view source on GitHub ↗
(root: string, path: string)

Source from the content-addressed store, hash-verified

221}
222
223export function findModule(root: string, path: string): RouteResult | undefined {
224 const ext = extname(path);
225 if (!ext) throw new Error(`empty extension: ${path}`);
226 const exts = [ext];
227 if (ext === ".js") exts.push(".ts", ".jsx", ".tsx");
228 return route(root, path.slice(0, -ext.length), exts);
229}
230
231export async function readJavaScript(sourcePath: string): Promise<string> {
232 const source = await readFile(sourcePath, "utf-8");

Callers 9

renderModuleFunction · 0.85
readPagesFunction · 0.85
findPagePathsMethod · 0.85
findPageMethod · 0.85
getWatchPathMethod · 0.85
getDefaultSearchPathsFunction · 0.85
PreviewServerClass · 0.85
buildFunction · 0.85
getModuleInfoFunction · 0.85

Calls 1

routeFunction · 0.85

Tested by

no test coverage detected