@@ -189,7 +189,7 @@ export type ResumableState = {
189
189
hasHtml : boolean ,
190
190
191
191
// Resources - Request local cache
192
- preloadsMap : { [ key : string ] : null } ,
192
+ preloadsMap : { [ key : string ] : PreloadProps } ,
193
193
preconnectsMap : { [ key : string ] : null } ,
194
194
stylesMap : { [ key : string ] : null } ,
195
195
scriptsMap : { [ key : string ] : null } ,
@@ -2139,23 +2139,23 @@ function pushLink(
2139
2139
let stylesInPrecedence = renderState . precedences . get ( precedence ) ;
2140
2140
if ( ! resumableState . stylesMap . hasOwnProperty ( key ) ) {
2141
2141
const resourceProps = stylesheetPropsFromRawProps ( props ) ;
2142
- const preloadResource = renderState . preloadsMap . get ( key ) ;
2143
2142
let state = NoState ;
2144
- if ( preloadResource ) {
2145
- // If we already had a preload we don't want that resource to flush directly.
2146
- // We let the newly created resource govern flushing.
2147
- preloadResource . state |= Blocked ;
2148
- adoptPreloadPropsForStylesheetProps (
2149
- resourceProps ,
2150
- preloadResource . props ,
2151
- ) ;
2152
- if ( preloadResource . state & Flushed ) {
2143
+ if ( resumableState . preloadsMap . hasOwnProperty ( key ) ) {
2144
+ const preloadProps : PreloadProps = resumableState . preloadsMap [ key ] ;
2145
+ adoptPreloadPropsForStylesheetProps ( resourceProps , preloadProps ) ;
2146
+ const preloadResource = renderState . preloadsMap . get ( key ) ;
2147
+ if ( preloadResource ) {
2148
+ // If we already had a preload we don't want that resource to flush directly.
2149
+ // We let the newly created resource govern flushing.
2150
+ preloadResource . state |= Blocked ;
2151
+ if ( preloadResource . state & Flushed ) {
2152
+ state = PreloadFlushed ;
2153
+ }
2154
+ } else {
2155
+ // If we resumed then we assume that this was already flushed
2156
+ // by the shell.
2153
2157
state = PreloadFlushed ;
2154
2158
}
2155
- } else if ( resumableState . preloadsMap . hasOwnProperty ( key ) ) {
2156
- // If we resumed then we assume that this was already flushed
2157
- // by the shell.
2158
- state = PreloadFlushed ;
2159
2159
}
2160
2160
const resource = {
2161
2161
type : 'stylesheet ',
@@ -2549,7 +2549,7 @@ function pushImg(
2549
2549
referrerPolicy : props . referrerPolicy ,
2550
2550
} ,
2551
2551
} ;
2552
- resumableState . preloadsMap [ key ] = null ;
2552
+ resumableState . preloadsMap [ key ] = resource . props ;
2553
2553
renderState . preloadsMap . set ( key , resource ) ;
2554
2554
pushLinkImpl ( resource . chunks , resource . props ) ;
2555
2555
if (
@@ -2907,13 +2907,16 @@ function pushScript(
2907
2907
renderState . scripts . add ( resource ) ;
2908
2908
2909
2909
let scriptProps = props ;
2910
- const preloadResource = renderState . preloadsMap . get ( key ) ;
2911
- if ( preloadResource ) {
2912
- // If we already had a preload we don't want that resource to flush directly.
2913
- // We let the newly created resource govern flushing.
2914
- preloadResource. state |= Blocked ;
2910
+ if ( resumableState . preloadsMap . hasOwnProperty ( key ) ) {
2911
+ const preloadProps : PreloadProps = resumableState . preloadsMap [ key ] ;
2915
2912
scriptProps = { ...props } ;
2916
- adoptPreloadPropsForScriptProps ( scriptProps , preloadResource . props ) ;
2913
+ adoptPreloadPropsForScriptProps ( scriptProps , preloadProps ) ;
2914
+ const preloadResource = renderState . preloadsMap . get ( key ) ;
2915
+ if ( preloadResource ) {
2916
+ // If we already had a preload we don't want that resource to flush directly.
2917
+ // We let the newly created resource govern flushing.
2918
+ preloadResource. state |= Blocked ;
2919
+ }
2917
2920
}
2918
2921
// encode the tag as Chunks
2919
2922
pushScriptImpl ( resource . chunks , scriptProps ) ;
@@ -4958,12 +4961,12 @@ type PreloadAsProps = {
4958
4961
rel : 'preload' ,
4959
4962
as : string ,
4960
4963
href : ?string ,
4961
- [ string ] : mixed ,
4964
+ [ string ] : ? string ,
4962
4965
} ;
4963
4966
type PreloadModuleProps = {
4964
4967
rel : 'modulepreload' ,
4965
4968
href : ?string ,
4966
- [ string ] : mixed ,
4969
+ [ string ] : ? string ,
4967
4970
} ;
4968
4971
type PreloadProps = PreloadAsProps | PreloadModuleProps ;
4969
4972
type PreloadResource = TResource < 'preload' , PreloadProps > ;
@@ -5135,9 +5138,9 @@ function preload(href: string, as: string, options?: ?PreloadImplOptions) {
5135
5138
state : NoState ,
5136
5139
props,
5137
5140
} ;
5138
- resumableState . preloadsMap [ key ] = null ;
5141
+ resumableState . preloadsMap [ key ] = props ;
5139
5142
renderState . preloadsMap . set ( key , resource ) ;
5140
- pushLinkImpl ( resource . chunks , resource . props ) ;
5143
+ pushLinkImpl ( resource . chunks , props ) ;
5141
5144
if ( as === 'font' ) {
5142
5145
renderState . fontPreloads . add ( resource ) ;
5143
5146
} else if ( as === 'image' && resource . props . fetchPriority === 'high' ) {
@@ -5186,7 +5189,7 @@ function preloadModule(
5186
5189
state : NoState ,
5187
5190
props ,
5188
5191
} ;
5189
- resumableState . preloadsMap [ key ] = null ;
5192
+ resumableState . preloadsMap [ key ] = props ;
5190
5193
renderState . preloadsMap . set ( key , resource ) ;
5191
5194
pushLinkImpl ( resource . chunks , resource . props ) ;
5192
5195
renderState . bulkPreloads . add ( resource ) ;
@@ -5397,7 +5400,7 @@ function preloadBootstrapScript(
5397
5400
state : NoState ,
5398
5401
props ,
5399
5402
} ;
5400
- resumableState . preloadsMap [ key ] = null ;
5403
+ resumableState . preloadsMap [ key ] = props ;
5401
5404
renderState . preloadsMap . set ( key , resource ) ;
5402
5405
renderState . bootstrapScripts . add ( resource ) ;
5403
5406
pushLinkImpl ( resource . chunks , props ) ;
@@ -5441,7 +5444,7 @@ function preloadBootstrapModule(
5441
5444
state : NoState ,
5442
5445
props,
5443
5446
} ;
5444
- resumableState . preloadsMap [ key ] = null ;
5447
+ resumableState . preloadsMap [ key ] = props ;
5445
5448
renderState . preloadsMap . set ( key , resource ) ;
5446
5449
renderState . bootstrapScripts . add ( resource ) ;
5447
5450
pushLinkImpl ( resource . chunks , props ) ;
0 commit comments