diff --git a/.changeset/nervous-socks-end.md b/.changeset/nervous-socks-end.md new file mode 100644 index 000000000000..eb690f87eff8 --- /dev/null +++ b/.changeset/nervous-socks-end.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +fix: prerender page when prerender set to 'auto' and ssr set to true diff --git a/packages/kit/src/core/prerender/prerender.js b/packages/kit/src/core/prerender/prerender.js index 0e6f86306fda..07d7f0136807 100644 --- a/packages/kit/src/core/prerender/prerender.js +++ b/packages/kit/src/core/prerender/prerender.js @@ -413,7 +413,7 @@ export async function prerender() { // People can opt out of this behavior by explicitly setting prerender to false (should_prerender !== false && get_option(nodes, 'ssr') === false && !page?.server?.actions ? 'auto' - : false); + : should_prerender ?? false); prerender_map.set(route.id, prerender); } diff --git a/packages/kit/test/prerendering/basics/test/test.js b/packages/kit/test/prerendering/basics/test/test.js index 5304db89018f..d205597f3446 100644 --- a/packages/kit/test/prerendering/basics/test/test.js +++ b/packages/kit/test/prerendering/basics/test/test.js @@ -139,7 +139,7 @@ test('decodes paths when writing files', () => { assert.equal(content, JSON.stringify({ path: 'path with encoded spaces' })); }); -test('prerendering is set to true in global code of hooks.js', () => { +test('prerendering is set to true in root +layout.js', () => { const content = read('prerendering-true.html'); assert.ok(content.includes('
prerenderable shell
diff --git a/packages/kit/test/prerendering/ssr-false/test/test.js b/packages/kit/test/prerendering/ssr-false/test/test.js index 6b70952efcce..86912a8685ba 100644 --- a/packages/kit/test/prerendering/ssr-false/test/test.js +++ b/packages/kit/test/prerendering/ssr-false/test/test.js @@ -18,8 +18,13 @@ test('prerenders /prerenderable-2 shell', () => { assert.ok(!content.includes('prerenderable shell')); }); +test('prerenders /prerenderable-3 shell with ssr=true and prerender=auto', () => { + const content = read('prerenderable-3.html'); + assert.ok(content.includes('prerenderable shell')); +}); + test('does not prerender non prerenderable things', () => { - assert.equal(fs.readdirSync(build).length, 2); + assert.equal(fs.readdirSync(build).length, 3); }); test('keeps not-explicitly-prerendered routes in the manifest', () => {