-
-
Notifications
You must be signed in to change notification settings - Fork 362
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
SSR Experimental #8356
SSR Experimental #8356
Conversation
✅ Deploy Preview for koda-canary ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Reviewpad Report
|
AI-Generated Summary: This pull request contains updates to multiple files throughout the codebase with a consistent theme of refining the code to improve efficiency, robustness, compatibility with server-side rendering, and readability. The dependencies in the Most importantly, the adaptation for server-side rendering (SSR) is visible in many files, through the use of conditional checks (like In several places, the LocalStorage operations have also been made more null-safe by using optional chaining ( Moreover, the import of heavy libraries and plugins has been moved to Vue Some noticeable changes have been made to alter method of async import for the web3Enable from '@polkadot/extension-dapp' module now only on the client-side, ensuring that runtime errors in contexts such as testing and SSR are mitigated. The server-side rendering (ssr) previously set to false has also been made true in the The newly added file Code has been fine-tuned for improved readability with changes to import statements, formatting, and breaking down complex logical checks into more straightforward syntax. Console logs have been added in some places presumably for debugging purposes. The overall changes to components, services, and utilities are mostly about improving maintainability, robustness, SSR compatibility while some new dependencies added to the lock file hint at extending the functionality. |
@roiLeo Hi, sorry I didn't ask you what the status of this task is, I just saw that it's been in Draft status for a few weeks and I wanted to do something interesting Friday night. The project is at least locally up and running, I'll need help with testing. About this PRI've been able to solve almost all of the problems you've encountered. I didn't use ClientOnly at all, pinia stores state is restored from localStorage but it can be placed in a cookie, also no dark mode bug. The only problem I've found is that on netlify every second/third refresh of the page the same error like yours crashes UPDATE: I solved problem on netlify. The only big problem left is that the tests are failing |
cc @yangwao you'll be glad |
nice, but I can't open the preview page need to test it on the Cloudflare pages also |
How can I do it? On netlify preview everything is fine |
hmm yesterday preview was fine... |
@preschian check it please https://deploy-preview-8356--koda-canary.netlify.app/ I think the error was caused by my last commit yesterday, now I did a revert and everything is ok |
cc @yangwao |
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.
- Some of main components need ClientOnly (like darkmode)
- Dropdowns looks weird
- profile/wallet doesn't work on reload
same thing as #7725
@roiLeo thanks! I'm checking |
@roiLeo could you give me more details about this please
I fixed stores which connected with localStorage, it should be persist |
@@ -0,0 +1,33 @@ | |||
export default function (customBreakpoint?: number) { |
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.
Function default
has 26 lines of code (exceeds 25 allowed). Consider refactoring.
SSR affects performance in such a way that a user with poor internet will see content faster, i.e. instead of a white screen they will get html + css right away. It is also useful for SEO. Btw Idk I got other results in Lighthouse: canary https://canary.kodadot.xyz/ Checked in Google Chrome Incognito with disabled cache. If you don't even look at scores, you can see serious improvements in the metrics. Yes for mobile the overall score has decreased a bit (this is mainly due to the ssr images not affecting it), but it is worth paying attention to the metrics, they have improved significantly. And about the size of the PR, yes it is really big, but there is no other way to do it. I just saw that @roiLeo also worked on SSR, so I thought it was important for the project |
|
||
const isRmrk = computed(() => prefix.value === 'rmrk') | ||
onMounted(() => { |
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.
Identical blocks of code found in 2 locations. Consider refactoring.
const isAssetHub = computed( | ||
() => prefix.value === 'ahk' || prefix.value === 'ahp', //|| prefix.value === 'ahr' | ||
) | ||
watch(prefix, () => { |
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.
Identical blocks of code found in 2 locations. Consider refactoring.
Code Climate has analyzed commit 7d9b2cf and detected 3 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Tests are green |
Hey @roiLeo @preschian I know the PR turned out gigantic and realize it's risky to merge it into the main branch. So I won't mind, and I won't be upset if you close it. I did it on my own initiative and the task was really interesting. Below I will write a list of tricky problems that I managed to solve, as it may be useful in the future:
If the activation of ssr is still of interest to you, please let me know and I'll look into it. I have some ideas on how to break this PR into many smaller ones. For example, PR1. Replace the use of browser APIs/client APIs (like I did in the browserAPIs file) PR2. Add await page.waitForLoadState('networkidle') to tests and command cd .output/server/node_modules/tslib; npm pkg set 'exports[.].imports.node'='./tslib.es6.mjs' PR3. Integration pinia with localStorage (module @pinia-plugin-persistedstate/nuxt and PR4. Find places where html attributes (like src for img tag) are changed using computed/watch and use there useStore and watchPostEffect. Also replace changes using JS with CSS where possible PR5. Here we can change ssr flag to true in nuxt.config |
It works now 👍 could you test with Cloudflare pages? I already added this branch to our cf-pages, but it didn't work. Try to integrate your forked repo with Cloudflare pages, it's free https://pages.cloudflare.com/. Just to make sure the build on cf-pages was ok |
I always like the ideas about gradual release 👍
This is still too big because it affects all endpoints. To minimize the risk, I think we can enable it by endpoints: PR -> ssr only on |
@preschian btw ye, I can wrap client side pages in Update I've found this, so we can manage ssr for pages in config |
Then I think this PR can be closed and I'll create an epic task with small subtasks. Does that sound good to you guys? |
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.
wow, I can see that this branch start to look good there is a lot of progress compared to #7725
Now we have to test that nothing breaks: on first load, with cache, without cache, with reload etc..
Note: I still see light mode logo on dark mode 2 sec before it change
@@ -6,7 +6,10 @@ | |||
width="740" | |||
height="1000" | |||
alt="" /> | |||
<img :src="landingImage[0]" class="landing-shapes" alt="" /> | |||
<img | |||
src="/landing-shape-header-left-light.svg" |
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.
oh this is new
@include ktheme() { | ||
filter: theme('landing-shape-header'); | ||
} |
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.
why put code in this component?
https://caniuse.com/css-filters global 97% ok
email: '#000000', | ||
text: '#000000', | ||
}, | ||
} as const |
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.
as const?
@@ -7,7 +6,13 @@ import { useChainStore } from '@/stores/chain' | |||
|
|||
// } | |||
|
|||
export default defineNuxtPlugin(() => { | |||
export default defineNuxtPlugin(async () => { | |||
if (!process.client) { |
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.
rename file to polkadot.client.ts
for only client side
if (!process.client) { | ||
return | ||
} |
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.
pwa.client.ts
@roiLeo to avoid flash logo for different themes we have to use css and don't use js for styling anymore. But anyway this PR is so big, I'll separate it to many parts, I think we will have ssr within 1-2 weeks |
Thank you for your contribution to the KodaDot - One Stop Shop for Polkadot NFTs.
👇 __ Let's make a quick check before the contribution.
PR Type
Context
Before submitting pull request, please make sure:
Optional
Did your issue had any of the "$" label on it?
Community participation
Screenshot 📸
Copilot Summary
🤖[deprecated] Generated by Copilot at a264c75
The pull request improves the compatibility, performance, and readability of various components by using custom hooks and services to access browser APIs and environment variables. It also refactors some code to simplify logic and avoid reactivity issues. The main files affected are
components/blog/BlogPost.vue
,components/carousel/utils/useCarouselEvents.ts
,components/chart/PriceChart.vue
,components/collection/HeroButtons.vue
,components/collection/unlockable/CountdownTimer.vue
,components/collection/unlockable/UnlockableLoader.vue
,components/common/ConnectWallet/ConnectWalletModal.vue
,components/CookieBanner.vue
,components/gallery/GalleryItemTabsPanel/GalleryItemTabsPanel.vue
,components/MessageNotify.vue
,components/Navbar.vue
,components/profile/ProfileDetail.vue
,components/base/MediaItem.vue
,components/collection/unlockable/UnlockableHeroButtons.vue
,components/CustomSubstackEmbed.vue
,components/gallery/GalleryItemButton/GalleryItemShareBtn.vue
,components/landing/MobileHeroBanner.vue
,components/navbar/NotificationBoxButton.vue
,components/navbar/ShoppingCartButton.vue
, andcomponents/search/SearchBar.vue
.🤖[deprecated] Generated by Copilot at a264c75