| 2316 | }); |
| 2317 | } |
| 2318 | function upsertGraphModule(rawId: string, code: string, deps: string[]) { |
| 2319 | const id = normalizeGraphId(rawId); |
| 2320 | const normDeps = deps |
| 2321 | .map((d) => normalizeGraphId(d)) |
| 2322 | .filter(Boolean) |
| 2323 | .slice() |
| 2324 | .sort(); |
| 2325 | const hash = computeHash(code); |
| 2326 | const existing = graph.get(id); |
| 2327 | if (existing && existing.hash === hash && existing.deps.length === normDeps.length && existing.deps.every((d, i) => d === normDeps[i])) return; // unchanged |
| 2328 | graphVersion++; |
| 2329 | const gm: GraphModule = { id, deps: normDeps, hash }; |
| 2330 | graph.set(id, gm); |
| 2331 | if (verbose) { |
| 2332 | try { |
| 2333 | console.log('[hmr-ws][graph] upsert', { id, deps: normDeps, hash, graphVersion }); |
| 2334 | console.log('[hmr-ws][graph] size', graph.size); |
| 2335 | } catch {} |
| 2336 | } |
| 2337 | emitDelta([gm], []); |
| 2338 | } |
| 2339 | function isTypescriptFlavor(): boolean { |
| 2340 | try { |
| 2341 | return ACTIVE_STRATEGY?.flavor === 'typescript'; |