fix(javascript): share source-map resolution and preserve path uncertainty

This commit is contained in:
morluto
2026-10-13 13:48:24 +08:00
parent 73dd8d6ed5
commit 3ae826ceba
16 changed files with 551 additions and 67 deletions
@@ -19,31 +19,6 @@ export const isBeforeSourceMapLeafStop = (
);
};
/** Resolve one declaration with the same pinned upstream implementation used by full maps. */
export const resolveSourceMapSource = (
source: string | null,
sourceRoot: string | null | undefined,
mapUrl: string,
): string => {
const map = new TraceMap(
{
version: 3,
names: [],
sources: [source ?? ""],
...(sourceRoot == null ? {} : { sourceRoot }),
mappings: "",
},
mapUrl,
);
const resolved = map.resolvedSources[0];
if (resolved === undefined)
throw new SourceMapFormatFailure(
"format",
"Source-map resolver did not return the requested source identity.",
);
return resolved;
};
/** Decode leaf mappings and validate producer indices before any consumer publishes them. */
export const decodeValidatedSourceMapLeaves = (
leaves: readonly SourceMapLeaf[],