MCPcopy
hub / github.com/facebook/react / invokeCompiler

Function invokeCompiler

compiler/apps/playground/components/Editor/EditorImpl.tsx:63–88  ·  view source on GitHub ↗
(
  source: string,
  language: 'flow' | 'typescript',
  options: PluginOptions,
)

Source from the content-addressed store, hash-verified

61}
62
63function invokeCompiler(
64 source: string,
65 language: 'flow' | 'typescript',
66 options: PluginOptions,
67): CompilerTransformOutput {
68 const ast = parseInput(source, language);
69 let result = transformFromAstSync(ast, source, {
70 filename: '_playgroundFile.js',
71 highlightCode: false,
72 retainLines: true,
73 plugins: [[BabelPluginReactCompiler, options]],
74 ast: true,
75 sourceType: 'module',
76 configFile: false,
77 sourceMaps: true,
78 babelrc: false,
79 });
80 if (result?.ast == null || result?.code == null || result?.map == null) {
81 throw new Error('Expected successful compilation');
82 }
83 return {
84 code: result.code,
85 sourceMaps: result.map,
86 language,
87 };
88}
89
90const COMMON_HOOKS: Array<[string, Hook]> = [
91 [

Callers 1

compileFunction · 0.85

Calls 1

parseInputFunction · 0.70

Tested by

no test coverage detected