mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 12:20:20 +01:00
Rename references to "forget" in playground
ghstack-source-id: fc2d58e4d5195c3ec157f65b3e1c94de39ff2070 Pull Request resolved: https://github.com/facebook/react-forget/pull/2836
This commit is contained in:
parent
594f335201
commit
9ae3e74c3e
1
compiler/apps/playground/.gitignore
vendored
1
compiler/apps/playground/.gitignore
vendored
|
|
@ -4,7 +4,6 @@
|
|||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
/forget
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ const Home: NextPage = () => {
|
|||
<Head>
|
||||
<title>
|
||||
{process.env.NODE_ENV === "development"
|
||||
? "[DEV] React Forget Playground"
|
||||
: "React Forget Playground"}
|
||||
? "[DEV] React Compiler Playground"
|
||||
: "React Compiler Playground"}
|
||||
</title>
|
||||
<meta
|
||||
name="viewport"
|
||||
|
|
|
|||
|
|
@ -12,14 +12,14 @@ export default function RootLayout({
|
|||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
"use no forget";
|
||||
"use no memo";
|
||||
return (
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>
|
||||
{process.env.NODE_ENV === "development"
|
||||
? "[DEV] React Forget Playground"
|
||||
: "React Forget Playground"}
|
||||
? "[DEV] React Compiler Playground"
|
||||
: "React Compiler Playground"}
|
||||
</title>
|
||||
<meta
|
||||
name="viewport"
|
||||
|
|
|
|||
|
|
@ -5,14 +5,13 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
|
||||
import MonacoEditor, { loader, type Monaco } from "@monaco-editor/react";
|
||||
import { CompilerErrorDetail } from "babel-plugin-react-forget/src";
|
||||
import invariant from "invariant";
|
||||
import type { editor } from "monaco-editor";
|
||||
import * as monaco from "monaco-editor";
|
||||
import { useEffect, useState } from "react";
|
||||
import { renderForgetMarkers } from "../../lib/forgetMonacoDiagnostics";
|
||||
import { renderReactCompilerMarkers } from "../../lib/reactCompilerMonacoDiagnostics";
|
||||
import { useStore, useStoreDispatch } from "../StoreContext";
|
||||
import { monacoOptions } from "./monacoOptions";
|
||||
// TODO: Make TS recognize .d.ts files, in addition to loading them with webpack.
|
||||
|
|
@ -36,7 +35,7 @@ export default function Input({ errors }: Props) {
|
|||
const uri = monaco.Uri.parse(`file:///index.js`);
|
||||
const model = monaco.editor.getModel(uri);
|
||||
invariant(model, "Model must exist for the selected input file.");
|
||||
renderForgetMarkers({ monaco, model, details: errors });
|
||||
renderReactCompilerMarkers({ monaco, model, details: errors });
|
||||
// N.B. that `tabSize` is a model property, not an editor property.
|
||||
// So, the tab size has to be set per model.
|
||||
model.updateOptions({ tabSize: 2 });
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ export default function Header() {
|
|||
process.env.NODE_ENV === "development" && "text-yellow-600",
|
||||
)}
|
||||
/>
|
||||
<p className="hidden select-none sm:block">React Forget Playground</p>
|
||||
<p className="hidden select-none sm:block">React Compiler Playground</p>
|
||||
</div>
|
||||
<div className="flex items-center text-[15px] gap-4">
|
||||
<button
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
|
||||
import { Monaco } from "@monaco-editor/react";
|
||||
import {
|
||||
CompilerErrorDetail,
|
||||
|
|
@ -13,7 +12,7 @@ import {
|
|||
} from "babel-plugin-react-forget/src";
|
||||
import { MarkerSeverity, type editor } from "monaco-editor";
|
||||
|
||||
function mapForgetSeverityToMonaco(
|
||||
function mapReactCompilerSeverityToMonaco(
|
||||
level: ErrorSeverity,
|
||||
monaco: Monaco,
|
||||
): MarkerSeverity {
|
||||
|
|
@ -25,14 +24,14 @@ function mapForgetSeverityToMonaco(
|
|||
}
|
||||
}
|
||||
|
||||
function mapForgetDiagnosticToMonacoMarker(
|
||||
function mapReactCompilerDiagnosticToMonacoMarker(
|
||||
detail: CompilerErrorDetail,
|
||||
monaco: Monaco,
|
||||
): editor.IMarkerData | null {
|
||||
if (detail.loc == null || typeof detail.loc === "symbol") {
|
||||
return null;
|
||||
}
|
||||
const severity = mapForgetSeverityToMonaco(detail.severity, monaco);
|
||||
const severity = mapReactCompilerSeverityToMonaco(detail.severity, monaco);
|
||||
let message = detail.printErrorMessage();
|
||||
return {
|
||||
severity,
|
||||
|
|
@ -44,20 +43,20 @@ function mapForgetDiagnosticToMonacoMarker(
|
|||
};
|
||||
}
|
||||
|
||||
type ForgetMarkerConfig = {
|
||||
type ReactCompilerMarkerConfig = {
|
||||
monaco: Monaco;
|
||||
model: editor.ITextModel;
|
||||
details: CompilerErrorDetail[];
|
||||
};
|
||||
let decorations: string[] = [];
|
||||
export function renderForgetMarkers({
|
||||
export function renderReactCompilerMarkers({
|
||||
monaco,
|
||||
model,
|
||||
details,
|
||||
}: ForgetMarkerConfig): void {
|
||||
}: ReactCompilerMarkerConfig): void {
|
||||
let markers = [];
|
||||
for (const detail of details) {
|
||||
const marker = mapForgetDiagnosticToMonacoMarker(detail, monaco);
|
||||
const marker = mapReactCompilerDiagnosticToMonacoMarker(detail, monaco);
|
||||
if (marker == null) {
|
||||
continue;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user