Unable to parse webpack source URLs, how to work around around?
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/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
- Lĩnh vực
- tooling
Hướng nghiên cứu
Bắt đầu với đường dẫn bị lỗi trong lib/util.js quanh dòng 181, sau đó lần theo các hàm gọi nó trong source-map-consumer.js quanh các dòng 206-207 và ví dụ webpack source-map được cung cấp. Tái hiện lỗi phân tích URL bằng mã TypeScript được cung cấp và kiểm tra cách các source đã được phân tích được truyền vào computeSourceURL. Hoàn thành khi các source URL của webpack không còn gây ra lỗi giải mã được báo cáo.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
It looks like it's failing right here:
https://github.com/mozilla/source-map/blob/60adcb064bf033702d954d6d3f9bc3635dcb744b/lib/util.js#L181
I have this code for parsing the string sourcemap from a JS file, but it's not working:
const CACHE: Record<string, SourceMapConsumer> = {}
async function loadFile(
line: string,
): Promise<SourceMapConsumer | void> {
const link = CACHE[`${line}`]
if (link) {
return link
}
const res = await fetch(line)
const text = await res.text()
const last = text.trim().split('\n').pop() ?? ''
console.log(text)
console.log(last)
if (
last.match(
/(\/\/# sourceMappingURL=data:application\/json;charset=utf-8;base64,)/,
)
) {
console.log(last.slice(RegExp.$1.length))
const json = JSON.parse(
atob(last.slice(RegExp.$1.length)),
) as RawSourceMap
json.sources.forEach((source, i) => {
json.sources[i] = source.replace(/^webpack:\/\//g, 'http://')
})
console.log(json)
const sm = await new SourceMapConsumer(json)
CACHE[`${line}`] = sm
return sm
}
}
async function readFileLocation(
file: string,
line: number,
rise: number,
): Promise<[string, number | undefined, number | undefined]> {
const link = await loadFile(file)
const trace = {
column: rise,
filename: file,
line: line,
}
if (link) {
const token = link.originalPositionFor(trace)
if (token.source) {
return [
token.source,
token.line == null ? undefined : token.line,
token.column == null ? undefined : token.column,
]
} else {
return [file, line, rise]
}
} else {
return [file, line, rise]
}
}
export async function testSourceMaps(error: Error): Promise<string> {
const stack = getFileLineColumn(error.stack?.split('\n') ?? [])
const list: Array<string> = []
for (const data of stack) {
const [file, line, column] = await readFileLocation(
data.file,
data.line ?? 0,
data.column ?? 0,
)
console.log(file, line, column)
}
}
As you can see in the example, I tried to replace webpack:// with http:// but it didn't seem to help:
json.sources[i] = source.replace(/^webpack:\/\//g, 'http://')
How do I get this working, any suggestions? The error I'm getting is:
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'decode')
at new URLStateMachine (url-state-machine.js:546:1)
at module.exports.basicURLParse (url-state-machine.js:1264:1)
at new URLImpl (URL-impl.js:13:1)
at Object.setup (URL.js:317:1)
at new URL (URL.js:26:1)
at util.js:179:1
at Object.computeSourceURL (util.js:431:1)
at source-map-consumer.js:207:1
at Array.map (<anonymous>)
at source-map-consumer.js:206:1
The JSON looks liek this when I parse the sourcemap in this fashion:
Any help would be greatly appreciated. Thank you.
- 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
Chuẩn bị môi trường
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 good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
amponce/archive-movie-browser#354 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
saayam-for-all/webapp#1870 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Imageomics/OpenCite#66 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
chr15m/twiiit.com#20 ·
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
antropos17/Aegis#629 ·
Maintainer thường phản hồi trong vòng 4 ngày