fix(source-maps): reuse admitted source URL identities

This commit is contained in:
morluto committed 2026-10-24 00:01:19 +08:00
1 parent 7fbc2b5652
commit 9066444f6b
7 files changed
+180 -91

No files matched your search

@@ -1,11 +1,10 @@
import { expect, it } from "vitest";
import { TraceMap } from "@jridgewell/trace-mapping";
import { analyzeJavaScriptArtifactFiles } from "./JavaScriptArtifactAnalysis.js";
const HASH = "a".repeat(64);
it("retains batched TraceMap-resolved paths and null source positions", () => {
it("retains resolved source declarations, Unicode spelling and null source positions", () => {
const sourceMapText = JSON.stringify({
version: 3,
file: "main.js",
@@ -35,20 +34,6 @@ it("retains batched TraceMap-resolved paths and null source positions", () => {
});
const originals = analysis.source_maps[0]?.sources;
const original = originals?.[0];
const producerPath = new TraceMap(
{
version: 3,
file: "main.js",
sourceRoot: "../src/",
sources: ["cafe\u0301.ts", "", "other.ts"],
names: [],
mappings: "",
},
"file:///artifact/dist/main.js.map",
).resolvedSources[0];
if (producerPath === undefined)
throw new Error("TraceMap should resolve its single source declaration");
expect(originals?.[1]?.reference).toBeNull();
expect(originals?.[2]?.reference?.resolution).toEqual({
kind: "artifact-relative",
@@ -63,10 +48,4 @@ it("retains batched TraceMap-resolved paths and null source positions", () => {
path: "src/cafe\u0301.ts",
},
});
expect(original?.reference?.resolution).toEqual({
kind: "artifact-relative",
path: decodeURIComponent(
new URL(producerPath).pathname.slice("/artifact/".length),
),
});
});