diff --git a/.changeset/breezy-onions-remember.md b/.changeset/breezy-onions-remember.md new file mode 100644 index 000000000000..0f1e44f4c91a --- /dev/null +++ b/.changeset/breezy-onions-remember.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +create `__data.json` for pathnames with trailing slashes, including `/` diff --git a/.changeset/eight-chicken-sin.md b/.changeset/eight-chicken-sin.md new file mode 100644 index 000000000000..7695a508e948 --- /dev/null +++ b/.changeset/eight-chicken-sin.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +Disable meta http-equiv tags for static amp configuration diff --git a/.changeset/four-ties-destroy.md b/.changeset/four-ties-destroy.md new file mode 100644 index 000000000000..e8eab00e6f5e --- /dev/null +++ b/.changeset/four-ties-destroy.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/adapter-auto': patch +--- + +Attempt to bump @next version of adapter-auto diff --git a/.changeset/great-seahorses-fry.md b/.changeset/great-seahorses-fry.md new file mode 100644 index 000000000000..fd5436210718 --- /dev/null +++ b/.changeset/great-seahorses-fry.md @@ -0,0 +1,5 @@ +--- +'create-svelte': patch +--- + +fix `@typescript-eslint/no-empty-interface` lint error when starting a new app with eslint diff --git a/.changeset/pre.json b/.changeset/pre.json index b9c26a0a5e62..3a36ac4d5f7f 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -10,10 +10,10 @@ "@sveltejs/app-utils": "0.0.18", "create-svelte": "2.0.0-alpha.19", "@sveltejs/kit": "0.0.30", - "@sveltejs/vite-plugin-svelte": "1.0.0-next.0", + "@sveltejs/vite-plugin-svelte": "0.0.1", "@sveltejs/adapter-cloudflare-workers": "0.0.1", - "@sveltejs/adapter-cloudflare": "1.0.0-next.0", - "@sveltejs/adapter-auto": "1.0.0-next", + "@sveltejs/adapter-cloudflare": "0.0.1", + "@sveltejs/adapter-auto": "0.0.1", "set-env-action": "1.0.0", "~TODO~": "0.0.1", "prerendering-test-basics": "0.0.1", @@ -51,6 +51,7 @@ "brave-turkeys-bathe", "brave-weeks-allow", "breezy-games-count", + "breezy-onions-remember", "breezy-sheep-dress", "breezy-students-refuse", "bright-cherries-hug", @@ -141,6 +142,7 @@ "early-snakes-peel", "early-wasps-obey", "eight-birds-run", + "eight-chicken-sin", "eight-glasses-sparkle", "eight-hats-worry", "eight-keys-give", @@ -197,6 +199,7 @@ "four-cheetahs-yawn", "four-news-turn", "four-pillows-give", + "four-ties-destroy", "fresh-adults-ring", "fresh-dolls-destroy", "fresh-hats-tie", @@ -240,6 +243,7 @@ "great-guests-visit", "great-kangaroos-eat", "great-queens-rule", + "great-seahorses-fry", "green-mayflies-shave", "green-spoons-count", "grumpy-days-compete", @@ -687,6 +691,7 @@ "tidy-pigs-peel", "tidy-turkeys-rule", "tidy-wasps-shave", + "tiny-badgers-love", "tiny-candles-repeat", "tiny-files-smile", "tiny-gorillas-whisper", @@ -714,6 +719,7 @@ "twelve-feet-deny", "twelve-goats-knock", "twelve-onions-burn", + "twenty-dogs-shout", "twenty-dryers-hope", "twenty-hairs-shave", "twenty-numbers-destroy", diff --git a/.changeset/tiny-badgers-love.md b/.changeset/tiny-badgers-love.md new file mode 100644 index 000000000000..4d38e8402957 --- /dev/null +++ b/.changeset/tiny-badgers-love.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +Ignore click event if url does not have origin (e.g. `mailto:`, `tel:`) diff --git a/.changeset/twenty-dogs-shout.md b/.changeset/twenty-dogs-shout.md new file mode 100644 index 000000000000..2a5d994c15b0 --- /dev/null +++ b/.changeset/twenty-dogs-shout.md @@ -0,0 +1,6 @@ +--- +'@sveltejs/adapter-auto': patch +'@sveltejs/adapter-cloudflare': patch +--- + +Attempt to force @next version bump diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 91bb939b2c9e..2ec4201f039d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: pnpm/action-setup@v2.1.0 + - uses: pnpm/action-setup@v2.2.0 with: version: 6.23.2 - uses: actions/setup-node@v2 @@ -39,7 +39,7 @@ jobs: steps: - run: git config --global core.autocrlf false - uses: actions/checkout@v2 - - uses: pnpm/action-setup@v2.1.0 + - uses: pnpm/action-setup@v2.2.0 with: version: 6.23.2 - uses: actions/setup-node@v2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 41bdc990d78c..24da638eb7c1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,7 +17,7 @@ jobs: with: # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits fetch-depth: 0 - - uses: pnpm/action-setup@v2.1.0 + - uses: pnpm/action-setup@v2.2.0 with: version: 6.23.2 - name: Setup Node.js diff --git a/documentation/docs/01-routing.md b/documentation/docs/01-routing.md index 3e5d198feb5c..425ffbf90b51 100644 --- a/documentation/docs/01-routing.md +++ b/documentation/docs/01-routing.md @@ -45,9 +45,7 @@ A file or directory can have multiple dynamic parts, like `[id]-[category].svelt ### Endpoints -Endpoints are modules written in `.js` (or `.ts`) files that export functions corresponding to HTTP methods. Their job is to allow pages to read and write data that is only available on the server (for example in a database, or on the filesystem). - -If an endpoint has the same filename as a page (except for the extension), the page will get its props from the endpoint. So a page like `src/routes/items/[id].svelte` could get its props from this file: +Endpoints are modules written in `.js` (or `.ts`) files that export [request handler](/docs/types#sveltejs-kit-requesthandler) functions corresponding to HTTP methods. Their job is to make it possible to read and write data that is only available on the server (for example in a database, or on the filesystem). ```js /// file: src/routes/items/[id].js @@ -81,7 +79,7 @@ export async function get({ params }) { > All server-side code, including endpoints, has access to `fetch` in case you need to request data from external APIs. Don't worry about the `$lib` import, we'll get to that [later](/docs/modules#$lib). -The job of this function is to return a `{ status, headers, body }` object representing the response, where `status` is an [HTTP status code](https://httpstatusdogs.com): +The job of a [request handler](/docs/types#sveltejs-kit-requesthandler) is to return a `{ status, headers, body }` object representing the response, where `status` is an [HTTP status code](https://httpstatusdogs.com): - `2xx` — successful response (default is `200`) - `3xx` — redirection (should be accompanied by a `location` header) @@ -90,7 +88,11 @@ The job of this function is to return a `{ status, headers, body }` object repre > If `{fallthrough: true}` is returned SvelteKit will [fall through](/docs/routing#advanced-routing-fallthrough-routes) to other routes until something responds, or will respond with a generic 404. -The returned `body` corresponds to the page's props: +#### Page endpoints + +If an endpoint has the same filename as a page (except for the extension), the page gets its props from the endpoint — via `fetch` during client-side navigation, or via direct function call during SSR. + +A page like `src/routes/items/[id].svelte` could get its props from the `body` in the endpoint above: ```svelte /// file: src/routes/items/[id].svelte @@ -102,6 +104,23 @@ The returned `body` corresponds to the page's props:

