Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/metro-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
},
"exports": {
".": "./src/index.js",
"./package.json": "./package.json"
"./package.json": "./package.json",
"./src/internalCallsites": "./src/internalCallsites.js"
},
"publishConfig": {
"exports": {
Expand Down
23 changes: 2 additions & 21 deletions packages/metro-config/src/index.flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,13 @@

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

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

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

const INTERNAL_CALLSITES_REGEX = new RegExp(
[
'/Libraries/BatchedBridge/MessageQueue\\.js$',
'/Libraries/Core/.+\\.js$',
'/Libraries/LogBox/.+\\.js$',
'/Libraries/Network/.+\\.js$',
'/Libraries/Pressability/.+\\.js$',
'/Libraries/Renderer/implementations/.+\\.js$',
'/Libraries/Utilities/.+\\.js$',
'/Libraries/vendor/.+\\.js$',
'/Libraries/WebSocket/.+\\.js$',
'/src/private/renderer/errorhandling/.+\\.js$',
'/metro-runtime/.+\\.js$',
'/node_modules/@babel/runtime/.+\\.js$',
'/node_modules/@react-native/js-polyfills/.+\\.js$',
'/node_modules/invariant/.+\\.js$',
'/node_modules/react-devtools-core/.+\\.js$',
'/node_modules/react-native/index.js$',
'/node_modules/react-refresh/.+\\.js$',
'/node_modules/scheduler/.+\\.js$',
'^\\[native code\\]$',
]
INTERNAL_CALLSITES_PATTERNS
// Make patterns work with both Windows and POSIX paths.
.map(pathPattern => pathPattern.replaceAll('/', '[/\\\\]'))
.join('|'),
Expand Down
45 changes: 45 additions & 0 deletions packages/metro-config/src/internalCallsites.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/

'use strict';

/**
* Path suffixes identifying stack frames from React Native internals. Used
* to collapse internal callsites in the symbolicator and to detect
* third-party modules in the serializer.
*
* Plain JavaScript with no dependencies: this module is also required
* directly (bypassing `src/index.js`) from runtimes without the monorepo
* toolchain, like the Buck worker zip, where `scripts/shared/babelRegister`
* cannot be resolved and Flow syntax cannot be parsed.
*/
const INTERNAL_CALLSITES_PATTERNS = [
'/react-native/Libraries/BatchedBridge/MessageQueue\\.js$',
'/react-native/Libraries/Core/.+\\.js$',
'/react-native/Libraries/LogBox/.+\\.js$',
'/react-native/Libraries/Network/.+\\.js$',
'/react-native/Libraries/Pressability/.+\\.js$',
'/react-native/Libraries/Renderer/implementations/.+\\.js$',
'/react-native/Libraries/Utilities/.+\\.js$',
'/react-native/Libraries/vendor/.+\\.js$',
'/react-native/Libraries/WebSocket/.+\\.js$',
'/react-native/src/private/renderer/errorhandling/.+\\.js$',
'/metro-runtime/.+\\.js$',
'/node_modules/@babel/runtime/.+\\.js$',
'/node_modules/@react-native/js-polyfills/.+\\.js$',
'/node_modules/invariant/.+\\.js$',
'/node_modules/react-devtools-core/.+\\.js$',
'/node_modules/react-native/index.js$',
'/node_modules/react-refresh/.+\\.js$',
'/node_modules/scheduler/.+\\.js$',
'^\\[native code\\]$',
];

module.exports = {INTERNAL_CALLSITES_PATTERNS};
Loading