[lit-html][labs/ssr-client] Fix compiled template support#3993
Merged
AndrewJakubowicz merged 11 commits intomainfrom Jul 10, 2023
Merged
[lit-html][labs/ssr-client] Fix compiled template support#3993AndrewJakubowicz merged 11 commits intomainfrom
AndrewJakubowicz merged 11 commits intomainfrom
Conversation
This commit fixes the type of `isTemplateResult` to return the correct type as the current implementation: a `TemplateResult` and a `CompiledTemplateResult`. Then I fixed the cache directive to work with both template types, and hydration to only work with uncompiled templates. Added a unit test for the compiled template case with the cache directive. An alternative I considered: - Make `isTemplateResult` stricter such that the type is only a `TemplateResult`. That is technically a breaking change (although people should not be depending on `CompiledTemplateResult`s) - And add the following helpers: `isCompiledTemplateResult` and `getTemplateStringsArray`.
🦋 Changeset detectedLatest commit: 089e81a The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
📊 Tachometer Benchmark ResultsSummarynop-update
render
update
update-reflect
Resultslit-element-list
render
update
update-reflect
lit-html-kitchen-sink
render
update
nop-update
lit-html-repeat
render
update
lit-html-template-heavy
render
update
reactive-element-list
render
update
update-reflect
|
augustjk
requested changes
Jul 6, 2023
Member
augustjk
left a comment
There was a problem hiding this comment.
Feel free to push back on any requested changes.
rictic
approved these changes
Jul 7, 2023
augustjk
approved these changes
Jul 7, 2023
Contributor
Author
|
I added two more small cleanup commits. 1. Use the PTAL |
augustjk
approved these changes
Jul 7, 2023
ffefb27 to
089e81a
Compare
justinfagnani
approved these changes
Jul 10, 2023
Merged
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Change is an independent part of #3984
Summary
Fix
isTemplateResultreturn type to includeCompiledTemplateResults, and then fix locations inlitthat didn't handleCompiledTemplates. Primarily thecachedirective.Changes
isTemplateResultto return the correct type (as per current implementation): aTemplateResultor aCompiledTemplateResult.hydrationandexperimental-hydrationdo not work with compiled templates by making the check more strict. Maybe could add a dev mode error?isTemplateResulttype tests.Considerations
I marked this as a minor change, however it is a breaking change in terms of TypeScript types. The return type of
isTemplateResultwithout a second argument now has an additional consideration and could break users ofisTemplateResult. However the type now more truthfully conveys whatisTemplateResultis asserting.Alternative considered:
isTemplateResultstricter such that the type is only aTemplateResult. A breaking change (although people should realistically not be depending onCompiledTemplateResults yet)isCompiledTemplateResultto check for CompiledTemplates, andgetTemplateStringsArrayto generically retrieve the template strings array from either a compiled or uncompiled template result.Test plan
Unit tests and type only tests added.