-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[breaking] prerender shells when ssr false and prerender not false (#…
…8131) * [breaking] prerender shells when ssr false and prerender not false Closes #3966 * fix * keep implicitly rendered route in the manifest * there's no 1 * additional check * omit type check for now, uncovered a unreleated issue
- Loading branch information
1 parent
8f807ea
commit f1ec316
Showing
21 changed files
with
184 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@sveltejs/kit': patch | ||
--- | ||
|
||
[breaking] prerender shells when ssr false and prerender not false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
!.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "prerendering-test-ssr-false", | ||
"private": true, | ||
"version": "0.0.2-next.0", | ||
"scripts": { | ||
"dev": "vite dev", | ||
"build": "vite build", | ||
"preview": "vite preview", | ||
"test": "svelte-kit sync && pnpm build && uvu test" | ||
}, | ||
"devDependencies": { | ||
"@sveltejs/kit": "workspace:*", | ||
"svelte": "^3.54.0", | ||
"svelte-check": "^2.9.2", | ||
"typescript": "^4.9.3", | ||
"uvu": "^0.5.6", | ||
"vite": "^4.0.0" | ||
}, | ||
"type": "module" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/// <reference types="@sveltejs/kit" />; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width" /> | ||
%sveltekit.head% | ||
</head> | ||
<body> | ||
%sveltekit.body% | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const ssr = false; |
1 change: 1 addition & 0 deletions
1
packages/kit/test/prerendering/ssr-false/src/routes/not-prerenderable/+page.server.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const actions = {}; |
1 change: 1 addition & 0 deletions
1
packages/kit/test/prerendering/ssr-false/src/routes/not-prerenderable/+page.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<p>Not prerenderable because it has +page.server.js actions</p> |
1 change: 1 addition & 0 deletions
1
packages/kit/test/prerendering/ssr-false/src/routes/opt-out/+page.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const prerender = false; |
1 change: 1 addition & 0 deletions
1
packages/kit/test/prerendering/ssr-false/src/routes/opt-out/+page.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<p>prerenderable shell, but opted out of prerendering explicitly</p> |
3 changes: 3 additions & 0 deletions
3
packages/kit/test/prerendering/ssr-false/src/routes/prerenderable-2/+page.server.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function load() { | ||
throw new Error('I should not be called during prerendering'); | ||
} |
1 change: 1 addition & 0 deletions
1
packages/kit/test/prerendering/ssr-false/src/routes/prerenderable-2/+page.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<p>prerenderable shell</p> |
3 changes: 3 additions & 0 deletions
3
packages/kit/test/prerendering/ssr-false/src/routes/prerenderable/+page.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function load() { | ||
throw new Error('I should not be called during prerendering'); | ||
} |
1 change: 1 addition & 0 deletions
1
packages/kit/test/prerendering/ssr-false/src/routes/prerenderable/+page.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<p>prerenderable shell</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** @type {import('@sveltejs/kit').Config} */ | ||
const config = { | ||
kit: {} | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import * as fs from 'fs'; | ||
import { fileURLToPath } from 'url'; | ||
import { test } from 'uvu'; | ||
import * as assert from 'uvu/assert'; | ||
|
||
const build = fileURLToPath(new URL('../.svelte-kit/output/prerendered/pages', import.meta.url)); | ||
|
||
/** @param {string} file */ | ||
const read = (file, encoding = 'utf-8') => fs.readFileSync(`${build}/${file}`, encoding); | ||
|
||
test('prerenders /prerenderable shell', () => { | ||
const content = read('prerenderable.html'); | ||
assert.ok(!content.includes('prerenderable shell')); | ||
}); | ||
|
||
test('prerenders /prerenderable-2 shell', () => { | ||
const content = read('prerenderable-2.html'); | ||
assert.ok(!content.includes('prerenderable shell')); | ||
}); | ||
|
||
test('does not prerender non prerenderable things', () => { | ||
assert.equal(fs.readdirSync(build).length, 2); | ||
}); | ||
|
||
test('keeps not-explicitly-prerendered routes in the manifest', () => { | ||
const manifest = fileURLToPath( | ||
new URL('../.svelte-kit/output/server/manifest.js', import.meta.url) | ||
); | ||
const content = fs.readFileSync(manifest, 'utf-8'); | ||
assert.ok(content.includes('/prerenderable')); | ||
assert.ok(content.includes('/prerenderable-2')); | ||
}); | ||
|
||
test.run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"compilerOptions": { | ||
"allowJs": true, | ||
"checkJs": true, | ||
"noEmit": true, | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"paths": { | ||
"@sveltejs/kit": ["../../../types"], | ||
"$lib": ["./src/lib"], | ||
"$lib/*": ["./src/lib/*"], | ||
"types": ["../../../types/internal"] | ||
} | ||
}, | ||
"extends": "./.svelte-kit/tsconfig.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import * as path from 'path'; | ||
import { sveltekit } from '@sveltejs/kit/vite'; | ||
|
||
/** @type {import('vite').UserConfig} */ | ||
const config = { | ||
build: { | ||
minify: false | ||
}, | ||
|
||
clearScreen: false, | ||
|
||
logLevel: 'silent', | ||
|
||
plugins: [sveltekit()], | ||
|
||
define: { | ||
'process.env.MY_ENV': '"MY_ENV DEFINED"' | ||
}, | ||
|
||
server: { | ||
fs: { | ||
allow: [path.resolve('../../../src')] | ||
} | ||
} | ||
}; | ||
|
||
export default config; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.