fix: prerender pages adjacent to endpoints - #15621
Conversation
🦋 Changeset detectedLatest commit: 116467f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
regressions fixed, should also close #10735 |
GET
| assert.isTrue(fs.existsSync(`${build}/get-and-post.html`)); | ||
| }); | ||
|
|
||
| test('prerendering a page with a linked GET server endpoint processes properly', () => { |
There was a problem hiding this comment.
This test passes even without the PR's fix. Do we really need it? Even if the endpoint wasn't discovered while crawling the page, the prerenderer would prerender the endpoint because it detects the exported prerender page option during analysis.
There was a problem hiding this comment.
I mean I see no harm done in keeping it, I put it there in part because I knew my code changed the behavior there and I wanted to be sure that there was no regression happening on my behalf. Fully up to yall.
teemingc
left a comment
There was a problem hiding this comment.
Thanks! This is looking good. I just have two concerns which I've outlined in the files changed.
GET…eeded to be truthy
suggested change by sveltekit contributors! Co-authored-by: Tee Ming <chewteeming01@gmail.com>
Co-authored-by: Tee Ming <chewteeming01@gmail.com>
Co-authored-by: Tee Ming <chewteeming01@gmail.com>
Co-authored-by: Tee Ming <chewteeming01@gmail.com>
Co-authored-by: Tee Ming <chewteeming01@gmail.com>
|
hit the big "rebase to sveltejs:main" button and nothing broke, supposedly looks good? |
Routes with content negotiation cannot be prerendered. This may potentially be fixed by sveltejs/kit#15621
|
This doesn't seem right to me. Surely if a route has both a |
|
Closing in favour of #16075 |
…erenderable (#16075) I'm pretty sure this, and not #15621, is the desired behaviour. Closes #15620 --- ### Please don't delete this checklist! Before submitting the PR, please make sure you do the following: - [x] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs - [x] This message body should clearly illustrate what problems it solves. - [ ] Ideally, include a test that fails without this PR but passes with it. ### Tests - [x] Run the tests with `pnpm test` and lint the project with `pnpm lint` and `pnpm check` ### Changesets - [x] If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running `pnpm changeset` and following the prompts. Changesets that add features should be `minor` and those that fix bugs should be `patch`. Please prefix changeset messages with `feat:`, `fix:`, or `chore:`. ### Edits - [x] Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.
closes #15620
closes #10735
This PR addresses #15620, and adds tests for any possible regressions as a result of the implemented fix. (edit: seems to also fix #10735)
Changes:
kit/src/core/postbuild/analyse.jsto add additional metadata fields to route metadata,page.prerenderandapi.prerender, which pass on the page and endpoint prerender fields. this prevents a regression which forces all parts of a route to prerender even if only one part requests it.kit/src/core/postbuild/prerender.jsto check ifpage.prerenderandapi.prerenderis true, and enqueue prerendering if so. uses\x00pageas a postfix to page keys within the preexistingseenset to differentiate between api endpoints and pages.kit/src/core/postbuild/prerender.js, added and documentedexpect_htmlparameter invisit()andenqueue()to specify that theAccept: text/htmlheader should be sent to the internal server when prerendering a page.prerendering/basics, one which tests the fix itself (seeprerender-with-server-endpoint) and one which confirms the non-existence of a possible regression (seelinked-api). both tests pass with flying colors :DPlease don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.Edits