-
Notifications
You must be signed in to change notification settings - Fork 601
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
feat: add defer-hydration
to ssr renderer
#6492
Merged
nicholasrice
merged 12 commits into
master
from
users/nirice/add-defer-hydration-to-ssr-renderer
Nov 1, 2022
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
0430995
yield defer-hydration attribute when configured
nicholasrice 2f4cac2
Make defer-hydration the default behavior, fixing tests
nicholasrice 4456bfc
adding disable deferHydration test
nicholasrice ee2207f
update readme
nicholasrice 6797357
update config comments
nicholasrice 99b72dd
fixing documentation
nicholasrice 93223b5
Change files
nicholasrice d4784f4
Merge branch 'master' into users/nirice/add-defer-hydration-to-ssr-reβ¦
nicholasrice 9803b3c
update API report
nicholasrice 40ee986
Merge branch 'users/nirice/add-defer-hydration-to-ssr-renderer' of htβ¦
nicholasrice a34b604
make deferHydration false by default
nicholasrice 71f327d
Merge branch 'master' into users/nirice/add-defer-hydration-to-ssr-reβ¦
nicholasrice File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@microsoft-fast-ssr-749d9ba6-9033-4475-8641-55e0cd3b14cc.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "prerelease", | ||
"comment": "Adds `defer-hydration` attribute emission during rendering", | ||
"packageName": "@microsoft/fast-ssr", | ||
"email": "nicholasrice@users.noreply.github.com", | ||
"dependentChangeType": "prerelease" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import { | ||
Compiler, | ||
ElementController, | ||
ElementStyles, | ||
Updates, | ||
ViewBehaviorFactory, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,36 @@ | ||
import "./install-dom-shim.js"; | ||
import fastSSR from "./exports.js"; | ||
import { test, expect } from "@playwright/test"; | ||
import { uniqueElementName } from "@microsoft/fast-element/testing"; | ||
import { FASTElement } from "@microsoft/fast-element"; | ||
import { consolidate } from "./test-utilities/consolidate.js"; | ||
|
||
|
||
test.describe("fastSSR default export", () => { | ||
test("should return a TemplateRenderer configured to create a RenderInfo object using the returned ElementRenderer", () => { | ||
const { templateRenderer, ElementRenderer } = fastSSR(); | ||
expect(templateRenderer.createRenderInfo().elementRenderers.includes(ElementRenderer)).toBe(true) | ||
}) | ||
|
||
test("should render FAST elements with the `defer-hydration` attribute by default", () => { | ||
const { templateRenderer } = fastSSR(); | ||
const name = uniqueElementName(); | ||
FASTElement.define(name); | ||
|
||
expect(consolidate(templateRenderer.render(`<${name}></${name}>`))).toBe(`<${name} defer-hydration><template shadowroot="open"></template></${name}>`) | ||
}); | ||
test("should render FAST elements with the `defer-hydration` attribute when deferHydration is configured to be true", () => { | ||
const { templateRenderer } = fastSSR({deferHydration: true}); | ||
const name = uniqueElementName(); | ||
FASTElement.define(name); | ||
|
||
expect(consolidate(templateRenderer.render(`<${name}></${name}>`))).toBe(`<${name} defer-hydration><template shadowroot="open"></template></${name}>`) | ||
}); | ||
test("should not render FAST elements with the `defer-hydration` attribute when deferHydration is configured to be false", () => { | ||
const { templateRenderer } = fastSSR({deferHydration: false}); | ||
const name = uniqueElementName(); | ||
FASTElement.define(name); | ||
|
||
expect(consolidate(templateRenderer.render(`<${name}></${name}>`))).toBe(`<${name}><template shadowroot="open"></template></${name}>`) | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if we should flip the default on this. Seems like most folks working with the library will want to hydrate automatically, yes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went back and forth on it. I think most applications of a reasonable size will want to defer hydration because they'll have services and contexts that will need to get set up, so hydration order will matter. We can still make it opt-in though, if that is a more predictable interface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think switching the default to be
false
is probably more what's expected, especially if someone is getting started.