MCPcopy Create free account
hub / github.com/vercel/vercel / resolveEntrypoint

Function resolveEntrypoint

packages/node/src/bundling-handler.js:55–69  ·  view source on GitHub ↗

* Resolve an extensionless entrypoint to an actual file path. * Tries common JS extensions in order, returning the first match.

(name)

Source from the content-addressed store, hash-verified

53 * Tries common JS extensions in order, returning the first match.
54 */
55function resolveEntrypoint(name) {
56 const base = resolve('./' + name);
57 for (const ext of ['.js', '.cjs', '.mjs']) {
58 const p = base + ext;
59 if (existsSync(p)) return p;
60 }
61 // If base is a directory, look for index files inside it
62 if (existsSync(base)) {
63 for (const ext of ['.js', '.cjs', '.mjs']) {
64 const p = resolve(base, 'index' + ext);
65 if (existsSync(p)) return p;
66 }
67 }
68 return null;
69}
70
71/**
72 * Load a module via dynamic import(). Works for both CJS and ESM regardless

Callers 1

Calls 1

resolveFunction · 0.70

Tested by

no test coverage detected