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

未关闭
#564 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 5 天内回复

@RaphaelFakhri 已经在做这个了。

开始于 2026年11月4日。

  • #565 来自 @RaphaelFakhri —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
30/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
javascript
领域
devtools

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
JavaScript
星标
3.7k
派生
392
平均合并
4 天 18 小时
30 天内合并 PR
1

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

mozilla/source-map 的其他 Issue

查看 mozilla/source-map 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。