mirror of
https://github.com/react/react-native.git
synced 2026-09-28 05:13:06 +08:00
RN: Flowify packages/react-native-fantom (#51784)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/51784 Adds `flow` to the remaining files that are lacking it in the `packages/react-native-fantom` directory. This also adds any necessary type annotations (using comment syntax). Changelog: [Internal] Reviewed By: SamChou19815 Differential Revision: D75886119 fbshipit-source-id: 6045b4037da21791db2a8960fbdb83aa2fb5bbf2
This commit is contained in:
committed by
Facebook GitHub Bot
parent
3728afa85f
commit
3d55f229cb
+9
-3
@@ -4,11 +4,14 @@
|
||||
* 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
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
// $FlowFixMe[cannot-resolve-module]
|
||||
// $FlowFixMe[untyped-import]
|
||||
const {defaults} = require('jest-config');
|
||||
|
||||
const PODS_LOCATIONS = [
|
||||
@@ -39,18 +42,21 @@ module.exports = {
|
||||
'<rootDir>/packages/react-native/Libraries/Renderer',
|
||||
'<rootDir>/packages/react-native/sdks/hermes/',
|
||||
...PODS_LOCATIONS,
|
||||
],
|
||||
] /*:: as $ReadOnlyArray<string> */,
|
||||
transformIgnorePatterns: ['node_modules/(?!@react-native/)'],
|
||||
haste: {
|
||||
defaultPlatform: 'ios',
|
||||
platforms: ['ios', 'android'],
|
||||
},
|
||||
moduleFileExtensions: ['fb.js'].concat(defaults.moduleFileExtensions),
|
||||
moduleFileExtensions: [
|
||||
'fb.js',
|
||||
...defaults.moduleFileExtensions,
|
||||
] /*:: as $ReadOnlyArray<string> */,
|
||||
modulePathIgnorePatterns: [
|
||||
'scripts/.*/__fixtures__/',
|
||||
'<rootDir>/packages/react-native/sdks/hermes/',
|
||||
...PODS_LOCATIONS,
|
||||
],
|
||||
] /*:: as $ReadOnlyArray<string> */,
|
||||
unmockedModulePathPatterns: [
|
||||
'node_modules/react/',
|
||||
'packages/react-native/Libraries/Renderer',
|
||||
|
||||
+3
-2
@@ -4,6 +4,7 @@
|
||||
* 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
|
||||
*/
|
||||
|
||||
@@ -13,7 +14,7 @@ const crypto = require('crypto');
|
||||
const fs = require('fs');
|
||||
|
||||
module.exports = {
|
||||
getHasteName(filePath) {
|
||||
getHasteName(filePath /*: string */) /*: ?string */ {
|
||||
if (filePath.endsWith('ReactNativeInternalFeatureFlags.js')) {
|
||||
return 'ReactNativeInternalFeatureFlags';
|
||||
}
|
||||
@@ -21,7 +22,7 @@ module.exports = {
|
||||
return null;
|
||||
},
|
||||
|
||||
getCacheKey() {
|
||||
getCacheKey() /*: string */ {
|
||||
return crypto
|
||||
.createHash('sha1')
|
||||
.update(fs.readFileSync(__filename))
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
* 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
|
||||
*/
|
||||
|
||||
@@ -12,26 +13,32 @@
|
||||
const baseConfig = require('../../../jest.config');
|
||||
const path = require('path');
|
||||
|
||||
const isCI = Boolean(process.env.SANDCASTLE || process.env.GITHUB_ACTIONS);
|
||||
const isCI =
|
||||
Boolean(process.env.SANDCASTLE) || Boolean(process.env.GITHUB_ACTIONS);
|
||||
|
||||
// In CI, we want to prewarm the caches/builds before running the tests so
|
||||
// that time isn't attributed to the first test that runs.
|
||||
const globalSetup /*: ?string */ = isCI
|
||||
? '<rootDir>/packages/react-native-fantom/runner/warmup/index.js'
|
||||
: null;
|
||||
|
||||
module.exports = {
|
||||
rootDir: path.resolve(__dirname, '../../..'),
|
||||
rootDir: path.resolve(__dirname, '../../..') /*:: as string */,
|
||||
roots: [
|
||||
'<rootDir>/packages/react-native',
|
||||
'<rootDir>/packages/react-native-fantom',
|
||||
'<rootDir>/packages/polyfills',
|
||||
],
|
||||
moduleFileExtensions: [...baseConfig.moduleFileExtensions, 'cpp', 'h'],
|
||||
moduleFileExtensions: [
|
||||
...baseConfig.moduleFileExtensions,
|
||||
'cpp',
|
||||
'h',
|
||||
] /*:: as $ReadOnlyArray<string> */,
|
||||
// This allows running Meta-internal tests with the `-test.fb.js` suffix.
|
||||
testRegex: '/__tests__/.*-itest(\\.fb)?\\.js$',
|
||||
testPathIgnorePatterns: baseConfig.testPathIgnorePatterns,
|
||||
transformIgnorePatterns: ['.*'],
|
||||
testRunner: '<rootDir>/packages/react-native-fantom/runner/index.js',
|
||||
watchPathIgnorePatterns: ['<rootDir>/packages/react-native-fantom/build/'],
|
||||
|
||||
// In CI, we want to prewarm the caches/builds before running the tests so
|
||||
// that time isn't attributed to the first test that runs.
|
||||
globalSetup: isCI
|
||||
? '<rootDir>/packages/react-native-fantom/runner/warmup/index.js'
|
||||
: null,
|
||||
globalSetup,
|
||||
};
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
* 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
|
||||
*/
|
||||
|
||||
|
||||
@@ -4,11 +4,16 @@
|
||||
* 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';
|
||||
|
||||
/*::
|
||||
import type {ConfigT, InputConfigT} from 'metro-config';
|
||||
*/
|
||||
|
||||
const {getDefaultConfig} = require('@react-native/metro-config');
|
||||
const {mergeConfig} = require('metro-config');
|
||||
const path = require('path');
|
||||
@@ -17,12 +22,12 @@ const rnTesterConfig = getDefaultConfig(
|
||||
path.resolve('../../../packages/rn-tester'),
|
||||
);
|
||||
|
||||
const JS_DIR = process.env.JS_DIR
|
||||
? path.resolve(process.cwd(), process.env.JS_DIR)
|
||||
: null;
|
||||
const cwd = process.cwd();
|
||||
const JS_DIR =
|
||||
process.env.JS_DIR != null ? path.resolve(cwd, process.env.JS_DIR) : null;
|
||||
const NODE_MODULES = path.sep + 'node_modules' + path.sep;
|
||||
|
||||
const config = {
|
||||
const config /*: InputConfigT */ = {
|
||||
projectRoot: path.resolve(__dirname, '../../..'),
|
||||
reporter: {
|
||||
update: () => {},
|
||||
@@ -30,21 +35,21 @@ const config = {
|
||||
resolver: {
|
||||
blockList: /\/RendererProxy\.fb\.js$/, // Disable dependency injection for the renderer
|
||||
sourceExts: ['fb.js', ...rnTesterConfig.resolver.sourceExts],
|
||||
nodeModulesPaths: JS_DIR
|
||||
? [path.join(JS_DIR, 'public', 'node_modules')]
|
||||
: [],
|
||||
nodeModulesPaths:
|
||||
JS_DIR != null ? [path.join(JS_DIR, 'public', 'node_modules')] : [],
|
||||
hasteImplModulePath: path.resolve(__dirname, 'hasteImpl.js'),
|
||||
resolveRequest: JS_DIR
|
||||
? (ctx, dep, platform) =>
|
||||
ctx.originModulePath.includes(NODE_MODULES)
|
||||
? ctx.resolveRequest(ctx, dep, platform)
|
||||
: // Disable hierarchical node_modules lookup from 1P code.
|
||||
ctx.resolveRequest(
|
||||
{...ctx, disableHierarchicalLookup: true},
|
||||
dep,
|
||||
platform,
|
||||
)
|
||||
: null,
|
||||
resolveRequest:
|
||||
JS_DIR != null
|
||||
? (ctx, dep, platform) =>
|
||||
ctx.originModulePath.includes(NODE_MODULES)
|
||||
? ctx.resolveRequest(ctx, dep, platform)
|
||||
: // Disable hierarchical node_modules lookup from 1P code.
|
||||
ctx.resolveRequest(
|
||||
{...ctx, disableHierarchicalLookup: true},
|
||||
dep,
|
||||
platform,
|
||||
)
|
||||
: null,
|
||||
},
|
||||
transformer: {
|
||||
// We need to wrap the default transformer so we can run it from source
|
||||
@@ -55,13 +60,14 @@ const config = {
|
||||
// Force an empty list so Metro doesn't inject InitializeCore in tests.
|
||||
getModulesRunBeforeMainModule: () => [],
|
||||
},
|
||||
watchFolders: JS_DIR
|
||||
? [
|
||||
path.join(JS_DIR, 'RKJSModules', 'vendor', 'react'),
|
||||
path.join(JS_DIR, 'tools', 'metro', 'packages', 'metro-runtime'),
|
||||
path.join(JS_DIR, 'public', 'node_modules'),
|
||||
]
|
||||
: [],
|
||||
watchFolders:
|
||||
JS_DIR != null
|
||||
? [
|
||||
path.join(JS_DIR, 'RKJSModules', 'vendor', 'react'),
|
||||
path.join(JS_DIR, 'tools', 'metro', 'packages', 'metro-runtime'),
|
||||
path.join(JS_DIR, 'public', 'node_modules'),
|
||||
]
|
||||
: [],
|
||||
};
|
||||
|
||||
module.exports = mergeConfig(rnTesterConfig, config);
|
||||
module.exports = mergeConfig(rnTesterConfig, config) /*:: as ConfigT */;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
* 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
|
||||
*/
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
* 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
|
||||
*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user