Unverified Commit 270744b7 authored by Sebastian "Sebbie" Silbermann's avatar Sebastian "Sebbie" Silbermann Committed by GitHub

[build-sourcemaps] Only compute codeframe once (#80326)

parent e74a8245
...@@ -275,12 +275,6 @@ function getSourcemappedFrameIfPossible( ...@@ -275,12 +275,6 @@ function getSourcemappedFrameIfPossible(
} }
} }
const sourceContent: string | null =
sourceMapConsumer.sourceContentFor(
sourcePosition.source,
/* returnNullOnMissing */ true
) ?? null
const applicableSourceMap = findApplicableSourceMapPayload( const applicableSourceMap = findApplicableSourceMapPayload(
frame, frame,
sourceMapPayload sourceMapPayload
...@@ -321,16 +315,33 @@ function getSourcemappedFrameIfPossible( ...@@ -321,16 +315,33 @@ function getSourcemappedFrameIfPossible(
ignored, ignored,
} }
const codeFrame = getOriginalCodeFrame( /** undefined = not yet computed*/
originalFrame, let codeFrame: string | null | undefined
sourceContent,
inspectOptions.colors
)
return { return Object.defineProperty(
stack: originalFrame, {
code: codeFrame, stack: originalFrame,
} code: null,
},
'code',
{
get: () => {
if (codeFrame === undefined) {
const sourceContent: string | null =
sourceMapConsumer.sourceContentFor(
sourcePosition.source,
/* returnNullOnMissing */ true
) ?? null
codeFrame = getOriginalCodeFrame(
originalFrame,
sourceContent,
inspectOptions.colors
)
}
return codeFrame
},
}
)
} }
function parseAndSourceMap( function parseAndSourceMap(
...@@ -372,10 +383,10 @@ function parseAndSourceMap( ...@@ -372,10 +383,10 @@ function parseAndSourceMap(
) )
if ( if (
sourcemappedFrame.code !== null &&
sourceFrame === null && sourceFrame === null &&
// TODO: Is this the right choice? // TODO: Is this the right choice?
!sourcemappedFrame.stack.ignored !sourcemappedFrame.stack.ignored &&
sourcemappedFrame.code !== null
) { ) {
sourceFrame = sourcemappedFrame.code sourceFrame = sourcemappedFrame.code
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment