Logger-test.ts — react Source File
Architecture documentation for Logger-test.ts, a typescript file in the react codebase. 5 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 23ce0d0c_7009_482d_b3bb_8436415f28d1["Logger-test.ts"] c6896d44_e5ce_4c66_954a_6a203b10cde4["RunReactCompilerBabelPlugin.ts"] 23ce0d0c_7009_482d_b3bb_8436415f28d1 --> c6896d44_e5ce_4c66_954a_6a203b10cde4 e5c20bc0_002d_505d_5103_d80b6808cb30["runBabelPluginReactCompiler"] 23ce0d0c_7009_482d_b3bb_8436415f28d1 --> e5c20bc0_002d_505d_5103_d80b6808cb30 6ec70299_8c45_d057_8deb_dd41bb1f7153["index.ts"] 23ce0d0c_7009_482d_b3bb_8436415f28d1 --> 6ec70299_8c45_d057_8deb_dd41bb1f7153 52e3d8d7_abf4_7343_1f98_3f701ec04082["types"] 23ce0d0c_7009_482d_b3bb_8436415f28d1 --> 52e3d8d7_abf4_7343_1f98_3f701ec04082 7b0f5d46_efcb_4a2d_89c1_7cee4a0f9bc8["invariant"] 23ce0d0c_7009_482d_b3bb_8436415f28d1 --> 7b0f5d46_efcb_4a2d_89c1_7cee4a0f9bc8 style 23ce0d0c_7009_482d_b3bb_8436415f28d1 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 * as t from '@babel/types';
import invariant from 'invariant';
import {runBabelPluginReactCompiler} from '../Babel/RunReactCompilerBabelPlugin';
import type {Logger, LoggerEvent} from '../Entrypoint';
it('logs succesful compilation', () => {
const logs: [string | null, LoggerEvent][] = [];
const logger: Logger = {
logEvent(filename, event) {
logs.push([filename, event]);
},
};
const _ = runBabelPluginReactCompiler(
'function Component(props) { return <div>{props}</div> }',
'test.js',
'flow',
{logger, panicThreshold: 'all_errors'},
);
const [filename, event] = logs.at(0)!;
expect(filename).toContain('test.js');
expect(event.kind).toEqual('CompileSuccess');
invariant(event.kind === 'CompileSuccess', 'typescript be smarter');
expect(event.fnName).toEqual('Component');
expect(event.fnLoc?.end).toEqual({column: 55, index: 55, line: 1});
expect(event.fnLoc?.start).toEqual({column: 0, index: 0, line: 1});
});
it('logs failed compilation', () => {
const logs: [string | null, LoggerEvent][] = [];
const logger: Logger = {
logEvent(filename, event) {
logs.push([filename, event]);
},
};
expect(() => {
runBabelPluginReactCompiler(
'function Component(props) { props.foo = 1; return <div>{props}</div> }',
'test.js',
'flow',
{logger, panicThreshold: 'all_errors'},
);
}).toThrow();
const [filename, event] = logs.at(0)!;
expect(filename).toContain('test.js');
expect(event.kind).toEqual('CompileError');
invariant(event.kind === 'CompileError', 'typescript be smarter');
expect(event.detail.severity).toEqual('Error');
//@ts-ignore
const {start, end, identifierName} =
event.detail.primaryLocation() as t.SourceLocation;
expect(start).toEqual({column: 28, index: 28, line: 1});
expect(end).toEqual({column: 33, index: 33, line: 1});
expect(identifierName).toEqual('props');
// Make sure event.fnLoc is different from event.detail.loc
expect(event.fnLoc?.start).toEqual({column: 0, index: 0, line: 1});
expect(event.fnLoc?.end).toEqual({column: 70, index: 70, line: 1});
});
Domain
Dependencies
Source
Frequently Asked Questions
What does Logger-test.ts do?
Logger-test.ts is a source file in the react codebase, written in typescript. It belongs to the TestingUtilities domain.
What does Logger-test.ts depend on?
Logger-test.ts imports 5 module(s): RunReactCompilerBabelPlugin.ts, index.ts, invariant, runBabelPluginReactCompiler, types.
Where is Logger-test.ts in the architecture?
Logger-test.ts is located at compiler/packages/babel-plugin-react-compiler/src/__tests__/Logger-test.ts (domain: TestingUtilities, directory: compiler/packages/babel-plugin-react-compiler/src/__tests__).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free