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

Ouverte
#564 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 5 jours

@RaphaelFakhri y travaille déjà.

Depuis le 4/11/2026.

  • #565 par @RaphaelFakhri — ouverte

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
30/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
À l'abandon
Stack technique
javascript
Domaine
devtools

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.

Langage dominant
JavaScript
Étoiles
3.7k
Forks
392
Merge moyen
4 j 18 h
PR mergées (30 j)
1

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de mozilla/source-map

Toutes les issues de mozilla/source-map

Issues similaires

Plus d'issues JavaScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.