feat(debug): show rendering issues during SSR (#1256)

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
This commit is contained in:
Marvin Hagemeister
2023-06-08 08:53:14 +02:00
committed by GitHub
co-authored by Asher Gomez
parent 273aa2ac5c
commit be08573a95
8 changed files with 99 additions and 1 deletions
+14 -1
View File
@@ -56,6 +56,11 @@ function isObject(value: unknown) {
value !== null;
}
function isDevMode() {
// Env var is only set in prod (on Deploy).
return Deno.env.get("DENO_DEPLOYMENT_ID") === undefined;
}
interface StaticFile {
/** The URL to the static file on disk. */
localUrl: URL;
@@ -94,6 +99,7 @@ export class ServerContext {
plugins: Plugin[],
configPath: string,
jsxConfig: JSXConfig,
dev: boolean = isDevMode(),
) {
this.#routes = routes;
this.#islands = islands;
@@ -104,7 +110,7 @@ export class ServerContext {
this.#notFound = notFound;
this.#error = error;
this.#plugins = plugins;
this.#dev = typeof Deno.env.get("DENO_DEPLOYMENT_ID") !== "string"; // Env var is only set in prod (on Deploy).
this.#dev = dev;
this.#builder = new EsbuildBuilder({
buildID: BUILD_ID,
entrypoints: collectEntrypoints(this.#dev, this.#islands, this.#plugins),
@@ -320,6 +326,12 @@ export class ServerContext {
}
}
const dev = isDevMode();
if (dev) {
// Ensure that debugging hooks are set up for SSR rendering
await import("preact/debug");
}
return new ServerContext(
routes,
islands,
@@ -332,6 +344,7 @@ export class ServerContext {
opts.plugins ?? [],
configPath,
jsxConfig,
dev,
);
}
+1
View File
@@ -17,6 +17,7 @@ export default function DefaultErrorPage(props: ErrorPageProps) {
return h(
"div",
{
class: "frsh-error-page",
style: {
display: "flex",
justifyContent: "center",