Files
react-native/packages/react-native-fantom/runner/entrypoint-template.js
T
Nick LefeverandFacebook GitHub Bot ed106640c3 Rename fantom_internal_flags pragma to fantom_react_fb_flags (#49728)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49728

See title.

Resolving https://www.internalfb.com/diff/D70242739?dst_version_fbid=1295747645054627&transaction_fbid=1285615715828636

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D70328653

fbshipit-source-id: c3e7377760f53bc37d1a6f3e25a0053e12d4f66e
2025-02-27 09:50:45 -08:00

79 lines
2.0 KiB
JavaScript

/**
* 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
* @oncall react_native
*/
import type {SnapshotConfig} from '../runtime/snapshotContext';
import type {
FantomTestConfigJsOnlyFeatureFlags,
FantomTestConfigReactInternalFeatureFlags,
} from './getFantomTestConfig';
module.exports = function entrypointTemplate({
testPath,
setupModulePath,
featureFlagsModulePath,
featureFlags,
reactInternalFeatureFlags,
snapshotConfig,
isRunningFromCI,
}: {
testPath: string,
setupModulePath: string,
featureFlagsModulePath: string,
featureFlags: FantomTestConfigJsOnlyFeatureFlags,
reactInternalFeatureFlags: FantomTestConfigReactInternalFeatureFlags,
snapshotConfig: SnapshotConfig,
isRunningFromCI: boolean,
}): string {
return `/**
* 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.
*
* ${'@'}generated
* @noformat
* @noflow
* @oncall react_native
*/
import {registerTest} from '${setupModulePath}';
import {setConstants} from '@react-native/fantom';
${
Object.keys(featureFlags).length > 0
? `import * as ReactNativeFeatureFlags from '${featureFlagsModulePath}';
ReactNativeFeatureFlags.override({
${Object.entries(featureFlags)
.map(([name, value]) => ` ${name}: () => ${JSON.stringify(value)},`)
.join('\n')}
});`
: ''
}
${
Object.keys(reactInternalFeatureFlags).length > 0
? `import ReactNativeInternalFeatureFlags from 'ReactNativeInternalFeatureFlags';
${Object.entries(reactInternalFeatureFlags)
.map(
([name, value]) =>
`ReactNativeInternalFeatureFlags.${name} = ${JSON.stringify(value)};`,
)
.join('\n')}`
: ''
}
setConstants({
isRunningFromCI: ${String(isRunningFromCI)},
});
registerTest(() => require('${testPath}'), ${JSON.stringify(snapshotConfig)});
`;
};