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

Aperta
#564 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 5 giorni

@RaphaelFakhri ci sta già lavorando.

Dal 4/11/2026.

  • #565 di @RaphaelFakhri — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
30/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
javascript
Ambito
devtools

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
JavaScript
Stelle
3.7k
Fork
392
Merge medio
4g 18h
PR unite (30g)
1

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di mozilla/source-map

Tutte le issue di mozilla/source-map

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.