From 453cf0704ea45782b8eb1af4eec32776eb74daa1 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Mon, 2 Oct 2023 10:26:16 +0200 Subject: [PATCH] fix: docs islands not hydrated on safari 12 (#1837) --- src/runtime/entrypoints/main.ts | 1 + src/runtime/polyfills.ts | 5 +++++ www/fresh.config.ts | 3 +++ 3 files changed, 9 insertions(+) create mode 100644 src/runtime/polyfills.ts diff --git a/src/runtime/entrypoints/main.ts b/src/runtime/entrypoints/main.ts index 4bea985a..8665f2d1 100644 --- a/src/runtime/entrypoints/main.ts +++ b/src/runtime/entrypoints/main.ts @@ -1,3 +1,4 @@ +import "../polyfills.ts"; import { Component, ComponentChildren, diff --git a/src/runtime/polyfills.ts b/src/runtime/polyfills.ts new file mode 100644 index 00000000..948fa5f1 --- /dev/null +++ b/src/runtime/polyfills.ts @@ -0,0 +1,5 @@ +// Polyfill for old safari versions +if (typeof globalThis === "undefined") { + // @ts-ignore polyfill + window.globalThis = window; +} diff --git a/www/fresh.config.ts b/www/fresh.config.ts index 4b076dd4..67aa3598 100644 --- a/www/fresh.config.ts +++ b/www/fresh.config.ts @@ -3,5 +3,8 @@ import twindConfig from "./twind.config.ts"; import { defineConfig } from "$fresh/server.ts"; export default defineConfig({ + build: { + target: "safari12", + }, plugins: [twindPlugin(twindConfig)], });