{item.title}

``` +Because the page and route have the same URL, you will need to include an `accept: application/json` header to get JSON from the endpoint rather than HTML from the page. You can also get the raw data by appending `/__data.json` to the URL, e.g. `/items/__data.json`. + +#### Standalone endpoints + +Most commonly, endpoints exist to provide data to the page with which they're paired. They can, however, exist separately from pages. Standalone endpoints have slightly more flexibility over the returned `body` type — in addition to objects, they can return a `Uint8Array`. + +Standalone endpoints can be given a file extension if desired, or accessed directly if not: + +| filename | endpoint | +| ----------------------------- | ---------- | +| src/routes/data/index.json.js | /data.json | +| src/routes/data.json.js | /data.json | +| src/routes/data/index.js | /data | +| src/routes/data.js | /data | + +> Support for streaming request and response bodies is [coming soon](https://github.com/sveltejs/kit/issues/3419). + #### POST, PUT, PATCH, DELETE Endpoints can handle any HTTP method — not just `GET` — by exporting the corresponding function: @@ -191,8 +210,6 @@ export async function post({ request }) { ``` -If you request the route with an `accept: application/json` header, SvelteKit will render the endpoint data as JSON, rather than the page as HTML. You can also get the raw data by appending `/__data.json` to the URL, e.g. `/items/__data.json`. - #### Body parsing The `request` object is an instance of the standard [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) class. As such, accessing the request body is easy: @@ -263,21 +280,6 @@ export default config; > Using native `
` behaviour ensures your app continues to work when JavaScript fails or is disabled. -### Standalone endpoints - -Most commonly, endpoints exist to provide data to the page with which they're paired. They can, however, exist separately from pages. Standalone endpoints have slightly more flexibility over the returned `body` type — in addition to objects, they can return a string or a `Uint8Array`. - -> Support for streaming request and response bodies is [coming soon](https://github.com/sveltejs/kit/issues/3419). - -Standalone endpoints can be given a file extension if desired, or accessed directly if not: - -| filename | endpoint | -| ----------------------------- | ---------- | -| src/routes/data/index.json.js | /data.json | -| src/routes/data.json.js | /data.json | -| src/routes/data/index.js | /data | -| src/routes/data.js | /data | - ### Private modules Files and directories with a leading `_` or `.` (other than [`.well-known`](https://en.wikipedia.org/wiki/Well-known_URI)) are private by default, meaning that they do not create routes (but can be imported by files that do). You can configure which modules are considered public or private with the [`routes`](/docs/configuration#routes) configuration. diff --git a/packages/adapter-auto/CHANGELOG.md b/packages/adapter-auto/CHANGELOG.md index d86e0f786211..7676deb9877d 100644 --- a/packages/adapter-auto/CHANGELOG.md +++ b/packages/adapter-auto/CHANGELOG.md @@ -1,5 +1,20 @@ # @sveltejs/adapter-auto +## 1.0.0-next.26 + +### Patch Changes + +- Attempt to force @next version bump ([#4088](https://github.com/sveltejs/kit/pull/4088)) + +- Updated dependencies [[`46f44a61`](https://github.com/sveltejs/kit/commit/46f44a61624bed525e393e669da9b7db566a1e18)]: + - @sveltejs/adapter-cloudflare@1.0.0-next.13 + +## 1.0.0-next.25 + +### Patch Changes + +- Attempt to bump @next version of adapter-auto ([#4082](https://github.com/sveltejs/kit/pull/4082)) + ## 1.0.0-next.24 ### Patch Changes diff --git a/packages/adapter-auto/package.json b/packages/adapter-auto/package.json index acd5a54d3f10..0920b09c1524 100644 --- a/packages/adapter-auto/package.json +++ b/packages/adapter-auto/package.json @@ -1,6 +1,6 @@ { "name": "@sveltejs/adapter-auto", - "version": "1.0.0-next.24", + "version": "1.0.0-next.26", "repository": { "type": "git", "url": "https://github.com/sveltejs/kit", diff --git a/packages/adapter-cloudflare/CHANGELOG.md b/packages/adapter-cloudflare/CHANGELOG.md index 21a6a92653a2..41ffeb4431f5 100644 --- a/packages/adapter-cloudflare/CHANGELOG.md +++ b/packages/adapter-cloudflare/CHANGELOG.md @@ -1,5 +1,11 @@ # @sveltejs/adapter-cloudflare +## 1.0.0-next.13 + +### Patch Changes + +- Attempt to force @next version bump ([#4088](https://github.com/sveltejs/kit/pull/4088)) + ## 1.0.0-next.12 ### Patch Changes diff --git a/packages/adapter-cloudflare/package.json b/packages/adapter-cloudflare/package.json index 8ea34245c606..02611503f020 100644 --- a/packages/adapter-cloudflare/package.json +++ b/packages/adapter-cloudflare/package.json @@ -1,6 +1,6 @@ { "name": "@sveltejs/adapter-cloudflare", - "version": "1.0.0-next.12", + "version": "1.0.0-next.13", "repository": { "type": "git", "url": "https://github.com/sveltejs/kit", diff --git a/packages/adapter-netlify/README.md b/packages/adapter-netlify/README.md index ef567b62d5f8..52979b7bc155 100644 --- a/packages/adapter-netlify/README.md +++ b/packages/adapter-netlify/README.md @@ -66,7 +66,6 @@ During compilation, redirect rules are automatically appended to your `_redirect [functions] directory = "functions" - node_bundler = "esbuild" ``` ## Changelog diff --git a/packages/create-svelte/CHANGELOG.md b/packages/create-svelte/CHANGELOG.md index 67a07c0c6163..6b600dbdadc7 100644 --- a/packages/create-svelte/CHANGELOG.md +++ b/packages/create-svelte/CHANGELOG.md @@ -1,5 +1,11 @@ # create-svelte +## 2.0.0-next.120 + +### Patch Changes + +- fix `@typescript-eslint/no-empty-interface` lint error when starting a new app with eslint ([#4077](https://github.com/sveltejs/kit/pull/4077)) + ## 2.0.0-next.119 ### Patch Changes diff --git a/packages/create-svelte/package.json b/packages/create-svelte/package.json index 03c33a1a8657..4faaa7c8a3f6 100644 --- a/packages/create-svelte/package.json +++ b/packages/create-svelte/package.json @@ -1,6 +1,6 @@ { "name": "create-svelte", - "version": "2.0.0-next.119", + "version": "2.0.0-next.120", "repository": { "type": "git", "url": "https://github.com/sveltejs/kit", diff --git a/packages/create-svelte/templates/default/src/app.d.ts b/packages/create-svelte/templates/default/src/app.d.ts index 5d1bd737f7f5..dec2abdb691e 100644 --- a/packages/create-svelte/templates/default/src/app.d.ts +++ b/packages/create-svelte/templates/default/src/app.d.ts @@ -7,9 +7,9 @@ declare namespace App { userid: string; } - interface Platform {} + // interface Platform {} - interface Session {} + // interface Session {} - interface Stuff {} + // interface Stuff {} } diff --git a/packages/create-svelte/templates/skeleton/src/app.d.ts b/packages/create-svelte/templates/skeleton/src/app.d.ts index 5ec43e560407..9cbf1c51cb74 100644 --- a/packages/create-svelte/templates/skeleton/src/app.d.ts +++ b/packages/create-svelte/templates/skeleton/src/app.d.ts @@ -3,11 +3,8 @@ // See https://kit.svelte.dev/docs/types#the-app-namespace // for information about these interfaces declare namespace App { - interface Locals {} - - interface Platform {} - - interface Session {} - - interface Stuff {} + // interface Locals {} + // interface Platform {} + // interface Session {} + // interface Stuff {} } diff --git a/packages/kit/CHANGELOG.md b/packages/kit/CHANGELOG.md index 117d5374c5a2..cefa36e4d781 100644 --- a/packages/kit/CHANGELOG.md +++ b/packages/kit/CHANGELOG.md @@ -1,5 +1,19 @@ # @sveltejs/kit +## 1.0.0-next.284 + +### Patch Changes + +- Disable meta http-equiv tags for static amp configuration ([#4073](https://github.com/sveltejs/kit/pull/4073)) + +* Ignore click event if url does not have origin (e.g. `mailto:`, `tel:`) ([#4072](https://github.com/sveltejs/kit/pull/4072)) + +## 1.0.0-next.283 + +### Patch Changes + +- create `__data.json` for pathnames with trailing slashes, including `/` ([#4066](https://github.com/sveltejs/kit/pull/4066)) + ## 1.0.0-next.282 ### Patch Changes diff --git a/packages/kit/package.json b/packages/kit/package.json index a1c3da708cbd..d396c3835b0b 100644 --- a/packages/kit/package.json +++ b/packages/kit/package.json @@ -1,6 +1,6 @@ { "name": "@sveltejs/kit", - "version": "1.0.0-next.282", + "version": "1.0.0-next.284", "repository": { "type": "git", "url": "https://github.com/sveltejs/kit", @@ -16,7 +16,7 @@ }, "devDependencies": { "@playwright/test": "^1.17.1", - "@rollup/plugin-replace": "^3.0.0", + "@rollup/plugin-replace": "^4.0.0", "@types/amphtml-validator": "^1.0.1", "@types/cookie": "^0.4.1", "@types/marked": "^4.0.1", diff --git a/packages/kit/src/runtime/client/router.js b/packages/kit/src/runtime/client/router.js index a0301ab0e968..53cb01de9b32 100644 --- a/packages/kit/src/runtime/client/router.js +++ b/packages/kit/src/runtime/client/router.js @@ -180,6 +180,7 @@ export class Router { if (!a.href) return; + const is_svg_a_element = a instanceof SVGAElement; const url = get_href(a); const url_string = url.toString(); if (url_string === location.href) { @@ -187,6 +188,11 @@ export class Router { return; } + // Ignore if url does not have origin (e.g. `mailto:`, `tel:`.) + // MEMO: Without this condition, firefox will open mailer twice. + // See: https://github.com/sveltejs/kit/issues/4045 + if (!is_svg_a_element && url.origin === 'null') return; + // Ignore if tag has // 1. 'download' attribute // 2. 'rel' attribute includes external @@ -197,7 +203,7 @@ export class Router { } // Ignore if has a target - if (a instanceof SVGAElement ? a.target.baseVal : a.target) return; + if (is_svg_a_element ? a.target.baseVal : a.target) return; // Check if new url only differs by hash and use the browser default behavior in that case // This will ensure the `hashchange` event is fired diff --git a/packages/kit/src/runtime/server/page/load_node.js b/packages/kit/src/runtime/server/page/load_node.js index 194a00bdfcbf..96bcfc641d89 100644 --- a/packages/kit/src/runtime/server/page/load_node.js +++ b/packages/kit/src/runtime/server/page/load_node.js @@ -346,7 +346,7 @@ export async function load_node({ // generate __data.json files when prerendering if (shadow.body && state.prerender) { - const pathname = `${event.url.pathname}/__data.json`; + const pathname = `${event.url.pathname.replace(/\/$/, '')}/__data.json`; const dependency = { response: new Response(undefined), diff --git a/packages/kit/src/runtime/server/page/render.js b/packages/kit/src/runtime/server/page/render.js index 6970d2e944a7..eab46902efbe 100644 --- a/packages/kit/src/runtime/server/page/render.js +++ b/packages/kit/src/runtime/server/page/render.js @@ -278,7 +278,7 @@ export async function render_response({ } } - if (state.prerender) { + if (state.prerender && !options.amp) { const http_equiv = []; const csp_headers = csp.get_meta(); diff --git a/packages/kit/src/utils/url.js b/packages/kit/src/utils/url.js index 8029bf82472e..5f34ca4306d9 100644 --- a/packages/kit/src/utils/url.js +++ b/packages/kit/src/utils/url.js @@ -39,7 +39,7 @@ export function is_root_relative(path) { /** * @param {string} path - * @param {'always' | 'never' | 'ignore'} trailing_slash + * @param {import('types').TrailingSlash} trailing_slash */ export function normalize_path(path, trailing_slash) { if (path === '/' || trailing_slash === 'ignore') return path; diff --git a/packages/kit/test/apps/basics/src/routes/anchor-with-manual-scroll/anchor.svelte b/packages/kit/test/apps/basics/src/routes/anchor-with-manual-scroll/anchor.svelte index 5f7ba71be5cb..be660c5859b2 100644 --- a/packages/kit/test/apps/basics/src/routes/anchor-with-manual-scroll/anchor.svelte +++ b/packages/kit/test/apps/basics/src/routes/anchor-with-manual-scroll/anchor.svelte @@ -8,16 +8,9 @@ }); -
They (don't) see me...
-
+
They (don't) see me...
+

The browser scrolls to me

-

I take precedence

+

I take precedence

- - diff --git a/packages/kit/test/apps/basics/src/routes/anchor/anchor.svelte b/packages/kit/test/apps/basics/src/routes/anchor/anchor.svelte index 2c4e5feeebf8..57406e6d3a09 100644 --- a/packages/kit/test/apps/basics/src/routes/anchor/anchor.svelte +++ b/packages/kit/test/apps/basics/src/routes/anchor/anchor.svelte @@ -1,11 +1,4 @@ -
They (don't) see me...
-
+
They (don't) see me...
+

The browser scrolls to me

- - diff --git a/packages/kit/test/apps/basics/src/routes/use-action/focus-and-scroll.svelte b/packages/kit/test/apps/basics/src/routes/use-action/focus-and-scroll.svelte index 430c14300fb4..7dd3bb9fe6fa 100644 --- a/packages/kit/test/apps/basics/src/routes/use-action/focus-and-scroll.svelte +++ b/packages/kit/test/apps/basics/src/routes/use-action/focus-and-scroll.svelte @@ -10,15 +10,8 @@
They (don't) see me scrollin'...
-
+
-
They (not) focusin'
- - +
They (not) focusin'
diff --git a/packages/kit/test/apps/basics/test/test.js b/packages/kit/test/apps/basics/test/test.js index c83e450369fb..858659fb4ea8 100644 --- a/packages/kit/test/apps/basics/test/test.js +++ b/packages/kit/test/apps/basics/test/test.js @@ -53,7 +53,7 @@ test.describe.parallel('a11y', () => { page.type('#input', 'bar'), page.waitForFunction(() => window.location.search === '?foo=bar') ]); - expect(await page.locator('#input')).toBeFocused(); + await expect(page.locator('#input')).toBeFocused(); } }); @@ -230,17 +230,19 @@ test.describe('Scrolling', () => { test('url-supplied anchor is ignored with onMount() scrolling on navigation to page', async ({ page, clicknav, + javaScriptEnabled, in_view }) => { await page.goto('/anchor-with-manual-scroll'); await clicknav('[href="/anchor-with-manual-scroll/anchor#go-to-element"]'); - expect(await in_view('#abcde')).toBe(true); + if (javaScriptEnabled) expect(await in_view('#abcde')).toBe(true); + else expect(await in_view('#go-to-element')).toBe(true); }); test('app-supplied scroll and focus work on direct page load', async ({ page, in_view }) => { await page.goto('/use-action/focus-and-scroll'); expect(await in_view('#input')).toBe(true); - expect(await page.locator('#input')).toBeFocused(); + await expect(page.locator('#input')).toBeFocused(); }); test('app-supplied scroll and focus work on navigation to page', async ({ @@ -251,7 +253,7 @@ test.describe('Scrolling', () => { await page.goto('/use-action'); await clicknav('[href="/use-action/focus-and-scroll"]'); expect(await in_view('#input')).toBe(true); - expect(await page.locator('#input')).toBeFocused(); + await expect(page.locator('input')).toBeFocused(); }); test('scroll positions are recovered on reloading the page', async ({ page, back, app }) => { diff --git a/packages/kit/test/prerendering/basics/src/routes/index.js b/packages/kit/test/prerendering/basics/src/routes/index.js new file mode 100644 index 000000000000..a566f067fabc --- /dev/null +++ b/packages/kit/test/prerendering/basics/src/routes/index.js @@ -0,0 +1,7 @@ +export function get() { + return { + body: { + message: 'hello' + } + }; +} diff --git a/packages/kit/test/prerendering/basics/src/routes/index.svelte b/packages/kit/test/prerendering/basics/src/routes/index.svelte index 6e7c1e6ac83f..7c991db4005a 100644 --- a/packages/kit/test/prerendering/basics/src/routes/index.svelte +++ b/packages/kit/test/prerendering/basics/src/routes/index.svelte @@ -1 +1,6 @@ -

hello

+ + +

{message}

diff --git a/packages/kit/test/prerendering/basics/test/test.js b/packages/kit/test/prerendering/basics/test/test.js index eb07ec1cd2b1..03594e1bd1dd 100644 --- a/packages/kit/test/prerendering/basics/test/test.js +++ b/packages/kit/test/prerendering/basics/test/test.js @@ -63,9 +63,9 @@ test('loads a file with spaces in the filename', () => { assert.ok(content.includes('

answer: 42

'), content); }); -test('generates __data.json file for shadow endpoint', () => { - const json = read('shadowed-get/__data.json'); - assert.equal(json, JSON.stringify({ answer: 42 })); +test('generates __data.json file for shadow endpoints', () => { + assert.equal(read('__data.json'), JSON.stringify({ message: 'hello' })); + assert.equal(read('shadowed-get/__data.json'), JSON.stringify({ answer: 42 })); }); test('does not prerender page with shadow endpoint with non-GET handler', () => { diff --git a/packages/kit/types/ambient.d.ts b/packages/kit/types/ambient.d.ts index 5cffcef510be..5ee79a4340bb 100644 --- a/packages/kit/types/ambient.d.ts +++ b/packages/kit/types/ambient.d.ts @@ -1,5 +1,3 @@ -/* eslint-disable import/no-duplicates */ - declare namespace App { interface Locals {} interface Platform {} diff --git a/packages/kit/types/index.d.ts b/packages/kit/types/index.d.ts index 666d8dcfd279..2cd30be8c304 100644 --- a/packages/kit/types/index.d.ts +++ b/packages/kit/types/index.d.ts @@ -1,24 +1,25 @@ /// /// +import './ambient'; + import { CompileOptions } from 'svelte/types/compiler/interfaces'; import { - Logger, - PrerenderOnErrorValue, - SSRNodeLoader, - SSRRoute, - TrailingSlash, + AdapterEntry, + Body, Either, + Fallthrough, + Logger, MaybePromise, + PrerenderOnErrorValue, RecursiveRequired, - RouteDefinition, - AdapterEntry, - ResponseHeaders, - Fallthrough, RequiredResolveOptions, - Body + ResponseHeaders, + RouteDefinition, + SSRNodeLoader, + SSRRoute, + TrailingSlash } from './internal'; -import './ambient'; export interface Adapter { name: string; @@ -31,7 +32,7 @@ export interface Builder { mkdirp(dir: string): void; appDir: string; - trailingSlash: 'always' | 'never' | 'ignore'; + trailingSlash: TrailingSlash; /** * Create entry points that map to individual functions @@ -171,7 +172,7 @@ export namespace Csp { type BaseSource = 'self' | 'unsafe-eval' | 'unsafe-hashes' | 'unsafe-inline' | 'none'; type CryptoSource = `${'nonce' | 'sha256' | 'sha384' | 'sha512'}-${string}`; type FrameSource = HostSource | SchemeSource | 'self' | 'none'; - type HostNameScheme = `${string}.${string}` | `localhost`; + type HostNameScheme = `${string}.${string}` | 'localhost'; type HostSource = `${HostProtocolSchemes}${HostNameScheme}${PortScheme}`; type HostProtocolSchemes = `${string}://` | ''; type HttpDelineator = '/' | '?' | '#' | '\\'; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f886f30f1375..185609670d25 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -225,7 +225,7 @@ importers: packages/kit: specifiers: '@playwright/test': ^1.17.1 - '@rollup/plugin-replace': ^3.0.0 + '@rollup/plugin-replace': ^4.0.0 '@sveltejs/vite-plugin-svelte': ^1.0.0-next.32 '@types/amphtml-validator': ^1.0.1 '@types/cookie': ^0.4.1 @@ -261,7 +261,7 @@ importers: vite: 2.8.0 devDependencies: '@playwright/test': 1.17.1 - '@rollup/plugin-replace': 3.0.0_rollup@2.60.2 + '@rollup/plugin-replace': 4.0.0_rollup@2.60.2 '@types/amphtml-validator': 1.0.1 '@types/cookie': 0.4.1 '@types/marked': 4.0.1 @@ -1402,8 +1402,8 @@ packages: rollup: 2.60.2 dev: true - /@rollup/plugin-replace/3.0.0_rollup@2.60.2: - resolution: {integrity: sha512-3c7JCbMuYXM4PbPWT4+m/4Y6U60SgsnDT/cCyAyUKwFHg7pTSfsSQzIpETha3a3ig6OdOKzZz87D9ZXIK3qsDg==} + /@rollup/plugin-replace/4.0.0_rollup@2.60.2: + resolution: {integrity: sha512-+rumQFiaNac9y64OHtkHGmdjm7us9bo1PlbgQfdihQtuNxzjpaB064HbRnewUOggLQxVCCyINfStkgmBeQpv1g==} peerDependencies: rollup: ^1.20.0 || ^2.0.0 dependencies: