diff --git a/.changeset/sharp-glasses-mix.md b/.changeset/sharp-glasses-mix.md new file mode 100644 index 000000000000..6e6e813c75a7 --- /dev/null +++ b/.changeset/sharp-glasses-mix.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +[breaking] replace `router`/`hydrate` page options with `csr` diff --git a/documentation/docs/00-introduction.md b/documentation/docs/00-introduction.md index b8d93d0b6664..9416b4545a7d 100644 --- a/documentation/docs/00-introduction.md +++ b/documentation/docs/00-introduction.md @@ -12,7 +12,7 @@ title: Introduction SvelteKit is a framework for building extremely high-performance web apps. -Building an app with all the modern best practices is fiendishly complicated. Those practices include [build optimizations](https://vitejs.dev/guide/features.html#build-optimizations), so that you load only the minimal required code; [offline support](/docs/service-workers); [prefetching](/docs/a-options#sveltekit-prefetch) pages before the user initiates navigation; and [configurable rendering](/docs/page-options) that allows you to generate HTML [on the server](/docs/appendix#ssr) or [in the browser](/docs/page-options#router) at runtime or [at build-time](/docs/page-options#prerender). SvelteKit does all the boring stuff for you so that you can get on with the creative part. +Building an app with all the modern best practices is fiendishly complicated. Those practices include [build optimizations](https://vitejs.dev/guide/features.html#build-optimizations), so that you load only the minimal required code; [offline support](/docs/service-workers); [prefetching](/docs/a-options#sveltekit-prefetch) pages before the user initiates navigation; and [configurable rendering](/docs/page-options) that allows you to render your app [on the server](/docs/appendix#ssr) or [in the browser](/docs/appendix#csr) at runtime or [at build-time](/docs/page-options#prerender). SvelteKit does all the boring stuff for you so that you can get on with the creative part. It uses [Vite](https://vitejs.dev/) with a [Svelte plugin](https://github.com/sveltejs/vite-plugin-svelte) to provide a lightning-fast and feature-rich development experience with [Hot Module Replacement (HMR)](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/config.md#hot), where changes to your code are reflected in the browser instantly. diff --git a/documentation/docs/03-routing.md b/documentation/docs/03-routing.md index 462ff74754d3..92f6f270e9f6 100644 --- a/documentation/docs/03-routing.md +++ b/documentation/docs/03-routing.md @@ -70,9 +70,8 @@ This function runs alongside `+page.svelte`, which means it runs on the server d As well as `load`, `page.js` can export values that configure the page's behaviour: - `export const prerender = true` or `false` or `'auto'` -- `export const hydrate = true` or `false` -- `export const router = true` or `false` - `export const ssr = true` or `false` +- `export const csr = true` or `false` You can find more information about these in [page options](/docs/page-options). @@ -111,7 +110,7 @@ export async function load({ params }) { During client-side navigation, SvelteKit will load this data from the server, which means that the returned value must be serializable using [devalue](https://github.com/rich-harris/devalue). -Like `+page.js`, `+page.server.js` can export [page options](/docs/page-options) — `prerender`, `hydrate`, `router` and `ssr`. +Like `+page.js`, `+page.server.js` can export [page options](/docs/page-options) — `prerender`, `ssr` and `csr`. #### Actions @@ -282,7 +281,7 @@ export function load() { } ``` -If a `+layout.js` exports [page options](/docs/page-options) — `prerender`, `hydrate` `router` and `ssr` — they will be used as defaults for child pages. +If a `+layout.js` exports [page options](/docs/page-options) — `prerender`, `ssr` and `csr` — they will be used as defaults for child pages. Data returned from a layout's `load` function is also available to all its child pages: @@ -302,7 +301,7 @@ Data returned from a layout's `load` function is also available to all its child To run your layout's `load` function on the server, move it to `+layout.server.js`, and change the `LayoutLoad` type to `LayoutServerLoad`. -Like `+layout.js`, `+layout.server.js` can export [page options](/docs/page-options) — `prerender`, `hydrate` `router` and `ssr`. +Like `+layout.js`, `+layout.server.js` can export [page options](/docs/page-options) — `prerender`, `ssr` and `csr`. ### +server diff --git a/documentation/docs/09-a-options.md b/documentation/docs/09-a-options.md index c5184f7793a9..090b603a6118 100644 --- a/documentation/docs/09-a-options.md +++ b/documentation/docs/09-a-options.md @@ -16,8 +16,6 @@ We can mitigate that by _prefetching_ the data. Adding a `data-sveltekit-prefetc ...will cause SvelteKit to run the page's `load` function as soon as the user hovers over the link (on a desktop) or touches it (on mobile), rather than waiting for the `click` event to trigger navigation. Typically, this buys us an extra couple of hundred milliseconds, which is the difference between a user interface that feels laggy, and one that feels snappy. -Note that prefetching will not work if the [`router`](/docs/page-options#router) setting is `false`. - You can also programmatically invoke `prefetch` from `$app/navigation`. ### data-sveltekit-reload diff --git a/documentation/docs/12-page-options.md b/documentation/docs/12-page-options.md index e8e44dd0af60..4067690edd89 100644 --- a/documentation/docs/12-page-options.md +++ b/documentation/docs/12-page-options.md @@ -68,35 +68,24 @@ For that reason among others, it's recommended that you always include a file ex For _pages_, we skirt around this problem by writing `foo/index.html` instead of `foo`. -### hydrate - -Ordinarily, SvelteKit [hydrates](/docs/appendix#hydration) your server-rendered HTML into an interactive page. Some pages don't require JavaScript at all — many blog posts and 'about' pages fall into this category. In these cases you can skip hydration through the `hydrate` export: - -```js -/// file: +page.js -export const hydrate = false; -``` - -> If `hydrate` and `router` are both `false`, SvelteKit will not add any JavaScript to the page at all. If [server-side rendering](/docs/hooks#handle) is disabled in `handle`, `hydrate` must be `true` or no content will be rendered. - -### router +Note that this will disable client-side routing for any navigation from this page, regardless of whether the router is already active. -SvelteKit includes a [client-side router](/docs/appendix#routing) that intercepts navigations (from the user clicking on links, or interacting with the back/forward buttons) and updates the page contents, rather than letting the browser handle the navigation by reloading. +### ssr -In certain circumstances you might need to disable [client-side routing](/docs/appendix#routing) through the `router` export: +Normally, SvelteKit renders your page on the server first and sends that HTML to the client where it's hydrated. If you set `ssr` to `false`, it renders an empty 'shell' page instead. This is useful if your page is unable to be rendered on the server, but in most situations it's not recommended ([see appendix](/docs/appendix#ssr)). ```js /// file: +page.js -export const router = false; +export const ssr = false; ``` -Note that this will disable client-side routing for any navigation from this page, regardless of whether the router is already active. +### csr -### ssr - -Normally, SvelteKit renders your page on the server first and sends that HTML to the client where it's hydrated. If you set `ssr` to `false`, it renders an empty 'shell' page instead. This is useful if your page accesses browser-only methods or objects, but in most situations it's not recommended ([see appendix](/docs/appendix#ssr)). +Ordinarily, SvelteKit [hydrates](/docs/appendix#hydration) your server-rendered HTML into an interactive client-side-rendered (CSR) page. Some pages don't require JavaScript at all — many blog posts and 'about' pages fall into this category. In these cases you can disable CSR: ```js /// file: +page.js -export const ssr = false; +export const csr = false; ``` + +> If both `ssr` and `csr` are `false`, nothing will be rendered! diff --git a/documentation/docs/17-seo.md b/documentation/docs/17-seo.md index 2e1d882dc117..6642cf509f53 100644 --- a/documentation/docs/17-seo.md +++ b/documentation/docs/17-seo.md @@ -99,14 +99,11 @@ const config = { export default config; ``` -...disabling `hydrate` and `router` in your root `+layout.js`/`+layout.server.js`... +...disabling `csr` in your root `+layout.js`/`+layout.server.js`... ```js /// file: src/routes/+layout.server.js -// the combination of these options -// disables JavaScript -export const hydrate = false; -export const router = false; +export const csr = false; ``` ...and transforming the HTML using `transformPageChunk` along with `transform` imported from `@sveltejs/amp`: diff --git a/packages/create-svelte/templates/default/src/routes/about/+page.ts b/packages/create-svelte/templates/default/src/routes/about/+page.ts index d08ebec1bdeb..3e13462cd998 100644 --- a/packages/create-svelte/templates/default/src/routes/about/+page.ts +++ b/packages/create-svelte/templates/default/src/routes/about/+page.ts @@ -1,12 +1,8 @@ -import { browser, dev } from '$app/environment'; +import { dev } from '$app/environment'; // we don't need any JS on this page, though we'll load // it in dev so that we get hot module replacement... -export const hydrate = dev; - -// ...but if the client-side router is already loaded -// (i.e. we came here from elsewhere in the app), use it -export const router = browser; +export const csr = dev; // since there's no dynamic data here, we can prerender // it so that it gets served as a static asset in prod diff --git a/packages/kit/src/runtime/client/client.js b/packages/kit/src/runtime/client/client.js index f530f1ac060f..5ef45d5d3706 100644 --- a/packages/kit/src/runtime/client/client.js +++ b/packages/kit/src/runtime/client/client.js @@ -107,8 +107,6 @@ export function create_client({ target, base, trailing_slash }) { /** @type {import('svelte').SvelteComponent} */ let root; - let router_enabled = true; - // keeping track of the history index in order to prevent popstate navigation events if needed let current_history_index = history.state?.[INDEX_KEY]; @@ -155,22 +153,18 @@ export function create_client({ target, base, trailing_slash }) { url = new URL(url, get_base_uri(document)); } - if (router_enabled) { - return navigate({ - url, - scroll: noscroll ? scroll_state() : null, - keepfocus, - redirect_chain, - details: { - state, - replaceState - }, - accepted: () => {}, - blocked: () => {} - }); - } - - await native_navigation(url); + return navigate({ + url, + scroll: noscroll ? scroll_state() : null, + keepfocus, + redirect_chain, + details: { + state, + replaceState + }, + accepted: () => {}, + blocked: () => {} + }); } /** @param {URL} url */ @@ -241,15 +235,7 @@ export function create_client({ target, base, trailing_slash }) { routeId: null }); } else { - if (router_enabled) { - goto(new URL(navigation_result.location, url).href, {}, [ - ...redirect_chain, - url.pathname - ]); - } else { - await native_navigation(new URL(navigation_result.location, location.href)); - } - + goto(new URL(navigation_result.location, url).href, {}, [...redirect_chain, url.pathname]); return false; } } else if (navigation_result.props?.page?.status >= 400) { @@ -354,9 +340,6 @@ export function create_client({ target, base, trailing_slash }) { page = navigation_result.props.page; } - const leaf_node = navigation_result.state.branch[navigation_result.state.branch.length - 1]; - router_enabled = leaf_node?.node.shared?.router !== false; - if (callback) callback(); updating = false; @@ -398,10 +381,8 @@ export function create_client({ target, base, trailing_slash }) { }); } - if (router_enabled) { - const navigation = { from: null, to: new URL(location.href) }; - callbacks.after_navigate.forEach((fn) => fn(navigation)); - } + const navigation = { from: null, to: new URL(location.href) }; + callbacks.after_navigate.forEach((fn) => fn(navigation)); started = true; } @@ -1185,8 +1166,6 @@ export function create_client({ target, base, trailing_slash }) { /** @param {MouseEvent} event */ addEventListener('click', (event) => { - if (!router_enabled) return; - // Adapted from https://github.com/visionmedia/page.js // MIT license https://github.com/visionmedia/page.js#license if (event.button || event.which !== 1) return; @@ -1256,7 +1235,7 @@ export function create_client({ target, base, trailing_slash }) { }); addEventListener('popstate', (event) => { - if (event.state && router_enabled) { + if (event.state) { // if a popstate-driven navigation is cancelled, we need to counteract it // with history.go, which means we end up back here, hence this check if (event.state[INDEX_KEY] === current_history_index) return; diff --git a/packages/kit/src/runtime/client/start.js b/packages/kit/src/runtime/client/start.js index aeadbc23d40f..ac27e445dc2a 100644 --- a/packages/kit/src/runtime/client/start.js +++ b/packages/kit/src/runtime/client/start.js @@ -1,19 +1,11 @@ import { create_client } from './client.js'; import { init } from './singletons.js'; import { set_paths } from '../paths.js'; - -export { set_public_env } from '../env-public.js'; +import { set_public_env } from '../env-public.js'; /** * @param {{ - * paths: { - * assets: string; - * base: string; - * }, - * target: Element; - * route: boolean; - * spa: boolean; - * trailing_slash: import('types').TrailingSlash; + * env: Record; * hydrate: { * status: number; * error: Error | (import('../server/page/types').SerializedHttpError); @@ -23,9 +15,18 @@ export { set_public_env } from '../env-public.js'; * data: Array; * errors: Record | null; * }; + * paths: { + * assets: string; + * base: string; + * }, + * target: Element; + * trailing_slash: import('types').TrailingSlash; * }} opts */ -export async function start({ paths, target, route, spa, trailing_slash, hydrate }) { +export async function start({ env, hydrate, paths, target, trailing_slash }) { + set_public_env(env); + set_paths(paths); + const client = create_client({ target, base: paths.base, @@ -33,16 +34,14 @@ export async function start({ paths, target, route, spa, trailing_slash, hydrate }); init({ client }); - set_paths(paths); if (hydrate) { await client._hydrate(hydrate); + } else { + client.goto(location.href, { replaceState: true }); } - if (route) { - if (spa) client.goto(location.href, { replaceState: true }); - client._start_router(); - } + client._start_router(); dispatchEvent(new CustomEvent('sveltekit:start')); } diff --git a/packages/kit/src/runtime/server/index.js b/packages/kit/src/runtime/server/index.js index eaaddfefe48f..d9cf65be4f46 100644 --- a/packages/kit/src/runtime/server/index.js +++ b/packages/kit/src/runtime/server/index.js @@ -221,7 +221,7 @@ export async function respond(request, options, state) { event, options, state, - page_config: { router: true, hydrate: true, ssr: false }, + page_config: { ssr: false, csr: true }, status: 200, error: null, branch: [], diff --git a/packages/kit/src/runtime/server/page/index.js b/packages/kit/src/runtime/server/page/index.js index 2691c0f8e354..1d05961f9b90 100644 --- a/packages/kit/src/runtime/server/page/index.js +++ b/packages/kit/src/runtime/server/page/index.js @@ -141,9 +141,8 @@ export async function render_page(event, route, page, options, state, resolve_op fetched, cookies, page_config: { - hydrate: true, - router: true, - ssr: false + ssr: false, + csr: get_option(nodes, 'csr') ?? true }, status, error: null, @@ -273,7 +272,7 @@ export async function render_page(event, route, page, options, state, resolve_op options, state, resolve_opts, - page_config: { router: true, hydrate: true, ssr: true }, + page_config: { ssr: true, csr: true }, status, error, branch: compact(branch.slice(0, j + 1)).concat({ @@ -323,8 +322,7 @@ export async function render_page(event, route, page, options, state, resolve_op state, resolve_opts, page_config: { - router: get_option(nodes, 'router') ?? true, - hydrate: get_option(nodes, 'hydrate') ?? true, + csr: get_option(nodes, 'csr') ?? true, ssr: true }, status, diff --git a/packages/kit/src/runtime/server/page/render.js b/packages/kit/src/runtime/server/page/render.js index a966268bf0a7..4ca30dc50516 100644 --- a/packages/kit/src/runtime/server/page/render.js +++ b/packages/kit/src/runtime/server/page/render.js @@ -23,7 +23,7 @@ const updated = { * cookies: import('set-cookie-parser').Cookie[]; * options: import('types').SSROptions; * state: import('types').SSRState; - * page_config: { hydrate: boolean, router: boolean; ssr: boolean }; + * page_config: { ssr: boolean; csr: boolean }; * status: number; * error: HttpError | Error | null; * event: import('types').RequestEvent; @@ -201,17 +201,11 @@ export async function render_response({ // prettier-ignore const init_app = ` - import { set_public_env, start } from ${s(prefixed(entry.file))}; - - set_public_env(${s(options.public_env)}); + import { start } from ${s(prefixed(entry.file))}; start({ - target: document.querySelector('[data-sveltekit-hydrate="${target}"]').parentNode, - paths: ${s(options.paths)}, - route: ${!!page_config.router}, - spa: ${!page_config.ssr}, - trailing_slash: ${s(options.trailing_slash)}, - hydrate: ${page_config.ssr && page_config.hydrate ? `{ + env: ${s(options.public_env)}, + hydrate: ${page_config.ssr ? `{ status: ${status}, error: ${error && serialize_error(error, e => e.stack)}, node_ids: [${branch.map(({ node }) => node.index).join(', ')}], @@ -219,7 +213,10 @@ export async function render_response({ routeId: ${s(event.routeId)}, data: ${serialized.data}, errors: ${serialized.errors} - }` : 'null'} + }` : 'null'}, + paths: ${s(options.paths)}, + target: document.querySelector('[data-sveltekit-hydrate="${target}"]').parentNode, + trailing_slash: ${s(options.trailing_slash)} }); `; @@ -266,7 +263,7 @@ export async function render_response({ head += `\n\t`; } - if (page_config.router || page_config.hydrate) { + if (page_config.csr) { for (const dep of modulepreloads) { const path = prefixed(dep); link_header_preloads.add(`<${encodeURI(path)}>; rel="modulepreload"; nopush`); @@ -286,7 +283,7 @@ export async function render_response({ body += `\n\t\t`; } - if (page_config.ssr && page_config.hydrate) { + if (page_config.ssr && page_config.csr) { /** @type {string[]} */ const serialized_data = []; diff --git a/packages/kit/src/runtime/server/page/respond_with_error.js b/packages/kit/src/runtime/server/page/respond_with_error.js index 658814175172..739bc06b3674 100644 --- a/packages/kit/src/runtime/server/page/respond_with_error.js +++ b/packages/kit/src/runtime/server/page/respond_with_error.js @@ -70,9 +70,8 @@ export async function respond_with_error({ event, options, state, status, error, options, state, page_config: { - hydrate: get_option([default_layout], 'hydrate') ?? true, - router: get_option([default_layout], 'router') ?? true, - ssr + ssr, + csr: get_option([default_layout], 'csr') ?? true }, status, error, diff --git a/packages/kit/src/runtime/server/utils.js b/packages/kit/src/runtime/server/utils.js index d44235e9c704..26c173ad86d6 100644 --- a/packages/kit/src/runtime/server/utils.js +++ b/packages/kit/src/runtime/server/utils.js @@ -137,7 +137,7 @@ export function data_response(data) { } /** - * @template {'hydrate' | 'prerender' | 'router' | 'ssr'} Option + * @template {'prerender' | 'ssr' | 'csr'} Option * @template {Option extends 'prerender' ? import('types').PrerenderOption : boolean} Value * * @param {Array} nodes @@ -146,13 +146,20 @@ export function data_response(data) { * @returns {Value | undefined} */ export function get_option(nodes, option) { - return nodes.reduce( - (value, node) => - /** @type {any} TypeScript's too dumb to understand this */ ( - node?.shared?.[option] ?? node?.server?.[option] ?? value - ), - /** @type {Value | undefined} */ (undefined) - ); + return nodes.reduce((value, node) => { + // TODO remove for 1.0 + for (const thing of [node?.server, node?.shared]) { + if (thing && ('router' in thing || 'hydrate' in thing)) { + throw new Error( + '`export const hydrate` and `export const router` have been replaced with `export const csr`. See https://github.com/sveltejs/kit/pull/6446' + ); + } + } + + return /** @type {any} TypeScript's too dumb to understand this */ ( + node?.shared?.[option] ?? node?.server?.[option] ?? value + ); + }, /** @type {Value | undefined} */ (undefined)); } /** diff --git a/packages/kit/test/apps/amp/src/routes/+layout.js b/packages/kit/test/apps/amp/src/routes/+layout.js index 9ed282a3fa1d..26bb5688768d 100644 --- a/packages/kit/test/apps/amp/src/routes/+layout.js +++ b/packages/kit/test/apps/amp/src/routes/+layout.js @@ -1,2 +1 @@ -export const hydrate = false; -export const router = false; +export const csr = false; diff --git a/packages/kit/test/apps/basics/src/routes/no-csr/+page.js b/packages/kit/test/apps/basics/src/routes/no-csr/+page.js new file mode 100644 index 000000000000..91108411276b --- /dev/null +++ b/packages/kit/test/apps/basics/src/routes/no-csr/+page.js @@ -0,0 +1,7 @@ +export const csr = false; + +/** @type {import('./$types').PageLoad} */ +export async function load({ fetch }) { + const res = await fetch('/no-csr/data.json'); + return await res.json(); +} diff --git a/packages/kit/test/apps/basics/src/routes/no-csr/+page.svelte b/packages/kit/test/apps/basics/src/routes/no-csr/+page.svelte new file mode 100644 index 000000000000..d4ffc8937ec3 --- /dev/null +++ b/packages/kit/test/apps/basics/src/routes/no-csr/+page.svelte @@ -0,0 +1,7 @@ + + +

look ma no javascript

+

type: {data.type}

diff --git a/packages/kit/test/apps/basics/src/routes/no-hydrate.json/+server.js b/packages/kit/test/apps/basics/src/routes/no-csr/data.json/+server.js similarity index 80% rename from packages/kit/test/apps/basics/src/routes/no-hydrate.json/+server.js rename to packages/kit/test/apps/basics/src/routes/no-csr/data.json/+server.js index 0fabcc3f4ad6..adadfe46a3df 100644 --- a/packages/kit/test/apps/basics/src/routes/no-hydrate.json/+server.js +++ b/packages/kit/test/apps/basics/src/routes/no-csr/data.json/+server.js @@ -2,6 +2,6 @@ import { json } from '@sveltejs/kit'; export function GET() { return json({ - type: 'no-hydrate' + type: 'no-csr' }); } diff --git a/packages/kit/test/apps/basics/src/routes/no-hydrate/+page.js b/packages/kit/test/apps/basics/src/routes/no-hydrate/+page.js deleted file mode 100644 index eddde8cf1a50..000000000000 --- a/packages/kit/test/apps/basics/src/routes/no-hydrate/+page.js +++ /dev/null @@ -1,11 +0,0 @@ -export const hydrate = false; - -/** @type {import('@sveltejs/kit').Load} */ -export async function load({ fetch }) { - const res = await fetch('/no-hydrate.json'); - - /** @type {any} */ - const { type } = await res.json(); - - return { type }; -} diff --git a/packages/kit/test/apps/basics/src/routes/no-hydrate/+page.svelte b/packages/kit/test/apps/basics/src/routes/no-hydrate/+page.svelte deleted file mode 100644 index 6ca14342e1ea..000000000000 --- a/packages/kit/test/apps/basics/src/routes/no-hydrate/+page.svelte +++ /dev/null @@ -1,12 +0,0 @@ - - - - -other diff --git a/packages/kit/test/apps/basics/src/routes/no-hydrate/no-js/+page.js b/packages/kit/test/apps/basics/src/routes/no-hydrate/no-js/+page.js deleted file mode 100644 index f043bbaa8e4a..000000000000 --- a/packages/kit/test/apps/basics/src/routes/no-hydrate/no-js/+page.js +++ /dev/null @@ -1,2 +0,0 @@ -export const router = false; -export const hydrate = false; diff --git a/packages/kit/test/apps/basics/src/routes/no-hydrate/no-js/+page.svelte b/packages/kit/test/apps/basics/src/routes/no-hydrate/no-js/+page.svelte deleted file mode 100644 index a840a265dd12..000000000000 --- a/packages/kit/test/apps/basics/src/routes/no-hydrate/no-js/+page.svelte +++ /dev/null @@ -1 +0,0 @@ -

look ma no javascript

diff --git a/packages/kit/test/apps/basics/src/routes/no-hydrate/other/+page.svelte b/packages/kit/test/apps/basics/src/routes/no-hydrate/other/+page.svelte deleted file mode 100644 index 2ac0e4037772..000000000000 --- a/packages/kit/test/apps/basics/src/routes/no-hydrate/other/+page.svelte +++ /dev/null @@ -1 +0,0 @@ -hydrate diff --git a/packages/kit/test/apps/basics/src/routes/no-router/+layout.svelte b/packages/kit/test/apps/basics/src/routes/no-router/+layout.svelte deleted file mode 100644 index ef4b0dbfea12..000000000000 --- a/packages/kit/test/apps/basics/src/routes/no-router/+layout.svelte +++ /dev/null @@ -1,12 +0,0 @@ - - - - -a -b - - diff --git a/packages/kit/test/apps/basics/src/routes/no-router/a/+page.js b/packages/kit/test/apps/basics/src/routes/no-router/a/+page.js deleted file mode 100644 index 90f739775e8b..000000000000 --- a/packages/kit/test/apps/basics/src/routes/no-router/a/+page.js +++ /dev/null @@ -1 +0,0 @@ -export const router = false; diff --git a/packages/kit/test/apps/basics/src/routes/no-router/a/+page.svelte b/packages/kit/test/apps/basics/src/routes/no-router/a/+page.svelte deleted file mode 100644 index 57f9d40797b8..000000000000 --- a/packages/kit/test/apps/basics/src/routes/no-router/a/+page.svelte +++ /dev/null @@ -1 +0,0 @@ -

a

diff --git a/packages/kit/test/apps/basics/src/routes/no-router/b/+page.svelte b/packages/kit/test/apps/basics/src/routes/no-router/b/+page.svelte deleted file mode 100644 index e96ed3db8987..000000000000 --- a/packages/kit/test/apps/basics/src/routes/no-router/b/+page.svelte +++ /dev/null @@ -1 +0,0 @@ -

b

diff --git a/packages/kit/test/apps/basics/src/routes/scroll/cross-document/a/+page.js b/packages/kit/test/apps/basics/src/routes/scroll/cross-document/a/+page.js deleted file mode 100644 index 90f739775e8b..000000000000 --- a/packages/kit/test/apps/basics/src/routes/scroll/cross-document/a/+page.js +++ /dev/null @@ -1 +0,0 @@ -export const router = false; diff --git a/packages/kit/test/apps/basics/src/routes/scroll/cross-document/a/+page.svelte b/packages/kit/test/apps/basics/src/routes/scroll/cross-document/a/+page.svelte index 902e783cdb8b..356bf895e9d4 100644 --- a/packages/kit/test/apps/basics/src/routes/scroll/cross-document/a/+page.svelte +++ b/packages/kit/test/apps/basics/src/routes/scroll/cross-document/a/+page.svelte @@ -2,4 +2,4 @@
-b +b diff --git a/packages/kit/test/apps/basics/src/routes/scroll/cross-document/b/+page.js b/packages/kit/test/apps/basics/src/routes/scroll/cross-document/b/+page.js deleted file mode 100644 index b33c2aee87a1..000000000000 --- a/packages/kit/test/apps/basics/src/routes/scroll/cross-document/b/+page.js +++ /dev/null @@ -1 +0,0 @@ -export const router = true; diff --git a/packages/kit/test/apps/basics/src/routes/scroll/cross-document/c/+page.js b/packages/kit/test/apps/basics/src/routes/scroll/cross-document/c/+page.js deleted file mode 100644 index b33c2aee87a1..000000000000 --- a/packages/kit/test/apps/basics/src/routes/scroll/cross-document/c/+page.js +++ /dev/null @@ -1 +0,0 @@ -export const router = true; diff --git a/packages/kit/test/apps/basics/test/client.test.js b/packages/kit/test/apps/basics/test/client.test.js index 1762d0c172e2..6bc0c73e2f0d 100644 --- a/packages/kit/test/apps/basics/test/client.test.js +++ b/packages/kit/test/apps/basics/test/client.test.js @@ -414,31 +414,6 @@ test.describe('Load', () => { }); test.describe('Page options', () => { - test('disables router if router=false', async ({ page, clicknav }) => { - await page.goto('/no-router/a'); - - await page.click('button'); - expect(await page.textContent('button')).toBe('clicks: 1'); - - await Promise.all([page.waitForNavigation(), page.click('[href="/no-router/b"]')]); - expect(await page.textContent('button')).toBe('clicks: 0'); - - // wait until hydration before interacting with button - await page.waitForSelector('body.started'); - - await page.click('button'); - expect(await page.textContent('button')).toBe('clicks: 1'); - - // wait until hydration before attempting backwards client-side navigation - await page.waitForSelector('body.started'); - - await clicknav('[href="/no-router/a"]'); - expect(await page.textContent('button')).toBe('clicks: 1'); - - await Promise.all([page.waitForNavigation(), page.click('[href="/no-router/b"]')]); - expect(await page.textContent('button')).toBe('clicks: 0'); - }); - test('applies generated component styles with ssr=false (hides announcer)', async ({ page, clicknav diff --git a/packages/kit/test/apps/basics/test/test.js b/packages/kit/test/apps/basics/test/test.js index c409e8f92f5a..6a9bc4cf0d8e 100644 --- a/packages/kit/test/apps/basics/test/test.js +++ b/packages/kit/test/apps/basics/test/test.js @@ -1007,44 +1007,24 @@ test.describe('Nested layouts', () => { }); test.describe('Page options', () => { - test('does not hydrate page with hydrate=false', async ({ page, javaScriptEnabled }) => { - await page.goto('/no-hydrate'); - - await page.click('button'); - expect(await page.textContent('button')).toBe('clicks: 0'); - - if (javaScriptEnabled) { - await Promise.all([page.waitForNavigation(), page.click('[href="/no-hydrate/other"]')]); - await Promise.all([page.waitForNavigation(), page.click('[href="/no-hydrate"]')]); - - await page.click('button'); - expect(await page.textContent('button')).toBe('clicks: 1'); - } else { - // ensure data wasn't inlined - expect( - await page.evaluate( - () => document.querySelectorAll('script[sveltekit\\:data-type="data"]').length - ) - ).toBe(0); - } - }); - - test('does not include modulepreload links if JS is completely disabled', async ({ + test('does not include