diff --git a/site/app/components/Repl.tsx b/site/app/components/Repl.tsx new file mode 100644 index 000000000..428e88f21 --- /dev/null +++ b/site/app/components/Repl.tsx @@ -0,0 +1,24 @@ +import { useEffect, useRef } from "react"; +import { XTerm } from "@pablo-lion/xterm-react"; +import { WebLinksAddon } from '@xterm/addon-web-links'; +import { Terminal } from '@xterm/xterm'; +import { startRepl } from "../../generated/main.mjs"; + +export default function Repl() { + /* eslint-disable @typescript-eslint/no-explicit-any */ + const xtermRef = useRef(null); + + useEffect(() => { + if (xtermRef.current) { + const terminal = xtermRef.current.terminal as Terminal; + terminal.loadAddon(new WebLinksAddon()); + startRepl(terminal); + } + }, []); + + return ( +
+ +
+ ); +} \ No newline at end of file diff --git a/site/app/page.tsx b/site/app/page.tsx index bd89e2d56..bf273949c 100644 --- a/site/app/page.tsx +++ b/site/app/page.tsx @@ -1,23 +1,13 @@ 'use client'; -import { useEffect, useRef } from "react"; import Image from "next/image"; -import { XTerm } from "@pablo-lion/xterm-react"; -import { WebLinksAddon } from '@xterm/addon-web-links'; -import { startRepl } from "../generated/main.mjs"; -import "../types/main.d.ts"; +import dynamic from 'next/dynamic'; -export default function Home() { - const xtermRef = useRef(null); - - useEffect(() => { - if (xtermRef.current) { - const terminal = xtermRef.current.terminal; - terminal.loadAddon(new WebLinksAddon()); - startRepl(terminal); - } - }, []); +const Repl = dynamic(() => import('./components/Repl'), { + ssr: false +}) +export default function Home() { return (
@@ -30,56 +20,10 @@ export default function Home() { priority />

Chester: A Programming Language

-
- -
+
); diff --git a/site/next.config.mjs b/site/next.config.mjs index ebd84c417..c3889279b 100644 --- a/site/next.config.mjs +++ b/site/next.config.mjs @@ -23,6 +23,12 @@ const nextConfig = { images: { unoptimized: true, }, + webpack: (config, { isServer }) => { + if (!isServer) { + config.output.globalObject = 'this'; + } + return config; + }, }; export default nextConfig; \ No newline at end of file