Skip to content

Commit 571b390

Browse files
vzaidmanmeta-codesync[bot]
authored andcommitted
Scope INTERNAL_CALLSITES_REGEX to the react-native package (#58577)
Summary: Pull Request resolved: #58577 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 8d658f4 commit 571b390

5 files changed

Lines changed: 37 additions & 23 deletions

File tree

‎.prettierrc.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module.exports = {
2323
},
2424
},
2525
{
26-
files: ['*.js', '*.js.flow'],
26+
files: ['*.js', '*.js.flow', '*.json.flow'],
2727
options: {
2828
parser: 'flow',
2929
},

‎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.json": "./src/internalCallsites.json"
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.json';
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: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[
2+
"/react-native/Libraries/BatchedBridge/MessageQueue\\.js$",
3+
"/react-native/Libraries/Core/.+\\.js$",
4+
"/react-native/Libraries/LogBox/.+\\.js$",
5+
"/react-native/Libraries/Network/.+\\.js$",
6+
"/react-native/Libraries/Pressability/.+\\.js$",
7+
"/react-native/Libraries/Renderer/implementations/.+\\.js$",
8+
"/react-native/Libraries/Utilities/.+\\.js$",
9+
"/react-native/Libraries/vendor/.+\\.js$",
10+
"/react-native/Libraries/WebSocket/.+\\.js$",
11+
"/react-native/src/private/renderer/errorhandling/.+\\.js$",
12+
"/metro-runtime/.+\\.js$",
13+
"/node_modules/@babel/runtime/.+\\.js$",
14+
"/node_modules/@react-native/js-polyfills/.+\\.js$",
15+
"/node_modules/invariant/.+\\.js$",
16+
"/node_modules/react-devtools-core/.+\\.js$",
17+
"/node_modules/react-native/index.js$",
18+
"/node_modules/react-refresh/.+\\.js$",
19+
"/node_modules/scheduler/.+\\.js$",
20+
"^\\[native code\\]$"
21+
]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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
8+
* @format
9+
*/
10+
11+
declare module.exports: ReadonlyArray<string>;

0 commit comments

Comments
 (0)