diff --git a/src/javascript/sourceMaps/SourceMapFormat.ts b/src/javascript/sourceMaps/SourceMapFormat.ts index bebde09738..838c1082df 100644 --- a/src/javascript/sourceMaps/SourceMapFormat.ts +++ b/src/javascript/sourceMaps/SourceMapFormat.ts @@ -355,7 +355,10 @@ export const inspectSourceMapValue = ( } const leaf = inspectLeaf(node, budget, options); leaves.push({ map: leaf, offset: node.offset, stop: node.stop }); - if (options.profile !== "browser-collection") + if (options.profile !== "browser-collection") { + const ignoredSources = new Set( + leaf.ignoreList ?? leaf.x_google_ignoreList ?? [], + ); for (const [sourceIndex, source] of leaf.sources.entries()) declarations.push({ sectionPath: node.path, @@ -363,10 +366,9 @@ export const inspectSourceMapValue = ( source, root: leaf.sourceRoot ?? null, content: leaf.sourcesContent?.[sourceIndex] ?? null, - ignored: (leaf.ignoreList ?? leaf.x_google_ignoreList ?? []).includes( - sourceIndex, - ), + ignored: ignoredSources.has(sourceIndex), }); + } } return { format: root.sections === undefined ? "regular" : "indexed", diff --git a/src/javascript/sourceMaps/TraceSourceMap.test.ts b/src/javascript/sourceMaps/TraceSourceMap.test.ts index 0f3c6abdf0..ddb70b9fa4 100644 --- a/src/javascript/sourceMaps/TraceSourceMap.test.ts +++ b/src/javascript/sourceMaps/TraceSourceMap.test.ts @@ -29,6 +29,47 @@ it("traces BOM-prefixed maps with a source-map transport prefix ending in CR", ( }); }); +it("keeps ignore-list precedence and section-local indexes for duplicate sources", () => { + const map = { + version: 3, + sections: [ + { + offset: { line: 0, column: 0 }, + map: { + ...leaf, + sources: ["same.ts", "same.ts"], + sourcesContent: ["first", "second"], + mappings: "AAAA,ACAA", + ignoreList: [1, 1], + x_google_ignoreList: [0], + }, + }, + { + offset: { line: 1, column: 0 }, + map: { ...leaf, x_google_ignoreList: [0] }, + }, + { + offset: { line: 2, column: 0 }, + map: { ...leaf, ignoreList: [], x_google_ignoreList: [0] }, + }, + ], + }; + expect(trace(map).matches).toMatchObject([ + { source_index: 0, ignored: false, content: { text: "first" } }, + { source_index: 1, ignored: true, content: { text: "second" } }, + ]); + expect(trace(map, { line: 2, column: 0 }).matches[0]).toMatchObject({ + section_path: [1], + source_index: 0, + ignored: true, + }); + expect(trace(map, { line: 3, column: 0 }).matches[0]).toMatchObject({ + section_path: [2], + source_index: 0, + ignored: false, + }); +}); + describe("upstream source-map point evidence", () => { it("preserves every duplicate-column/source-URL candidate and its own embedded bytes", () => { const report = trace({