This repository has been archived by the owner on May 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 83
feat(styleLoader): aggregate stylesheets and dedupe if already loaded #1099
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1052bda
feat(styleLoader): aggregate stylesheets and dedupe if already loaded
eddhurst 84eebf5
Merge branch 'main' into feature/aggregate-ssr-styles-loader
eddhurst 4eaf62c
feat(moduleStyles): refactor side effect to dedicated loop function
eddhurst aeae31c
chore(moduleStyles): make returns consistent, remove newlines
eddhurst 28ba2aa
Merge branch 'feature/aggregate-ssr-styles-loader' of https://github.…
eddhurst 1bc7876
Merge branch 'main' into feature/aggregate-ssr-styles-loader
JAdshead 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
8 changes: 6 additions & 2 deletions
8
__tests__/server/utils/__snapshots__/renderModuleStyles.spec.js.snap
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,7 +1,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`renderModuleStyles should handle a mix of modules with and without SSR styles 1`] = `"<style class="ssr-css">.test-module-b_class { color: red; }</style><style class="ssr-css">.test-module-d_class { color: red; }</style>"`; | ||
exports[`renderModuleStyles should deduplicate aggregatedStyles that have the same digest hash 1`] = `"<style id="shared_hash_deps" data-ssr="true">.test-module-a_deps { color: blue; }</style><style id="shared_hash_local" data-ssr="true">.test-module-a_local { color: rebeccapurple; }</style><style id="unique-hash_deps" data-ssr="true">.test-module-c_deps { color: blue; }</style><style id="unique-hash_local" data-ssr="true">.test-module-c_local { color: rebeccapurple; }</style>"`; | ||
|
||
exports[`renderModuleStyles should handle a mix of modules with and without SSR styles 1`] = `"<style class="ssr-css">.test-module-b_class { color: red; }</style><style class="ssr-css">.test-module-d_class { color: red; }</style><style id="test-module-e_deps" data-ssr="true">.test-module-e_deps { color: blue; }</style><style id="test-module-e_local" data-ssr="true">.test-module-e_local { color: rebeccapurple; }</style>"`; | ||
|
||
exports[`renderModuleStyles should handle modules with SSR styles 1`] = `"<style class="ssr-css">.test-module_class { color: red; }</style>"`; | ||
|
||
exports[`renderModuleStyles should not send empty styles 1`] = `"<style class="ssr-css">.test-module-b_class { color: red; }</style>"`; | ||
exports[`renderModuleStyles should handle modules with aggregated SSR styles 1`] = `"<style id="test-module_deps" data-ssr="true">.test-module_deps { color: blue; }</style><style id="test-module_local" data-ssr="true">.test-module_local { color: rebeccapurple; }</style>"`; | ||
|
||
exports[`renderModuleStyles should not send empty styles 1`] = `"<style class="ssr-css">.test-module-b_class { color: red; }</style><style id="test-module-d_deps" data-ssr="true">.test-module-d_deps { color: blue; }</style><style id="test-module-d_local" data-ssr="true">.test-module-d_local { color: rebeccapurple; }</style>"`; |
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
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.
What is the difference between
data-ssr="true'
andclass="ssr-css"
?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.
strictly speaking none - although a style tag ought not have a class name because we're not applying styles onto the element. The idea here was more of a debug step to allow us to more easily track which styles are being hydrated and which are not. We could dispense with this entirely, but it felt like that might still be a useful step for more easily debugging / visualising the changes.