Ep 7 - SvelteKit bug hunt safari
Agenda for this week
Weekly Journal Review
Walk-through of last week
Walk-through of the differences between builds
.403and.420of SvelteKitWalk-through of the buggy behavior that needs to be solved.
Upgrade
.420to the latest.465.New bug found!
Break time: Which to do?
- Downgrade SK/Vite to fix
Cannot stringify a functionwhen exporting markdown render function to+page.sveltefrom+page.server.js, OR - Build a reproduction repo for the original page refresh bug (and potential run into the stringify bug again). Same same.
- Downgrade SK/Vite to fix
Research:
- How to lock SvelteKit to a build version
- Stackoverflow: How do I lock sveltekit down to a version?
- Will using a Svelte store solve the stringify issue?
- How to create a proper reproduction
- When creating an Issue, use the Bug Report template
Reproduction A link to a repository, or a fork of https://node.new/sveltekit, that reproduces the issue. Reproductions must be short, self-contained and correct and must not contain files or code that aren’t relevant to the issue — please do NOT just paste a link to your project. Explaining how to reproduce is generally not enough. It pushes the burden of creating a reproduction project onto a small set of volunteer maintainers and isn’t scalable. If no reproduction is provided, the issue will be closed.
- Example procedure:
- Name your repro with a distinctive name so it doesn’t collide with other repros in the maintainers’ system.
- Start fresh:
$ npm init svelte - Select Skeleton project
- Select default for all options (i.e. “No”)
- Install dependencies with npm, NOT Yarn or pnpm. npm is the gold standard.
- Use minimal code and files to reproduce the Issue.
- A “perfect” example of an Issue repro: URI Encoding inconsistent between SSR and Browser routers
- When creating an Issue, use the Bug Report template
- How to lock SvelteKit to a build version
Stringify bug:
A breaking change in
.422was the root cause of the issue.From Issue #6007:
Closes #5936. This behaviour is nothing more than a historical accident. It’s buggy, and there’s no reason to keep it.
If we want routes to serve both HTML and non-HTML, #5896 is a more promising approach.
Apparently the solution will be to move the
+page.server.jscode to a+server.jsfile because they support returning JSON data as a Response.
Move the
+page.server.jscode to a+server.js!- Add
.mdfile in$lib - Add
testroute. - Inside
testadd+page.server.jsthat:import().mdfilereturnimport object to+page.svelte
- Inside
testadd+page.sveltethat:- exports
data - uses import object in a
<svelte:component>elements
- exports
- Add
Update: That didn’t work.
Update update: Both problems only needed changes to two lines of code!
Turns out there’s a new way to render the code in
+page.server.jsbefore exporting it:lessonContent.defaultis now
lessonContent.default.render().htmlAnd you no longer need to use a dynamic component:
<svelte:component this={data.lessonContent} />is now:
{@html data.lessonContent}In hindsight, checking the original theme commits for changes would have saved hours of grinding, but at least I learned some things along the say (see above).
Cleanup
- Update schedule for next stream (README.md)