-
Notifications
You must be signed in to change notification settings - Fork 53
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
Hydrated Nested Svelte Components Losing Styles #37
Comments
Yes, I found that also - first time, I was confused, my solution was to move the css inline to global css file - not great solution though. Maybe because when server rendered some component not appear yet, so css is purged in the client |
@halafi and I will be looking at this tomorrow. Relevant file: https://github.com/Elderjs/elderjs/blob/master/src/utils/svelteComponent.ts Angles to explore:
|
From memory it should not be the second option. Rendering a "top-level" component should take into consideration all the sub-components and render it all out with HTML, HEAD and CSS, as long as there isn't any async/await involved. |
So I think in this case the SSR component render behaves as expected, no html / css for the mobile menu is there if No css emitted for html css. The client side svelte component mounts the html on 🍔 button click, but doesn't load any css - I guess we should have all styles in additional .css file, but probably emitted by the client side component render in svelteComponent? -- I didn't find a fix, but a quick workaround: always render the mobile menu in Navigation component |
It appears that the css isn't emitted when there is a boolean that is false-y during SSR. Another work around for V1 is to use I think it may be worth opening an issue with Svelte on because it appears that NOT emitting CSS on the client is the desired behavior... except when the compiler is given 'ssr'. Having discussed the options with @halafi, Elder.js has few ways to solve this problem directly due to our complex rollup process.
I like the 2nd option the best, but not sure how to get a script to fire EVERY time rollup runs if it isn't a rollup config. |
I once again encountered this bug when trying to use a modal/dialog component that mounts itself as a new "app". All the styles are lost. Examples usage of said modal/dialog. <script>
import { Confirm } from 'dialog';
async function handleDelete() {
const proceed = await Confirm('Really?');
....
}
</script>
|
@nickreese Is it fixed already in newest release ? |
cool thanks |
@nickreese I'm still getting this issue as of v1.1.8 and was able to reproduce it with the template on updated packages (as well as default template with no updated packages) by isolating / stripping components. Should I copy+paste it or is it enough that you're aware it's still an issue? There's a caveat: This only happens for Additionally, on the new update I'm having a weird issue in my project where changing files during development won't apply after rollup detects the change, and most styles for the entire app disappear forcing me to restart rollup to get it to apply the changes (back to normal). I think these changes not applying doesn't just apply to styles, though, and I'm not confident I can reproduce it on the template... however my codebase doesn't deviate too far from the template besides updated packages. Just an FYI, if you update all the packages in the template you'll need to install postcss manually as it's not included in the (Very tiny nitpick from before but I noticed the CSS sourcemaps are sort of working now! Which is great except most of the components I'm seeing aren't mapping 1:1 and while the file is all correct, the lines all map to end up at the last line of the style tag. Not sure if you've noticed this yet?) EDIT: Just wanted to mention the specific issue I'm having is similar to the example above where Kev is toggling a menu. Because of that the |
@armchair-traveller sorry about the issues. Been digging into css edge cases all week. If you can create a repo that I can clone that would be helpful. I’m surprised falsey values would be excluded with this implementation. Honestly it appears we’re up against a rock and a hard place with the Svelte ssr component only emitting truth-y styles and with the Svelte plugin changing when SvelteKit is released we either need to write our own Rollup plugin or just write css to a single central file though that doesn’t seem ideal. Further the Svelte plugin is looking at dropping sourcemap support so that will cause our support to drop as well. My current thought is to go back to the old CSS implementation without sourcemaps that has falsey value issues and allow users to add their own rollup plugins to handle css files if desired and toggle off adding CSS into the html. Lots of digging left to do and unfortunately there just isnt an easy one size fits all solution that I see. |
@nickreese no worries. I'm confident you'll get it resolved in a satisfactory manner. Repo: https://github.com/armchair-traveller/elderjs-issue-37 Kind of sad they're dropping sourcemap support in the Svelte plugin but I guess there's not enough demand to deter them from doing so, which is understandable if that's the case. |
I can confirm the same issue. |
@s-kris make sure you’re on the latest release and have rerun rollup. |
@nickreese Thank you :) |
I ran across a problem where a hydrated components nested component lost some or all of it's styles. The following component has
hydrate-client
on it:and
The workaround I found is to move the content of
MobileMenu.svelte
intoNavigation.svelte
.The text was updated successfully, but these errors were encountered: