File tree Expand file tree Collapse file tree 2 files changed +21
-6
lines changed
packages/react-router/lib Expand file tree Collapse file tree 2 files changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,19 @@ function initSsrInfo(): void {
5050 window . __reactRouterManifest &&
5151 window . __reactRouterRouteModules
5252 ) {
53+ if ( window . __reactRouterManifest . sri === true ) {
54+ const importMap = document . querySelector ( "script[rr-importmap]" ) ;
55+ if ( importMap ?. textContent ) {
56+ try {
57+ window . __reactRouterManifest . sri = JSON . parse (
58+ importMap . textContent
59+ ) . integrity ;
60+ } catch ( err ) {
61+ console . error ( "Failed to parse import map" , err ) ;
62+ }
63+ }
64+ }
65+
5366 ssrInfo = {
5467 context : window . __reactRouterContext ,
5568 manifest : window . __reactRouterManifest ,
Original file line number Diff line number Diff line change @@ -797,16 +797,15 @@ import(${JSON.stringify(manifest.entry.module)});`;
797797
798798 return isHydrated ? null : (
799799 < >
800- { manifest . sri ? (
800+ { typeof manifest . sri === "object" ? (
801801 < script
802+ rr-importmap = ""
802803 type = "importmap"
803804 suppressHydrationWarning
804805 dangerouslySetInnerHTML = { {
805- __html : sri
806- ? JSON . stringify ( {
807- integrity : sri ,
808- } )
809- : "" ,
806+ __html : JSON . stringify ( {
807+ integrity : sri ,
808+ } ) ,
810809 } }
811810 />
812811 ) : null }
@@ -816,13 +815,15 @@ import(${JSON.stringify(manifest.entry.module)});`;
816815 href = { manifest . url }
817816 crossOrigin = { props . crossOrigin }
818817 integrity = { sri [ manifest . url ] }
818+ suppressHydrationWarning
819819 />
820820 ) : null }
821821 < link
822822 rel = "modulepreload"
823823 href = { manifest . entry . module }
824824 crossOrigin = { props . crossOrigin }
825825 integrity = { sri [ manifest . entry . module ] }
826+ suppressHydrationWarning
826827 />
827828 { preloads . map ( ( path ) => (
828829 < link
@@ -831,6 +832,7 @@ import(${JSON.stringify(manifest.entry.module)});`;
831832 href = { path }
832833 crossOrigin = { props . crossOrigin }
833834 integrity = { sri [ path ] }
835+ suppressHydrationWarning
834836 />
835837 ) ) }
836838 { initialScripts }
You can’t perform that action at this time.
0 commit comments