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
2 changes: 1 addition & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {
},
},
{
files: ['*.js', '*.js.flow'],
files: ['*.js', '*.js.flow', '*.json.flow'],
options: {
parser: 'flow',
},
Expand Down
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.json": "./src/internalCallsites.json"
},
"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.json';
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
21 changes: 21 additions & 0 deletions packages/metro-config/src/internalCallsites.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[
"/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\\]$"
]
11 changes: 11 additions & 0 deletions packages/metro-config/src/internalCallsites.json.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* 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
* @format
*/

declare module.exports: ReadonlyArray<string>;
Loading