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

fix(ssr): make sync mode default, fix it #4869

Merged
merged 5 commits into from
Nov 15, 2024
Merged

Conversation

nolanlawson
Copy link
Collaborator

Details

We know sync mode is fastest, so this PR makes it the default. We can always disable it in the fixture tests for easier debugging.

This also fixes #4838.

Does this pull request introduce a breaking change?

  • 😮‍💨 No, it does not introduce a breaking change.

Does this pull request introduce an observable change?

  • 🤞 No, it does not introduce an observable change.

GUS work item

W-17150209
W-17219266

@nolanlawson nolanlawson requested a review from a team as a code owner November 14, 2024 23:22
@@ -16,8 +16,6 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));

const { tmpDir, styledComponents } = generateStyledComponents();

const SSR_MODE = 'asyncYield';

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Rather than redeclare this in every benchmark, or import @lwc/shared into the benchmark code, I'm opting to just delete it from the benchmark code entirely and let the default naturally apply. YAGNI

@@ -34,7 +34,6 @@ export const expectedFailures = new Set([
'empty-text-with-comments-non-static-optimized/index.js',
'global-html-attributes/index.js',
'if-conditional-slot-content/index.js',
'rehydration/index.js',
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This test passes in sync mode 🥲

@@ -48,7 +48,7 @@ const bYieldFromChildGenerator = esTemplateWithYield`
// The 'instance' variable is shadowed here so that a contextful relationship
// is established between components rendered in slotted content & the "parent"
// component that contains the <slot>.
shadow: async function* (instance) {
shadow: async function* generateSlottedContent(instance) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We need a name so the transmogrifier can find it

@@ -79,7 +79,7 @@ const bYieldFromChildGenerator = esTemplateWithYield`
`<EsBlockStatement>;

const bAddContent = esTemplate`
addContent(${/* slot name */ is.expression} ?? "", async function* (${
addContent(${/* slot name */ is.expression} ?? "", async function* generateSlottedContent(${
Copy link
Collaborator Author

@nolanlawson nolanlawson Nov 14, 2024

Choose a reason for hiding this comment

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

Amazingly this does not conflict with other functions in the same scope because function names follow var semantics so you can just keep redeclaring it. ❤️ JS

Actually it turns out that because these are function expressions and not function declarations, the name doesn't matter at all. You can't reference it.

(node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression') &&
node.id &&
pattern.test(node.id.name)
) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Function declarations are when you have the function on their own line, function expressions are when it's just passed in to another function or the value in an object etc.

@nolanlawson nolanlawson enabled auto-merge (squash) November 15, 2024 20:43
@nolanlawson
Copy link
Collaborator Author

/nucleus ignore --reason "this test failure is actually due to lwc-test failing due to another PR"

@nolanlawson nolanlawson merged commit cdbf06c into master Nov 15, 2024
11 checks passed
@nolanlawson nolanlawson deleted the nolan/make-sync-default branch November 15, 2024 21:04
@nolanlawson
Copy link
Collaborator Author

This is due to #4865 so we can fix lwc-test separately after we release.

@nolanlawson
Copy link
Collaborator Author

salesforce/lwc-test#339

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[SSR] non-asyncYield modes failing fixture tests
2 participants