makeTransform.ts — react Source File
Architecture documentation for makeTransform.ts, a typescript file in the react codebase. 5 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR f1d5d1b2_14d7_0dd7_7ad6_0df868e68b2c["makeTransform.ts"] 79f67f1f_fbf5_bcc4_6d8b_e7d4bc3d179c["babel-jest"] f1d5d1b2_14d7_0dd7_7ad6_0df868e68b2c --> 79f67f1f_fbf5_bcc4_6d8b_e7d4bc3d179c 33e3aca7_66ee_ce27_72ad_b6d7fb17e06c["babel-plugin-react-compiler"] f1d5d1b2_14d7_0dd7_7ad6_0df868e68b2c --> 33e3aca7_66ee_ce27_72ad_b6d7fb17e06c 6a88ed04_6732_212f_bbac_658bd7cb3b65["child_process"] f1d5d1b2_14d7_0dd7_7ad6_0df868e68b2c --> 6a88ed04_6732_212f_bbac_658bd7cb3b65 ceff537f_04b5_ea96_fed3_19a0a7315bc6["traverse"] f1d5d1b2_14d7_0dd7_7ad6_0df868e68b2c --> ceff537f_04b5_ea96_fed3_19a0a7315bc6 52e3d8d7_abf4_7343_1f98_3f701ec04082["types"] f1d5d1b2_14d7_0dd7_7ad6_0df868e68b2c --> 52e3d8d7_abf4_7343_1f98_3f701ec04082 style f1d5d1b2_14d7_0dd7_7ad6_0df868e68b2c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/**
* 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.
*/
import babelJest from 'babel-jest';
import {
validateEnvironmentConfig,
EnvironmentConfig,
} from 'babel-plugin-react-compiler';
import {execSync} from 'child_process';
import type {NodePath, Visitor} from '@babel/traverse';
import type {CallExpression} from '@babel/types';
import BabelPluginReactCompiler from 'babel-plugin-react-compiler';
/**
* -- IMPORTANT --
* When making changes to any babel plugins defined this file
* (e.g. `ReactForgetFunctionTransform`), make sure to bump e2eTransformerCacheKey
* as our script files are currently not used for babel cache breaking!!
*/
const e2eTransformerCacheKey = 1;
const forgetOptions: EnvironmentConfig = validateEnvironmentConfig({
enableAssumeHooksFollowRulesOfReact: true,
});
const debugMode = process.env['DEBUG_FORGET_COMPILER'] != null;
const compilerCacheKey = execSync(
'yarn --silent --cwd ../.. hash packages/babel-plugin-react-compiler/dist',
)
.toString()
.trim();
if (debugMode) {
console.log('cachebreaker', compilerCacheKey);
}
module.exports = (useForget: boolean) => {
function createTransformer() {
return babelJest.createTransformer({
passPerPreset: true,
presets: [
'@babel/preset-typescript',
{
plugins: [
useForget
? [
BabelPluginReactCompiler,
{
environment: forgetOptions,
/*
* Jest hashes the babel config as a cache breaker.
* (see https://github.com/jestjs/jest/blob/v29.6.2/packages/babel-jest/src/index.ts#L84)
*/
compilerCacheKey,
transformOptionsCacheKey: forgetOptions,
e2eTransformerCacheKey,
},
]
: '@babel/plugin-syntax-jsx',
],
},
'@babel/preset-react',
{
plugins: [
[
function BabelPluginRewriteRequirePath(): {visitor: Visitor} {
return {
visitor: {
CallExpression(path: NodePath<CallExpression>): void {
const {callee} = path.node;
if (
callee.type === 'Identifier' &&
callee.name === 'require'
) {
const arg = path.node.arguments[0];
if (arg.type === 'StringLiteral') {
/*
* The compiler adds requires of "React", which is expected to be a wrapper
* around the "react" package. For tests, we just rewrite the require.
*/
if (arg.value === 'React') {
arg.value = 'react';
}
}
}
},
},
};
},
],
'@babel/plugin-transform-modules-commonjs',
],
},
],
targets: {
esmodules: true,
},
} as any);
/*
* typecast needed as DefinitelyTyped does not have updated Babel configs types yet
* (missing passPerPreset and targets).
*/
}
return {
createTransformer,
};
};
Domain
Subdomains
Functions
Dependencies
- babel-jest
- babel-plugin-react-compiler
- child_process
- traverse
- types
Source
Frequently Asked Questions
What does makeTransform.ts do?
makeTransform.ts is a source file in the react codebase, written in typescript. It belongs to the TestingUtilities domain, E2E subdomain.
What functions are defined in makeTransform.ts?
makeTransform.ts defines 1 function(s): module.
What does makeTransform.ts depend on?
makeTransform.ts imports 5 module(s): babel-jest, babel-plugin-react-compiler, child_process, traverse, types.
Where is makeTransform.ts in the architecture?
makeTransform.ts is located at compiler/packages/babel-plugin-react-compiler/scripts/jest/makeTransform.ts (domain: TestingUtilities, subdomain: E2E, directory: compiler/packages/babel-plugin-react-compiler/scripts/jest).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free