Indexed source maps: allGeneratedPositionsFor only returns positions from the first section that contains the source

Aberta
#564 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 5 dias

@RaphaelFakhri já está trabalhando nisso.

Desde 4/11/2026.

  • #565 de @RaphaelFakhri — aberto

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
30/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Estagnada
Stack de tecnologia
javascript
Domínio
devtools

Direção de pesquisa

Start at IndexedSourceMapConsumer.prototype.allGeneratedPositionsFor and compare how it searches sections with how eachMapping reports mappings from both. Reproduce the example with two sections listing shared.js, then check that the result contains positions from both sections: lines 1 and 3, with columns 0 and 4. An open pull request (#565) is already linked to this issue.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

IndexedSourceMapConsumer.prototype.allGeneratedPositionsFor looks up the first section whose map lists the requested source and returns positions from that section only. When the same original source appears in more than one section, for example a shared helper module that two concatenated chunks both include, positions in the later sections are missing from the result. Tools that use this method to set breakpoints on an original line miss those generated locations.

Steps to reproduce

const { SourceMapConsumer } = require("source-map");

(async () => {
  const map = await new SourceMapConsumer({
    version: 3,
    file: "min.js",
    sections: [
      {
        offset: { line: 0, column: 0 },
        map: { version: 3, sources: ["shared.js"], names: [], mappings: "AAAA" },
      },
      {
        offset: { line: 2, column: 4 },
        map: { version: 3, sources: ["shared.js"], names: [], mappings: "AAAA" },
      },
    ],
  });
  console.log(
    map.allGeneratedPositionsFor({ source: "shared.js", line: 1, column: 0 })
  );
  map.destroy();
})();

Expected result

[ { line: 1, column: 0, lastColumn: null }, { line: 3, column: 4, lastColumn: null } ]

Actual result

[ { line: 1, column: 0, lastColumn: null } ]

map.sources lists shared.js twice, and eachMapping reports both mappings, so only allGeneratedPositionsFor drops the second one.

Reproduced on master at 8c668f3.

Linguagem predominante
JavaScript
Estrelas
3.7k
Forks
392
Merge médio
4d 18h
PRs com merge (30d)
1

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de mozilla/source-map

Todas as issues de mozilla/source-map

Issues semelhantes

Mais issues de JavaScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.