findDirectivesDynamicGating() — react Function Reference
Architecture documentation for the findDirectivesDynamicGating() function in Program.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD eeae9a52_a6ca_1fc5_b5ef_49075de37df1["findDirectivesDynamicGating()"] 9aa4477d_960b_1ea1_b6d9_36076aaa70bd["Program.ts"] eeae9a52_a6ca_1fc5_b5ef_49075de37df1 -->|defined in| 9aa4477d_960b_1ea1_b6d9_36076aaa70bd 931a40c4_9b75_45bd_9aff_f4c45e92c16d["tryFindDirectiveEnablingMemoization()"] 931a40c4_9b75_45bd_9aff_f4c45e92c16d -->|calls| eeae9a52_a6ca_1fc5_b5ef_49075de37df1 11c511ca_2971_a23f_cfd6_2897f2fe1b13["applyCompiledFunctions()"] 11c511ca_2971_a23f_cfd6_2897f2fe1b13 -->|calls| eeae9a52_a6ca_1fc5_b5ef_49075de37df1 9f0e6a52_ff9e_00f3_1760_5fddfd89b234["Ok()"] eeae9a52_a6ca_1fc5_b5ef_49075de37df1 -->|calls| 9f0e6a52_ff9e_00f3_1760_5fddfd89b234 073c81a5_c389_d108_5b8f_4d6dc6eece83["push()"] eeae9a52_a6ca_1fc5_b5ef_49075de37df1 -->|calls| 073c81a5_c389_d108_5b8f_4d6dc6eece83 6d8385f7_ca89_0968_e79e_ed2e1aa846c9["hasAnyErrors()"] eeae9a52_a6ca_1fc5_b5ef_49075de37df1 -->|calls| 6d8385f7_ca89_0968_e79e_ed2e1aa846c9 9217845a_d29d_c624_b607_e3b35cf604bc["Err()"] eeae9a52_a6ca_1fc5_b5ef_49075de37df1 -->|calls| 9217845a_d29d_c624_b607_e3b35cf604bc 8e8b7ee8_d3c2_f98d_17e1_c5ff5fff1940["map()"] eeae9a52_a6ca_1fc5_b5ef_49075de37df1 -->|calls| 8e8b7ee8_d3c2_f98d_17e1_c5ff5fff1940 style eeae9a52_a6ca_1fc5_b5ef_49075de37df1 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts lines 87–144
function findDirectivesDynamicGating(
directives: Array<t.Directive>,
opts: ParsedPluginOptions,
): Result<
{
gating: ExternalFunction;
directive: t.Directive;
} | null,
CompilerError
> {
if (opts.dynamicGating === null) {
return Ok(null);
}
const errors = new CompilerError();
const result: Array<{directive: t.Directive; match: string}> = [];
for (const directive of directives) {
const maybeMatch = DYNAMIC_GATING_DIRECTIVE.exec(directive.value.value);
if (maybeMatch != null && maybeMatch[1] != null) {
if (t.isValidIdentifier(maybeMatch[1])) {
result.push({directive, match: maybeMatch[1]});
} else {
errors.push({
reason: `Dynamic gating directive is not a valid JavaScript identifier`,
description: `Found '${directive.value.value}'`,
category: ErrorCategory.Gating,
loc: directive.loc ?? null,
suggestions: null,
});
}
}
}
if (errors.hasAnyErrors()) {
return Err(errors);
} else if (result.length > 1) {
const error = new CompilerError();
error.push({
reason: `Multiple dynamic gating directives found`,
description: `Expected a single directive but found [${result
.map(r => r.directive.value.value)
.join(', ')}]`,
category: ErrorCategory.Gating,
loc: result[0].directive.loc ?? null,
suggestions: null,
});
return Err(error);
} else if (result.length === 1) {
return Ok({
gating: {
source: opts.dynamicGating.source,
importSpecifierName: result[0].match,
},
directive: result[0].directive,
});
} else {
return Ok(null);
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does findDirectivesDynamicGating() do?
findDirectivesDynamicGating() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts.
Where is findDirectivesDynamicGating() defined?
findDirectivesDynamicGating() is defined in compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts at line 87.
What does findDirectivesDynamicGating() call?
findDirectivesDynamicGating() calls 5 function(s): Err, Ok, hasAnyErrors, map, push.
What calls findDirectivesDynamicGating()?
findDirectivesDynamicGating() is called by 2 function(s): applyCompiledFunctions, tryFindDirectiveEnablingMemoization.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free