babel-plugin-annotate-react-code.ts — react Source File
Architecture documentation for babel-plugin-annotate-react-code.ts, a typescript file in the react codebase. 2 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 90fd4a4d_9742_70a7_9512_f9dd5b565200["babel-plugin-annotate-react-code.ts"] 102f7d62_f771_0080_dd43_d867f5a8bd55["core"] 90fd4a4d_9742_70a7_9512_f9dd5b565200 --> 102f7d62_f771_0080_dd43_d867f5a8bd55 52e3d8d7_abf4_7343_1f98_3f701ec04082["types"] 90fd4a4d_9742_70a7_9512_f9dd5b565200 --> 52e3d8d7_abf4_7343_1f98_3f701ec04082 style 90fd4a4d_9742_70a7_9512_f9dd5b565200 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 type * as BabelCore from '@babel/core';
import {NodePath} from '@babel/core';
import * as t from '@babel/types';
export default function AnnotateReactCodeBabelPlugin(
_babel: typeof BabelCore,
): BabelCore.PluginObj {
return {
name: 'annotate-react-code',
visitor: {
Program(prog): void {
annotate(prog);
},
},
};
}
function annotate(program: NodePath<t.Program>): void {
function traverseFn(fn: BabelFn): void {
if (!shouldVisit(fn)) {
return;
}
fn.skip();
const body = fn.node.body;
if (t.isBlockStatement(body)) {
body.body.unshift(buildTypeOfReactForget());
}
}
program.traverse({
FunctionDeclaration: traverseFn,
FunctionExpression: traverseFn,
ArrowFunctionExpression: traverseFn,
});
}
function shouldVisit(fn: BabelFn): boolean {
return (
// Component declarations are known components
(fn.isFunctionDeclaration() && isComponentDeclaration(fn.node)) ||
// Otherwise check if this is a component or hook-like function
isComponentOrHookLike(fn)
);
}
function buildTypeOfReactForget(): t.Statement {
// typeof globalThis[Symbol.for("react_forget")]
return t.expressionStatement(
t.unaryExpression(
'typeof',
t.memberExpression(
// ... (234 more lines)
Domain
Subdomains
Functions
Dependencies
- core
- types
Source
Frequently Asked Questions
What does babel-plugin-annotate-react-code.ts do?
babel-plugin-annotate-react-code.ts is a source file in the react codebase, written in typescript. It belongs to the TestingUtilities domain, Fixtures subdomain.
What functions are defined in babel-plugin-annotate-react-code.ts?
babel-plugin-annotate-react-code.ts defines 14 function(s): AnnotateReactCodeBabelPlugin, annotate, buildTypeOfReactForget, callsHooksOrCreatesJsx, getFunctionName, isComponentDeclaration, isComponentName, isComponentOrHookLike, isForwardRefCallback, isHook, and 4 more.
What does babel-plugin-annotate-react-code.ts depend on?
babel-plugin-annotate-react-code.ts imports 2 module(s): core, types.
Where is babel-plugin-annotate-react-code.ts in the architecture?
babel-plugin-annotate-react-code.ts is located at compiler/packages/babel-plugin-react-compiler/scripts/babel-plugin-annotate-react-code.ts (domain: TestingUtilities, subdomain: Fixtures, directory: compiler/packages/babel-plugin-react-compiler/scripts).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free