Load the built dist — the probe measures the shipping allocator, not src.
()
| 52 | |
| 53 | /** Load the built dist — the probe measures the shipping allocator, not src. */ |
| 54 | async function loadDist() { |
| 55 | const distIndex = join(REPO_ROOT, 'dist/index.js'); |
| 56 | if (!existsSync(distIndex)) { |
| 57 | console.error('dist/ not built — run `npm run build` first.'); |
| 58 | process.exit(2); |
| 59 | } |
| 60 | const idx = await import(pathToFileURL(distIndex).href); |
| 61 | const tools = await import(pathToFileURL(join(REPO_ROOT, 'dist/mcp/tools.js')).href); |
| 62 | // esModuleInterop: dynamic import of CJS yields { default: module.exports, ...named } |
| 63 | const CodeGraph = idx.default?.default ?? idx.default ?? idx.CodeGraph; |
| 64 | const ToolHandler = tools.ToolHandler ?? tools.default?.ToolHandler; |
| 65 | if (typeof CodeGraph?.openSync !== 'function' || typeof ToolHandler !== 'function') { |
| 66 | console.error('could not resolve CodeGraph/ToolHandler from dist/'); |
| 67 | process.exit(2); |
| 68 | } |
| 69 | return { CodeGraph, ToolHandler }; |
| 70 | } |
| 71 | |
| 72 | /** `internal/gen/**` → /^internal\/gen\/.*$/ . Supports `**`, `*` and literals. */ |
| 73 | function globToRegExp(glob) { |