fix(sourcemaps)!: preserve nullable source declarations
Accept absent map-level sourcesContent and preserve null source-name slots alongside known originals and aligned content. Represent unnamed local declarations explicitly, retain leaf-local and flattened indices, and preserve declared indexed-section order across consumers. Account for added indices before browser output allocation. Accept legacy retained rows without indices. Consolidate public CLI/MCP source-map fixtures and update the stale named-source-only assertion. BREAKING CHANGE: Browser source-map original and mapping rows expose null for unavailable source names instead of inventing an unknown-source string. New index fields are optional when reading older retained evidence. Refs #2023, #2024
This commit is contained in:
@@ -751,7 +751,7 @@ describe("web source-map sourcesContent validation", () => {
|
||||
JSON.stringify({
|
||||
version: 3,
|
||||
sources: ["source.ts"],
|
||||
sourcesContent: [null],
|
||||
sourcesContent: null,
|
||||
names: [],
|
||||
mappings: "",
|
||||
}),
|
||||
@@ -763,10 +763,61 @@ describe("web source-map sourcesContent validation", () => {
|
||||
expect(result.items[0]).toMatchObject({
|
||||
status: "included",
|
||||
original_sources: [
|
||||
{ source: `${origin}/assets/source.ts`, artifact: null },
|
||||
{
|
||||
source_index: 0,
|
||||
declaration_index: 0,
|
||||
source: `${origin}/assets/source.ts`,
|
||||
artifact: null,
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps unnamed source slots and mapping indices", async () => {
|
||||
const result = await fetchWebSourceMaps([request], input(), undefined, {
|
||||
fetch: () =>
|
||||
Promise.resolve(
|
||||
new Response(
|
||||
JSON.stringify({
|
||||
version: 3,
|
||||
sources: [null, "source.ts"],
|
||||
sourcesContent: ["unknown source text", "named source text"],
|
||||
names: [],
|
||||
mappings: "ACAA",
|
||||
}),
|
||||
{ status: 200 },
|
||||
),
|
||||
),
|
||||
});
|
||||
|
||||
expect(result.items[0]).toMatchObject({
|
||||
status: "partial",
|
||||
original_sources: [
|
||||
{
|
||||
source_index: 0,
|
||||
declaration_index: 0,
|
||||
source: null,
|
||||
artifact: { text: "unknown source text" },
|
||||
},
|
||||
{
|
||||
source_index: 1,
|
||||
declaration_index: 1,
|
||||
source: `${origin}/assets/source.ts`,
|
||||
artifact: { text: "named source text" },
|
||||
},
|
||||
],
|
||||
mappings: [
|
||||
{
|
||||
source_index: 1,
|
||||
declaration_index: 1,
|
||||
source: `${origin}/assets/source.ts`,
|
||||
},
|
||||
],
|
||||
});
|
||||
expect(result.items[0]?.limitation).toContain(
|
||||
"unnamed source at declaration 0",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("source-map original dependency syntax", () => {
|
||||
|
||||
@@ -345,7 +345,7 @@ it.each(cases)(
|
||||
item.mappings.map((entry) => [
|
||||
entry.generated_line,
|
||||
entry.generated_column,
|
||||
entry.source.replace(origin + "/", ""),
|
||||
entry.source?.replace(origin + "/", "") ?? null,
|
||||
]),
|
||||
).toEqual(expected);
|
||||
expect(item.artifact.sha256).toBe(
|
||||
|
||||
Reference in New Issue
Block a user