BabelPlugin.ts — react Source File
Architecture documentation for BabelPlugin.ts, a typescript file in the react codebase. 8 imports, 2 dependents.
Entity Profile
Dependency Diagram
graph LR f3b73a1d_8eeb_a8b2_a886_c8b8c2f58490["BabelPlugin.ts"] 6ec70299_8c45_d057_8deb_dd41bb1f7153["index.ts"] f3b73a1d_8eeb_a8b2_a886_c8b8c2f58490 --> 6ec70299_8c45_d057_8deb_dd41bb1f7153 4b6a2a26_9073_8d0b_6c3b_1cbce53fd41c["Reanimated.ts"] f3b73a1d_8eeb_a8b2_a886_c8b8c2f58490 --> 4b6a2a26_9073_8d0b_6c3b_1cbce53fd41c 8c3f654e_430d_510c_2d6c_7c99e928ff65["injectReanimatedFlag"] f3b73a1d_8eeb_a8b2_a886_c8b8c2f58490 --> 8c3f654e_430d_510c_2d6c_7c99e928ff65 842dd25b_450e_d53a_86da_7c3b96f1f5f7["pipelineUsesReanimatedPlugin"] f3b73a1d_8eeb_a8b2_a886_c8b8c2f58490 --> 842dd25b_450e_d53a_86da_7c3b96f1f5f7 93f3a2c7_a7ce_3c94_87fe_ee7d66d9b64b["ValidateNoUntransformedReferences.ts"] f3b73a1d_8eeb_a8b2_a886_c8b8c2f58490 --> 93f3a2c7_a7ce_3c94_87fe_ee7d66d9b64b e9305144_35b9_6cfd_0fec_af0783a96987["validateNoUntransformedReferences"] f3b73a1d_8eeb_a8b2_a886_c8b8c2f58490 --> e9305144_35b9_6cfd_0fec_af0783a96987 102f7d62_f771_0080_dd43_d867f5a8bd55["core"] f3b73a1d_8eeb_a8b2_a886_c8b8c2f58490 --> 102f7d62_f771_0080_dd43_d867f5a8bd55 2ed45bcd_6c82_3ccd_0e20_fa96b5111055[".."] f3b73a1d_8eeb_a8b2_a886_c8b8c2f58490 --> 2ed45bcd_6c82_3ccd_0e20_fa96b5111055 c6896d44_e5ce_4c66_954a_6a203b10cde4["RunReactCompilerBabelPlugin.ts"] c6896d44_e5ce_4c66_954a_6a203b10cde4 --> f3b73a1d_8eeb_a8b2_a886_c8b8c2f58490 6ac54a3f_a69d_fd38_4990_8c55e48a4c31["index.ts"] 6ac54a3f_a69d_fd38_4990_8c55e48a4c31 --> f3b73a1d_8eeb_a8b2_a886_c8b8c2f58490 style f3b73a1d_8eeb_a8b2_a886_c8b8c2f58490 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 {compileProgram, Logger, parsePluginOptions} from '../Entrypoint';
import {
injectReanimatedFlag,
pipelineUsesReanimatedPlugin,
} from '../Entrypoint/Reanimated';
import validateNoUntransformedReferences from '../Entrypoint/ValidateNoUntransformedReferences';
import {CompilerError} from '..';
const ENABLE_REACT_COMPILER_TIMINGS =
process.env['ENABLE_REACT_COMPILER_TIMINGS'] === '1';
/*
* The React Forget Babel Plugin
* @param {*} _babel
* @returns
*/
export default function BabelPluginReactCompiler(
_babel: typeof BabelCore,
): BabelCore.PluginObj {
return {
name: 'react-forget',
visitor: {
/*
* Note: Babel does some "smart" merging of visitors across plugins, so even if A is inserted
* prior to B, if A does not have a Program visitor and B does, B will run first. We always
* want Forget to run true to source as possible.
*/
Program: {
enter(prog, pass): void {
try {
const filename = pass.filename ?? 'unknown';
if (ENABLE_REACT_COMPILER_TIMINGS === true) {
performance.mark(`${filename}:start`, {
detail: 'BabelPlugin:Program:start',
});
}
let opts = parsePluginOptions(pass.opts);
const isDev =
(typeof __DEV__ !== 'undefined' && __DEV__ === true) ||
process.env['NODE_ENV'] === 'development';
if (
opts.enableReanimatedCheck === true &&
pipelineUsesReanimatedPlugin(pass.file.opts.plugins)
) {
opts = injectReanimatedFlag(opts);
}
if (
opts.environment.enableResetCacheOnSourceFileChanges !== false &&
isDev
) {
opts = {
...opts,
environment: {
...opts.environment,
enableResetCacheOnSourceFileChanges: true,
},
};
}
const result = compileProgram(prog, {
opts,
filename: pass.filename ?? null,
comments: pass.file.ast.comments ?? [],
code: pass.file.code,
});
validateNoUntransformedReferences(
prog,
pass.filename ?? null,
opts.logger,
opts.environment,
result,
);
if (ENABLE_REACT_COMPILER_TIMINGS === true) {
performance.mark(`${filename}:end`, {
detail: 'BabelPlugin:Program:end',
});
}
} catch (e) {
if (e instanceof CompilerError) {
throw e.withPrintedMessage(pass.file.code, {eslint: false});
}
throw e;
}
},
exit(_, pass): void {
if (ENABLE_REACT_COMPILER_TIMINGS === true) {
const filename = pass.filename ?? 'unknown';
const measurement = performance.measure(filename, {
start: `${filename}:start`,
end: `${filename}:end`,
detail: 'BabelPlugin:Program',
});
if ('logger' in pass.opts && pass.opts.logger != null) {
const logger: Logger = pass.opts.logger as Logger;
logger.logEvent(filename, {
kind: 'Timing',
measurement,
});
}
}
},
},
},
};
}
Domain
Subdomains
Functions
Dependencies
Imported By
Source
Frequently Asked Questions
What does BabelPlugin.ts do?
BabelPlugin.ts is a source file in the react codebase, written in typescript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in BabelPlugin.ts?
BabelPlugin.ts defines 1 function(s): BabelPluginReactCompiler.
What does BabelPlugin.ts depend on?
BabelPlugin.ts imports 8 module(s): .., Reanimated.ts, ValidateNoUntransformedReferences.ts, core, index.ts, injectReanimatedFlag, pipelineUsesReanimatedPlugin, validateNoUntransformedReferences.
What files import BabelPlugin.ts?
BabelPlugin.ts is imported by 2 file(s): RunReactCompilerBabelPlugin.ts, index.ts.
Where is BabelPlugin.ts in the architecture?
BabelPlugin.ts is located at compiler/packages/babel-plugin-react-compiler/src/Babel/BabelPlugin.ts (domain: BabelCompiler, subdomain: Validation, directory: compiler/packages/babel-plugin-react-compiler/src/Babel).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free