compile() — react Function Reference
Architecture documentation for the compile() function in compilation.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD 01f84d19_40f4_ddcb_bf42_a422f8d05d88["compile()"] 9ba26589_c539_da05_fcd2_2ca7851645ba["compilation.ts"] 01f84d19_40f4_ddcb_bf42_a422f8d05d88 -->|defined in| 9ba26589_c539_da05_fcd2_2ca7851645ba d650dd8a_ed84_070b_b673_b427fbcb5f8d["Editor()"] d650dd8a_ed84_070b_b673_b427fbcb5f8d -->|calls| 01f84d19_40f4_ddcb_bf42_a422f8d05d88 736dd773_fb1f_3bb4_d30a_8caa66060372["parseOptions()"] 01f84d19_40f4_ddcb_bf42_a422f8d05d88 -->|calls| 736dd773_fb1f_3bb4_d30a_8caa66060372 1796e62b_c805_a4b0_f7fd_34e2bc4068da["invokeCompiler()"] 01f84d19_40f4_ddcb_bf42_a422f8d05d88 -->|calls| 1796e62b_c805_a4b0_f7fd_34e2bc4068da style 01f84d19_40f4_ddcb_bf42_a422f8d05d88 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/apps/playground/lib/compilation.ts lines 183–308
export function compile(
source: string,
mode: 'compiler' | 'linter',
configOverrides: string,
): [CompilerOutput, 'flow' | 'typescript', PluginOptions | null] {
const results = new Map<string, Array<PrintedCompilerPipelineValue>>();
const error = new CompilerError();
const otherErrors: Array<CompilerErrorDetail | CompilerDiagnostic> = [];
const upsert: (result: PrintedCompilerPipelineValue) => void = result => {
const entry = results.get(result.name);
if (Array.isArray(entry)) {
entry.push(result);
} else {
results.set(result.name, [result]);
}
};
let language: 'flow' | 'typescript';
if (source.match(/\@flow/)) {
language = 'flow';
} else {
language = 'typescript';
}
let transformOutput;
let baseOpts: PluginOptions | null = null;
try {
baseOpts = parseOptions(source, mode, configOverrides);
} catch (err) {
error.details.push(
new CompilerErrorDetail({
category: ErrorCategory.Config,
reason: `Unexpected failure when transforming configs! \n${err}`,
loc: null,
suggestions: null,
}),
);
}
if (baseOpts) {
try {
const logIR = (result: CompilerPipelineValue): void => {
switch (result.kind) {
case 'ast': {
break;
}
case 'hir': {
upsert({
kind: 'hir',
fnName: result.value.id,
name: result.name,
value: printFunctionWithOutlined(result.value),
});
break;
}
case 'reactive': {
upsert({
kind: 'reactive',
fnName: result.value.id,
name: result.name,
value: printReactiveFunctionWithOutlined(result.value),
});
break;
}
case 'debug': {
upsert({
kind: 'debug',
fnName: null,
name: result.name,
value: result.value,
});
break;
}
default: {
const _: never = result;
throw new Error(`Unhandled result ${result}`);
}
}
};
// Add logger options to the parsed options
const opts = {
...baseOpts,
logger: {
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does compile() do?
compile() is a function in the react codebase, defined in compiler/apps/playground/lib/compilation.ts.
Where is compile() defined?
compile() is defined in compiler/apps/playground/lib/compilation.ts at line 183.
What does compile() call?
compile() calls 2 function(s): invokeCompiler, parseOptions.
What calls compile()?
compile() is called by 1 function(s): Editor.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free