diff --git a/src/bootstrap.tsx b/src/bootstrap.tsx new file mode 100644 index 0000000..4221fb3 --- /dev/null +++ b/src/bootstrap.tsx @@ -0,0 +1,18 @@ +import { lazy, Suspense } from "react"; +import { createRoot } from "react-dom/client"; +import { ErrorBoundary } from "react-error-boundary"; + +const Index = lazy(async () => import("./index")); +const containerId = "root"; +const container = document.getElementById(containerId); +if (!container) { + throw Error(`couldn't find element with id ${containerId}!`); +} +const root = createRoot(container); +root.render( + Something went wrong...}> + + + + , +); diff --git a/src/index.tsx b/src/index.tsx index 51706af..cf3252a 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,18 +1,19 @@ import { lazy, Suspense } from "react"; -import { createRoot } from "react-dom/client"; +import type { ReactElement } from "react"; import { ErrorBoundary } from "react-error-boundary"; const App = lazy(async () => import("./App")); -const containerId = "root"; -const container = document.getElementById(containerId); -if (!container) { - throw Error(`couldn't find element with id ${containerId}!`); + +export default function Index(): ReactElement { + return ( + + + + + + ); +} + +function Fallback({ error }: { error: Error }): ReactElement { + return

{error.message}

; } -const root = createRoot(container); -root.render( - shit hit the fan bruv!}> - - - - , -); diff --git a/webpack.config.mjs b/webpack.config.mjs index 1981d5d..2e9ae7f 100644 --- a/webpack.config.mjs +++ b/webpack.config.mjs @@ -52,7 +52,7 @@ function webpackConfig(_env, { mode = "development" }) { return { mode, devtool: isDevelopment ? "eval-source-map" : "source-map", - entry: "./src/index.tsx", + entry: "./src/bootstrap.tsx", devServer: { hot: true, historyApiFallback: true, @@ -94,6 +94,13 @@ function webpackConfig(_env, { mode = "development" }) { }), isDevelopment && new ReactRefreshWebpackPlugin(), ].filter(Boolean), + performance: + mode === "production" + ? { + maxEntrypointSize: 200000, + hints: "warning", + } + : undefined, }; }