@@ -20,8 +20,6 @@ if (typeof window !== 'undefined') {
20
20
window . addEventListener ( terminationEvent , function ( ) {
21
21
ga ( 'send' , 'timing' , 'JS Dependencies' , 'unload' ) ;
22
22
} ) ;
23
-
24
- disableAllRuntimeStyleInjection ( ) ;
25
23
}
26
24
27
25
export default function MyApp ( { Component, pageProps} : AppProps ) {
@@ -55,37 +53,3 @@ export default function MyApp({Component, pageProps}: AppProps) {
55
53
56
54
return < Component { ...pageProps } /> ;
57
55
}
58
-
59
- // HACK(css-in-js): We use Sandpack, which uses Stitches (css-in-js lib).
60
- // This causes style recalc during hydration which is bad for perf.
61
- // Instead, let's rely on the SSR'd <style> tag defined in _document.tsx.
62
- // This is obviously quite fragile but hopefully it'll be solved upstream.
63
- let didWarn = false ;
64
- function disableAllRuntimeStyleInjection ( ) {
65
- // Prevent Stitches from finding the <style> tag from the server:
66
- Object . defineProperty ( document , 'styleSheets' , {
67
- get ( ) {
68
- return [ ] ;
69
- } ,
70
- } ) ;
71
- // It will try to create a new <style> tag and insert stuff there...
72
- const realInsertRule = CSSStyleSheet . prototype . insertRule ;
73
- CSSStyleSheet . prototype . insertRule = function ( ) {
74
- if ( process . env . NODE_ENV !== 'production' ) {
75
- if ( ! didWarn ) {
76
- console . warn (
77
- 'Something is trying to inject runtime CSS-in-JS.\n' +
78
- 'All <style> insertions will be ignored.' ,
79
- arguments
80
- ) ;
81
- }
82
- didWarn = true ;
83
- }
84
- // ... but we'll prevent it from affecting the document:
85
- this . disabled = true ;
86
- // @ts -ignore
87
- return realInsertRule . apply ( this , arguments ) ;
88
- } ;
89
- // We're not supposed to use any other library that inserts <style> tags.
90
- // In longer term, ideally, Sandpack should offer a zero-runtime option.
91
- }
0 commit comments