[Fizz] Fix non-script modulepreload tracking (#36564)
GitHub Commits - Example: React

[Fizz] Fix non-script modulepreload tracking (#36564)

[Fizz] Fix non-script modulepreload tracking (#36564)

File tree

  • react-dom-bindings/src/server

Changes

Original file line number | Diff line number | Diff line change
---|---|---
@@ -6556,7 +6556,7 @@ | function preloadModule( | |
6556 | 6556 | resumableState
6557 | 6557 | .moduleUnknownResources
6558 | 6558 | .hasOwnProperty ( as ) ;
6559 | 6559 | let resources ;
6560 | 6560 | if ( hasAsType ) {
6561 | 6561 | - resources = resumableState . unknownResources [ as ] ;
6562 | 6562 | + resources = resumableState . moduleUnknownResources [ as ] ;
6563 | 6563 | if ( resources . hasOwnProperty ( key ) ) {
6564 | 6564 | // we can return if we already have this resource
6565 | 6565 | return;

Original file line number | Diff line number | Diff line change
---|---|---
@@ -6532,6 +6532,34 @@ | body { | |
6532 | 6532 | ) ;
6533 | 6533 | } ) ;
6534 | 6534 |
6535 | 6535 | + it ( 'preloads multiple non-script modules with the same as type' , async ( ) => {
6536 | 6536 | + function App ( ) {
6537 | 6537 | + ReactDOM . preloadModule ( 'serviceworker one' , { as : 'serviceworker' } ) ;
6538 | 6538 | + ReactDOM . preloadModule ( 'serviceworker two' , { as : 'serviceworker' } ) ;
6539 | 6539 | + return hello ;
6540 | 6540 | + }
6541 | 6541 | +
6542 | 6542 | + await act ( ( ) => {
6543 | 6543 | + renderToPipeableStream ( ) . pipe ( writable ) ;
6544 | 6544 | + } ) ;
6545 | 6545 | +
6546 | 6546 | + expect ( getMeaningfulChildren ( document . body ) ) . toEqual (
6547 | 6547 | +
6548 | 6548 | + <div>
6549 | 6549 | + <link rel="modulepreload" href="serviceworker one" as="serviceworker">
6550 | 6550 | + <link rel="modulepreload" href="serviceworker two" as="serviceworker">
6551 | 6551 | + hello
6552 | 6552 | + </div>
6553 | 6553 | + ,
6554 | 6554 | + ) ;
6555 | 6555 | + } ) ;
6556 | 6556 |
6557 | 6557 | it ( 'warns if you provide invalid arguments' , async ( ) => {
6558 | 6558 | function App ( ) {
6559 | 6559 | ReactDOM . preloadModule ( ) ;

You can’t perform that action at this time.

0 commit comments

Comments

No comments yet. Start the discussion.