Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

TypeError when creating a SourceMapGenerator from a SourceMapConsumer of an index map

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

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
45/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
tooling

Hướng nghiên cứu

Bắt đầu với lib/source-map-generator.js quanh fromSourceMap và lib/util.js quanh relative, sau đó tái hiện lỗi bằng ví dụ test.js trong issue. Thêm một bài kiểm thử hồi quy cho việc chuyển đổi một SourceMapConsumer của index-map, đồng thời xem xét các phép so sánh sourceRoot hiện có. Công việc được xem là hoàn tất khi quá trình chuyển đổi không còn phát sinh lỗi và các bài kiểm thử liên quan đều đạt.

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

Mô tả

needs-triage

When calling SourceMapGenerator.fromSourceMap with a SourceMapConsumer for an index map, the following error is thrown:

TypeError: Cannot read property 'replace' of undefined
    at Object.relative (C:\dev\scratch\source-map-test\node_modules\source-map\lib\util.js:255:17)
    at C:\dev\scratch\source-map-test\node_modules\source-map\lib\source-map-generator.js:75:31
    at Array.forEach (<anonymous>)
    at Function.fromSourceMap (C:\dev\scratch\source-map-test\node_modules\source-map\lib\source-map-generator.js:72:32)
    at test (C:\dev\scratch\source-map-test\test.js:17:52)
    at <anonymous>

test.js

const sourcemap = require("source-map");
async function test() {
    const map = { 
        file: "generated.js",
        version: 3,
        sections: [
            { offset: { column: 0, line: 0 }, map: {
                file: "part.js",
                version: 3,
                sources: ["source.js"],
                mappings: "",
                names: []
            } }
        ]
    };
    const consumer = await new sourcemap.SourceMapConsumer(map);
    const generator = sourcemap.SourceMapGenerator.fromSourceMap(consumer); // TypeError
}

The error seems to be due to a strict inequality (!==) check on sourceRoot whereas all other checks against sourceRoot use loose inequality (!=).

Ngôn ngữ chính
JavaScript
Star
3.7k
Fork
370
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

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.