Skip to content

Commit 399970d

Browse files
authored
fix(lit): polyfill Constructable Stylesheet Objects (mdn#12811)
Polyfill for `CSSStyleSheet()` constructor etc, mainly for Safari < 16.4. Required for webpack css-loader exportType "css-style-sheet". Note: Async import is a compromise, as top-level await requires Safari 15+.
1 parent c3d57d9 commit 399970d

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

client/src/app.tsx

+9
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ import { Newsletter } from "./newsletter";
3737
import { Curriculum } from "./curriculum";
3838
import { useGA } from "./ga-context";
3939

40+
if (!("adoptedStyleSheets" in Document.prototype)) {
41+
// Polyfill for CSSStyleSheet() constructor etc, mainly for Safari < 16.4.
42+
// Required for webpack css-loader exportType "css-style-sheet".
43+
// Note: Async import is a compromise, as top-level await requires Safari 15+.
44+
import(
45+
/* webpackChunkName: "construct-style-sheets-polyfill" */ "construct-style-sheets-polyfill"
46+
);
47+
}
48+
4049
const AllFlaws = React.lazy(() => import("./flaws"));
4150
const Translations = React.lazy(() => import("./translations"));
4251
const WritersHomepage = React.lazy(() => import("./writers-homepage"));

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
"compression": "^1.8.0",
104104
"compute-baseline": "^0.3.0",
105105
"concurrently": "^9.1.2",
106+
"construct-style-sheets-polyfill": "^3.1.0",
106107
"cookie": "^0.7.2",
107108
"cookie-parser": "^1.4.7",
108109
"cross-spawn": "^7.0.6",

yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -5412,6 +5412,11 @@ connect-history-api-fallback@^2.0.0:
54125412
resolved "https://registry.yarnpkg.com/connect-history-api-fallback/-/connect-history-api-fallback-2.0.0.tgz#647264845251a0daf25b97ce87834cace0f5f1c8"
54135413
integrity sha512-U73+6lQFmfiNPrYbXqr6kZ1i1wiRqXnp2nhMsINseWXO8lDau0LGEffJ8kQi4EjLZympVgRdvqjAgiZ1tgzDDA==
54145414

5415+
construct-style-sheets-polyfill@^3.1.0:
5416+
version "3.1.0"
5417+
resolved "https://registry.yarnpkg.com/construct-style-sheets-polyfill/-/construct-style-sheets-polyfill-3.1.0.tgz#c490abd79efdb359fafa62ec14ea55232be0eecf"
5418+
integrity sha512-HBLKP0chz8BAY6rBdzda11c3wAZeCZ+kIG4weVC2NM3AXzxx09nhe8t0SQNdloAvg5GLuHwq/0SPOOSPvtCcKw==
5419+
54155420
[email protected], content-disposition@^0.5.2:
54165421
version "0.5.4"
54175422
resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.4.tgz#8b82b4efac82512a02bb0b1dcec9d2c5e8eb5bfe"

0 commit comments

Comments
 (0)