Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fizz] Readability refactor (follow up to #25437) #25865

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mofeiZ
Copy link
Contributor

@mofeiZ mofeiZ commented Dec 9, 2022

Summary

Follow-up / cleanup PR to #25437

  • Split write[...]Instruction into two sets of functions, functions writing the inline script format and functions writing the data attribute format. This is only moving code around (no functional changes)
  • removed redundant test helper

How did you test this change?

  • Only ReactDOM www build should be affected (small bundle size change from moving code around)
  • ReactDOMFizzServer-test.js ReactDOMFloat-test.js

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Dec 9, 2022
@sizebot
Copy link

sizebot commented Dec 9, 2022

Comparing: b14d7fa...d19472b

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js = 154.37 kB 154.37 kB = 48.97 kB 48.98 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 156.29 kB 156.29 kB = 49.63 kB 49.63 kB
facebook-www/ReactDOM-prod.classic.js = 533.12 kB 533.12 kB = 94.96 kB 94.96 kB
facebook-www/ReactDOM-prod.modern.js = 518.22 kB 518.22 kB = 92.76 kB 92.76 kB
facebook-www/ReactDOMForked-prod.classic.js = 533.12 kB 533.12 kB = 94.96 kB 94.96 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
facebook-www/ReactDOMServerStreaming-prod.modern.js +1.05% 128.86 kB 130.21 kB +0.42% 24.73 kB 24.83 kB
facebook-www/ReactDOMServer-prod.modern.js +1.02% 123.73 kB 125.00 kB +0.52% 23.42 kB 23.54 kB
facebook-www/ReactDOMServer-prod.classic.js +1.00% 126.87 kB 128.14 kB +0.41% 24.04 kB 24.14 kB
facebook-www/ReactDOMServerStreaming-dev.modern.js +0.65% 332.61 kB 334.78 kB +0.17% 74.04 kB 74.17 kB
facebook-www/ReactDOMServer-dev.modern.js +0.64% 337.37 kB 339.53 kB +0.16% 75.12 kB 75.24 kB
facebook-www/ReactDOMServer-dev.classic.js +0.63% 344.06 kB 346.23 kB +0.15% 76.54 kB 76.66 kB

Generated by 🚫 dangerJS against d19472b

@mofeiZ mofeiZ marked this pull request as ready for review December 9, 2022 23:07
@mofeiZ
Copy link
Contributor Author

mofeiZ commented Jan 5, 2023

@gnoff ping for feedback 🙂

Copy link
Collaborator

@gnoff gnoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced each variant needs to be broken out into separate functions but I already felt the pain of the previous factoring when implementing renderIntoContainer and did a very similar reorganization of the writeCompletedBoundary implementation.

Because rebasing that PR onto this may be riskier than the other way around do you mind waiting until that one merges in and then rebasing onto it?

Comment on lines +2424 to +2440
if (
!enableFizzExternalRuntime ||
responseState.streamingFormat === ScriptStreamingFormat;
if (scriptFormat) {
writeChunk(destination, responseState.startInlineScript);
if (!responseState.sentCompleteSegmentFunction) {
// The first time we write this, we'll need to include the full implementation.
responseState.sentCompleteSegmentFunction = true;
writeChunk(destination, completeSegmentScript1Full);
} else {
// Future calls can just reuse the same function.
writeChunk(destination, completeSegmentScript1Partial);
}
responseState.streamingFormat === ScriptStreamingFormat
) {
return writeCompletedSegmentInstructionScript(
destination,
responseState,
contentSegmentID,
);
} else {
return writeCompletedSegmentInstructionData(
destination,
responseState,
contentSegmentID,
);
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hello @mofeiZ

how about this?
I think else seems unnecessary 😄

  if (
    !enableFizzExternalRuntime ||
    responseState.streamingFormat === ScriptStreamingFormat
  ) {
    return writeCompletedSegmentInstructionScript(
      destination,
      responseState,
      contentSegmentID,
    );
  } 
  return writeCompletedSegmentInstructionData(
    destination,
    responseState,
    contentSegmentID,
  );
  

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants