mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 06:23:38 +00:00
unminify: Update for webpack chunk splitting.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
committed by
Anders Kaseorg
parent
2e1529e879
commit
f7245e9ec6
@@ -29,22 +29,23 @@ class SourceMap:
|
|||||||
out = '' # type: str
|
out = '' # type: str
|
||||||
for ln in stacktrace.splitlines():
|
for ln in stacktrace.splitlines():
|
||||||
out += ln + '\n'
|
out += ln + '\n'
|
||||||
match = re.search(r'/static/webpack-bundles/(.+)(\.[\.0-9a-f]+\.js):(\d+):(\d+)', ln)
|
match = re.search(r'/static/webpack-bundles/([^:]+):(\d+):(\d+)', ln)
|
||||||
if match:
|
if match:
|
||||||
# Get the appropriate source map for the minified file.
|
# Get the appropriate source map for the minified file.
|
||||||
minified_src = match.groups()[0] + match.groups()[1]
|
minified_src = match.groups()[0]
|
||||||
index = self._index_for(minified_src)
|
index = self._index_for(minified_src)
|
||||||
|
|
||||||
gen_line, gen_col = list(map(int, match.groups()[2:4]))
|
gen_line, gen_col = list(map(int, match.groups()[1:3]))
|
||||||
# The sourcemap lib is 0-based, so subtract 1 from line and col.
|
# The sourcemap lib is 0-based, so subtract 1 from line and col.
|
||||||
try:
|
try:
|
||||||
result = index.lookup(line=gen_line-1, column=gen_col-1)
|
result = index.lookup(line=gen_line-1, column=gen_col-1)
|
||||||
display_src = result.src
|
display_src = result.src
|
||||||
webpack_prefix = "webpack:///"
|
if display_src is not None:
|
||||||
if display_src.startswith(webpack_prefix):
|
webpack_prefix = "webpack:///"
|
||||||
display_src = display_src[len(webpack_prefix):]
|
if display_src.startswith(webpack_prefix):
|
||||||
out += (' = %s line %d column %d\n' %
|
display_src = display_src[len(webpack_prefix):]
|
||||||
(display_src, result.src_line+1, result.src_col+1))
|
out += (' = %s line %d column %d\n' %
|
||||||
|
(display_src, result.src_line+1, result.src_col+1))
|
||||||
except IndexError:
|
except IndexError:
|
||||||
out += ' [Unable to look up in source map]\n'
|
out += ' [Unable to look up in source map]\n'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user