-
Notifications
You must be signed in to change notification settings - Fork 46.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DevTools] Print component stacks as error objects to get source mapping #30289
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,6 +73,10 @@ module.exports = { | |
__EXTENSION__: false, | ||
__PROFILE__: false, | ||
__TEST__: NODE_ENV === 'test', | ||
// TODO: Should this be feature tested somehow? | ||
__IS_CHROME__: false, | ||
__IS_FIREFOX__: false, | ||
__IS_EDGE__: false, | ||
Comment on lines
+76
to
+79
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ugh, Will update this later There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not quite sure why more of these weren't reached and subsequently errored before. Not sure why just the ones I added mattered. |
||
'process.env.DEVTOOLS_PACKAGE': `"react-devtools-inline"`, | ||
'process.env.DEVTOOLS_VERSION': `"${DEVTOOLS_VERSION}"`, | ||
'process.env.EDITOR_URL': EDITOR_URL != null ? `"${EDITOR_URL}"` : null, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,12 +29,19 @@ export function describeBuiltInComponentFrame(name: string): string { | |
prefix = (match && match[1]) || ''; | ||
} | ||
} | ||
let suffix = ''; | ||
if (__IS_CHROME__ || __IS_EDGE__) { | ||
suffix = ' (<anonymous>)'; | ||
} else if (__IS_FIREFOX__) { | ||
suffix = '@unknown:0:0'; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Chrome parses the name as the location if it doesn't have one. Firefox skips lines that don't have location so we need to add a fake one which can be anything really. I don't think there's any special case that doesn't linkify it. Safari is fine without it. |
||
// We use the prefix to ensure our stacks line up with native stack frames. | ||
return '\n' + prefix + name; | ||
// We use a suffix to ensure it gets parsed natively. | ||
return '\n' + prefix + name + suffix; | ||
} | ||
|
||
export function describeDebugInfoFrame(name: string, env: ?string): string { | ||
return describeBuiltInComponentFrame(name + (env ? ' (' + env + ')' : '')); | ||
return describeBuiltInComponentFrame(name + (env ? ' [' + env + ']' : '')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because parenthesis are parsed as part of the location in Chrome we need to replace those with brackets. Not sure why I used parenthesis in the first place really. |
||
} | ||
|
||
let reentry = false; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,8 @@ export function describeFiber( | |
currentDispatcherRef: CurrentDispatcherRef, | ||
): string { | ||
const { | ||
HostHoistable, | ||
HostSingleton, | ||
HostComponent, | ||
LazyComponent, | ||
SuspenseComponent, | ||
|
@@ -40,6 +42,8 @@ export function describeFiber( | |
} = workTagMap; | ||
|
||
switch (workInProgress.tag) { | ||
case HostHoistable: | ||
case HostSingleton: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was missing previously leading to missing frames for html/body which lead to mismatches. |
||
case HostComponent: | ||
return describeBuiltInComponentFrame(workInProgress.type); | ||
case LazyComponent: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will probably add
__IS_NATIVE__
here as well.