Skip to content

Commit a85ec04

Browse files
sebmarkbageeps1lon
andauthored
[DevTools] Ignore List Stack Traces (#34210)
Co-authored-by: Sebastian Sebbie Silbermann <sebastian.silbermann@vercel.com>
1 parent 7d29ecb commit a85ec04

File tree

15 files changed

+89
-61
lines changed

15 files changed

+89
-61
lines changed

fixtures/flight/config/webpack.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const TerserPlugin = require('terser-webpack-plugin');
1515
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
1616
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
1717
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
18+
const DevToolsIgnorePlugin = require('devtools-ignore-webpack-plugin');
1819
const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent');
1920
const paths = require('./paths');
2021
const modules = require('./modules');
@@ -685,6 +686,15 @@ module.exports = function (webpackEnv) {
685686
},
686687
}),
687688
// Fork Start
689+
new DevToolsIgnorePlugin({
690+
shouldIgnorePath: function (path) {
691+
return (
692+
path.includes('/node_modules/') ||
693+
path.includes('/webpack/') ||
694+
path.endsWith('/src/index.js')
695+
);
696+
},
697+
}),
688698
new ReactFlightWebpackPlugin({
689699
isServer: false,
690700
clientReferences: {

fixtures/flight/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"concurrently": "^7.3.0",
3030
"css-loader": "^6.5.1",
3131
"css-minimizer-webpack-plugin": "^3.2.0",
32+
"devtools-ignore-webpack-plugin": "^0.2.0",
3233
"dotenv": "^10.0.0",
3334
"dotenv-expand": "^5.1.0",
3435
"file-loader": "^6.2.0",

fixtures/flight/server/region.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ function filterStackFrame(sourceURL, functionName) {
5858
sourceURL !== '' &&
5959
!sourceURL.startsWith('node:') &&
6060
!sourceURL.includes('node_modules') &&
61-
!sourceURL.endsWith('library.js')
61+
!sourceURL.endsWith('library.js') &&
62+
!sourceURL.includes('/server/region.js')
6263
);
6364
}
6465

fixtures/flight/yarn.lock

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4614,6 +4614,11 @@ detect-port-alt@^1.1.6:
46144614
address "^1.0.1"
46154615
debug "^2.6.0"
46164616

4617+
devtools-ignore-webpack-plugin@^0.2.0:
4618+
version "0.2.0"
4619+
resolved "https://registry.yarnpkg.com/devtools-ignore-webpack-plugin/-/devtools-ignore-webpack-plugin-0.2.0.tgz#a7b3d1bd0f593c7fee5cbb7534b07860e5e2447c"
4620+
integrity sha512-4P+1Y1VhSt1MRBRF6my8N1bs9nNMOFfIFSBHI6u18W73iCHWXNHTSWYeMoQQ72PIIHrP1q4koKpYg1Em3jb9Rw==
4621+
46174622
didyoumean@^1.2.2:
46184623
version "1.2.2"
46194624
resolved "https://registry.yarnpkg.com/didyoumean/-/didyoumean-1.2.2.tgz#989346ffe9e839b4555ecf5666edea0d3e8ad037"
@@ -8650,16 +8655,7 @@ string-length@^5.0.1:
86508655
char-regex "^2.0.0"
86518656
strip-ansi "^7.0.1"
86528657

8653-
"string-width-cjs@npm:string-width@^4.2.0":
8654-
version "4.2.3"
8655-
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
8656-
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
8657-
dependencies:
8658-
emoji-regex "^8.0.0"
8659-
is-fullwidth-code-point "^3.0.0"
8660-
strip-ansi "^6.0.1"
8661-
8662-
string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
8658+
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
86638659
version "4.2.3"
86648660
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
86658661
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -8730,14 +8726,7 @@ string_decoder@^1.1.1:
87308726
dependencies:
87318727
safe-buffer "~5.2.0"
87328728

8733-
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
8734-
version "6.0.1"
8735-
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
8736-
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
8737-
dependencies:
8738-
ansi-regex "^5.0.1"
8739-
8740-
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
8729+
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
87418730
version "6.0.1"
87428731
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
87438732
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
@@ -9452,16 +9441,7 @@ wordwrap@~1.0.0:
94529441
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
94539442
integrity sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==
94549443

9455-
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
9456-
version "7.0.0"
9457-
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
9458-
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
9459-
dependencies:
9460-
ansi-styles "^4.0.0"
9461-
string-width "^4.1.0"
9462-
strip-ansi "^6.0.0"
9463-
9464-
wrap-ansi@^7.0.0:
9444+
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
94659445
version "7.0.0"
94669446
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
94679447
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==

packages/react-devtools-shared/src/__tests__/utils-test.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
401401
exports.f = f;
402402
function f() { }
403403
//# sourceMappingURL=`;
404-
const result = ['', 'http://test/a.mts', 1, 17];
404+
const result = {
405+
location: ['', 'http://test/a.mts', 1, 17],
406+
ignored: false,
407+
};
405408
const fs = {
406409
'http://test/a.mts': `export function f() {}`,
407410
'http://test/a.mjs.map': `{"version":3,"file":"a.mjs","sourceRoot":"","sources":["a.mts"],"names":[],"mappings":";;AAAA,cAAsB;AAAtB,SAAgB,CAAC,KAAI,CAAC"}`,

packages/react-devtools-shared/src/devtools/views/Components/InspectedElement.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
* @flow
88
*/
99

10+
import type {SourceMappedLocation} from 'react-devtools-shared/src/symbolicateSource';
11+
1012
import * as React from 'react';
1113
import {useCallback, useContext, useSyncExternalStore} from 'react';
1214
import {TreeStateContext} from './TreeContext';
@@ -28,8 +30,6 @@ import useEditorURL from '../useEditorURL';
2830

2931
import styles from './InspectedElement.css';
3032

31-
import type {ReactFunctionLocation} from 'shared/ReactTypes';
32-
3333
export type Props = {};
3434

3535
// TODO Make edits and deletes also use transition API!
@@ -61,7 +61,7 @@ export default function InspectedElementWrapper(_: Props): React.Node {
6161
? inspectedElement.stack[0]
6262
: null;
6363

64-
const symbolicatedSourcePromise: Promise<ReactFunctionLocation | null> =
64+
const symbolicatedSourcePromise: Promise<SourceMappedLocation | null> =
6565
React.useMemo(() => {
6666
if (fetchFileWithCaching == null) return noSourcePromise;
6767

packages/react-devtools-shared/src/devtools/views/Components/InspectedElementSourcePanel.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@ import {withPermissionsCheck} from 'react-devtools-shared/src/frontend/utils/wit
1717

1818
import useOpenResource from '../useOpenResource';
1919

20+
import type {SourceMappedLocation} from 'react-devtools-shared/src/symbolicateSource';
2021
import type {ReactFunctionLocation} from 'shared/ReactTypes';
2122
import styles from './InspectedElementSourcePanel.css';
2223

2324
import formatLocationForDisplay from './formatLocationForDisplay';
2425

2526
type Props = {
2627
source: ReactFunctionLocation,
27-
symbolicatedSourcePromise: Promise<ReactFunctionLocation | null>,
28+
symbolicatedSourcePromise: Promise<SourceMappedLocation | null>,
2829
};
2930

3031
function InspectedElementSourcePanel({
@@ -80,7 +81,7 @@ function CopySourceButton({source, symbolicatedSourcePromise}: Props) {
8081
);
8182
}
8283

83-
const [, sourceURL, line, column] = symbolicatedSource;
84+
const [, sourceURL, line, column] = symbolicatedSource.location;
8485
const handleCopy = withPermissionsCheck(
8586
{permissions: ['clipboardWrite']},
8687
() => copy(`${sourceURL}:${line}:${column}`),
@@ -98,11 +99,11 @@ function FormattedSourceString({source, symbolicatedSourcePromise}: Props) {
9899

99100
const [linkIsEnabled, viewSource] = useOpenResource(
100101
source,
101-
symbolicatedSource,
102+
symbolicatedSource == null ? null : symbolicatedSource.location,
102103
);
103104

104105
const [, sourceURL, line, column] =
105-
symbolicatedSource == null ? source : symbolicatedSource;
106+
symbolicatedSource == null ? source : symbolicatedSource.location;
106107

107108
return (
108109
<div

packages/react-devtools-shared/src/devtools/views/Components/InspectedElementView.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ import type {
3434
} from 'react-devtools-shared/src/frontend/types';
3535
import type {HookNames} from 'react-devtools-shared/src/frontend/types';
3636
import type {ToggleParseHookNames} from './InspectedElementContext';
37-
import type {ReactFunctionLocation} from 'shared/ReactTypes';
37+
import type {SourceMappedLocation} from 'react-devtools-shared/src/symbolicateSource';
3838

3939
type Props = {
4040
element: Element,
4141
hookNames: HookNames | null,
4242
inspectedElement: InspectedElement,
4343
parseHookNames: boolean,
4444
toggleParseHookNames: ToggleParseHookNames,
45-
symbolicatedSourcePromise: Promise<ReactFunctionLocation | null>,
45+
symbolicatedSourcePromise: Promise<SourceMappedLocation | null>,
4646
};
4747

4848
export default function InspectedElementView({

packages/react-devtools-shared/src/devtools/views/Components/InspectedElementViewSourceButton.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ import ButtonIcon from '../ButtonIcon';
1313
import Button from '../Button';
1414

1515
import type {ReactFunctionLocation} from 'shared/ReactTypes';
16+
import type {SourceMappedLocation} from 'react-devtools-shared/src/symbolicateSource';
1617

1718
import useOpenResource from '../useOpenResource';
1819

1920
type Props = {
2021
source: null | ReactFunctionLocation,
21-
symbolicatedSourcePromise: Promise<ReactFunctionLocation | null> | null,
22+
symbolicatedSourcePromise: Promise<SourceMappedLocation | null> | null,
2223
};
2324

2425
function InspectedElementViewSourceButton({
@@ -42,7 +43,7 @@ function InspectedElementViewSourceButton({
4243

4344
type ActualSourceButtonProps = {
4445
source: null | ReactFunctionLocation,
45-
symbolicatedSourcePromise: Promise<ReactFunctionLocation | null> | null,
46+
symbolicatedSourcePromise: Promise<SourceMappedLocation | null> | null,
4647
};
4748
function ActualSourceButton({
4849
source,
@@ -55,7 +56,7 @@ function ActualSourceButton({
5556

5657
const [buttonIsEnabled, viewSource] = useOpenResource(
5758
source,
58-
symbolicatedSource,
59+
symbolicatedSource == null ? null : symbolicatedSource.location,
5960
);
6061
return (
6162
<Button

packages/react-devtools-shared/src/devtools/views/Components/OpenInEditorButton.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ import Button from 'react-devtools-shared/src/devtools/views/Button';
1313
import ButtonIcon from 'react-devtools-shared/src/devtools/views/ButtonIcon';
1414

1515
import type {ReactFunctionLocation} from 'shared/ReactTypes';
16+
import type {SourceMappedLocation} from 'react-devtools-shared/src/symbolicateSource';
1617

1718
import {checkConditions} from '../Editor/utils';
1819

1920
type Props = {
2021
editorURL: string,
2122
source: ReactFunctionLocation,
22-
symbolicatedSourcePromise: Promise<ReactFunctionLocation | null>,
23+
symbolicatedSourcePromise: Promise<SourceMappedLocation | null>,
2324
};
2425

2526
function OpenInEditorButton({
@@ -31,7 +32,7 @@ function OpenInEditorButton({
3132

3233
const {url, shouldDisableButton} = checkConditions(
3334
editorURL,
34-
symbolicatedSource ? symbolicatedSource : source,
35+
symbolicatedSource ? symbolicatedSource.location : source,
3536
);
3637

3738
return (

0 commit comments

Comments
 (0)