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

Đang mở
#564 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 5 ngày

@RaphaelFakhri đang làm issue này rồi.

Từ ngày 4/11/2026.

  • #565 của @RaphaelFakhri — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
30/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
javascript
Lĩnh vực
devtools

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
JavaScript
Star
3.7k
Fork
392
Merge trung bình
4 ngày 18 giờ
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của mozilla/source-map

Tất cả issue của mozilla/source-map

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.