From 140dd7dc3232f828ffe35764aa7e22f1e9425a96 Mon Sep 17 00:00:00 2001 From: "pull[bot]" <39814207+pull[bot]@users.noreply.github.com> Date: Wed, 17 May 2023 15:07:59 -0700 Subject: [PATCH] [pull] master from sveltejs:master (#8) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: Add a speedier script tag for prerendered redirects (#9911) * feat: Add a script redirect to prerendered pages * changeset * Update .changeset/hungry-rocks-hunt.md Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com> * fix test * feat: Update string escaping * Update .changeset/hungry-rocks-hunt.md Co-authored-by: Conduitry --------- Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com> Co-authored-by: Conduitry * fix: avoid inlining raw/url CSS imports (#9925) * fix: use transformRequest for CSS modules * just avoid raw or url * test and changeset * use parsed query * remove only * Update packages/kit/test/apps/basics/test/cross-platform/test.js * drive by test speed up * feat: prerender & analyse in worker rather than subprocess to support Deno (#9919) * feat(fork): use workers * Create hot-actors-hope.md * Update packages/kit/src/utils/fork.js Co-authored-by: Rich Harris --------- Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> Co-authored-by: Rich Harris * avoid using isMainThread, since it interacts poorly with vitest (#9941) Co-authored-by: Rich Harris * chore: bump vite and devalue (#9933) * bump vite and devalue * update templates * merge master * fix test --------- Co-authored-by: Rich Harris * chore: uvu -> vitest for create-svelte tests (#9910) * chore: uvu -> vitest for create-svelte tests * format * concurrency (#9921) * realised we werent typechecking this file, found some errors. fixed * Wait for beforeAll hook to complete * simplify * exclude create-svelte/template files from prettier, so that we can emit correctly formatted templates * remove unused file * Revert "exclude create-svelte/template files from prettier, so that we can emit correctly formatted templates" This reverts commit aa188d4ca3ce94fa739452ce8fa78d63442eb1b5. --------- Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> Co-authored-by: Rich Harris * feat: unshadow `form` and `data` in `enhance` (#9902) * feat: Un-shadow `data` and `form` in `enhance`, warn about future deprecation in dev * changeset * snek * Update .changeset/odd-crews-own.md Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> * Update packages/kit/test/apps/dev-only/package.json Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> * am not smart * still not smart * oops * oof * add deprecation notice --------- Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> Co-authored-by: Rich Harris * fix: Set loader: { '.wasm': 'copy' } in esbuild config in `adapter-cloudflare-workers` (#9940) * fix: Set loader: { '.wasm': 'copy' } in esbuild config in `adapter-cloudflare-workers` Copies WASM files in Cloudflare instead of trying to load them. Related to #9909 * Create brave-peaches-buy.md * Update packages/adapter-cloudflare-workers/index.js * format --------- Co-authored-by: Rich Harris Co-authored-by: Rich Harris * fix: Flaky test (#9947) * fix: Flaky test * reuse locator * add semi * drive by test speed up * another classic * oh my god brain, y u so bad --------- Co-authored-by: gtmnayan <50981692+gtm-nayan@users.noreply.github.com> Co-authored-by: gtmnayan * remove envVarsInUse (#9942) Co-authored-by: Rich Harris * fix: type `vitePlugin` in config (#9946) * fix: type `vitePlugin` in config * changeset * fix: Set `loader: { '.wasm': 'copy' }` in esbuild config in `adapter-vercel` (#9944) * fix: Enable wasm copy in adapter-vercel * Create olive-rings-eat.md --------- Co-authored-by: Rich Harris * feat: crawl URLs in `` tags (#9900) * Crawl social-image urls during prerender * Formatting & Linting * Format changeset & added exhaustive list of crawlable urls * Changed severity to minor as described in #5228 * Added support for `property` attribute & limited valid names to just social tags * More tests * Better changeset message - I'm indecisive * Update .changeset/thirty-garlics-tan.md Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> * simplify * simplify * Removed redundant data-sanitation * DRY out --------- Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> Co-authored-by: Rich Harris * Version Packages (#9893) Co-authored-by: github-actions[bot] * feat: support AWS via SST in adapter-auto (#9874) * [feat] support AWS via SST in adapter-auto * Sync * Delete 95-adapter-aws-sst.md * Update .changeset/rotten-ducks-tan.md --------- Co-authored-by: Rich Harris * Version Packages (#9953) Co-authored-by: github-actions[bot] * only cache response if response has cache-control header (#9885) * only cache response if response has cache-control header * add changeset * Version Packages (#9955) Co-authored-by: github-actions[bot] * fix: ensure styles are loaded in dev mode for routes containing special characters (#9894) * Fix loading styles for routes containing special characters in dev mode. SvelteKit doesn't decode special characters in pathnames when loading CSS modules in dev mode, resulting in an error: Internal server error: Failed to load url /src/routes/(special)/hinnap%C3%A4ring/+page.svelte?svelte=&type=style&lang.css=&inline= (resolved id: /src/routes/(special)/hinnap%C3%A4ring/+page.svelte?svelte&type=style&lang.css). Does the file exist? Actual path: /src/routes/(special)/hinnapäring/ Fix by using decodeURI on the url.pathname when loading CSS modules. * Create stale-houses-yell.md * decodeURL inside if * add test --------- Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> Co-authored-by: Rich Harris * feat: Warn users when submitting forms with files but no `enctype="multipart/form-data"` (#9888) * fix: Package name keeps me from filtering with pnpm * feat: Warn users when submitting a form containing a file without the correct enctype * changeset * Update packages/kit/src/runtime/app/forms.js Co-authored-by: gtmnayan <50981692+gtm-nayan@users.noreply.github.com> * style * moar style tweaks * better test skip * Update .changeset/tasty-llamas-relate.md Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> * DRY out * only warn once per submit * Update .changeset/tasty-llamas-relate.md Co-authored-by: Rich Harris --------- Co-authored-by: gtmnayan <50981692+gtm-nayan@users.noreply.github.com> Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> Co-authored-by: Rich Harris Co-authored-by: Rich Harris * Version Packages (#9957) Co-authored-by: github-actions[bot] * security: Stop automatically adding URLs from server-side `load` `fetch` calls to dependencies (#9945) * feat: Add `dangerZone` config * breaking: Don't implicitly track deps in server-side fetch * changeset * bein dumb * fix: Server load invalidation * fix: Write config for server * fix: test * unsurprisingly i am dumb * docs: Clarify difference between server `fetch` and universal `fetch` * tests * rename to trackServerFetches --------- Co-authored-by: Rich Harris * Version Packages (#9963) Co-authored-by: github-actions[bot] --------- Co-authored-by: S. Elliott Johnson Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com> Co-authored-by: Conduitry Co-authored-by: gtmnayan <50981692+gtm-nayan@users.noreply.github.com> Co-authored-by: Fernando López Guevara Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> Co-authored-by: Rich Harris Co-authored-by: Rich Harris Co-authored-by: Rich Harris Co-authored-by: Conner Co-authored-by: gtmnayan Co-authored-by: Loris Sigrist <43482866+LorisSigrist@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] Co-authored-by: Frank Co-authored-by: Frank Dumont Co-authored-by: Reio Remma --- .changeset/honest-news-hunt.md | 5 - .changeset/olive-dogs-bathe.md | 5 - .changeset/shy-pears-invent.md | 5 - .../docs/20-core-concepts/20-load.md | 4 +- .../25-build-and-deploy/30-adapter-auto.md | 1 + .../25-build-and-deploy/90-adapter-vercel.md | 5 +- packages/adapter-auto/CHANGELOG.md | 6 + packages/adapter-auto/adapters.js | 6 + packages/adapter-auto/package.json | 2 +- .../adapter-cloudflare-workers/CHANGELOG.md | 9 + packages/adapter-cloudflare-workers/index.js | 5 +- .../adapter-cloudflare-workers/package.json | 2 +- packages/adapter-cloudflare/CHANGELOG.md | 15 ++ packages/adapter-cloudflare/package.json | 2 +- packages/adapter-cloudflare/src/worker.js | 3 +- packages/adapter-static/package.json | 2 +- .../test/apps/prerendered/package.json | 2 +- .../adapter-static/test/apps/spa/package.json | 2 +- packages/adapter-vercel/CHANGELOG.md | 13 + packages/adapter-vercel/index.d.ts | 5 - packages/adapter-vercel/index.js | 13 +- packages/adapter-vercel/package.json | 2 +- packages/create-svelte/package.json | 4 +- .../templates/default/package.json | 2 +- .../templates/default/package.template.json | 2 +- .../templates/skeleton/package.template.json | 2 +- .../skeletonlib/package.template.json | 2 +- packages/create-svelte/test/check.js | 135 +++++++---- packages/create-svelte/tsconfig.json | 2 +- packages/create-svelte/vitest.config.js | 5 + packages/kit/CHANGELOG.md | 36 +++ packages/kit/package.json | 6 +- packages/kit/src/core/config/index.spec.js | 3 + packages/kit/src/core/config/options.js | 5 + packages/kit/src/core/postbuild/crawl.js | 111 +++++---- .../core/postbuild/fixtures/meta/input.html | 14 ++ .../core/postbuild/fixtures/meta/output.json | 4 + packages/kit/src/core/postbuild/prerender.js | 7 +- packages/kit/src/core/sync/write_server.js | 1 + packages/kit/src/exports/vite/dev/index.js | 15 +- packages/kit/src/runtime/app/forms.js | 85 +++++-- .../kit/src/runtime/server/cookie.spec.js | 6 +- packages/kit/src/runtime/server/data/index.js | 3 +- packages/kit/src/runtime/server/page/index.js | 3 +- .../kit/src/runtime/server/page/load_data.js | 15 +- .../runtime/server/page/respond_with_error.js | 3 +- packages/kit/src/utils/fork.js | 36 ++- packages/kit/test/apps/amp/package.json | 2 +- packages/kit/test/apps/basics/package.json | 2 +- .../old-property-access/+page.server.js | 26 ++ .../enhance/old-property-access/+page.svelte | 60 +++++ .../file-without-enctype/+page.server.js | 6 + .../actions/file-without-enctype/+page.svelte | 8 + .../apps/basics/src/routes/css/+page.svelte | 17 +- .../apps/basics/src/routes/css/_manual.css | 3 + .../routes/css/enc\303\266ded/+page.svelte" | 7 + .../kit/test/apps/basics/test/client.test.js | 5 +- .../apps/basics/test/cross-platform/test.js | 34 +-- packages/kit/test/apps/basics/test/test.js | 63 +++++ packages/kit/test/apps/dev-only/package.json | 4 +- packages/kit/test/apps/embed/package.json | 2 +- packages/kit/test/apps/options-2/package.json | 2 +- packages/kit/test/apps/options/package.json | 2 +- .../server-fetch-invalidate/+page.server.js | 6 + .../server-fetch-invalidate/+page.svelte | 6 + .../count.json/+server.js | 10 + .../kit/test/apps/options/svelte.config.js | 3 + packages/kit/test/apps/options/test/test.js | 19 ++ packages/kit/test/apps/writes/package.json | 2 +- .../package.json | 2 +- .../package.json | 2 +- .../package.json | 2 +- .../package.json | 2 +- .../apps/private-dynamic-env/package.json | 2 +- .../package.json | 2 +- .../apps/private-static-env/package.json | 2 +- .../package.json | 2 +- .../apps/server-only-folder/package.json | 2 +- .../package.json | 2 +- .../apps/server-only-module/package.json | 2 +- .../apps/syntax-error/package.json | 2 +- .../kit/test/prerendering/basics/package.json | 2 +- .../src/routes/redirect-encoded/+page.svelte | 0 .../routes/redirect-malicious/+page.svelte | 0 .../src/routes/redirect-relative/+page.js | 6 + .../src/routes/redirect-server/+page.svelte | 0 .../basics/src/routes/redirect/+page.svelte | 0 .../prerendering/basics/test/tests.spec.js | 23 +- .../test/prerendering/options/package.json | 2 +- .../test/prerendering/paths-base/package.json | 2 +- .../paths-base/test/tests.spec.js | 5 +- packages/kit/types/ambient.d.ts | 23 +- packages/kit/types/index.d.ts | 13 + packages/kit/types/internal.d.ts | 1 + pnpm-lock.yaml | 223 +++++++++--------- renovate.json | 4 +- sites/kit.svelte.dev/package.json | 2 +- 97 files changed, 874 insertions(+), 366 deletions(-) delete mode 100644 .changeset/honest-news-hunt.md delete mode 100644 .changeset/olive-dogs-bathe.md delete mode 100644 .changeset/shy-pears-invent.md create mode 100644 packages/create-svelte/vitest.config.js create mode 100644 packages/kit/src/core/postbuild/fixtures/meta/input.html create mode 100644 packages/kit/src/core/postbuild/fixtures/meta/output.json create mode 100644 packages/kit/test/apps/basics/src/routes/actions/enhance/old-property-access/+page.server.js create mode 100644 packages/kit/test/apps/basics/src/routes/actions/enhance/old-property-access/+page.svelte create mode 100644 packages/kit/test/apps/basics/src/routes/actions/file-without-enctype/+page.server.js create mode 100644 packages/kit/test/apps/basics/src/routes/actions/file-without-enctype/+page.svelte create mode 100644 packages/kit/test/apps/basics/src/routes/css/_manual.css create mode 100644 "packages/kit/test/apps/basics/src/routes/css/enc\303\266ded/+page.svelte" create mode 100644 packages/kit/test/apps/options/source/pages/server-fetch-invalidate/+page.server.js create mode 100644 packages/kit/test/apps/options/source/pages/server-fetch-invalidate/+page.svelte create mode 100644 packages/kit/test/apps/options/source/pages/server-fetch-invalidate/count.json/+server.js delete mode 100644 packages/kit/test/prerendering/basics/src/routes/redirect-encoded/+page.svelte delete mode 100644 packages/kit/test/prerendering/basics/src/routes/redirect-malicious/+page.svelte create mode 100644 packages/kit/test/prerendering/basics/src/routes/redirect-relative/+page.js delete mode 100644 packages/kit/test/prerendering/basics/src/routes/redirect-server/+page.svelte delete mode 100644 packages/kit/test/prerendering/basics/src/routes/redirect/+page.svelte diff --git a/.changeset/honest-news-hunt.md b/.changeset/honest-news-hunt.md deleted file mode 100644 index 9ea73a1cb34f..000000000000 --- a/.changeset/honest-news-hunt.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@sveltejs/adapter-cloudflare': patch ---- - -fix: Copy .wasm files during build diff --git a/.changeset/olive-dogs-bathe.md b/.changeset/olive-dogs-bathe.md deleted file mode 100644 index 1d0f193ac71c..000000000000 --- a/.changeset/olive-dogs-bathe.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@sveltejs/kit': patch ---- - -fix: stop setting Kit cookie defaults on cookies parsed from headers diff --git a/.changeset/shy-pears-invent.md b/.changeset/shy-pears-invent.md deleted file mode 100644 index 85c3b97a4a87..000000000000 --- a/.changeset/shy-pears-invent.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@sveltejs/kit': patch ---- - -fix: only skip hydration with vite overlay if current page is an error diff --git a/documentation/docs/20-core-concepts/20-load.md b/documentation/docs/20-core-concepts/20-load.md index 7a332ae07471..46dd991f7c85 100644 --- a/documentation/docs/20-core-concepts/20-load.md +++ b/documentation/docs/20-core-concepts/20-load.md @@ -537,7 +537,7 @@ Dependency tracking does not apply _after_ the `load` function has returned — ### Manual invalidation -You can also re-run `load` functions that apply to the current page using [`invalidate(url)`](modules#$app-navigation-invalidate), which re-runs all `load` functions that depend on `url`, and [`invalidateAll()`](modules#$app-navigation-invalidateall), which re-runs every `load` function. +You can also re-run `load` functions that apply to the current page using [`invalidate(url)`](modules#$app-navigation-invalidate), which re-runs all `load` functions that depend on `url`, and [`invalidateAll()`](modules#$app-navigation-invalidateall), which re-runs every `load` function. Server load functions will never automatically depend on a fetched `url` to avoid leaking secrets to the client. A `load` function depends on `url` if it calls `fetch(url)` or `depends(url)`. Note that `url` can be a custom identifier that starts with `[a-z]:`: @@ -585,7 +585,7 @@ To summarize, a `load` function will re-run in the following situations: - It references a property of `params` whose value has changed - It references a property of `url` (such as `url.pathname` or `url.search`) whose value has changed. Properties in `request.url` are _not_ tracked - It calls `await parent()` and a parent `load` function re-ran -- It declared a dependency on a specific URL via [`fetch`](#making-fetch-requests) or [`depends`](types#public-types-loadevent), and that URL was marked invalid with [`invalidate(url)`](modules#$app-navigation-invalidate) +- It declared a dependency on a specific URL via [`fetch`](#making-fetch-requests) (universal load only) or [`depends`](types#public-types-loadevent), and that URL was marked invalid with [`invalidate(url)`](modules#$app-navigation-invalidate) - All active `load` functions were forcibly re-run with [`invalidateAll()`](modules#$app-navigation-invalidateall) `params` and `url` can change in response to a `` link click, a [`
` interaction](form-actions#get-vs-post), a [`goto`](modules#$app-navigation-goto) invocation, or a [`redirect`](modules#sveltejs-kit-redirect). diff --git a/documentation/docs/25-build-and-deploy/30-adapter-auto.md b/documentation/docs/25-build-and-deploy/30-adapter-auto.md index d0719ebafc3d..e52f5967bd3b 100644 --- a/documentation/docs/25-build-and-deploy/30-adapter-auto.md +++ b/documentation/docs/25-build-and-deploy/30-adapter-auto.md @@ -8,6 +8,7 @@ When you create a new SvelteKit project with `npm create svelte@latest`, it inst - [`@sveltejs/adapter-netlify`](adapter-netlify) for [Netlify](https://netlify.com/) - [`@sveltejs/adapter-vercel`](adapter-vercel) for [Vercel](https://vercel.com/) - [`svelte-adapter-azure-swa`](https://github.com/geoffrich/svelte-adapter-azure-swa) for [Azure Static Web Apps](https://docs.microsoft.com/en-us/azure/static-web-apps/) +- [`svelte-kit-sst`](https://github.com/serverless-stack/sst/tree/master/packages/svelte-kit-sst) for [AWS via SST](https://docs.sst.dev/start/svelte) It's recommended to install the appropriate adapter to your `devDependencies` once you've settled on a target environment, since this will add the adapter to your lockfile and slightly improve install times on CI. diff --git a/documentation/docs/25-build-and-deploy/90-adapter-vercel.md b/documentation/docs/25-build-and-deploy/90-adapter-vercel.md index 9f81325e0e2c..7a04c63a89ce 100644 --- a/documentation/docs/25-build-and-deploy/90-adapter-vercel.md +++ b/documentation/docs/25-build-and-deploy/90-adapter-vercel.md @@ -54,8 +54,7 @@ The following options apply to all functions: - `regions`: an array of [edge network regions](https://vercel.com/docs/concepts/edge-network/regions) (defaulting to `["iad1"]` for serverless functions) or `'all'` if `runtime` is `edge` (its default). Note that multiple regions for serverless functions are only supported on Enterprise plans - `split`: if `true`, causes a route to be deployed as an individual function. If `split` is set to `true` at the adapter level, all routes will be deployed as individual functions -Additionally, the following options apply to edge functions: -- `envVarsInUse`: an array of environment variables that should be accessible inside the edge function +Additionally, the following option applies to edge functions: - `external`: an array of dependencies that esbuild should treat as external when bundling functions. This should only be used to exclude optional dependencies that will not run outside Node And the following option apply to serverless functions: @@ -130,7 +129,7 @@ export function load() {

This staging environment was deployed from {data.deploymentGitBranch}.

``` -Since all of these variables are unchanged between build time and run time when building on Vercel, we recommend using `$env/static/private` — which will statically replace the variables, enabling optimisations like dead code elimination — rather than `$env/dynamic/private`. If you're deploying with `edge: true` you must either use `$env/static/private` or populate the `envVarsInUse` configuration. +Since all of these variables are unchanged between build time and run time when building on Vercel, we recommend using `$env/static/private` — which will statically replace the variables, enabling optimisations like dead code elimination — rather than `$env/dynamic/private`. ## Notes diff --git a/packages/adapter-auto/CHANGELOG.md b/packages/adapter-auto/CHANGELOG.md index 323df65051b9..ac7c9c066087 100644 --- a/packages/adapter-auto/CHANGELOG.md +++ b/packages/adapter-auto/CHANGELOG.md @@ -1,5 +1,11 @@ # @sveltejs/adapter-auto +## 2.1.0 + +### Minor Changes + +- [feat] support AWS via SST ([#9874](https://github.com/sveltejs/kit/pull/9874)) + ## 2.0.1 ### Patch Changes diff --git a/packages/adapter-auto/adapters.js b/packages/adapter-auto/adapters.js index a904f1af4dcb..13ec6d189b97 100644 --- a/packages/adapter-auto/adapters.js +++ b/packages/adapter-auto/adapters.js @@ -24,5 +24,11 @@ export const adapters = [ test: () => process.env.GITHUB_ACTION_REPOSITORY === 'Azure/static-web-apps-deploy', module: 'svelte-adapter-azure-swa', version: '0.13' + }, + { + name: 'AWS via SST', + test: () => !!process.env.SST, + module: 'svelte-kit-sst', + version: '2' } ]; diff --git a/packages/adapter-auto/package.json b/packages/adapter-auto/package.json index 7ace0212bfd2..856e80a17038 100644 --- a/packages/adapter-auto/package.json +++ b/packages/adapter-auto/package.json @@ -1,6 +1,6 @@ { "name": "@sveltejs/adapter-auto", - "version": "2.0.1", + "version": "2.1.0", "description": "Automatically chooses the SvelteKit adapter for your current environment, if possible.", "repository": { "type": "git", diff --git a/packages/adapter-cloudflare-workers/CHANGELOG.md b/packages/adapter-cloudflare-workers/CHANGELOG.md index 587290f89bf5..c000a8360a78 100644 --- a/packages/adapter-cloudflare-workers/CHANGELOG.md +++ b/packages/adapter-cloudflare-workers/CHANGELOG.md @@ -1,5 +1,14 @@ # @sveltejs/adapter-cloudflare-workers +## 1.1.2 + +### Patch Changes + +- fix: Copy .wasm files during build ([#9940](https://github.com/sveltejs/kit/pull/9940)) + +- Updated dependencies [[`50acb22ca`](https://github.com/sveltejs/kit/commit/50acb22caf2901283e044cdfda36db6f07b3e0ae), [`2e6da9496`](https://github.com/sveltejs/kit/commit/2e6da9496bdace2c65040b9d1845c44801ca868c), [`a81106b3a`](https://github.com/sveltejs/kit/commit/a81106b3a817829c41e048207d6253e63988c58c), [`a6338a0b1`](https://github.com/sveltejs/kit/commit/a6338a0b124f54bda7ba3fe64be1d6173e118d00), [`4a85b7f08`](https://github.com/sveltejs/kit/commit/4a85b7f0820d35c7830c00afe1df3c94fcbf8c3d), [`26d2b7f8f`](https://github.com/sveltejs/kit/commit/26d2b7f8f5ca29c60ef61b936ff86deaeb1636ce), [`bc70b4e63`](https://github.com/sveltejs/kit/commit/bc70b4e636fcbd9593356996bf737e014ff8c238), [`ab9f57721`](https://github.com/sveltejs/kit/commit/ab9f57721fca146af7c4eb41f4875fafa5dfc0d2)]: + - @sveltejs/kit@1.17.0 + ## 1.1.1 ### Patch Changes diff --git a/packages/adapter-cloudflare-workers/index.js b/packages/adapter-cloudflare-workers/index.js index c30cc409ed01..e21c1b9bdd38 100644 --- a/packages/adapter-cloudflare-workers/index.js +++ b/packages/adapter-cloudflare-workers/index.js @@ -63,7 +63,10 @@ export default function ({ config = 'wrangler.toml' } = {}) { outfile: main, bundle: true, external: ['__STATIC_CONTENT_MANIFEST'], - format: 'esm' + format: 'esm', + loader: { + '.wasm': 'copy' + } }); builder.log.minor('Copying assets...'); diff --git a/packages/adapter-cloudflare-workers/package.json b/packages/adapter-cloudflare-workers/package.json index 1795aaf30447..0a900d4c7cf7 100644 --- a/packages/adapter-cloudflare-workers/package.json +++ b/packages/adapter-cloudflare-workers/package.json @@ -1,6 +1,6 @@ { "name": "@sveltejs/adapter-cloudflare-workers", - "version": "1.1.1", + "version": "1.1.2", "description": "SvelteKit adapter that creates a Cloudflare Workers site using a function for dynamic server rendering", "repository": { "type": "git", diff --git a/packages/adapter-cloudflare/CHANGELOG.md b/packages/adapter-cloudflare/CHANGELOG.md index de6397b83577..39013a237f7f 100644 --- a/packages/adapter-cloudflare/CHANGELOG.md +++ b/packages/adapter-cloudflare/CHANGELOG.md @@ -1,5 +1,20 @@ # @sveltejs/adapter-cloudflare +## 2.2.4 + +### Patch Changes + +- fix: require explicit cache-control header for caching ([#9885](https://github.com/sveltejs/kit/pull/9885)) + +## 2.2.3 + +### Patch Changes + +- fix: Copy .wasm files during build ([#9909](https://github.com/sveltejs/kit/pull/9909)) + +- Updated dependencies [[`50acb22ca`](https://github.com/sveltejs/kit/commit/50acb22caf2901283e044cdfda36db6f07b3e0ae), [`2e6da9496`](https://github.com/sveltejs/kit/commit/2e6da9496bdace2c65040b9d1845c44801ca868c), [`a81106b3a`](https://github.com/sveltejs/kit/commit/a81106b3a817829c41e048207d6253e63988c58c), [`a6338a0b1`](https://github.com/sveltejs/kit/commit/a6338a0b124f54bda7ba3fe64be1d6173e118d00), [`4a85b7f08`](https://github.com/sveltejs/kit/commit/4a85b7f0820d35c7830c00afe1df3c94fcbf8c3d), [`26d2b7f8f`](https://github.com/sveltejs/kit/commit/26d2b7f8f5ca29c60ef61b936ff86deaeb1636ce), [`bc70b4e63`](https://github.com/sveltejs/kit/commit/bc70b4e636fcbd9593356996bf737e014ff8c238), [`ab9f57721`](https://github.com/sveltejs/kit/commit/ab9f57721fca146af7c4eb41f4875fafa5dfc0d2)]: + - @sveltejs/kit@1.17.0 + ## 2.2.2 ### Patch Changes diff --git a/packages/adapter-cloudflare/package.json b/packages/adapter-cloudflare/package.json index c3b804873b6a..490b70a05a32 100644 --- a/packages/adapter-cloudflare/package.json +++ b/packages/adapter-cloudflare/package.json @@ -1,6 +1,6 @@ { "name": "@sveltejs/adapter-cloudflare", - "version": "2.2.2", + "version": "2.2.4", "description": "Adapter for building SvelteKit applications on Cloudflare Pages with Workers integration", "repository": { "type": "git", diff --git a/packages/adapter-cloudflare/src/worker.js b/packages/adapter-cloudflare/src/worker.js index dcdcb9a46efb..6a421a4e9ba9 100644 --- a/packages/adapter-cloudflare/src/worker.js +++ b/packages/adapter-cloudflare/src/worker.js @@ -55,7 +55,8 @@ const worker = { // write to `Cache` only if response is not an error, // let `Cache.save` handle the Cache-Control and Vary headers - return res.status >= 400 ? res : Cache.save(req, res, context); + pragma = res.headers.get('cache-control') || ''; + return pragma && res.status < 400 ? Cache.save(req, res, context) : res; } }; diff --git a/packages/adapter-static/package.json b/packages/adapter-static/package.json index d05e0ffc4b64..c088e800c655 100644 --- a/packages/adapter-static/package.json +++ b/packages/adapter-static/package.json @@ -36,7 +36,7 @@ "sirv": "^2.0.3", "svelte": "^3.56.0", "typescript": "^4.9.4", - "vite": "^4.3.0" + "vite": "^4.3.6" }, "peerDependencies": { "@sveltejs/kit": "^1.5.0" diff --git a/packages/adapter-static/test/apps/prerendered/package.json b/packages/adapter-static/test/apps/prerendered/package.json index 3991546e9707..01aa1f753408 100644 --- a/packages/adapter-static/test/apps/prerendered/package.json +++ b/packages/adapter-static/test/apps/prerendered/package.json @@ -12,7 +12,7 @@ "@sveltejs/kit": "workspace:^", "sirv-cli": "^2.0.2", "svelte": "^3.56.0", - "vite": "^4.3.0" + "vite": "^4.3.6" }, "type": "module" } diff --git a/packages/adapter-static/test/apps/spa/package.json b/packages/adapter-static/test/apps/spa/package.json index 2131b984f15d..542e122a251f 100644 --- a/packages/adapter-static/test/apps/spa/package.json +++ b/packages/adapter-static/test/apps/spa/package.json @@ -13,7 +13,7 @@ "@sveltejs/kit": "workspace:^", "sirv-cli": "^2.0.2", "svelte": "^3.56.0", - "vite": "^4.3.0" + "vite": "^4.3.6" }, "type": "module" } diff --git a/packages/adapter-vercel/CHANGELOG.md b/packages/adapter-vercel/CHANGELOG.md index fc16bab2543e..92fa5d85fa89 100644 --- a/packages/adapter-vercel/CHANGELOG.md +++ b/packages/adapter-vercel/CHANGELOG.md @@ -1,5 +1,18 @@ # @sveltejs/adapter-vercel +## 3.0.0 + +### Major Changes + +- breaking: remove obsolete `envVarsInUse` option ([#9942](https://github.com/sveltejs/kit/pull/9942)) + +### Patch Changes + +- fix: Copy .wasm files during build ([#9944](https://github.com/sveltejs/kit/pull/9944)) + +- Updated dependencies [[`50acb22ca`](https://github.com/sveltejs/kit/commit/50acb22caf2901283e044cdfda36db6f07b3e0ae), [`2e6da9496`](https://github.com/sveltejs/kit/commit/2e6da9496bdace2c65040b9d1845c44801ca868c), [`a81106b3a`](https://github.com/sveltejs/kit/commit/a81106b3a817829c41e048207d6253e63988c58c), [`a6338a0b1`](https://github.com/sveltejs/kit/commit/a6338a0b124f54bda7ba3fe64be1d6173e118d00), [`4a85b7f08`](https://github.com/sveltejs/kit/commit/4a85b7f0820d35c7830c00afe1df3c94fcbf8c3d), [`26d2b7f8f`](https://github.com/sveltejs/kit/commit/26d2b7f8f5ca29c60ef61b936ff86deaeb1636ce), [`bc70b4e63`](https://github.com/sveltejs/kit/commit/bc70b4e636fcbd9593356996bf737e014ff8c238), [`ab9f57721`](https://github.com/sveltejs/kit/commit/ab9f57721fca146af7c4eb41f4875fafa5dfc0d2)]: + - @sveltejs/kit@1.17.0 + ## 2.4.3 ### Patch Changes diff --git a/packages/adapter-vercel/index.d.ts b/packages/adapter-vercel/index.d.ts index 5b4a70b3fd51..634f90ed8db9 100644 --- a/packages/adapter-vercel/index.d.ts +++ b/packages/adapter-vercel/index.d.ts @@ -63,11 +63,6 @@ export interface EdgeConfig { * More info: https://vercel.com/docs/concepts/edge-network/regions */ regions?: string[] | 'all'; - /** - * List of environment variable names that will be available for the Edge Function to utilize. - * Edge only. - */ - envVarsInUse?: string[]; /** * List of packages that should not be bundled into the Edge Function. * Edge only. diff --git a/packages/adapter-vercel/index.js b/packages/adapter-vercel/index.js index c947d80bab12..5efdfefdc952 100644 --- a/packages/adapter-vercel/index.js +++ b/packages/adapter-vercel/index.js @@ -96,13 +96,6 @@ const plugin = function (defaults = {}) { const tmp = builder.getBuildDirectory(`vercel-tmp/${name}`); const relativePath = path.posix.relative(tmp, builder.getServerDirectory()); - const envVarsInUse = new Set(); - routes.forEach((route) => { - route.config?.envVarsInUse?.forEach((x) => { - envVarsInUse.add(x); - }); - }); - builder.copy(`${files}/edge.js`, `${tmp}/edge.js`, { replace: { SERVER: `${relativePath}/index.js`, @@ -124,7 +117,10 @@ const plugin = function (defaults = {}) { format: 'esm', external: config.external, sourcemap: 'linked', - banner: { js: 'globalThis.global = globalThis;' } + banner: { js: 'globalThis.global = globalThis;' }, + loader: { + '.wasm': 'copy' + } }); write( @@ -133,7 +129,6 @@ const plugin = function (defaults = {}) { { runtime: config.runtime, regions: config.regions, - envVarsInUse: [...envVarsInUse], entrypoint: 'index.js' }, null, diff --git a/packages/adapter-vercel/package.json b/packages/adapter-vercel/package.json index b57df0ae2372..024297e2ceb4 100644 --- a/packages/adapter-vercel/package.json +++ b/packages/adapter-vercel/package.json @@ -1,6 +1,6 @@ { "name": "@sveltejs/adapter-vercel", - "version": "2.4.3", + "version": "3.0.0", "description": "A SvelteKit adapter that creates a Vercel app", "repository": { "type": "git", diff --git a/packages/create-svelte/package.json b/packages/create-svelte/package.json index cfd9562279a1..2d6bd356eb5e 100644 --- a/packages/create-svelte/package.json +++ b/packages/create-svelte/package.json @@ -26,11 +26,11 @@ "sucrase": "^3.29.0", "svelte": "^3.56.0", "tiny-glob": "^0.2.9", - "uvu": "^0.5.6" + "vitest": "^0.31.0" }, "scripts": { "build": "node scripts/build-templates", - "test": "pnpm build && uvu test", + "test": "pnpm build && vitest run", "check": "tsc", "lint": "prettier --check . --config ../../.prettierrc --ignore-path ../../.gitignore --ignore-path .gitignore --plugin prettier-plugin-svelte --plugin-search-dir=.", "format": "pnpm lint --write", diff --git a/packages/create-svelte/templates/default/package.json b/packages/create-svelte/templates/default/package.json index 945fe7a4ffce..21eabd41fbce 100644 --- a/packages/create-svelte/templates/default/package.json +++ b/packages/create-svelte/templates/default/package.json @@ -13,7 +13,7 @@ "@sveltejs/kit": "workspace:*", "svelte": "^3.56.0", "typescript": "^5.0.0", - "vite": "^4.3.0" + "vite": "^4.3.6" }, "type": "module", "dependencies": { diff --git a/packages/create-svelte/templates/default/package.template.json b/packages/create-svelte/templates/default/package.template.json index e7532950073b..fdfa355cf6d4 100644 --- a/packages/create-svelte/templates/default/package.template.json +++ b/packages/create-svelte/templates/default/package.template.json @@ -12,7 +12,7 @@ "@sveltejs/adapter-auto": "^2.0.0", "@sveltejs/kit": "^1.5.0", "svelte": "^3.54.0", - "vite": "^4.3.0" + "vite": "^4.3.6" }, "type": "module" } diff --git a/packages/create-svelte/templates/skeleton/package.template.json b/packages/create-svelte/templates/skeleton/package.template.json index 09fe6d4e46aa..bb4977c8f98d 100644 --- a/packages/create-svelte/templates/skeleton/package.template.json +++ b/packages/create-svelte/templates/skeleton/package.template.json @@ -11,7 +11,7 @@ "@sveltejs/adapter-auto": "^2.0.0", "@sveltejs/kit": "^1.5.0", "svelte": "^3.54.0", - "vite": "^4.3.0" + "vite": "^4.3.6" }, "type": "module" } diff --git a/packages/create-svelte/templates/skeletonlib/package.template.json b/packages/create-svelte/templates/skeletonlib/package.template.json index 47d09a05fcb2..e114f7dc31d2 100644 --- a/packages/create-svelte/templates/skeletonlib/package.template.json +++ b/packages/create-svelte/templates/skeletonlib/package.template.json @@ -26,7 +26,7 @@ "svelte": "^3.54.0", "tslib": "^2.4.1", "typescript": "^5.0.0", - "vite": "^4.3.0" + "vite": "^4.3.6" }, "svelte": "./dist/index.js", "types": "./dist/index.d.ts", diff --git a/packages/create-svelte/test/check.js b/packages/create-svelte/test/check.js index 46b79050d92a..5112fd424fb4 100644 --- a/packages/create-svelte/test/check.js +++ b/packages/create-svelte/test/check.js @@ -1,13 +1,16 @@ +import { exec, execSync } from 'node:child_process'; import fs from 'node:fs'; -import { execSync } from 'node:child_process'; import path from 'node:path'; -import { test } from 'uvu'; -import * as assert from 'uvu/assert'; -import { create } from '../index.js'; import { fileURLToPath } from 'node:url'; -import glob from 'tiny-glob'; +import { promisify } from 'node:util'; +import glob from 'tiny-glob/sync.js'; +import { beforeAll, describe, test } from 'vitest'; +import { create } from '../index.js'; -/** Resolve the given path relative to the current file */ +/** + * Resolve the given path relative to the current file + * @param {string} path + */ const resolve_path = (path) => fileURLToPath(new URL(path, import.meta.url)); // use a directory outside of packages to ensure it isn't added to the pnpm workspace @@ -19,18 +22,18 @@ const existing_workspace_overrides = JSON.parse( const overrides = { ...existing_workspace_overrides }; -(await glob(resolve_path('../../../packages') + '/*/package.json')).forEach((pkgPath) => { - const name = JSON.parse(fs.readFileSync(pkgPath, 'utf-8')).name; +for (const pkg_path of glob(resolve_path('../../../packages/*/package.json'))) { + const name = JSON.parse(fs.readFileSync(pkg_path, 'utf-8')).name; // use `file:` protocol for opting into stricter resolve logic which catches more bugs, // but only on CI because it doesn't work locally for some reason const protocol = process.env.CI ? 'file:' : ''; - overrides[name] = `${protocol}${path.dirname(path.resolve(pkgPath))}`; -}); + overrides[name] = `${protocol}${path.dirname(path.resolve(pkg_path))}`; +} try { const kit_dir = resolve_path('../../../packages/kit'); const ls_vite_result = execSync(`pnpm ls --json vite`, { cwd: kit_dir }); - const vite_version = JSON.parse(ls_vite_result)[0].devDependencies.vite.version; + const vite_version = JSON.parse(ls_vite_result.toString())[0].devDependencies.vite.version; overrides.vite = vite_version; } catch (e) { console.error('failed to parse installed vite version from packages/kit'); @@ -47,16 +50,61 @@ const workspace = { pnpm: { overrides }, devDependencies: overrides }; + fs.writeFileSync( path.join(test_workspace_dir, 'package.json'), JSON.stringify(workspace, null, '\t') ); + fs.writeFileSync(path.join(test_workspace_dir, 'pnpm-workspace.yaml'), 'packages:\n - ./*\n'); -for (const template of fs.readdirSync('templates')) { +const exec_async = promisify(exec); + +beforeAll(async () => { + await exec_async(`pnpm install --no-frozen-lockfile`, { + cwd: test_workspace_dir + }); +}, 60000); + +/** @param {any} pkg */ +function patch_package_json(pkg) { + Object.entries(overrides).forEach(([key, value]) => { + if (pkg.devDependencies?.[key]) { + pkg.devDependencies[key] = value; + } + + if (pkg.dependencies?.[key]) { + pkg.dependencies[key] = value; + } + + if (!pkg.pnpm) { + pkg.pnpm = {}; + } + + if (!pkg.pnpm.overrides) { + pkg.pnpm.overrides = {}; + } + + pkg.pnpm.overrides = { ...pkg.pnpm.overrides, ...overrides }; + }); + pkg.private = true; +} + +/** + * Tests in different templates can be run concurrently for a nice speedup locally, but tests within a template must be run sequentially. + * It'd be better to group tests by template, but vitest doesn't support that yet. + * @type {Map import('node:child_process').PromiseWithChild][]>} + */ +const script_test_map = new Map(); + +const templates = /** @type {Array<'default' | 'skeleton' | 'skeletonlib'>} */ ( + fs.readdirSync('templates') +); + +for (const template of templates) { if (template[0] === '.') continue; - for (const types of ['checkjs', 'typescript']) { + for (const types of /** @type {const} */ (['checkjs', 'typescript'])) { const cwd = path.join(test_workspace_dir, `${template}-${types}`); fs.rmSync(cwd, { recursive: true, force: true }); @@ -66,51 +114,38 @@ for (const template of fs.readdirSync('templates')) { types, prettier: true, eslint: true, - playwright: false + playwright: false, + vitest: false }); + const pkg = JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf-8')); - Object.entries(overrides).forEach(([key, value]) => { - if (pkg.devDependencies?.[key]) { - pkg.devDependencies[key] = value; - } - if (pkg.dependencies?.[key]) { - pkg.dependencies[key] = value; - } - if (!pkg.pnpm) { - pkg.pnpm = {}; - } - if (!pkg.pnpm.overrides) { - pkg.pnpm.overrides = {}; - } - pkg.pnpm.overrides = { ...pkg.pnpm.overrides, ...overrides }; - }); - pkg.private = true; + patch_package_json(pkg); + fs.writeFileSync(path.join(cwd, 'package.json'), JSON.stringify(pkg, null, '\t') + '\n'); // run provided scripts that are non-blocking. All of them should exit with 0 // package script requires lib dir - const scripts_to_test = ['sync', 'format', 'lint', 'check', 'build']; - if (fs.existsSync(path.join(cwd, 'src', 'lib'))) { - scripts_to_test.push('package'); - } + // TODO: lint should run before format + const scripts_to_test = ['format', 'lint', 'check', 'build', 'package'].filter( + (s) => s in pkg.scripts + ); - for (const script of scripts_to_test.filter((s) => !!pkg.scripts[s])) { - test(`${template}-${types}: ${script}`, () => { - try { - execSync(`pnpm ${script}`, { cwd, stdio: 'pipe' }); - } catch (e) { - assert.unreachable( - `script: ${script} failed\n` + - `---\nstdout:\n${e.stdout}\n` + - `---\nstderr:\n${e.stderr}` - ); - } - }); + for (const script of scripts_to_test) { + const tests = script_test_map.get(script) ?? []; + tests.push([`${template}-${types}`, () => exec_async(`pnpm ${script}`, { cwd })]); + script_test_map.set(script, tests); } } } -console.log('installing dependencies...'); -execSync('pnpm install --no-frozen-lockfile', { cwd: test_workspace_dir, stdio: 'ignore' }); -console.log('done installing dependencies'); -test.run(); +for (const [script, tests] of script_test_map) { + describe.concurrent( + script, + () => { + for (const [name, task] of tests) { + test(name, task); + } + }, + { timeout: 60000 } + ); +} diff --git a/packages/create-svelte/tsconfig.json b/packages/create-svelte/tsconfig.json index 8b8e546b7866..a21fc45c4068 100644 --- a/packages/create-svelte/tsconfig.json +++ b/packages/create-svelte/tsconfig.json @@ -10,5 +10,5 @@ "strict": true, "skipLibCheck": true }, - "include": ["./scripts/**/*", "./index.js", "./bin.js", "./utils.js"] + "include": ["./scripts/**/*", "./test/*.js", "./index.js", "./bin.js", "./utils.js"] } diff --git a/packages/create-svelte/vitest.config.js b/packages/create-svelte/vitest.config.js new file mode 100644 index 000000000000..3f5451417a27 --- /dev/null +++ b/packages/create-svelte/vitest.config.js @@ -0,0 +1,5 @@ +import { defineConfig } from 'vitest/config'; + +export default defineConfig({ + test: { dir: './test', include: ['*.js'] } +}); diff --git a/packages/kit/CHANGELOG.md b/packages/kit/CHANGELOG.md index a7b31fee3cc4..0faa1718fb26 100644 --- a/packages/kit/CHANGELOG.md +++ b/packages/kit/CHANGELOG.md @@ -1,5 +1,41 @@ # @sveltejs/kit +## 1.18.0 + +### Minor Changes + +- security: Stop implicitly tracking URLs as dependencies in server-side `load`s ([#9945](https://github.com/sveltejs/kit/pull/9945)) + +## 1.17.1 + +### Patch Changes + +- fix: ensure styles are loaded in dev mode for routes containing special characters ([#9894](https://github.com/sveltejs/kit/pull/9894)) + +- feat: warn users when enhancing forms with files but no `enctype="multipart/form-data"` ([#9888](https://github.com/sveltejs/kit/pull/9888)) + +## 1.17.0 + +### Minor Changes + +- feat: unshadow `data` and `form` in `enhance` and warn about future deprecation when used in `dev` mode ([#9902](https://github.com/sveltejs/kit/pull/9902)) + +- feat: crawl URLs in `` tags ([#9900](https://github.com/sveltejs/kit/pull/9900)) + +### Patch Changes + +- fix: avoid trying to inline raw or url css imports ([#9925](https://github.com/sveltejs/kit/pull/9925)) + +- feat: prerender in worker rather than subprocess to support Deno ([#9919](https://github.com/sveltejs/kit/pull/9919)) + +- perf: add `` ); written.add(file); diff --git a/packages/kit/src/core/sync/write_server.js b/packages/kit/src/core/sync/write_server.js index bf119dcfa7ac..647aa5924237 100644 --- a/packages/kit/src/core/sync/write_server.js +++ b/packages/kit/src/core/sync/write_server.js @@ -34,6 +34,7 @@ export const options = { app_template_contains_nonce: ${template.includes('%sveltekit.nonce%')}, csp: ${s(config.kit.csp)}, csrf_check_origin: ${s(config.kit.csrf.checkOrigin)}, + track_server_fetches: ${s(config.kit.dangerZone.trackServerFetches)}, embedded: ${config.kit.embedded}, env_public_prefix: '${config.kit.env.publicPrefix}', hooks: null, // added lazily, via \`get_hooks\` diff --git a/packages/kit/src/exports/vite/dev/index.js b/packages/kit/src/exports/vite/dev/index.js index b77c163d9aca..1f2a5b4881b5 100644 --- a/packages/kit/src/exports/vite/dev/index.js +++ b/packages/kit/src/exports/vite/dev/index.js @@ -176,19 +176,18 @@ export async function dev(vite, vite_config, svelte_config) { const styles = {}; for (const dep of deps) { - const url = new URL(dep.url, 'http://localhost/'); + const url = new URL(dep.url, 'dummy:/'); const query = url.searchParams; if ( - isCSSRequest(dep.file) || - (query.has('svelte') && query.get('type') === 'style') + (isCSSRequest(dep.file) || + (query.has('svelte') && query.get('type') === 'style')) && + !(query.has('raw') || query.has('url') || query.has('inline')) ) { - // setting `?inline` to load CSS modules as css string - query.set('inline', ''); - try { - const mod = await loud_ssr_load_module( - `${url.pathname}${url.search}${url.hash}` + query.set('inline', ''); + const mod = await vite.ssrLoadModule( + `${decodeURI(url.pathname)}${url.search}${url.hash}` ); styles[dep.url] = mod.default; } catch { diff --git a/packages/kit/src/runtime/app/forms.js b/packages/kit/src/runtime/app/forms.js index 24ef54daf79d..30858235032f 100644 --- a/packages/kit/src/runtime/app/forms.js +++ b/packages/kit/src/runtime/app/forms.js @@ -14,13 +14,34 @@ export function deserialize(result) { return parsed; } +/** + * @param {string} old_name + * @param {string} new_name + * @param {string} call_location + * @returns void + */ +function warn_on_access(old_name, new_name, call_location) { + if (!DEV) return; + // TODO 2.0: Remove this code + console.warn( + `\`${old_name}\` has been deprecated in favor of \`${new_name}\`. \`${old_name}\` will be removed in a future version. (Called from ${call_location})` + ); +} + +/** + * Shallow clone an element, so that we can access e.g. `form.action` without worrying + * that someone has added an `` (https://github.com/sveltejs/kit/issues/7593) + * @template {HTMLElement} T + * @param {T} element + * @returns {T} + */ +function clone(element) { + return /** @type {T} */ (HTMLElement.prototype.cloneNode.call(element)); +} + /** @type {import('$app/forms').enhance} */ -export function enhance(form, submit = () => {}) { - if ( - DEV && - /** @type {HTMLFormElement} */ (HTMLFormElement.prototype.cloneNode.call(form)).method !== - 'post' - ) { +export function enhance(form_element, submit = () => {}) { + if (DEV && clone(form_element).method !== 'post') { throw new Error('use:enhance can only be used on fields with method="POST"'); } @@ -35,7 +56,7 @@ export function enhance(form, submit = () => {}) { if (result.type === 'success') { if (reset !== false) { // We call reset from the prototype to avoid DOM clobbering - HTMLFormElement.prototype.reset.call(form); + HTMLFormElement.prototype.reset.call(form_element); } await invalidateAll(); } @@ -57,17 +78,28 @@ export function enhance(form, submit = () => {}) { const action = new URL( // We can't do submitter.formAction directly because that property is always set - // We do cloneNode for avoid DOM clobbering - https://github.com/sveltejs/kit/issues/7593 event.submitter?.hasAttribute('formaction') ? /** @type {HTMLButtonElement | HTMLInputElement} */ (event.submitter).formAction - : /** @type {HTMLFormElement} */ (HTMLFormElement.prototype.cloneNode.call(form)).action + : clone(form_element).action ); - const data = new FormData(form); + const form_data = new FormData(form_element); + + if (DEV && clone(form_element).enctype !== 'multipart/form-data') { + for (const value of form_data.values()) { + if (value instanceof File) { + // TODO 2.0: Upgrade to `throw Error` + console.warn( + 'Your form contains fields, but is missing the `enctype="multipart/form-data"` attribute. This will lead to inconsistent behavior between enhanced and native forms. For more details, see https://github.com/sveltejs/kit/issues/9819. This will be upgraded to an error in v2.0.' + ); + break; + } + } + } const submitter_name = event.submitter?.getAttribute('name'); if (submitter_name) { - data.append(submitter_name, event.submitter?.getAttribute('value') ?? ''); + form_data.append(submitter_name, event.submitter?.getAttribute('value') ?? ''); } const controller = new AbortController(); @@ -75,13 +107,22 @@ export function enhance(form, submit = () => {}) { let cancelled = false; const cancel = () => (cancelled = true); + // TODO 2.0: Remove `data` and `form` const callback = (await submit({ action, cancel, controller, - data, - form, + get data() { + warn_on_access('data', 'formData', 'use:enhance submit function'); + return form_data; + }, + formData: form_data, + get form() { + warn_on_access('form', 'formElement', 'use:enhance submit function'); + return form_element; + }, + formElement: form_element, submitter: event.submitter })) ?? fallback_callback; if (cancelled) return; @@ -97,7 +138,7 @@ export function enhance(form, submit = () => {}) { 'x-sveltekit-action': 'true' }, cache: 'no-store', - body: data, + body: form_data, signal: controller.signal }); @@ -110,8 +151,16 @@ export function enhance(form, submit = () => {}) { callback({ action, - data, - form, + get data() { + warn_on_access('data', 'formData', 'callback returned from use:enhance submit function'); + return form_data; + }, + formData: form_data, + get form() { + warn_on_access('form', 'formElement', 'callback returned from use:enhance submit function'); + return form_element; + }, + formElement: form_element, update: (opts) => fallback_callback({ action, result, reset: opts?.reset }), // @ts-expect-error generic constraints stuff we don't care about result @@ -119,12 +168,12 @@ export function enhance(form, submit = () => {}) { } // @ts-expect-error - HTMLFormElement.prototype.addEventListener.call(form, 'submit', handle_submit); + HTMLFormElement.prototype.addEventListener.call(form_element, 'submit', handle_submit); return { destroy() { // @ts-expect-error - HTMLFormElement.prototype.removeEventListener.call(form, 'submit', handle_submit); + HTMLFormElement.prototype.removeEventListener.call(form_element, 'submit', handle_submit); } }; } diff --git a/packages/kit/src/runtime/server/cookie.spec.js b/packages/kit/src/runtime/server/cookie.spec.js index b8ab71e73996..c707a1ee42bb 100644 --- a/packages/kit/src/runtime/server/cookie.spec.js +++ b/packages/kit/src/runtime/server/cookie.spec.js @@ -174,10 +174,10 @@ test('warns if cookie exceeds 4,129 bytes', () => { const error = /** @type {Error} */ (e); assert.equal(error.message, `Cookie "a" is too large, and will be discarded by the browser`); + } finally { + // @ts-expect-error + globalThis.__SVELTEKIT_DEV__ = false; } - - // @ts-expect-error - globalThis.__SVELTEKIT_DEV__ = false; }); test('get all cookies from header and set calls', () => { diff --git a/packages/kit/src/runtime/server/data/index.js b/packages/kit/src/runtime/server/data/index.js index 1fbec114a26d..8d38b1e10720 100644 --- a/packages/kit/src/runtime/server/data/index.js +++ b/packages/kit/src/runtime/server/data/index.js @@ -76,7 +76,8 @@ export async function render_data( } } return data; - } + }, + track_server_fetches: options.track_server_fetches }); } catch (e) { aborted = true; diff --git a/packages/kit/src/runtime/server/page/index.js b/packages/kit/src/runtime/server/page/index.js index fdf7713be962..b7009a27b9fe 100644 --- a/packages/kit/src/runtime/server/page/index.js +++ b/packages/kit/src/runtime/server/page/index.js @@ -150,7 +150,8 @@ export async function render_page(event, page, options, manifest, state, resolve if (parent) Object.assign(data, await parent.data); } return data; - } + }, + track_server_fetches: options.track_server_fetches }); } catch (e) { load_error = /** @type {Error} */ (e); diff --git a/packages/kit/src/runtime/server/page/load_data.js b/packages/kit/src/runtime/server/page/load_data.js index 5db45afdc673..ced84ab9918c 100644 --- a/packages/kit/src/runtime/server/page/load_data.js +++ b/packages/kit/src/runtime/server/page/load_data.js @@ -10,10 +10,18 @@ import { validate_depends } from '../../shared.js'; * state: import('types').SSRState; * node: import('types').SSRNode | undefined; * parent: () => Promise>; + * track_server_fetches: boolean; * }} opts * @returns {Promise} */ -export async function load_server_data({ event, state, node, parent }) { +export async function load_server_data({ + event, + state, + node, + parent, + // TODO 2.0: Remove this + track_server_fetches +}) { if (!node?.server) return null; let done = false; @@ -51,7 +59,10 @@ export async function load_server_data({ event, state, node, parent }) { ); } - uses.dependencies.add(url.href); + // TODO 2.0: Remove this + if (track_server_fetches) { + uses.dependencies.add(url.href); + } return event.fetch(info, init); }, 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 10607a09d8ad..2567b7e768e8 100644 --- a/packages/kit/src/runtime/server/page/respond_with_error.js +++ b/packages/kit/src/runtime/server/page/respond_with_error.js @@ -44,7 +44,8 @@ export async function respond_with_error({ event, state, node: default_layout, - parent: async () => ({}) + parent: async () => ({}), + track_server_fetches: options.track_server_fetches }); const server_data = await server_data_promise; diff --git a/packages/kit/src/utils/fork.js b/packages/kit/src/utils/fork.js index 58ed2dcb5066..cbf24ac1ba6e 100644 --- a/packages/kit/src/utils/fork.js +++ b/packages/kit/src/utils/fork.js @@ -1,5 +1,5 @@ import { fileURLToPath } from 'node:url'; -import child_process from 'node:child_process'; +import { Worker, parentPort } from 'node:worker_threads'; /** * Runs a task in a subprocess so any dangling stuff gets killed upon completion. @@ -11,23 +11,21 @@ import child_process from 'node:child_process'; * @returns {(opts: T) => Promise} A function that when called starts the subprocess */ export function forked(module, callback) { - if (process.env.SVELTEKIT_FORK && process.send) { - process.send({ type: 'ready', module }); - - process.on( + if (process.env.SVELTEKIT_FORK && parentPort) { + parentPort.on( 'message', /** @param {any} data */ async (data) => { if (data?.type === 'args' && data.module === module) { - if (process.send) { - process.send({ - type: 'result', - module, - payload: await callback(data.payload) - }); - } + parentPort?.postMessage({ + type: 'result', + module, + payload: await callback(data.payload) + }); } } ); + + parentPort.postMessage({ type: 'ready', module }); } /** @@ -36,20 +34,18 @@ export function forked(module, callback) { */ const fn = function (opts) { return new Promise((fulfil, reject) => { - const child = child_process.fork(fileURLToPath(module), { - stdio: 'inherit', + const worker = new Worker(fileURLToPath(module), { env: { ...process.env, SVELTEKIT_FORK: 'true' - }, - serialization: 'advanced' + } }); - child.on( + worker.on( 'message', /** @param {any} data */ (data) => { if (data?.type === 'ready' && data.module === module) { - child.send({ + worker.postMessage({ type: 'args', module, payload: opts @@ -57,13 +53,13 @@ export function forked(module, callback) { } if (data?.type === 'result' && data.module === module) { - child.kill(); + worker.terminate(); fulfil(data.payload); } } ); - child.on('exit', (code) => { + worker.on('exit', (code) => { if (code) { reject(new Error(`Failed with code ${code}`)); } diff --git a/packages/kit/test/apps/amp/package.json b/packages/kit/test/apps/amp/package.json index f6c2aa4c1974..b4a0a107b643 100644 --- a/packages/kit/test/apps/amp/package.json +++ b/packages/kit/test/apps/amp/package.json @@ -19,7 +19,7 @@ "svelte": "^3.56.0", "svelte-check": "^3.0.2", "typescript": "^4.9.4", - "vite": "^4.3.0" + "vite": "^4.3.6" }, "type": "module" } diff --git a/packages/kit/test/apps/basics/package.json b/packages/kit/test/apps/basics/package.json index 26df84a7d627..73c8fc868ed7 100644 --- a/packages/kit/test/apps/basics/package.json +++ b/packages/kit/test/apps/basics/package.json @@ -20,7 +20,7 @@ "svelte": "^3.56.0", "svelte-check": "^3.0.2", "typescript": "^4.9.4", - "vite": "^4.3.0" + "vite": "^4.3.6" }, "type": "module" } diff --git a/packages/kit/test/apps/basics/src/routes/actions/enhance/old-property-access/+page.server.js b/packages/kit/test/apps/basics/src/routes/actions/enhance/old-property-access/+page.server.js new file mode 100644 index 000000000000..4bdf1c67412b --- /dev/null +++ b/packages/kit/test/apps/basics/src/routes/actions/enhance/old-property-access/+page.server.js @@ -0,0 +1,26 @@ +// TODO 2.0: Remove this code and corresponding tests +export const actions = { + form_submit: () => { + return { + form_submit: true + }; + }, + + form_callback: () => { + return { + form_callback: true + }; + }, + + data_submit: () => { + return { + data_submit: true + }; + }, + + data_callback: () => { + return { + data_callback: true + }; + } +}; diff --git a/packages/kit/test/apps/basics/src/routes/actions/enhance/old-property-access/+page.svelte b/packages/kit/test/apps/basics/src/routes/actions/enhance/old-property-access/+page.svelte new file mode 100644 index 000000000000..1768c5d9dc7b --- /dev/null +++ b/packages/kit/test/apps/basics/src/routes/actions/enhance/old-property-access/+page.svelte @@ -0,0 +1,60 @@ + + + + + + +
+ +
+ +
+ +
+ +
+ +
diff --git a/packages/kit/test/apps/basics/src/routes/actions/file-without-enctype/+page.server.js b/packages/kit/test/apps/basics/src/routes/actions/file-without-enctype/+page.server.js new file mode 100644 index 000000000000..05260b09a0eb --- /dev/null +++ b/packages/kit/test/apps/basics/src/routes/actions/file-without-enctype/+page.server.js @@ -0,0 +1,6 @@ +export const actions = { + default: async ({ request }) => { + const data = await request.formData(); + console.log(data.get('file')); + } +}; diff --git a/packages/kit/test/apps/basics/src/routes/actions/file-without-enctype/+page.svelte b/packages/kit/test/apps/basics/src/routes/actions/file-without-enctype/+page.svelte new file mode 100644 index 000000000000..c33bef9f7e21 --- /dev/null +++ b/packages/kit/test/apps/basics/src/routes/actions/file-without-enctype/+page.svelte @@ -0,0 +1,8 @@ + + +
+ + +
diff --git a/packages/kit/test/apps/basics/src/routes/css/+page.svelte b/packages/kit/test/apps/basics/src/routes/css/+page.svelte index 45074c38b15c..fca01c864628 100644 --- a/packages/kit/test/apps/basics/src/routes/css/+page.svelte +++ b/packages/kit/test/apps/basics/src/routes/css/+page.svelte @@ -1,18 +1,17 @@ -
- this text is red -
+
this text is red
-
- this text is blue -
+
this text is blue
-
- this text is green -
+
this text is green
+ +
this text is black
other diff --git a/packages/kit/test/apps/basics/src/routes/css/_manual.css b/packages/kit/test/apps/basics/src/routes/css/_manual.css new file mode 100644 index 000000000000..a800732cbe85 --- /dev/null +++ b/packages/kit/test/apps/basics/src/routes/css/_manual.css @@ -0,0 +1,3 @@ +.not { + color: blue; +} diff --git "a/packages/kit/test/apps/basics/src/routes/css/enc\303\266ded/+page.svelte" "b/packages/kit/test/apps/basics/src/routes/css/enc\303\266ded/+page.svelte" new file mode 100644 index 000000000000..6c104c3daa3d --- /dev/null +++ "b/packages/kit/test/apps/basics/src/routes/css/enc\303\266ded/+page.svelte" @@ -0,0 +1,7 @@ +

this should be purple

+ + diff --git a/packages/kit/test/apps/basics/test/client.test.js b/packages/kit/test/apps/basics/test/client.test.js index bf8a748c0668..b95076c4520e 100644 --- a/packages/kit/test/apps/basics/test/client.test.js +++ b/packages/kit/test/apps/basics/test/client.test.js @@ -456,14 +456,15 @@ test.describe('Invalidation', () => { expect(shared).not.toBe(next_shared); }); - test('fetch in server load can be invalidated', async ({ page, app, request }) => { + test('fetch in server load cannot be invalidated', async ({ page, app, request }) => { + // TODO 2.0: Can remove this test after `dangerZone.trackServerFetches` and associated code is removed await request.get('/load/invalidation/server-fetch/count.json?reset'); await page.goto('/load/invalidation/server-fetch'); const selector = '[data-testid="count"]'; expect(await page.textContent(selector)).toBe('1'); await app.invalidate('/load/invalidation/server-fetch/count.json'); - expect(await page.textContent(selector)).toBe('2'); + expect(await page.textContent(selector)).toBe('1'); }); test('+layout.js is re-run when shared dep is invalidated', async ({ page }) => { diff --git a/packages/kit/test/apps/basics/test/cross-platform/test.js b/packages/kit/test/apps/basics/test/cross-platform/test.js index 1c34b889e302..170e3f5bd32a 100644 --- a/packages/kit/test/apps/basics/test/cross-platform/test.js +++ b/packages/kit/test/apps/basics/test/cross-platform/test.js @@ -6,29 +6,33 @@ import { test } from '../../../../utils.js'; test.describe.configure({ mode: 'parallel' }); test.describe('CSS', () => { - test('applies imported styles', async ({ page, get_computed_style }) => { + test('applies styles correctly', async ({ page, get_computed_style }) => { await page.goto('/css'); - expect(await get_computed_style('.styled', 'color')).toBe('rgb(255, 0, 0)'); - }); + test.step('applies imported styles', async () => { + expect(await get_computed_style('.styled', 'color')).toBe('rgb(255, 0, 0)'); + }); - test('applies layout styles', async ({ page, get_computed_style }) => { - await page.goto('/css'); + test.step('applies imported styles in the correct order', async () => { + expect(await get_computed_style('.overridden', 'color')).toBe('rgb(0, 128, 0)'); + }); - expect(await get_computed_style('footer', 'color')).toBe('rgb(128, 0, 128)'); - }); + test.step('applies layout styles', async () => { + expect(await get_computed_style('footer', 'color')).toBe('rgb(128, 0, 128)'); + }); - test('applies local styles', async ({ page, get_computed_style }) => { - await page.goto('/css'); + test.step('applies local styles', async () => { + expect(await get_computed_style('.also-styled', 'color')).toBe('rgb(0, 0, 255)'); + }); - expect(await get_computed_style('.also-styled', 'color')).toBe('rgb(0, 0, 255)'); + test.step('does not apply raw and url', async () => { + expect(await get_computed_style('.not', 'color')).toBe('rgb(0, 0, 0)'); + }); }); - test('applies imported styles in the correct order', async ({ page, get_computed_style }) => { - await page.goto('/css'); - - const color = await get_computed_style('.overridden', 'color'); - expect(color).toBe('rgb(0, 128, 0)'); + test('loads styles on routes with encoded characters', async ({ page, get_computed_style }) => { + await page.goto('/css/encöded'); + expect(await get_computed_style('h1', 'color')).toBe('rgb(128, 0, 128)'); }); }); diff --git a/packages/kit/test/apps/basics/test/test.js b/packages/kit/test/apps/basics/test/test.js index 6b976d2eee5d..740a7c1880c3 100644 --- a/packages/kit/test/apps/basics/test/test.js +++ b/packages/kit/test/apps/basics/test/test.js @@ -828,6 +828,69 @@ test.describe('Matchers', () => { }); test.describe('Actions', () => { + test('Submitting a form with a file input but no enctype="multipart/form-data" logs a warning', async ({ + page, + javaScriptEnabled + }) => { + test.skip(!javaScriptEnabled, 'Skip when JavaScript is disabled'); + test.skip(!process.env.DEV, 'Skip when not in dev mode'); + await page.goto('/actions/file-without-enctype'); + const log_promise = page.waitForEvent('console'); + await page.click('button'); + const log = await log_promise; + expect(log.text()).toBe( + 'Your form contains fields, but is missing the `enctype="multipart/form-data"` attribute. This will lead to inconsistent behavior between enhanced and native forms. For more details, see https://github.com/sveltejs/kit/issues/9819. This will be upgraded to an error in v2.0.' + ); + }); + + test(`Accessing v2 deprecated properties results in a warning log`, async ({ + page, + javaScriptEnabled + }) => { + test.skip(!javaScriptEnabled, 'skip when js is disabled'); + test.skip(!process.env.DEV, 'skip when not in dev mode'); + await page.goto('/actions/enhance/old-property-access'); + + for (const { id, old_name, new_name, call_location } of [ + { + id: 'access-form-in-submit', + old_name: 'form', + new_name: 'formElement', + call_location: 'use:enhance submit function' + }, + { + id: 'access-form-in-callback', + old_name: 'form', + new_name: 'formElement', + call_location: 'callback returned from use:enhance submit function' + }, + { + id: 'access-data-in-submit', + old_name: 'data', + new_name: 'formData', + call_location: 'use:enhance submit function' + }, + { + id: 'access-data-in-callback', + old_name: 'data', + new_name: 'formData', + call_location: 'callback returned from use:enhance submit function' + } + ]) { + await test.step(id, async () => { + const log_promise = page.waitForEvent('console'); + const button = page.locator(`#${id}`); + await button.click(); + await expect(button).toHaveAttribute('data-processed', 'true'); + const log = await log_promise; + expect(log.text()).toBe( + `\`${old_name}\` has been deprecated in favor of \`${new_name}\`. \`${old_name}\` will be removed in a future version. (Called from ${call_location})` + ); + expect(log.type()).toBe('warning'); + }); + } + }); + test('Error props are returned', async ({ page, javaScriptEnabled }) => { await page.goto('/actions/form-errors'); await page.click('button'); diff --git a/packages/kit/test/apps/dev-only/package.json b/packages/kit/test/apps/dev-only/package.json index 37ee1ab3a73d..a1dabaf48c9b 100644 --- a/packages/kit/test/apps/dev-only/package.json +++ b/packages/kit/test/apps/dev-only/package.json @@ -1,5 +1,5 @@ { - "name": "test-basics", + "name": "test-dev-only", "private": true, "version": "0.0.2-next.0", "scripts": { @@ -15,7 +15,7 @@ "svelte": "^3.56.0", "svelte-check": "^3.0.2", "typescript": "^4.9.4", - "vite": "^4.3.0" + "vite": "^4.3.6" }, "type": "module" } diff --git a/packages/kit/test/apps/embed/package.json b/packages/kit/test/apps/embed/package.json index c9b35e553f46..c831f4e202d1 100644 --- a/packages/kit/test/apps/embed/package.json +++ b/packages/kit/test/apps/embed/package.json @@ -17,7 +17,7 @@ "svelte": "^3.56.0", "svelte-check": "^3.0.2", "typescript": "^4.9.4", - "vite": "^4.3.0" + "vite": "^4.3.6" }, "type": "module" } diff --git a/packages/kit/test/apps/options-2/package.json b/packages/kit/test/apps/options-2/package.json index 11c0d0d24937..05cdfff51a86 100644 --- a/packages/kit/test/apps/options-2/package.json +++ b/packages/kit/test/apps/options-2/package.json @@ -18,7 +18,7 @@ "svelte": "^3.56.0", "svelte-check": "^3.0.2", "typescript": "^4.9.4", - "vite": "^4.3.0" + "vite": "^4.3.6" }, "type": "module" } diff --git a/packages/kit/test/apps/options/package.json b/packages/kit/test/apps/options/package.json index 5602453072f1..516375200394 100644 --- a/packages/kit/test/apps/options/package.json +++ b/packages/kit/test/apps/options/package.json @@ -17,7 +17,7 @@ "svelte": "^3.56.0", "svelte-check": "^3.0.2", "typescript": "^4.9.4", - "vite": "^4.3.0" + "vite": "^4.3.6" }, "type": "module" } diff --git a/packages/kit/test/apps/options/source/pages/server-fetch-invalidate/+page.server.js b/packages/kit/test/apps/options/source/pages/server-fetch-invalidate/+page.server.js new file mode 100644 index 000000000000..fc6a5abe8eac --- /dev/null +++ b/packages/kit/test/apps/options/source/pages/server-fetch-invalidate/+page.server.js @@ -0,0 +1,6 @@ +// TODO 2.0: Delete +/** @type {import('./$types').PageServerLoad} */ +export async function load({ fetch }) { + const res = await fetch('/path-base/server-fetch-invalidate/count.json'); + return res.json(); +} diff --git a/packages/kit/test/apps/options/source/pages/server-fetch-invalidate/+page.svelte b/packages/kit/test/apps/options/source/pages/server-fetch-invalidate/+page.svelte new file mode 100644 index 000000000000..3cadb6924412 --- /dev/null +++ b/packages/kit/test/apps/options/source/pages/server-fetch-invalidate/+page.svelte @@ -0,0 +1,6 @@ + + +

{data.count}

diff --git a/packages/kit/test/apps/options/source/pages/server-fetch-invalidate/count.json/+server.js b/packages/kit/test/apps/options/source/pages/server-fetch-invalidate/count.json/+server.js new file mode 100644 index 000000000000..443894c3dcf5 --- /dev/null +++ b/packages/kit/test/apps/options/source/pages/server-fetch-invalidate/count.json/+server.js @@ -0,0 +1,10 @@ +// TODO 2.0: Delete +import { json } from '@sveltejs/kit'; + +let count = 0; + +/** @type {import('./$types').RequestHandler} */ +export function GET({ url }) { + if (url.searchParams.has('reset')) count = 0; + return json({ count: count++ }); +} diff --git a/packages/kit/test/apps/options/svelte.config.js b/packages/kit/test/apps/options/svelte.config.js index 63a9e77106aa..ce787f38d5e9 100644 --- a/packages/kit/test/apps/options/svelte.config.js +++ b/packages/kit/test/apps/options/svelte.config.js @@ -9,6 +9,9 @@ const config = { 'require-trusted-types-for': ['script'] } }, + dangerZone: { + trackServerFetches: true + }, files: { assets: 'public', lib: 'source/components', diff --git a/packages/kit/test/apps/options/test/test.js b/packages/kit/test/apps/options/test/test.js index 295985858f70..43277cade6bc 100644 --- a/packages/kit/test/apps/options/test/test.js +++ b/packages/kit/test/apps/options/test/test.js @@ -297,3 +297,22 @@ test.describe('Routing', () => { await expect(page.locator('h2')).toHaveText('target: 0'); }); }); + +test.describe('load', () => { + // TODO 2.0: Remove this test + test('fetch in server load can be invalidated when `dangerZone.trackServerFetches` is set', async ({ + page, + app, + request, + javaScriptEnabled + }) => { + test.skip(!javaScriptEnabled, 'JavaScript is disabled'); + await request.get('/path-base/server-fetch-invalidate/count.json?reset'); + await page.goto('/path-base/server-fetch-invalidate'); + const selector = '[data-testid="count"]'; + + expect(await page.textContent(selector)).toBe('1'); + await app.invalidate('/path-base/server-fetch-invalidate/count.json'); + expect(await page.textContent(selector)).toBe('2'); + }); +}); diff --git a/packages/kit/test/apps/writes/package.json b/packages/kit/test/apps/writes/package.json index d9afd1f316d9..f464229a5e26 100644 --- a/packages/kit/test/apps/writes/package.json +++ b/packages/kit/test/apps/writes/package.json @@ -18,7 +18,7 @@ "svelte": "^3.56.0", "svelte-check": "^3.0.2", "typescript": "^4.9.4", - "vite": "^4.3.0" + "vite": "^4.3.6" }, "type": "module" } diff --git a/packages/kit/test/build-errors/apps/prerender-entry-generator-mismatch/package.json b/packages/kit/test/build-errors/apps/prerender-entry-generator-mismatch/package.json index a1176e486f96..192846788883 100644 --- a/packages/kit/test/build-errors/apps/prerender-entry-generator-mismatch/package.json +++ b/packages/kit/test/build-errors/apps/prerender-entry-generator-mismatch/package.json @@ -14,7 +14,7 @@ "svelte": "^3.56.0", "svelte-check": "^3.0.2", "typescript": "^4.9.4", - "vite": "^4.2.0" + "vite": "^4.3.6" }, "type": "module" } diff --git a/packages/kit/test/build-errors/apps/prerenderable-incorrect-fragment/package.json b/packages/kit/test/build-errors/apps/prerenderable-incorrect-fragment/package.json index ce33f478c912..192846788883 100644 --- a/packages/kit/test/build-errors/apps/prerenderable-incorrect-fragment/package.json +++ b/packages/kit/test/build-errors/apps/prerenderable-incorrect-fragment/package.json @@ -14,7 +14,7 @@ "svelte": "^3.56.0", "svelte-check": "^3.0.2", "typescript": "^4.9.4", - "vite": "^4.3.0" + "vite": "^4.3.6" }, "type": "module" } diff --git a/packages/kit/test/build-errors/apps/prerenderable-not-prerendered/package.json b/packages/kit/test/build-errors/apps/prerenderable-not-prerendered/package.json index 3faef7a592b3..db06bc33c62d 100644 --- a/packages/kit/test/build-errors/apps/prerenderable-not-prerendered/package.json +++ b/packages/kit/test/build-errors/apps/prerenderable-not-prerendered/package.json @@ -14,7 +14,7 @@ "svelte": "^3.56.0", "svelte-check": "^3.0.2", "typescript": "^4.9.4", - "vite": "^4.3.0" + "vite": "^4.3.6" }, "type": "module" } diff --git a/packages/kit/test/build-errors/apps/private-dynamic-env-dynamic-import/package.json b/packages/kit/test/build-errors/apps/private-dynamic-env-dynamic-import/package.json index 172a09e8cb97..bec07743361a 100644 --- a/packages/kit/test/build-errors/apps/private-dynamic-env-dynamic-import/package.json +++ b/packages/kit/test/build-errors/apps/private-dynamic-env-dynamic-import/package.json @@ -14,7 +14,7 @@ "svelte": "^3.56.0", "svelte-check": "^3.0.2", "typescript": "^4.9.4", - "vite": "^4.3.0" + "vite": "^4.3.6" }, "type": "module" } diff --git a/packages/kit/test/build-errors/apps/private-dynamic-env/package.json b/packages/kit/test/build-errors/apps/private-dynamic-env/package.json index c0aeac64395b..ea0138110191 100644 --- a/packages/kit/test/build-errors/apps/private-dynamic-env/package.json +++ b/packages/kit/test/build-errors/apps/private-dynamic-env/package.json @@ -14,7 +14,7 @@ "svelte": "^3.56.0", "svelte-check": "^3.0.2", "typescript": "^4.9.4", - "vite": "^4.3.0" + "vite": "^4.3.6" }, "type": "module" } diff --git a/packages/kit/test/build-errors/apps/private-static-env-dynamic-import/package.json b/packages/kit/test/build-errors/apps/private-static-env-dynamic-import/package.json index 53780bdad895..be8a4f923eb8 100644 --- a/packages/kit/test/build-errors/apps/private-static-env-dynamic-import/package.json +++ b/packages/kit/test/build-errors/apps/private-static-env-dynamic-import/package.json @@ -14,7 +14,7 @@ "svelte": "^3.56.0", "svelte-check": "^3.0.2", "typescript": "^4.9.4", - "vite": "^4.3.0" + "vite": "^4.3.6" }, "type": "module" } diff --git a/packages/kit/test/build-errors/apps/private-static-env/package.json b/packages/kit/test/build-errors/apps/private-static-env/package.json index c6316ac9e409..8eb6c9458d14 100644 --- a/packages/kit/test/build-errors/apps/private-static-env/package.json +++ b/packages/kit/test/build-errors/apps/private-static-env/package.json @@ -15,7 +15,7 @@ "svelte": "^3.56.0", "svelte-check": "^3.0.2", "typescript": "^4.9.4", - "vite": "^4.3.0" + "vite": "^4.3.6" }, "type": "module" } diff --git a/packages/kit/test/build-errors/apps/server-only-folder-dynamic-import/package.json b/packages/kit/test/build-errors/apps/server-only-folder-dynamic-import/package.json index ce6abb703f7f..04c70e69d267 100644 --- a/packages/kit/test/build-errors/apps/server-only-folder-dynamic-import/package.json +++ b/packages/kit/test/build-errors/apps/server-only-folder-dynamic-import/package.json @@ -14,7 +14,7 @@ "svelte": "^3.56.0", "svelte-check": "^3.0.2", "typescript": "^4.9.4", - "vite": "^4.3.0" + "vite": "^4.3.6" }, "type": "module" } diff --git a/packages/kit/test/build-errors/apps/server-only-folder/package.json b/packages/kit/test/build-errors/apps/server-only-folder/package.json index 89bc86aed195..e87f53f39471 100644 --- a/packages/kit/test/build-errors/apps/server-only-folder/package.json +++ b/packages/kit/test/build-errors/apps/server-only-folder/package.json @@ -14,7 +14,7 @@ "svelte": "^3.56.0", "svelte-check": "^3.0.2", "typescript": "^4.9.4", - "vite": "^4.3.0" + "vite": "^4.3.6" }, "type": "module" } diff --git a/packages/kit/test/build-errors/apps/server-only-module-dynamic-import/package.json b/packages/kit/test/build-errors/apps/server-only-module-dynamic-import/package.json index 0cd4b8e80638..d4c73ec5228a 100644 --- a/packages/kit/test/build-errors/apps/server-only-module-dynamic-import/package.json +++ b/packages/kit/test/build-errors/apps/server-only-module-dynamic-import/package.json @@ -14,7 +14,7 @@ "svelte": "^3.56.0", "svelte-check": "^3.0.2", "typescript": "^4.9.4", - "vite": "^4.3.0" + "vite": "^4.3.6" }, "type": "module" } diff --git a/packages/kit/test/build-errors/apps/server-only-module/package.json b/packages/kit/test/build-errors/apps/server-only-module/package.json index 04d383b975a4..a441cd554350 100644 --- a/packages/kit/test/build-errors/apps/server-only-module/package.json +++ b/packages/kit/test/build-errors/apps/server-only-module/package.json @@ -14,7 +14,7 @@ "svelte": "^3.56.0", "svelte-check": "^3.0.2", "typescript": "^4.9.4", - "vite": "^4.3.0" + "vite": "^4.3.6" }, "type": "module" } diff --git a/packages/kit/test/build-errors/apps/syntax-error/package.json b/packages/kit/test/build-errors/apps/syntax-error/package.json index 75a65431ede4..58d76a7590c6 100644 --- a/packages/kit/test/build-errors/apps/syntax-error/package.json +++ b/packages/kit/test/build-errors/apps/syntax-error/package.json @@ -12,7 +12,7 @@ "svelte": "^3.56.0", "svelte-check": "^3.0.2", "typescript": "^4.9.4", - "vite": "^4.3.0" + "vite": "^4.3.6" }, "type": "module" } diff --git a/packages/kit/test/prerendering/basics/package.json b/packages/kit/test/prerendering/basics/package.json index bdcdac932074..1f895c5f955f 100644 --- a/packages/kit/test/prerendering/basics/package.json +++ b/packages/kit/test/prerendering/basics/package.json @@ -15,7 +15,7 @@ "svelte": "^3.56.0", "svelte-check": "^3.0.2", "typescript": "^4.9.4", - "vite": "^4.3.0", + "vite": "^4.3.6", "vitest": "^0.31.0" }, "type": "module" diff --git a/packages/kit/test/prerendering/basics/src/routes/redirect-encoded/+page.svelte b/packages/kit/test/prerendering/basics/src/routes/redirect-encoded/+page.svelte deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/packages/kit/test/prerendering/basics/src/routes/redirect-malicious/+page.svelte b/packages/kit/test/prerendering/basics/src/routes/redirect-malicious/+page.svelte deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/packages/kit/test/prerendering/basics/src/routes/redirect-relative/+page.js b/packages/kit/test/prerendering/basics/src/routes/redirect-relative/+page.js new file mode 100644 index 000000000000..dc685417407a --- /dev/null +++ b/packages/kit/test/prerendering/basics/src/routes/redirect-relative/+page.js @@ -0,0 +1,6 @@ +import { redirect } from '@sveltejs/kit'; + +/** @type {import('@sveltejs/kit').Load} */ +export function load() { + throw redirect(301, '/env'); +} diff --git a/packages/kit/test/prerendering/basics/src/routes/redirect-server/+page.svelte b/packages/kit/test/prerendering/basics/src/routes/redirect-server/+page.svelte deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/packages/kit/test/prerendering/basics/src/routes/redirect/+page.svelte b/packages/kit/test/prerendering/basics/src/routes/redirect/+page.svelte deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/packages/kit/test/prerendering/basics/test/tests.spec.js b/packages/kit/test/prerendering/basics/test/tests.spec.js index 145f69364109..433be62c5b24 100644 --- a/packages/kit/test/prerendering/basics/test/tests.spec.js +++ b/packages/kit/test/prerendering/basics/test/tests.spec.js @@ -16,13 +16,16 @@ test('renders a redirect', () => { const content = read('redirect.html'); assert.equal( content, - '' + '' ); }); test('renders a server-side redirect', () => { const html = read('redirect-server.html'); - assert.equal(html, ''); + assert.equal( + html, + '' + ); const data = JSON.parse(read('redirect-server/__data.json')); @@ -36,7 +39,7 @@ test('does not double-encode redirect locations', () => { const content = read('redirect-encoded.html'); assert.equal( content, - '' + '' ); }); @@ -44,7 +47,15 @@ test('escapes characters in redirect', () => { const content = read('redirect-malicious.html'); assert.equal( content, - '' + '' + ); +}); + +test('renders a relative redirect', () => { + const content = read('redirect-relative.html'); + assert.equal( + content, + '' ); }); @@ -159,9 +170,7 @@ test('fetches data from local endpoint', () => { { type: 'data', data: [{ message: 1 }, 'hello'], - uses: { - dependencies: ['http://example.com/origin/message.json'] - } + uses: {} } ] }); diff --git a/packages/kit/test/prerendering/options/package.json b/packages/kit/test/prerendering/options/package.json index 37594889d19d..f040cdfe1157 100644 --- a/packages/kit/test/prerendering/options/package.json +++ b/packages/kit/test/prerendering/options/package.json @@ -14,7 +14,7 @@ "svelte": "^3.56.0", "svelte-check": "^3.0.2", "typescript": "^4.9.4", - "vite": "^4.3.0", + "vite": "^4.3.6", "vitest": "^0.31.0" }, "type": "module" diff --git a/packages/kit/test/prerendering/paths-base/package.json b/packages/kit/test/prerendering/paths-base/package.json index 4215dc66c362..3f8ec04e2d25 100644 --- a/packages/kit/test/prerendering/paths-base/package.json +++ b/packages/kit/test/prerendering/paths-base/package.json @@ -14,7 +14,7 @@ "svelte": "^3.56.0", "svelte-check": "^3.0.2", "typescript": "^4.9.4", - "vite": "^4.3.0", + "vite": "^4.3.6", "vitest": "^0.31.0" }, "type": "module" diff --git a/packages/kit/test/prerendering/paths-base/test/tests.spec.js b/packages/kit/test/prerendering/paths-base/test/tests.spec.js index 2790c0b86fcf..77674df89c93 100644 --- a/packages/kit/test/prerendering/paths-base/test/tests.spec.js +++ b/packages/kit/test/prerendering/paths-base/test/tests.spec.js @@ -14,7 +14,10 @@ test('prerenders /path-base', () => { test('prerenders /path-base/redirect', () => { const content = read('redirect.html'); - assert.equal(content, ''); + assert.equal( + content, + '' + ); }); test('prerenders /path-base/dynamic/foo', () => { diff --git a/packages/kit/types/ambient.d.ts b/packages/kit/types/ambient.d.ts index 9e6b92fa27e0..10e3529d238b 100644 --- a/packages/kit/types/ambient.d.ts +++ b/packages/kit/types/ambient.d.ts @@ -80,15 +80,36 @@ declare module '$app/forms' { Invalid extends Record | undefined = Record > = (input: { action: URL; + /** + * use `formData` instead of `data` + * @deprecated + */ data: FormData; + formData: FormData; + /** + * use `formElement` instead of `form` + * @deprecated + */ form: HTMLFormElement; + formElement: HTMLFormElement; controller: AbortController; cancel(): void; submitter: HTMLElement | null; }) => MaybePromise< | void | ((opts: { + /** + * use `formData` instead of `data` + * @deprecated + */ + data: FormData; + formData: FormData; + /** + * use `formElement` instead of `form` + * @deprecated + */ form: HTMLFormElement; + formElement: HTMLFormElement; action: URL; result: ActionResult; /** @@ -108,7 +129,7 @@ declare module '$app/forms' { Success extends Record | undefined = Record, Invalid extends Record | undefined = Record >( - form: HTMLFormElement, + formElement: HTMLFormElement, /** * Called upon submission with the given FormData and the `action` that should be triggered. * If `cancel` is called, the form will not be submitted. diff --git a/packages/kit/types/index.d.ts b/packages/kit/types/index.d.ts index 55c4589ec8a4..10c5c580d0e4 100644 --- a/packages/kit/types/index.d.ts +++ b/packages/kit/types/index.d.ts @@ -20,6 +20,7 @@ import { UniqueInterface } from './private.js'; import { BuildData, SSRNodeLoader, SSRRoute, ValidatedConfig } from './internal.js'; +import type { PluginOptions } from '@sveltejs/vite-plugin-svelte'; export { PrerenderOption } from './private.js'; @@ -186,6 +187,8 @@ export interface Config { }; /** Preprocessor options, if any. Preprocessing can alternatively also be done through Vite's preprocessor capabilities. */ preprocess?: any; + /** `vite-plugin-svelte` plugin options. */ + vitePlugin?: PluginOptions; /** Any additional options required by tooling that integrates with Svelte. */ [key: string]: any; } @@ -340,6 +343,16 @@ export interface KitConfig { */ checkOrigin?: boolean; }; + /** + * Here be dragons. Enable at your peril. + */ + dangerZone?: { + /** + * Automatically add server-side `fetch`ed URLs to the `dependencies` map of `load` functions. This will expose secrets + * to the client if your URL contains them. + */ + trackServerFetches?: boolean; + }; /** * Whether or not the app is embedded inside a larger app. If `true`, SvelteKit will add its event listeners related to navigation etc on the parent of `%sveltekit.body%` instead of `window`, and will pass `params` from the server rather than inferring them from `location.pathname`. * @default false diff --git a/packages/kit/types/internal.d.ts b/packages/kit/types/internal.d.ts index c2dce68abcd4..379328678073 100644 --- a/packages/kit/types/internal.d.ts +++ b/packages/kit/types/internal.d.ts @@ -333,6 +333,7 @@ export interface SSROptions { app_template_contains_nonce: boolean; csp: ValidatedConfig['kit']['csp']; csrf_check_origin: boolean; + track_server_fetches: boolean; embedded: boolean; env_public_prefix: string; hooks: ServerHooks; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 217361c7c5a8..ef47557b7c0d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -21,7 +21,7 @@ importers: version: 1.1.0 '@typescript-eslint/eslint-plugin': specifier: ^5.53.0 - version: 5.53.0(@typescript-eslint/parser@5.59.2)(eslint@8.33.0)(typescript@4.9.4) + version: 5.53.0(@typescript-eslint/parser@5.59.6)(eslint@8.33.0)(typescript@4.9.4) eslint: specifier: ^8.33.0 version: 8.33.0 @@ -223,8 +223,8 @@ importers: specifier: ^4.9.4 version: 4.9.4 vite: - specifier: ^4.3.0 - version: 4.3.0(@types/node@16.18.6) + specifier: ^4.3.6 + version: 4.3.6(@types/node@16.18.6) packages/adapter-static/test/apps/prerendered: devDependencies: @@ -238,8 +238,8 @@ importers: specifier: ^3.56.0 version: 3.56.0 vite: - specifier: ^4.3.0 - version: 4.3.0(@types/node@16.18.6) + specifier: ^4.3.6 + version: 4.3.6(@types/node@16.18.6) packages/adapter-static/test/apps/spa: devDependencies: @@ -256,8 +256,8 @@ importers: specifier: ^3.56.0 version: 3.56.0 vite: - specifier: ^4.3.0 - version: 4.3.0(@types/node@16.18.6) + specifier: ^4.3.6 + version: 4.3.6(@types/node@16.18.6) packages/adapter-vercel: dependencies: @@ -326,9 +326,9 @@ importers: tiny-glob: specifier: ^0.2.9 version: 0.2.9 - uvu: - specifier: ^0.5.6 - version: 0.5.6 + vitest: + specifier: ^0.31.0 + version: 0.31.0(playwright@1.30.0) packages/create-svelte/templates/default: dependencies: @@ -352,8 +352,8 @@ importers: specifier: ^5.0.0 version: 5.0.2 vite: - specifier: ^4.3.0 - version: 4.3.0(@types/node@16.18.6) + specifier: ^4.3.6 + version: 4.3.6(@types/node@16.18.6) packages/create-svelte/templates/skeleton: devDependencies: @@ -365,7 +365,7 @@ importers: dependencies: '@sveltejs/vite-plugin-svelte': specifier: ^2.1.1 - version: 2.1.1(svelte@3.56.0)(vite@4.3.0) + version: 2.1.1(svelte@3.56.0)(vite@4.3.6) '@types/cookie': specifier: ^0.5.1 version: 0.5.1 @@ -373,8 +373,8 @@ importers: specifier: ^0.5.0 version: 0.5.0 devalue: - specifier: ^4.3.0 - version: 4.3.0 + specifier: ^4.3.1 + version: 4.3.1 esm-env: specifier: ^1.0.0 version: 1.0.0 @@ -440,8 +440,8 @@ importers: specifier: ^4.9.4 version: 4.9.4 vite: - specifier: ^4.3.0 - version: 4.3.0(@types/node@16.18.6) + specifier: ^4.3.6 + version: 4.3.6(@types/node@16.18.6) vitest: specifier: ^0.31.0 version: 0.31.0(playwright@1.30.0) @@ -470,8 +470,8 @@ importers: specifier: ^4.9.4 version: 4.9.4 vite: - specifier: ^4.3.0 - version: 4.3.0(@types/node@16.18.6) + specifier: ^4.3.6 + version: 4.3.6(@types/node@16.18.6) packages/kit/test/apps/basics: devDependencies: @@ -494,8 +494,8 @@ importers: specifier: ^4.9.4 version: 4.9.4 vite: - specifier: ^4.3.0 - version: 4.3.0(@types/node@16.18.6) + specifier: ^4.3.6 + version: 4.3.6(@types/node@16.18.6) packages/kit/test/apps/dev-only: devDependencies: @@ -515,8 +515,8 @@ importers: specifier: ^4.9.4 version: 4.9.4 vite: - specifier: ^4.3.0 - version: 4.3.0(@types/node@16.18.6) + specifier: ^4.3.6 + version: 4.3.6(@types/node@16.18.6) packages/kit/test/apps/embed: devDependencies: @@ -536,8 +536,8 @@ importers: specifier: ^4.9.4 version: 4.9.4 vite: - specifier: ^4.3.0 - version: 4.3.0(@types/node@16.18.6) + specifier: ^4.3.6 + version: 4.3.6(@types/node@16.18.6) packages/kit/test/apps/options: devDependencies: @@ -557,8 +557,8 @@ importers: specifier: ^4.9.4 version: 4.9.4 vite: - specifier: ^4.3.0 - version: 4.3.0(@types/node@16.18.6) + specifier: ^4.3.6 + version: 4.3.6(@types/node@16.18.6) packages/kit/test/apps/options-2: devDependencies: @@ -581,8 +581,8 @@ importers: specifier: ^4.9.4 version: 4.9.4 vite: - specifier: ^4.3.0 - version: 4.3.0(@types/node@16.18.6) + specifier: ^4.3.6 + version: 4.3.6(@types/node@16.18.6) packages/kit/test/apps/writes: devDependencies: @@ -605,8 +605,8 @@ importers: specifier: ^4.9.4 version: 4.9.4 vite: - specifier: ^4.3.0 - version: 4.3.0(@types/node@16.18.6) + specifier: ^4.3.6 + version: 4.3.6(@types/node@16.18.6) packages/kit/test/build-errors: devDependencies: @@ -632,8 +632,8 @@ importers: specifier: ^4.9.4 version: 4.9.4 vite: - specifier: ^4.2.0 - version: 4.3.0(@types/node@16.18.6) + specifier: ^4.3.6 + version: 4.3.6(@types/node@16.18.6) packages/kit/test/build-errors/apps/prerenderable-incorrect-fragment: devDependencies: @@ -653,8 +653,8 @@ importers: specifier: ^4.9.4 version: 4.9.4 vite: - specifier: ^4.3.0 - version: 4.3.0(@types/node@16.18.6) + specifier: ^4.3.6 + version: 4.3.6(@types/node@16.18.6) packages/kit/test/build-errors/apps/prerenderable-not-prerendered: devDependencies: @@ -674,8 +674,8 @@ importers: specifier: ^4.9.4 version: 4.9.4 vite: - specifier: ^4.3.0 - version: 4.3.0(@types/node@16.18.6) + specifier: ^4.3.6 + version: 4.3.6(@types/node@16.18.6) packages/kit/test/build-errors/apps/private-dynamic-env: devDependencies: @@ -692,8 +692,8 @@ importers: specifier: ^4.9.4 version: 4.9.4 vite: - specifier: ^4.3.0 - version: 4.3.0(@types/node@16.18.6) + specifier: ^4.3.6 + version: 4.3.6(@types/node@16.18.6) packages/kit/test/build-errors/apps/private-dynamic-env-dynamic-import: devDependencies: @@ -710,8 +710,8 @@ importers: specifier: ^4.9.4 version: 4.9.4 vite: - specifier: ^4.3.0 - version: 4.3.0(@types/node@16.18.6) + specifier: ^4.3.6 + version: 4.3.6(@types/node@16.18.6) packages/kit/test/build-errors/apps/private-static-env: devDependencies: @@ -731,8 +731,8 @@ importers: specifier: ^4.9.4 version: 4.9.4 vite: - specifier: ^4.3.0 - version: 4.3.0(@types/node@16.18.6) + specifier: ^4.3.6 + version: 4.3.6(@types/node@16.18.6) packages/kit/test/build-errors/apps/private-static-env-dynamic-import: devDependencies: @@ -749,8 +749,8 @@ importers: specifier: ^4.9.4 version: 4.9.4 vite: - specifier: ^4.3.0 - version: 4.3.0(@types/node@16.18.6) + specifier: ^4.3.6 + version: 4.3.6(@types/node@16.18.6) packages/kit/test/build-errors/apps/server-only-folder: devDependencies: @@ -767,8 +767,8 @@ importers: specifier: ^4.9.4 version: 4.9.4 vite: - specifier: ^4.3.0 - version: 4.3.0(@types/node@16.18.6) + specifier: ^4.3.6 + version: 4.3.6(@types/node@16.18.6) packages/kit/test/build-errors/apps/server-only-folder-dynamic-import: devDependencies: @@ -785,8 +785,8 @@ importers: specifier: ^4.9.4 version: 4.9.4 vite: - specifier: ^4.3.0 - version: 4.3.0(@types/node@16.18.6) + specifier: ^4.3.6 + version: 4.3.6(@types/node@16.18.6) packages/kit/test/build-errors/apps/server-only-module: devDependencies: @@ -803,8 +803,8 @@ importers: specifier: ^4.9.4 version: 4.9.4 vite: - specifier: ^4.3.0 - version: 4.3.0(@types/node@16.18.6) + specifier: ^4.3.6 + version: 4.3.6(@types/node@16.18.6) packages/kit/test/build-errors/apps/server-only-module-dynamic-import: devDependencies: @@ -821,8 +821,8 @@ importers: specifier: ^4.9.4 version: 4.9.4 vite: - specifier: ^4.3.0 - version: 4.3.0(@types/node@16.18.6) + specifier: ^4.3.6 + version: 4.3.6(@types/node@16.18.6) packages/kit/test/build-errors/apps/syntax-error: devDependencies: @@ -839,8 +839,8 @@ importers: specifier: ^4.9.4 version: 4.9.4 vite: - specifier: ^4.3.0 - version: 4.3.0(@types/node@16.18.6) + specifier: ^4.3.6 + version: 4.3.6(@types/node@16.18.6) packages/kit/test/prerendering/basics: devDependencies: @@ -857,8 +857,8 @@ importers: specifier: ^4.9.4 version: 4.9.4 vite: - specifier: ^4.3.0 - version: 4.3.0(@types/node@16.18.6) + specifier: ^4.3.6 + version: 4.3.6(@types/node@16.18.6) vitest: specifier: ^0.31.0 version: 0.31.0(playwright@1.30.0) @@ -878,8 +878,8 @@ importers: specifier: ^4.9.4 version: 4.9.4 vite: - specifier: ^4.3.0 - version: 4.3.0(@types/node@16.18.6) + specifier: ^4.3.6 + version: 4.3.6(@types/node@16.18.6) vitest: specifier: ^0.31.0 version: 0.31.0(playwright@1.30.0) @@ -899,8 +899,8 @@ importers: specifier: ^4.9.4 version: 4.9.4 vite: - specifier: ^4.3.0 - version: 4.3.0(@types/node@16.18.6) + specifier: ^4.3.6 + version: 4.3.6(@types/node@16.18.6) vitest: specifier: ^0.31.0 version: 0.31.0(playwright@1.30.0) @@ -1025,8 +1025,8 @@ importers: specifier: ^4.9.4 version: 4.9.4 vite: - specifier: ^4.3.0 - version: 4.3.0(@types/node@16.18.6) + specifier: ^4.3.6 + version: 4.3.6(@types/node@16.18.6) vite-imagetools: specifier: ^4.0.19 version: 4.0.19(rollup@3.7.0) @@ -1705,7 +1705,7 @@ packages: svelte-local-storage-store: 0.4.0(svelte@3.56.0) dev: true - /@sveltejs/vite-plugin-svelte@2.1.1(svelte@3.56.0)(vite@4.3.0): + /@sveltejs/vite-plugin-svelte@2.1.1(svelte@3.56.0)(vite@4.3.6): resolution: {integrity: sha512-7YeBDt4us0FiIMNsVXxyaP4Hwyn2/v9x3oqStkHU3ZdIc5O22pGwUwH33wUqYo+7Itdmo8zxJ45Qvfm3H7UUjQ==} engines: {node: ^14.18.0 || >= 16} peerDependencies: @@ -1718,8 +1718,8 @@ packages: magic-string: 0.30.0 svelte: 3.56.0 svelte-hmr: 0.15.1(svelte@3.56.0) - vite: 4.3.0(@types/node@16.18.6) - vitefu: 0.2.4(vite@4.3.0) + vite: 4.3.6(@types/node@16.18.6) + vitefu: 0.2.4(vite@4.3.6) transitivePeerDependencies: - supports-color dev: false @@ -1859,7 +1859,7 @@ packages: '@types/node': 16.18.6 dev: true - /@typescript-eslint/eslint-plugin@5.53.0(@typescript-eslint/parser@5.59.2)(eslint@8.33.0)(typescript@4.9.4): + /@typescript-eslint/eslint-plugin@5.53.0(@typescript-eslint/parser@5.59.6)(eslint@8.33.0)(typescript@4.9.4): resolution: {integrity: sha512-alFpFWNucPLdUOySmXCJpzr6HKC3bu7XooShWM+3w/EL6J2HIoB2PFxpLnq4JauWVk6DiVeNKzQlFEaE+X9sGw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1870,7 +1870,7 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/parser': 5.59.2(eslint@8.33.0)(typescript@4.9.4) + '@typescript-eslint/parser': 5.59.6(eslint@8.33.0)(typescript@4.9.4) '@typescript-eslint/scope-manager': 5.53.0 '@typescript-eslint/type-utils': 5.53.0(eslint@8.33.0)(typescript@4.9.4) '@typescript-eslint/utils': 5.53.0(eslint@8.33.0)(typescript@4.9.4) @@ -1887,8 +1887,8 @@ packages: - supports-color dev: true - /@typescript-eslint/parser@5.59.2(eslint@8.33.0)(typescript@4.9.4): - resolution: {integrity: sha512-uq0sKyw6ao1iFOZZGk9F8Nro/8+gfB5ezl1cA06SrqbgJAt0SRoFhb9pXaHvkrxUpZaoLxt8KlovHNk8Gp6/HQ==} + /@typescript-eslint/parser@5.59.6(eslint@8.33.0)(typescript@4.9.4): + resolution: {integrity: sha512-7pCa6al03Pv1yf/dUg/s1pXz/yGMUBAw5EeWqNTFiSueKvRNonze3hma3lhdsOrQcaOXhbk5gKu2Fludiho9VA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 @@ -1897,9 +1897,9 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/scope-manager': 5.59.2 - '@typescript-eslint/types': 5.59.2 - '@typescript-eslint/typescript-estree': 5.59.2(typescript@4.9.4) + '@typescript-eslint/scope-manager': 5.59.6 + '@typescript-eslint/types': 5.59.6 + '@typescript-eslint/typescript-estree': 5.59.6(typescript@4.9.4) debug: 4.3.4 eslint: 8.33.0 typescript: 4.9.4 @@ -1915,12 +1915,12 @@ packages: '@typescript-eslint/visitor-keys': 5.53.0 dev: true - /@typescript-eslint/scope-manager@5.59.2: - resolution: {integrity: sha512-dB1v7ROySwQWKqQ8rEWcdbTsFjh2G0vn8KUyvTXdPoyzSL6lLGkiXEV5CvpJsEe9xIdKV+8Zqb7wif2issoOFA==} + /@typescript-eslint/scope-manager@5.59.6: + resolution: {integrity: sha512-gLbY3Le9Dxcb8KdpF0+SJr6EQ+hFGYFl6tVY8VxLPFDfUZC7BHFw+Vq7bM5lE9DwWPfx4vMWWTLGXgpc0mAYyQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: - '@typescript-eslint/types': 5.59.2 - '@typescript-eslint/visitor-keys': 5.59.2 + '@typescript-eslint/types': 5.59.6 + '@typescript-eslint/visitor-keys': 5.59.6 dev: true /@typescript-eslint/type-utils@5.53.0(eslint@8.33.0)(typescript@4.9.4): @@ -1948,8 +1948,8 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /@typescript-eslint/types@5.59.2: - resolution: {integrity: sha512-LbJ/HqoVs2XTGq5shkiKaNTuVv5tTejdHgfdjqRUGdYhjW1crm/M7og2jhVskMt8/4wS3T1+PfFvL1K3wqYj4w==} + /@typescript-eslint/types@5.59.6: + resolution: {integrity: sha512-tH5lBXZI7T2MOUgOWFdVNUILsI02shyQvfzG9EJkoONWugCG77NDDa1EeDGw7oJ5IvsTAAGVV8I3Tk2PNu9QfA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true @@ -1974,8 +1974,8 @@ packages: - supports-color dev: true - /@typescript-eslint/typescript-estree@5.59.2(typescript@4.9.4): - resolution: {integrity: sha512-+j4SmbwVmZsQ9jEyBMgpuBD0rKwi9RxRpjX71Brr73RsYnEr3Lt5QZ624Bxphp8HUkSKfqGnPJp1kA5nl0Sh7Q==} + /@typescript-eslint/typescript-estree@5.59.6(typescript@4.9.4): + resolution: {integrity: sha512-vW6JP3lMAs/Tq4KjdI/RiHaaJSO7IUsbkz17it/Rl9Q+WkQ77EOuOnlbaU8kKfVIOJxMhnRiBG+olE7f3M16DA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: typescript: '*' @@ -1983,12 +1983,12 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/types': 5.59.2 - '@typescript-eslint/visitor-keys': 5.59.2 + '@typescript-eslint/types': 5.59.6 + '@typescript-eslint/visitor-keys': 5.59.6 debug: 4.3.4 globby: 11.1.0 is-glob: 4.0.3 - semver: 7.5.0 + semver: 7.5.1 tsutils: 3.21.0(typescript@4.9.4) typescript: 4.9.4 transitivePeerDependencies: @@ -2023,12 +2023,12 @@ packages: eslint-visitor-keys: 3.4.0 dev: true - /@typescript-eslint/visitor-keys@5.59.2: - resolution: {integrity: sha512-EEpsO8m3RASrKAHI9jpavNv9NlEUebV4qmF1OWxSTtKSFBpC1NCmWazDQHFivRf0O1DV11BA645yrLEVQ0/Lig==} + /@typescript-eslint/visitor-keys@5.59.6: + resolution: {integrity: sha512-zEfbFLzB9ETcEJ4HZEEsCR9HHeNku5/Qw1jSS5McYJv5BR+ftYXwFFAH5Al+xkGaZEqowMwl7uoJjQb1YSPF8Q==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: - '@typescript-eslint/types': 5.59.2 - eslint-visitor-keys: 3.4.0 + '@typescript-eslint/types': 5.59.6 + eslint-visitor-keys: 3.4.1 dev: true /@typescript/twoslash@3.1.0: @@ -2813,8 +2813,8 @@ packages: resolution: {integrity: sha512-463v3ZeIrcWtdgIg6vI6XUncguvr2TnGl4SzDXinkt9mSLpBJKXT3mW6xT3VQdDN11+WVs29pgvivTc4Lp8v+w==} engines: {node: '>=8'} - /devalue@4.3.0: - resolution: {integrity: sha512-n94yQo4LI3w7erwf84mhRUkUJfhLoCZiLyoOZ/QFsDbcWNZePrLwbQpvZBUG2TNxwV3VjCKPxkiiQA6pe3TrTA==} + /devalue@4.3.1: + resolution: {integrity: sha512-Kc0TSP9IUU9eg55au5Q3YtqaYI2cgntVpunJV9Exbm9nvlBeTE5p2NqYHfpuXK6+VF2hF5PI+BPFPUti7e2N1g==} dev: false /diff@5.1.0: @@ -3022,6 +3022,11 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true + /eslint-visitor-keys@3.4.1: + resolution: {integrity: sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + dev: true + /eslint@8.33.0: resolution: {integrity: sha512-WjOpFQgKK8VrCnAtl8We0SUOy/oVZ5NHykyMiagV1M9r8IFpIJX7DduK6n1mpfhlG7T1NLWm2SuD8QB7KFySaA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -4210,8 +4215,8 @@ packages: thenify-all: 1.6.0 dev: true - /nanoid@3.3.4: - resolution: {integrity: sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==} + /nanoid@3.3.6: + resolution: {integrity: sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true @@ -4588,11 +4593,11 @@ packages: trouter: 3.2.0 dev: true - /postcss@8.4.21: - resolution: {integrity: sha512-tP7u/Sn/dVxK2NnruI4H9BG+x+Wxz6oeZ1cJ8P6G/PZY0IKk4k/63TDsQf2kQq3+qoJeLm2kIBUNlZe3zgb4Zg==} + /postcss@8.4.23: + resolution: {integrity: sha512-bQ3qMcpF6A/YjR55xtoTr0jGOlnPOKAIMdOWiv0EIT6HVPEaJiJB4NLljSbiHoC2RX7DN5Uvjtpbg1NPdwv1oA==} engines: {node: ^10 || ^12 || >=14} dependencies: - nanoid: 3.3.4 + nanoid: 3.3.6 picocolors: 1.0.0 source-map-js: 1.0.2 @@ -4898,8 +4903,8 @@ packages: glob: 10.0.0 dev: true - /rollup@3.20.6: - resolution: {integrity: sha512-2yEB3nQXp/tBQDN0hJScJQheXdvU2wFhh6ld7K/aiZ1vYcak6N/BKjY1QrU6BvO2JWYS8bEs14FRaxXosxy2zw==} + /rollup@3.21.7: + resolution: {integrity: sha512-KXPaEuR8FfUoK2uHwNjxTmJ18ApyvD6zJpYv9FOJSqLStmt6xOY84l1IjK2dSolQmoXknrhEFRaPRgOPdqCT5w==} engines: {node: '>=14.18.0', npm: '>=8.0.0'} hasBin: true optionalDependencies: @@ -4983,6 +4988,14 @@ packages: dependencies: lru-cache: 6.0.0 + /semver@7.5.1: + resolution: {integrity: sha512-Wvss5ivl8TMRZXXESstBA4uR5iXgEN/VC5/sOcuXdVLzcdkz4HWetIoRfG5gb5X+ij/G9rw9YoGn3QoQ8OCSpw==} + engines: {node: '>=10'} + hasBin: true + dependencies: + lru-cache: 6.0.0 + dev: true + /set-blocking@2.0.0: resolution: {integrity: sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==} @@ -5770,7 +5783,7 @@ packages: mlly: 1.2.0 pathe: 1.1.0 picocolors: 1.0.0 - vite: 4.3.0(@types/node@16.18.6) + vite: 4.3.6(@types/node@16.18.6) transitivePeerDependencies: - '@types/node' - less @@ -5781,8 +5794,8 @@ packages: - terser dev: true - /vite@4.3.0(@types/node@16.18.6): - resolution: {integrity: sha512-JTGFgDh3dVxeGBpuQX04Up+JZmuG6wu9414Ei36vQzaEruY/M4K0AgwtuB2b4HaBgB7R8l+LHxjB0jcgz4d2qQ==} + /vite@4.3.6(@types/node@16.18.6): + resolution: {integrity: sha512-cqIyLSbA6gornMS659AXTVKF7cvSHMdKmJJwQ9DXq3lwsT1uZSdktuBRlpHQ8VnOWx0QHtjDwxPpGtyo9Fh/Qg==} engines: {node: ^14.18.0 || >=16.0.0} hasBin: true peerDependencies: @@ -5808,12 +5821,12 @@ packages: dependencies: '@types/node': 16.18.6 esbuild: 0.17.18 - postcss: 8.4.21 - rollup: 3.20.6 + postcss: 8.4.23 + rollup: 3.21.7 optionalDependencies: fsevents: 2.3.2 - /vitefu@0.2.4(vite@4.3.0): + /vitefu@0.2.4(vite@4.3.6): resolution: {integrity: sha512-fanAXjSaf9xXtOOeno8wZXIhgia+CZury481LsDaV++lSvcU2R9Ch2bPh3PYFyoHW+w9LqAeYRISVQjUIew14g==} peerDependencies: vite: ^3.0.0 || ^4.0.0 @@ -5821,7 +5834,7 @@ packages: vite: optional: true dependencies: - vite: 4.3.0(@types/node@16.18.6) + vite: 4.3.6(@types/node@16.18.6) dev: false /vitest@0.31.0(playwright@1.30.0): @@ -5878,7 +5891,7 @@ packages: strip-literal: 1.0.1 tinybench: 2.5.0 tinypool: 0.5.0 - vite: 4.3.0(@types/node@16.18.6) + vite: 4.3.6(@types/node@16.18.6) vite-node: 0.31.0(@types/node@16.18.6) why-is-node-running: 2.2.2 transitivePeerDependencies: diff --git a/renovate.json b/renovate.json index 92b4007e75b4..293ea5651554 100644 --- a/renovate.json +++ b/renovate.json @@ -12,7 +12,9 @@ "ignoreDeps": [ "esbuild", "rollup", - "typescript" + "typescript", + "playwright", + "@playwright/test" ], "ignorePaths": [ "**/create-svelte/shared/**", diff --git a/sites/kit.svelte.dev/package.json b/sites/kit.svelte.dev/package.json index ad78727901f7..cf7008661bb9 100644 --- a/sites/kit.svelte.dev/package.json +++ b/sites/kit.svelte.dev/package.json @@ -26,7 +26,7 @@ "svelte": "^3.56.0", "tiny-glob": "^0.2.9", "typescript": "^4.9.4", - "vite": "^4.3.0", + "vite": "^4.3.6", "vite-imagetools": "^4.0.19", "vitest": "^0.31.0" },