-
Notifications
You must be signed in to change notification settings - Fork 46.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Account for Error stack frames having source maps already applied
Refactored code to account for the fact that, in some environments, Error stack frames will already have source maps applied (so the code does not need to re-map line and column numbers).
- Loading branch information
Brian Vaughn
committed
Jun 28, 2021
1 parent
a0de8da
commit 750bf77
Showing
8 changed files
with
162 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
|
||
import ErrorStackParser from 'error-stack-parser'; | ||
import testErrorStack, { | ||
SOURCE_STACK_FRAME_LINE_NUMBER, | ||
} from './ErrorTesterCompiled'; | ||
|
||
// Source maps are automatically applied to Error stack frames. | ||
export let sourceMapsAreAppliedToErrors: boolean = false; | ||
|
||
try { | ||
testErrorStack(); | ||
} catch (error) { | ||
const parsed = ErrorStackParser.parse(error); | ||
const topStackFrame = parsed[0]; | ||
const lineNumber = topStackFrame.lineNumber; | ||
if (lineNumber === SOURCE_STACK_FRAME_LINE_NUMBER) { | ||
sourceMapsAreAppliedToErrors = true; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
packages/react-devtools-extensions/src/ErrorTesterCompiled.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.