Source maps mapping looks wrong when using Webpack
Chưa có ai nhận issue này.
Đá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
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript, typescript, webpack
- Lĩnh vực
- devtools
Hướng nghiên cứu
Bắt đầu với project bên ngoài test-source-maps và kiểm tra dist/bundle.js.map cùng với các lời gọi generatedPositionFor() và originalPositionFor() được hiển thị trong issue. So sánh các mapping được trả về với các yêu cầu của source-map API và cấu hình Webpack; hoàn tất khi xác định được round trip có hợp lệ hay đã nhận diện được một lỗi mapping/cấu hình có thể tái hiện.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hello,
I've been experimenting with this repository. I tried to generate a simple project to use source maps using Webpack: https://github.com/eloparco/test-source-maps, where I produce a js bundle starting from Typescript and I want to use source maps for the mapping between the two.
I tried to play around with the generated source maps:
const SourceMapConsumer = require("source-map").SourceMapConsumer;
const fs = require("fs");
const SOURCEMAP_ABSOUTE_PATH = "/path/to/test-source-maps/dist/bundle.js.map";
const ORIGINAL_ABSOLUTE_PATH = "/path/to/test-source-maps/src/index.ts";
const GENERATED_ABSOLUTE_PATH = "/path/to/test-source-maps/dist/bundle.js";
const ORIGINAL_LINE = 11;
let json = JSON.parse(fs.readFileSync(SOURCEMAP_ABSOUTE_PATH).toString());
SourceMapConsumer.with(json, null, (consumer) => {
console.log(consumer.sources);
const generated = consumer.generatedPositionFor({
source: ORIGINAL_ABSOLUTE_PATH,
line: ORIGINAL_LINE,
column: 0,
});
console.log(generated);
const original = consumer.originalPositionFor({
line: generated.line,
column: generated.column,
});
console.log(original);
assert(original.line === ORIGINAL_LINE); // <------------ This assertion fails!!!
});
Here I use generatedPositionFor() to get the mapping from the original .ts file to the corresponding .js file. Then, I try to do the opposite and feed the line and column previously retrieved to originalPositionFor(), expecting it to return the original line/column that I passed to generatedPositionFor(). But that doesn't happen.
Is my understanding of source maps wrong? Or am I doing something wrong in the Webpack configuration?
Thanks
- 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
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của mozilla/source-map
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
mozilla/source-map#530 ·
-
allow wasm to be bundled Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
mozilla/source-map#527 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
mozilla/source-map#524 · 6 bình luận ·
-
source map seems like not work, is there some hints from the perspective of source-map tool? Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
mozilla/source-map#516 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
mozilla/source-map#510 · 1 reaction ·
Tất cả issue của mozilla/source-map
Issue tương tự
-
bug confirmed issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
open-webui/open-webui#30750 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Mend: dependency security vulnerability untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100