Skip to content

Commit 2b29b18

Browse files
vzaidmanfacebook-github-bot
authored andcommitted
Scope INTERNAL_CALLSITES_REGEX to the react-native package (#58577)
Summary: The `INTERNAL_CALLSITES_REGEX` entries like `/Libraries/Core/.+\.js$` match any path containing that substring, including unrelated packages that happen to have a `Libraries/` directory. Prefixing them with `/react-native/` is always correct: these files ship inside the `react-native` package, so they appear either as `.../packages/react-native/Libraries/...` in the monorepo or as `.../node_modules/react-native/Libraries/...` in installs. Unrelated third-party frames are no longer collapsed as internal. Changelog: [General][Fixed] - Scope Metro `INTERNAL_CALLSITES_REGEX` to the `react-native` package to avoid collapsing unrelated frames Differential Revision: D120179017
1 parent a408526 commit 2b29b18

3 files changed

Lines changed: 49 additions & 22 deletions

File tree

‎packages/metro-config/package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
},
2121
"exports": {
2222
".": "./src/index.js",
23-
"./package.json": "./package.json"
23+
"./package.json": "./package.json",
24+
"./src/internalCallsites": "./src/internalCallsites.js"
2425
},
2526
"publishConfig": {
2627
"exports": {

‎packages/metro-config/src/index.flow.js‎

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,13 @@
1010

1111
import type {ConfigT, InputConfigT} from 'metro-config';
1212

13+
import {INTERNAL_CALLSITES_PATTERNS} from './internalCallsites';
1314
import {getDefaultConfig as getBaseConfig, mergeConfig} from 'metro-config';
1415

1516
export type {MetroConfig} from 'metro-config';
1617

1718
const INTERNAL_CALLSITES_REGEX = new RegExp(
18-
[
19-
'/Libraries/BatchedBridge/MessageQueue\\.js$',
20-
'/Libraries/Core/.+\\.js$',
21-
'/Libraries/LogBox/.+\\.js$',
22-
'/Libraries/Network/.+\\.js$',
23-
'/Libraries/Pressability/.+\\.js$',
24-
'/Libraries/Renderer/implementations/.+\\.js$',
25-
'/Libraries/Utilities/.+\\.js$',
26-
'/Libraries/vendor/.+\\.js$',
27-
'/Libraries/WebSocket/.+\\.js$',
28-
'/src/private/renderer/errorhandling/.+\\.js$',
29-
'/metro-runtime/.+\\.js$',
30-
'/node_modules/@babel/runtime/.+\\.js$',
31-
'/node_modules/@react-native/js-polyfills/.+\\.js$',
32-
'/node_modules/invariant/.+\\.js$',
33-
'/node_modules/react-devtools-core/.+\\.js$',
34-
'/node_modules/react-native/index.js$',
35-
'/node_modules/react-refresh/.+\\.js$',
36-
'/node_modules/scheduler/.+\\.js$',
37-
'^\\[native code\\]$',
38-
]
19+
INTERNAL_CALLSITES_PATTERNS
3920
// Make patterns work with both Windows and POSIX paths.
4021
.map(pathPattern => pathPattern.replaceAll('/', '[/\\\\]'))
4122
.join('|'),
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow strict-local
8+
* @format
9+
*/
10+
11+
'use strict';
12+
13+
/**
14+
* Path suffixes identifying stack frames from React Native internals. Used
15+
* to collapse internal callsites in the symbolicator and to detect
16+
* third-party modules in the serializer.
17+
*
18+
* Plain JavaScript with no dependencies: this module is also required
19+
* directly (bypassing `src/index.js`) from runtimes without the monorepo
20+
* toolchain, like the Buck worker zip, where `scripts/shared/babelRegister`
21+
* cannot be resolved and Flow syntax cannot be parsed.
22+
*/
23+
const INTERNAL_CALLSITES_PATTERNS = [
24+
'/react-native/Libraries/BatchedBridge/MessageQueue\\.js$',
25+
'/react-native/Libraries/Core/.+\\.js$',
26+
'/react-native/Libraries/LogBox/.+\\.js$',
27+
'/react-native/Libraries/Network/.+\\.js$',
28+
'/react-native/Libraries/Pressability/.+\\.js$',
29+
'/react-native/Libraries/Renderer/implementations/.+\\.js$',
30+
'/react-native/Libraries/Utilities/.+\\.js$',
31+
'/react-native/Libraries/vendor/.+\\.js$',
32+
'/react-native/Libraries/WebSocket/.+\\.js$',
33+
'/react-native/src/private/renderer/errorhandling/.+\\.js$',
34+
'/metro-runtime/.+\\.js$',
35+
'/node_modules/@babel/runtime/.+\\.js$',
36+
'/node_modules/@react-native/js-polyfills/.+\\.js$',
37+
'/node_modules/invariant/.+\\.js$',
38+
'/node_modules/react-devtools-core/.+\\.js$',
39+
'/node_modules/react-native/index.js$',
40+
'/node_modules/react-refresh/.+\\.js$',
41+
'/node_modules/scheduler/.+\\.js$',
42+
'^\\[native code\\]$',
43+
];
44+
45+
module.exports = {INTERNAL_CALLSITES_PATTERNS};

0 commit comments

Comments
 (0)