parseExtRef
An external reference as a definition's dependencies write it (npm:x@1/sub#name), read back.
import type { ExtRef } from "#codebase/tcmts/core/types"; export function parseExtRef(ref: string): ExtRef | undefined { const m = /^((?:npm|node|tcm):(?:@[^/]+\/)?[^/#]+)(?:\/([^#]*))?#(.+)$/.exec(ref); return m ? { module: m[1]!, subpath: m[2] ?? "", export: m[3]! } : undefined; }