[playground] Add tab to display output from old architecture
Sathya Gunasekaran committed
Nov 24, 2022 at 18:04 UTC
9ae698c7340d5dd477b281bb03bd331c7f0613a7
1 file changed
+19
-3
compiler/forget/packages/playground/components/Editor/Output.tsx
+19
-3
@@ -4,17 +4,21 @@
4
* This source code is licensed under the MIT license found in the
5
* LICENSE file in the root directory of this source tree.
6
*/
7
-
7
import generate from "@babel/generator";
8
import MonacoEditor from "@monaco-editor/react";
10
-import { Diagnostic, HIR } from "babel-plugin-react-forget";
9
+import {
10
+ Diagnostic,
11
+ HIR,
12
+ OutputKind,
13
+ stringifyCompilerOutputs,
14
+} from "babel-plugin-react-forget";
15
import prettier from "prettier";
16
import prettierParserBabel from "prettier/parser-babel";
17
import { memo, useMemo } from "react";
18
+import compileOldArchitecture from "../../lib/compilerDriver";
19
import type { Store } from "../../lib/stores";
20
import TabbedWindow from "../TabbedWindow";
21
import { monacoOptions } from "./monacoOptions";
17
-
22
const {
23
parseFunctions,
24
Environment,
@@ -116,6 +120,17 @@ function compile(source: string): CompilerOutput | CompilerError {
120
// TODO(gsn: Update diagnostics ƒrom HIR output
121
function Output({ store }: Props) {
122
const compilerOutput = useMemo(() => compile(store.source), [store.source]);
123
+ const { outputs: oldCompilerOutputs } = useMemo(
124
+ () => compileOldArchitecture(store.source, store.compilerFlags),
125
+ [store]
126
+ );
127
+ const prettyOldCompilerOutput = useMemo(
128
+ () => stringifyCompilerOutputs(oldCompilerOutputs),
129
+ [oldCompilerOutputs]
130
+ );
131
+ const prettyOldCompilerOutputJS =
132
+ prettyOldCompilerOutput[OutputKind.JS] ?? "(Empty)";
133
+
134
if (typeof compilerOutput === "string") {
135
if (compilerOutput === "") return <div></div>;
136
return <div>error: ${compilerOutput}</div>;
@@ -163,6 +178,7 @@ function Output({ store }: Props) {
178
)}
179
</>
180
),
181
+ OldArchitecture: <TextTabContent output={prettyOldCompilerOutputJS} />,
182
}}
183
/>
184
);