-
Notifications
You must be signed in to change notification settings - Fork 35
Migrate to SvelteKit #311
Comments
Hi! We have considered it. In regards to moving the repository to the SvelteKit-proposed "lib for source, routes for docs", we have faced difficulties with migration. Something was off with the packaging. Or something, honestly, don't remember now (should have taken notes!). It didn't seem like a good experience back then, that was around a few months ago. Alternatively, we tried replacing Sapper with SvelteKit just for the docs and leaving the rest of the library as it is. We've managed to fix the issues that came up, but never got around to finishing it. Still, the experience of migrating to SvelteKit leaves things to be desired. I wouldn't call it a smooth migration just yet. That said, we are watching SvelteKit closely and will hop over as soon it becomes sufficiently stable. |
I guess by "lib for source", you mean Do you happen to have a branch where you're working on the docs migration? I'm one of the primary maintainers of SvelteKit and looking for any issues that need to be fixed before 1.0 since we're getting closer to that. I went through all the open source repos using Sapper and left this message with any large, active repos to help discover what blockers there might be. I'd want to make sure we have any issues fixed before declaring 1.0. We just migrated sveltesociety.dev and have a PR open for svelte.dev and were able to migrate those two, but I'm curious to see if there are issues that others might be facing out in the wild, so I'm happy to help if there are things that might be causing any difficulty. |
Yeah, ideally we'd like to make use of As for the branch – yes, I just pushed the existing migration work, you can see the pull request linked below. I notice a bit of jank when navigating the pages – whatever might be causing that. Also I feel like configuring the app to export statically might not be as straightforward as it was with Sapper. As for other issues that I've encountered – a known issue where Vite doesn't do |
There's some issues in dev mode that might cause a flash of unstyled content or other jankiness, but you won't see this in production. You do have an issue with loading your style sheets though - I left a comment on the PR about that
I'm not sure if there's some reason you expect it might be difficult, but in general all you need to do is install the static adapter, which is pretty straightforward: https://github.com/sveltejs/kit/tree/master/packages/adapter-static#usage I can give you more advice if you run into trouble or have a certain web host you're targeting
That should work by default soon. We have a PR out to start to address it: sveltejs/svelte#6835 Let me know if there's anything else I can do to help! |
When I mentioned jank a few days ago, I was recalling from memory. Today I went ahead and tried it again. The Vite server starts almost instantly, which is great, but then the first request to This amounts for a rather unpleasant development experience. I think we should stay with Sapper until this performance issue gets resolved. I'm happy to aid in investigating that issue. |
That's been fixed. Please upgrade to the latest version of SvelteKit The colors thing is weird. The text is not black for me, but is grey. Maybe it's something to do with us having different terminal themes |
This seems to be due to broken links. It appears we don't give very good error messages when trying to prefetch a page that doesn't exist. If you're able to fix all the links first then I can take another look at any remaining jank or performance issues E.g. if you're on http://localhost:3000/docs/components/button and click "migration guide" you will be taken to http://localhost:3000/docs/components/docs/migration-guide instead of http://localhost:3000/docs/migration-guide.
Did you just do that locally? I don't see the changes appearing
We print it in If your terminal theme is showing gray as black, it seems more to me like the bug would be in your terminal theme. I'm hesitant to try to work around that in SvelteKit because there's an infinite number of terminal themes out there and if we fix it for one then we'll probably break it for another. I haven't seen anyone else hit this issue before |
Fixed the links, supposedly. The jank is still there, on any page, even the
Yeah, but now I pushed the changes. |
I cannot reproduce any error when reloading the page. I can't find any open issues about it either. Enough people are using SvelteKit at this point that it has to be something specific to your project or more likely your machine since I can't reproduce it. Can you run I did encounter two errors on the console while clicking around. It looks like you have two file paths that didn't get updated:
|
I also can't reproduce any errors. I thought I'd give it a shot, since my OS is quite different than @illright's (I use Windows 10, he uses Linux and I forgot which distro 😁). To make it work, I first had to replace any usages of the custom resolve function from resolve.js with the one built-in in Node, while also removing the About the 2 errors, it is not that the file path has not been updated, but rather they were missed in the commit where all the styles where inlined. In fact, there are 5 of them and I believe they are a problem of copy-pasting files, forgetting to remove the style import, the styles not applying due to different selectors, and not getting any errors earlier due to the files existing. None of that is SvelteKit's problem, but I'm just writing my diagnosis of the issue so that we (@illright) can fix them. As for the issues described above, everything is working very smoothly. Yes, the initial page load is relatively slow, but I understand that's due to how Vite works, with all the compiling on demand. After the initial load, I get no more jittering. Also, all the colors look good on my terminal with a white background. System info
|
Thank you for testing! I'm also on Linux, for what it's worth. Maybe @illright should run Regarding |
|
My system info, where I get the lags
I've also brought up an Amazon EC2 instance with Attractions docs in dev mode, upd: no longer available. Let me know if it's needed and I'll bring it back up again. It seems a bit better (not seeing 500's anymore), but still janky, as in the reloads take a long time, not only the inital page load. AWS EC2's system info
|
The slow reloads seems to be because it's loading 485 files in dev mode. It appears to be loading all of In production mode, it's not bad. It only loads 33 files and is pretty snappy. Production mode build fails by default though. I sent a fix for that here: lgarron/clipboard-polyfill#144 |
Thank you for a thorough investigation :) I believe it was once a best practice for Sapper to install Svelte packages to development dependencies for SSR. I have a lot of questions:
|
Putting it dev dependencies is still a good place to put it. It won't affect this at all I actually have no idea how to fix this in Vite. It will probably be extremely hard to fix and not happen anytime soon. In the meantime, what I would recommend is doing a deep import as a workaround. It looks like that was recommended even in Sapper actually: dylanblokhuis/svelte-feather-icons#10 (comment) You should not bundle the library ahead of time (ignore that I said that. I edited my comment above) I think your users may have to do deep imports of attractions for the meantime as well if performance is an issue for them. I hate having to recommend that, but I'm afraid it's the best I have at the moment. |
I've implemented a preprocessor that does rudimentary import re-routing and it seems to work well in my case. I've read the thread you've linked and saw that you were discussing a similar thing with the maintainers of Carbon Components. Perhaps we should polish it up and publish it, maybe even under the hood of the Svelte organization. What do you think? As a future improvement, we could make this automatic – follow the Node resolution algorithm and rewrite imports without specifying the rule. |
Yes, I proposed making a generic library for it in carbon-design-system/carbon-preprocess-svelte#20. Though there's also been another proposed solution that we may want to consider: sveltejs/kit#2612 (comment) It seems like the PR to convert to SvelteKit is getting pretty close now! Is there anything else you want to fix before merging it? |
First we got to set up the static exports and verify that everything works. Shouldn't be too long |
Oh, yeah, I forgot about that. We will have to wait a little for that because we'll need lgarron/clipboard-polyfill#144 fixed before |
UPD: never mind, it can't. I've just read the docs a bit further, and it says that. Oh well. |
I've added the static adapter. There seems to be an issue regarding the link paths in the resulting HTML. I run the following command (after patching up attractions/docs$ env APP_BASEPATH=/attractions/1337 pnpm build It generates an <head>
<!-- hardcoded in app.html -->
<link rel="manifest" href="/manifest.json" crossorigin="use-credentials" />
<meta name="msapplication-config" content="/browserconfig.xml" />
<!-- generated in place of %sveltekit.head% -->
<link rel="modulepreload" href="/attractions/1337/_app/start-8730cdc3.js">
</head> Notice how the path of Sapper used to have a placeholder Another thing that isn't great about non-standard bases with SvelteKit: when you run |
Since |
You could file a feature request in the SvelteKit repo and in the meantime you could create a |
I haven't tested, but possibly that will be fixed when we upgrade to the latest version of Vite vitejs/vite#5268 |
But that still doesn't solve the issue of some paths being static and others (ones generated by SvelteKit) being rebased onto the base path. Any idea on how to prevent SvelteKit from generating links with the base of /? |
You could prefix the static links with some placeholder like |
Is this a known issue though, or should it be filed as a bug? |
I don't think there's any open issue to track it |
There is now. We'll wait until this is resolved to continue migrating. |
It seems a nice thing for us to add, but it's relatively low priority given that it doesn't affect all users and can be implemented on the user-side. I'd consider a PR if you want to send one or you can add the workaround here. I just wanted to be honest with you, that I think you'd be waiting quite a long time if you waited for us to implement it. |
sveltejs/kit#2697 has been resolved, so hopefully you can continue the migration now! |
@benmccann We've proceeded further with the migration, however, now, a rather puzzling error appears upon trying to export the site:
To reproduce this, run The error suggests that we have a link to |
This is a regression in Kit. I sent a fix (sveltejs/kit#3367). In the meantime, you can make it work by temporarily downgrading to |
The SvelteKit fix has been merged and release, so it should work now with the latest version of SvelteKit |
@illright just checking in on this since it seemed like you were almost done with it. is there anything you're currently stuck on that I might be able to lend some advice about? |
Nothing particular that we're stuck with, we're not making much progress due to a lack of motivation :) I appreciate you checking in though, I might come back to this for another burst some time soon. |
@benmccann I have restarted the work in the new Pull Request linked above. Please take a look and tell me what you think. The failing pipeline for now is the linting one, which is expected when moving from JavaScript to TypeScript and uncovering a lot of problems. |
Sapper is no longer actively developed and SvelteKit is a much better experience
Migration guide: https://kit.svelte.dev/migrating
The text was updated successfully, but these errors were encountered: