From fae75f1f03c2147c2bae4845c3a4440bb9ca6c6d Mon Sep 17 00:00:00 2001 From: lukasIO Date: Mon, 7 Jun 2021 05:41:22 +0200 Subject: [PATCH 01/10] Add initial location state to router (#1643) --- .changeset/happy-pumas-thank.md | 5 +++++ documentation/docs/05-modules.md | 2 +- packages/kit/src/runtime/client/router.js | 7 ++++--- 3 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 .changeset/happy-pumas-thank.md diff --git a/.changeset/happy-pumas-thank.md b/.changeset/happy-pumas-thank.md new file mode 100644 index 000000000000..dfa6285a11ea --- /dev/null +++ b/.changeset/happy-pumas-thank.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +add optional state parameter for goto function diff --git a/documentation/docs/05-modules.md b/documentation/docs/05-modules.md index 31da56aece12..25d8608c6b28 100644 --- a/documentation/docs/05-modules.md +++ b/documentation/docs/05-modules.md @@ -21,7 +21,7 @@ import { amp, browser, dev, prerendering } from '$app/env'; import { goto, invalidate, prefetch, prefetchRoutes } from '$app/navigation'; ``` -- `goto(href, { replaceState, noscroll })` returns a `Promise` that resolves when SvelteKit navigates (or fails to navigate, in which case the promise rejects) to the specified `href`. The second argument is optional. If `replaceState` is true, a new history entry won't be created. If `noscroll` is true, the browser won't scroll to the top of the page after navigation. +- `goto(href, { replaceState, noscroll, state })` returns a `Promise` that resolves when SvelteKit navigates (or fails to navigate, in which case the promise rejects) to the specified `href`. The second argument is optional. If `replaceState` is true, a new history entry won't be created. If `noscroll` is true, the browser won't scroll to the top of the page after navigation. If state is set, its value will be used to set the initital state of the new history entry, it defaults to `{}`. - `invalidate(href)` causes any `load` functions belonging to the currently active page to re-run if they `fetch` the resource in question. It returns a `Promise` that resolves when the page is subsequently updated. - `prefetch(href)` programmatically prefetches the given page, which means a) ensuring that the code for the page is loaded, and b) calling the page's `load` function with the appropriate options. This is the same behaviour that SvelteKit triggers when the user taps or mouses over an `` element with [sveltekit:prefetch](#anchor-options-sveltekit-prefetch). If the next navigation is to `href`, the values returned from `load` will be used, making navigation instantaneous. Returns a `Promise` that resolves when the prefetch is complete. - `prefetchRoutes(routes)` — programmatically prefetches the code for routes that haven't yet been fetched. Typically, you might call this to speed up subsequent navigation. If no argument is given, all routes will be fetched; otherwise, you can specify routes by any matching pathname such as `/about` (to match `src/routes/about.svelte`) or `/blog/*` (to match `src/routes/blog/[slug].svelte`). Unlike `prefetch`, this won't call `load` for individual pages. Returns a `Promise` that resolves when the routes have been prefetched. diff --git a/packages/kit/src/runtime/client/router.js b/packages/kit/src/runtime/client/router.js index 45189ada92f6..4f3594e176ba 100644 --- a/packages/kit/src/runtime/client/router.js +++ b/packages/kit/src/runtime/client/router.js @@ -135,6 +135,7 @@ export class Router { if (!this.owns(url)) return; const noscroll = a.hasAttribute('sveltekit:noscroll'); + history.pushState({}, '', url.href); this._navigate(url, noscroll ? scroll_state() : null, [], url.hash); event.preventDefault(); @@ -178,14 +179,14 @@ export class Router { /** * @param {string} href - * @param {{ noscroll?: boolean, replaceState?: boolean }} opts + * @param {{ noscroll?: boolean, replaceState?: boolean, state?: any }} opts * @param {string[]} chain */ - async goto(href, { noscroll = false, replaceState = false } = {}, chain) { + async goto(href, { noscroll = false, replaceState = false, state = {} } = {}, chain) { const url = new URL(href, get_base_uri(document)); if (this.enabled && this.owns(url)) { - history[replaceState ? 'replaceState' : 'pushState']({}, '', href); + history[replaceState ? 'replaceState' : 'pushState'](state, '', href); return this._navigate(url, noscroll ? scroll_state() : null, chain, url.hash); } From b1aa656205dc437d0760689b4288de53bb00a70e Mon Sep 17 00:00:00 2001 From: Ignatius Bagus Date: Tue, 8 Jun 2021 00:32:54 +0700 Subject: [PATCH 02/10] fix: match up ambient modules for goto (#1649) --- packages/kit/src/runtime/client/router.js | 6 ++++-- packages/kit/types/ambient-modules.d.ts | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/kit/src/runtime/client/router.js b/packages/kit/src/runtime/client/router.js index 4f3594e176ba..5cef18b494e6 100644 --- a/packages/kit/src/runtime/client/router.js +++ b/packages/kit/src/runtime/client/router.js @@ -178,8 +178,10 @@ export class Router { } /** - * @param {string} href - * @param {{ noscroll?: boolean, replaceState?: boolean, state?: any }} opts + * @typedef {Parameters} GotoParams + * + * @param {GotoParams[0]} href + * @param {GotoParams[1]} opts * @param {string[]} chain */ async goto(href, { noscroll = false, replaceState = false, state = {} } = {}, chain) { diff --git a/packages/kit/types/ambient-modules.d.ts b/packages/kit/types/ambient-modules.d.ts index 1683677b0408..ad2119153ee5 100644 --- a/packages/kit/types/ambient-modules.d.ts +++ b/packages/kit/types/ambient-modules.d.ts @@ -22,11 +22,11 @@ declare module '$app/navigation' { * Returns a Promise that resolves when SvelteKit navigates (or fails to navigate, in which case the promise rejects) to the specified href. * * @param href Where to navigate to - * @param opts Optional. If `replaceState` is `true`, a new history entry won't be created. If `noscroll` is `true`, the browser won't scroll to the top of the page after navigation. + * @param opts Optional. If `replaceState` is `true`, a new history entry won't be created. If `noscroll` is `true`, the browser won't scroll to the top of the page after navigation. If state is set, its value will be used to set the initital state of the new history entry, it defaults to `{}` */ export function goto( href: string, - opts?: { replaceState?: boolean; noscroll?: boolean } + opts?: { replaceState?: boolean; noscroll?: boolean; state?: any } ): Promise; /** * Returns a Promise that resolves when SvelteKit re-runs any current `load` functions that depend on `href` From 0b780a61ef13996ac24be1aa74e5f70a447ca208 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Thu, 10 Jun 2021 09:12:26 -0400 Subject: [PATCH 03/10] Re-bundle server app in adapter-node (#1648) * prepare adapter-node runtime for bundling * add esbuild as dependency of adapter-node * bundle app as part of adapter-node's adapt phase * add changeset * add require() shim for requires not transformed by esbuild esbuild doesn't seem to transform require()s of Node builtins into imports, so define a global.require for them. --- .changeset/tiny-socks-sparkle.md | 5 +++++ packages/adapter-node/index.js | 17 ++++++++++++----- packages/adapter-node/package.json | 3 +++ packages/adapter-node/rollup.config.js | 4 ++-- packages/adapter-node/src/index.js | 7 ++++--- packages/adapter-node/src/require_shim.js | 2 ++ pnpm-lock.yaml | 3 +++ 7 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 .changeset/tiny-socks-sparkle.md create mode 100644 packages/adapter-node/src/require_shim.js diff --git a/.changeset/tiny-socks-sparkle.md b/.changeset/tiny-socks-sparkle.md new file mode 100644 index 000000000000..62f494d853b1 --- /dev/null +++ b/.changeset/tiny-socks-sparkle.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/adapter-node': patch +--- + +Bundle server-side app during adapt phase diff --git a/packages/adapter-node/index.js b/packages/adapter-node/index.js index 6b7192aa6136..9ac22d0b0eca 100644 --- a/packages/adapter-node/index.js +++ b/packages/adapter-node/index.js @@ -1,6 +1,7 @@ -import { copyFileSync } from 'fs'; +import { readFileSync } from 'fs'; import { join } from 'path'; import { fileURLToPath } from 'url'; +import esbuild from 'esbuild'; /** * @param {{ @@ -18,11 +19,17 @@ export default function ({ out = 'build' } = {}) { utils.copy_client_files(static_directory); utils.copy_static_files(static_directory); - utils.log.minor('Copying server'); - utils.copy_server_files(out); - + utils.log.minor('Building server'); const files = fileURLToPath(new URL('./files', import.meta.url)); - copyFileSync(`${files}/server.js`, `${out}/index.js`); + utils.copy(files, '.svelte-kit/node'); + await esbuild.build({ + entryPoints: ['.svelte-kit/node/index.js'], + outfile: join(out, 'index.js'), + bundle: true, + external: Object.keys(JSON.parse(readFileSync('package.json', 'utf8')).dependencies || {}), + format: 'esm', + platform: 'node' + }); utils.log.minor('Prerendering static pages'); await utils.prerender({ diff --git a/packages/adapter-node/package.json b/packages/adapter-node/package.json index 47367355937e..ae47764b4d9f 100644 --- a/packages/adapter-node/package.json +++ b/packages/adapter-node/package.json @@ -20,6 +20,9 @@ "check-format": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore", "prepublishOnly": "npm run build" }, + "dependencies": { + "esbuild": "^0.12.5" + }, "devDependencies": { "@rollup/plugin-json": "^4.1.0", "@sveltejs/kit": "workspace:*", diff --git a/packages/adapter-node/rollup.config.js b/packages/adapter-node/rollup.config.js index dd33517bc2fc..f3e467c1f300 100644 --- a/packages/adapter-node/rollup.config.js +++ b/packages/adapter-node/rollup.config.js @@ -5,10 +5,10 @@ import json from '@rollup/plugin-json'; export default { input: 'src/index.js', output: { - file: 'files/server.js', + file: 'files/index.js', format: 'esm', sourcemap: true }, plugins: [nodeResolve(), commonjs(), json()], - external: ['./app.js', ...require('module').builtinModules] + external: ['../output/server/app.js', ...require('module').builtinModules] }; diff --git a/packages/adapter-node/src/index.js b/packages/adapter-node/src/index.js index 57f241238fc5..b678c3c978c3 100644 --- a/packages/adapter-node/src/index.js +++ b/packages/adapter-node/src/index.js @@ -1,10 +1,11 @@ +import './require_shim'; import { createServer } from './server'; -/*eslint import/no-unresolved: [2, { ignore: ['\.\/app\.js$'] }]*/ -import * as app from './app.js'; +// TODO hardcoding the relative location makes this brittle +import { render } from '../output/server/app.js'; // eslint-disable-line import/no-unresolved const { HOST = '0.0.0.0', PORT = 3000 } = process.env; -const instance = createServer({ render: app.render }).listen(PORT, HOST, () => { +const instance = createServer({ render }).listen(PORT, HOST, () => { console.log(`Listening on port ${PORT}`); }); diff --git a/packages/adapter-node/src/require_shim.js b/packages/adapter-node/src/require_shim.js new file mode 100644 index 000000000000..f335a1e3bde0 --- /dev/null +++ b/packages/adapter-node/src/require_shim.js @@ -0,0 +1,2 @@ +import { createRequire } from 'module'; +global.require = createRequire(import.meta.url); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b60bb720ce05..0e7a7226ca21 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -95,12 +95,15 @@ importers: '@sveltejs/kit': workspace:* c8: ^7.7.2 compression: ^1.7.4 + esbuild: ^0.12.5 node-fetch: ^3.0.0-beta.9 polka: ^1.0.0-next.15 rollup: ^2.47.0 sirv: ^1.0.12 typescript: ^4.2.4 uvu: ^0.5.1 + dependencies: + esbuild: 0.12.5 devDependencies: '@rollup/plugin-json': 4.1.0_rollup@2.47.0 '@sveltejs/kit': link:../kit From b6763ccf057b5954e2a14568b7c3575456776f4b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 10 Jun 2021 09:16:08 -0400 Subject: [PATCH 04/10] Version Packages (next) (#1635) Co-authored-by: github-actions[bot] --- .changeset/pre.json | 4 ++++ packages/adapter-node/CHANGELOG.md | 6 ++++++ packages/adapter-node/package.json | 2 +- packages/kit/CHANGELOG.md | 8 ++++++++ packages/kit/package.json | 2 +- 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.changeset/pre.json b/.changeset/pre.json index 78c0de89f64e..bb48f7ef81d0 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -105,11 +105,13 @@ "gorgeous-radios-matter", "gorgeous-radios-tan", "gorgeous-taxis-smash", + "great-bugs-travel", "great-kangaroos-eat", "great-queens-rule", "green-spoons-count", "happy-dancers-call", "happy-nails-draw", + "happy-pumas-thank", "healthy-moons-attend", "healthy-pumpkins-bathe", "heavy-humans-check", @@ -290,6 +292,7 @@ "tiny-candles-repeat", "tiny-gorillas-whisper", "tiny-kids-sort", + "tiny-socks-sparkle", "tiny-starfishes-exist", "tough-chefs-remember", "tough-lamps-brake", @@ -303,6 +306,7 @@ "twelve-feet-deny", "twelve-goats-knock", "twelve-onions-burn", + "twenty-dryers-hope", "two-crabs-tease", "two-students-melt", "two-ties-begin", diff --git a/packages/adapter-node/CHANGELOG.md b/packages/adapter-node/CHANGELOG.md index 8f3e753cb906..910fe233c2f6 100644 --- a/packages/adapter-node/CHANGELOG.md +++ b/packages/adapter-node/CHANGELOG.md @@ -1,5 +1,11 @@ # @sveltejs/adapter-node +## 1.0.0-next.25 + +### Patch Changes + +- 0b780a6: Bundle server-side app during adapt phase + ## 1.0.0-next.24 ### Patch Changes diff --git a/packages/adapter-node/package.json b/packages/adapter-node/package.json index ae47764b4d9f..37f63fbf941d 100644 --- a/packages/adapter-node/package.json +++ b/packages/adapter-node/package.json @@ -1,6 +1,6 @@ { "name": "@sveltejs/adapter-node", - "version": "1.0.0-next.24", + "version": "1.0.0-next.25", "type": "module", "exports": { "import": "./index.js" diff --git a/packages/kit/CHANGELOG.md b/packages/kit/CHANGELOG.md index 278fd848fc2c..b34f34465963 100644 --- a/packages/kit/CHANGELOG.md +++ b/packages/kit/CHANGELOG.md @@ -1,5 +1,13 @@ # @sveltejs/kit +## 1.0.0-next.114 + +### Patch Changes + +- 5aa64ab: fix: SSL for HMR websockets #844 +- fae75f1: add optional state parameter for goto function +- fbd5f8a: package command can now transpile TypeScript files + ## 1.0.0-next.113 ### Patch Changes diff --git a/packages/kit/package.json b/packages/kit/package.json index 25fd539e7c20..a3000808f136 100644 --- a/packages/kit/package.json +++ b/packages/kit/package.json @@ -1,6 +1,6 @@ { "name": "@sveltejs/kit", - "version": "1.0.0-next.113", + "version": "1.0.0-next.114", "type": "module", "dependencies": { "@sveltejs/vite-plugin-svelte": "^1.0.0-next.10", From dc56d3cef4ec0aca3d074757c4a15d1f640c5c56 Mon Sep 17 00:00:00 2001 From: Ignatius Bagus Date: Fri, 11 Jun 2021 09:44:40 +0700 Subject: [PATCH 05/10] Fix navigation when `base` path is set and validate that option's value (#1666) Co-authored-by: Sidharth Vinod --- .changeset/soft-bikes-bake.md | 5 +++++ documentation/docs/14-configuration.md | 2 +- packages/kit/src/core/load_config/index.js | 6 ++++-- packages/kit/src/core/load_config/index.spec.js | 14 +++++++++++++- packages/kit/src/runtime/client/router.js | 2 +- 5 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 .changeset/soft-bikes-bake.md diff --git a/.changeset/soft-bikes-bake.md b/.changeset/soft-bikes-bake.md new file mode 100644 index 000000000000..aa06e7a6a307 --- /dev/null +++ b/.changeset/soft-bikes-bake.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +Fix navigation when `base` path is set and validate that option's value diff --git a/documentation/docs/14-configuration.md b/documentation/docs/14-configuration.md index 87448b3a9142..598704a5d02b 100644 --- a/documentation/docs/14-configuration.md +++ b/documentation/docs/14-configuration.md @@ -116,7 +116,7 @@ Whether to [hydrate](#ssr-and-javascript-hydrate) the server-rendered HTML with An object containing zero or more of the following `string` values: - `assets` — an absolute path, or a path relative to `base`, where your app's files are served from. This is useful if your files are served from a storage bucket of some kind -- `base` — a root-relative (i.e. starts with `/`) path that specifies where your app is served from. This allows the app to live on a non-root path +- `base` — a root-relative path that must start, but not end with `/` (e.g. `/base-path`). This specifies where your app is served from and allows the app to live on a non-root path ### prerender diff --git a/packages/kit/src/core/load_config/index.js b/packages/kit/src/core/load_config/index.js index 767304d9de1a..7973a6fc8a3f 100644 --- a/packages/kit/src/core/load_config/index.js +++ b/packages/kit/src/core/load_config/index.js @@ -135,8 +135,10 @@ export function validate_config(config) { // resolve paths const { paths } = validated.kit; - if (paths.base !== '' && !paths.base.startsWith('/')) { - throw new Error('config.kit.paths.base must be a root-relative path'); + if (paths.base !== '' && (paths.base.endsWith('/') || !paths.base.startsWith('/'))) { + throw new Error( + "kit.paths.base option must be a root-relative path that starts but doesn't end with '/'. See https://kit.svelte.dev/docs#configuration-paths" + ); } paths.assets = resolve(paths.base, paths.assets); diff --git a/packages/kit/src/core/load_config/index.spec.js b/packages/kit/src/core/load_config/index.spec.js index d1138752f849..6f11b28d79c3 100644 --- a/packages/kit/src/core/load_config/index.spec.js +++ b/packages/kit/src/core/load_config/index.spec.js @@ -171,7 +171,19 @@ test('fails if paths.base is not root-relative', () => { } } }); - }, /^config\.kit\.paths\.base must be a root-relative path$/); + }, /^kit\.paths\.base option must be a root-relative path that starts but doesn't end with '\/'. See https:\/\/kit\.svelte\.dev\/docs#configuration-paths$/); +}); + +test("fails if paths.base ends with '/'", () => { + assert.throws(() => { + validate_config({ + kit: { + paths: { + base: '/github-pages/' + } + } + }); + }, /^kit\.paths\.base option must be a root-relative path that starts but doesn't end with '\/'. See https:\/\/kit\.svelte\.dev\/docs#configuration-paths$/); }); test('fails if prerender.pages are invalid', () => { diff --git a/packages/kit/src/runtime/client/router.js b/packages/kit/src/runtime/client/router.js index 5cef18b494e6..8dadc3defd42 100644 --- a/packages/kit/src/runtime/client/router.js +++ b/packages/kit/src/runtime/client/router.js @@ -245,7 +245,7 @@ export class Router { if (incorrect) { info.path = has_trailing_slash ? info.path.slice(0, -1) : info.path + '/'; - history.replaceState({}, '', `${info.path}${location.search}`); + history.replaceState({}, '', `${this.base}${info.path}${location.search}`); } } From 2f7578759c631ac944d3e6966f5ac0816894e970 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Thu, 10 Jun 2021 20:47:06 -0700 Subject: [PATCH 06/10] Update load documentation --- documentation/docs/03-loading.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/documentation/docs/03-loading.md b/documentation/docs/03-loading.md index 6b68e1578528..1b7c57d0ec10 100644 --- a/documentation/docs/03-loading.md +++ b/documentation/docs/03-loading.md @@ -59,6 +59,13 @@ type LoadOutput = { If `load` returns nothing, SvelteKit will [fall through](#routing-advanced-fallthrough-routes) to other routes until something responds, or will respond with a generic 404. > `load` only applies to components that define pages, not the components that they import. +> +> It is important to note that `load` may run on either the server or in the client browser. Code called inside `load` blocks: +> +> - should use the SvelteKit-provided [`fetch`](#loading-input-fetch) method for getting data in order to avoid duplicate network requests +> - should generally run on the same domain as any upstream API servers requiring credentials +> - should not reference `window`, `document`, or any browser-specific objects +> - should not reference any API keys or secrets directly, which will be exposed to the client, but instead call an endpoint using any required secrets ### Input @@ -91,12 +98,6 @@ So if the example above was `src/routes/blog/[slug].svelte` and the URL was `htt `context` is passed from layout components to child layouts and page components. For the root `__layout.svelte` component, it is equal to `{}`, but if that component's `load` function returns an object with a `context` property, it will be available to subsequent `load` functions. -> It is important to note that `load` may run on either the server or in the client browser. Code called inside `load` blocks: -> -> - should run on the same domain as any upstream API servers requiring credentials -> - should not reference `window`, `document` or any browser-specific objects -> - should not reference any API keys or secrets, which will be exposed to the client - ### Output If you return a Promise from `load`, SvelteKit will delay rendering until the promise resolves. The return value has several properties, all optional: From 523c3e2a8ec448d99b1d33687d93f3fd834f6236 Mon Sep 17 00:00:00 2001 From: Glen Huang Date: Fri, 11 Jun 2021 11:50:32 +0800 Subject: [PATCH 07/10] allow vite.alias to be an array (#1640) --- .changeset/long-hotels-hunt.md | 5 +++++ packages/kit/src/core/dev/index.js | 24 +++++++++++++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 .changeset/long-hotels-hunt.md diff --git a/.changeset/long-hotels-hunt.md b/.changeset/long-hotels-hunt.md new file mode 100644 index 000000000000..afed95211d9e --- /dev/null +++ b/.changeset/long-hotels-hunt.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +Allow vite.alias to be an array diff --git a/packages/kit/src/core/dev/index.js b/packages/kit/src/core/dev/index.js index 9f3a92c9e55e..2cdd474857f4 100644 --- a/packages/kit/src/core/dev/index.js +++ b/packages/kit/src/core/dev/index.js @@ -84,6 +84,8 @@ class Watcher extends EventEmitter { this.server = await get_server(this.https, user_config, (req, res) => handler(req, res)); + const alias = user_config.resolve && user_config.resolve.alias; + /** * @type {vite.ViteDevServer} */ @@ -93,11 +95,23 @@ class Watcher extends EventEmitter { root: this.cwd, resolve: { ...user_config.resolve, - alias: { - ...(user_config.resolve && user_config.resolve.alias), - $app: path.resolve(`${this.dir}/runtime/app`), - $lib: this.config.kit.files.lib - } + alias: Array.isArray(alias) + ? [ + ...alias, + { + find: '$app', + replacement: path.resolve(`${this.dir}/runtime/app`) + }, + { + find: '$lib', + replacement: this.config.kit.files.lib + } + ] + : { + ...alias, + $app: path.resolve(`${this.dir}/runtime/app`), + $lib: this.config.kit.files.lib + } }, plugins: [ ...(user_config.plugins || []), From 6fd46d16dd1d2ea762eacba365fd331a98b09a5a Mon Sep 17 00:00:00 2001 From: Dominik G Date: Fri, 11 Jun 2021 16:01:28 +0200 Subject: [PATCH 08/10] Fix: update vite-plugin-svelte and vite (#1673) * fix: update vite-plugin-svelte to ^1.0.0-next.11 and use its named export * update vite to 2.3.7 * fix: run pnpm i to sync lockfile --- .changeset/shy-jeans-fly.md | 6 +++ packages/kit/package.json | 4 +- packages/kit/src/core/build/index.js | 2 +- packages/kit/src/core/dev/index.js | 2 +- pnpm-lock.yaml | 69 +++++++++++++--------------- 5 files changed, 42 insertions(+), 41 deletions(-) create mode 100644 .changeset/shy-jeans-fly.md diff --git a/.changeset/shy-jeans-fly.md b/.changeset/shy-jeans-fly.md new file mode 100644 index 000000000000..e939fb6d2f24 --- /dev/null +++ b/.changeset/shy-jeans-fly.md @@ -0,0 +1,6 @@ +--- +'@sveltejs/kit': patch +--- + +* update vite-plugin-svelte to 1.0.0-next.11 and use its named export +* update vite to 2.3.7 diff --git a/packages/kit/package.json b/packages/kit/package.json index a3000808f136..424c49030a0b 100644 --- a/packages/kit/package.json +++ b/packages/kit/package.json @@ -3,10 +3,10 @@ "version": "1.0.0-next.114", "type": "module", "dependencies": { - "@sveltejs/vite-plugin-svelte": "^1.0.0-next.10", + "@sveltejs/vite-plugin-svelte": "^1.0.0-next.11", "cheap-watch": "^1.0.3", "sade": "^1.7.4", - "vite": "2.3.6" + "vite": "2.3.7" }, "devDependencies": { "@rollup/plugin-replace": "^2.4.2", diff --git a/packages/kit/src/core/build/index.js b/packages/kit/src/core/build/index.js index d4495ba213ed..e5c6f4c2ffd6 100644 --- a/packages/kit/src/core/build/index.js +++ b/packages/kit/src/core/build/index.js @@ -5,7 +5,7 @@ import create_manifest_data from '../../core/create_manifest_data/index.js'; import { copy_assets, get_no_external, posixify, resolve_entry } from '../utils.js'; import { create_app } from '../../core/create_app/index.js'; import vite from 'vite'; -import svelte from '@sveltejs/vite-plugin-svelte'; +import { svelte } from '@sveltejs/vite-plugin-svelte'; import glob from 'tiny-glob/sync.js'; import { SVELTE_KIT } from '../constants.js'; diff --git a/packages/kit/src/core/dev/index.js b/packages/kit/src/core/dev/index.js index 2cdd474857f4..7c1dc4953777 100644 --- a/packages/kit/src/core/dev/index.js +++ b/packages/kit/src/core/dev/index.js @@ -12,7 +12,7 @@ import { rimraf } from '../filesystem/index.js'; import { respond } from '../../runtime/server/index.js'; import { getRawBody } from '../node/index.js'; import { copy_assets, get_no_external, resolve_entry } from '../utils.js'; -import svelte from '@sveltejs/vite-plugin-svelte'; +import { svelte } from '@sveltejs/vite-plugin-svelte'; import { get_server } from '../server/index.js'; import '../../install-fetch.js'; import { SVELTE_KIT } from '../constants.js'; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0e7a7226ca21..693d088d4c12 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -200,7 +200,7 @@ importers: packages/kit: specifiers: '@rollup/plugin-replace': ^2.4.2 - '@sveltejs/vite-plugin-svelte': ^1.0.0-next.10 + '@sveltejs/vite-plugin-svelte': ^1.0.0-next.11 '@types/amphtml-validator': ^1.0.1 '@types/cookie': ^0.4.0 '@types/globrex': ^0.1.0 @@ -230,12 +230,12 @@ importers: tiny-glob: ^0.2.8 typescript: ^4.2.4 uvu: ^0.5.1 - vite: 2.3.6 + vite: 2.3.7 dependencies: - '@sveltejs/vite-plugin-svelte': 1.0.0-next.10_be4c24a5e2250521d961d7d752448683 + '@sveltejs/vite-plugin-svelte': 1.0.0-next.11_74e52d7dcd586025195c15edb3940938 cheap-watch: 1.0.3 sade: 1.7.4 - vite: 2.3.6 + vite: 2.3.7 devDependencies: '@rollup/plugin-replace': 2.4.2_rollup@2.47.0 '@types/amphtml-validator': 1.0.1 @@ -640,23 +640,20 @@ packages: rollup: 2.47.0 dev: false - /@sveltejs/vite-plugin-svelte/1.0.0-next.10_be4c24a5e2250521d961d7d752448683: - resolution: {integrity: sha512-ImvxbhPePm2hWNTKBSA3LHAYGwiEjHjvvgfPLXm4R87sfZ+BMXql9jBmDpzUC/URBLT4BB3Jxos/i523qkJBHg==} - engines: {node: '>=12.0.0'} + /@sveltejs/vite-plugin-svelte/1.0.0-next.11_74e52d7dcd586025195c15edb3940938: + resolution: {integrity: sha512-EYR1I145k5rflVqhPwk3442m3bkYimTKSHM9uO5KdomXzt+GS9ZSBJQE3/wy1Di9V8OnGa3oKpckI3OZsHkTIA==} + engines: {node: ^12.20 || ^14.13.1 || >= 16} peerDependencies: - svelte: ^3.37.0 - vite: ^2.2.3 + svelte: ^3.38.2 + vite: ^2.3.7 dependencies: '@rollup/pluginutils': 4.1.0_rollup@2.47.0 chalk: 4.1.1 debug: 4.3.2 - hash-sum: 2.0.0 require-relative: 0.8.7 - slash: 4.0.0 - source-map: 0.7.3 svelte: 3.38.2 - svelte-hmr: 0.14.3_svelte@3.38.2 - vite: 2.3.6 + svelte-hmr: 0.14.4_svelte@3.38.2 + vite: 2.3.7 transitivePeerDependencies: - rollup - supports-color @@ -1534,6 +1531,12 @@ packages: requiresBuild: true dev: false + /esbuild/0.12.8: + resolution: {integrity: sha512-sx/LwlP/SWTGsd9G4RlOPrXnIihAJ2xwBUmzoqe2nWwbXORMQWtAGNJNYLBJJqa3e9PWvVzxdrtyFZJcr7D87g==} + hasBin: true + requiresBuild: true + dev: false + /escalade/3.1.1: resolution: {integrity: sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==} engines: {node: '>=6'} @@ -2022,10 +2025,6 @@ packages: dependencies: function-bind: 1.1.1 - /hash-sum/2.0.0: - resolution: {integrity: sha512-WdZTbAByD+pHfl/g9QSsBIIwy8IT+EsPiKDs0KNX+zSHhdDLFKdZu0BQHljvO+0QI/BasbMSUa8wYNCZTvhslg==} - dev: false - /hosted-git-info/2.8.9: resolution: {integrity: sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==} dev: true @@ -2533,8 +2532,8 @@ packages: thenify-all: 1.6.0 dev: true - /nanoid/3.1.22: - resolution: {integrity: sha512-/2ZUaJX2ANuLtTvqTlgqBQNJoQO398KyJgZloL0PZkC0dpysjncRUPsFe3DUPzz/y3h+u7C46np8RMuvF3jsSQ==} + /nanoid/3.1.23: + resolution: {integrity: sha512-FiB0kzdP0FFVGDKlRLEQ1BgDzU87dy5NnzjeW9YZNt+/c3+q82EQDUwniSAUxp/F0gFNI1ZhKU1FqYsMuqZVnw==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true dev: false @@ -2869,13 +2868,13 @@ packages: resolution: {integrity: sha512-me2dL+chJVb88zpE228MvA6wIRy1CuXxGTwI5hYe4DnSnXRbtJT+9ggRj+49kgHgs/AKMTKOt/EkTHSvQJmRXA==} dev: true - /postcss/8.2.14: - resolution: {integrity: sha512-+jD0ZijcvyCqPQo/m/CW0UcARpdFylq04of+Q7RKX6f/Tu+dvpUI/9Sp81+i6/vJThnOBX09Quw0ZLOVwpzX3w==} + /postcss/8.3.2: + resolution: {integrity: sha512-y1FK/AWdZlBF5lusS5j5l4/vF67+vQZt1SXPVJ32y1kRGDQyrs1zk32hG1cInRTu14P0V+orPz+ifwW/7rR4bg==} engines: {node: ^10 || ^12 || >=14} dependencies: colorette: 1.2.2 - nanoid: 3.1.22 - source-map: 0.6.1 + nanoid: 3.1.23 + source-map-js: 0.6.2 dev: false /preferred-pm/3.0.3: @@ -3197,11 +3196,6 @@ packages: engines: {node: '>=8'} dev: true - /slash/4.0.0: - resolution: {integrity: sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==} - engines: {node: '>=12'} - dev: false - /slice-ansi/4.0.0: resolution: {integrity: sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==} engines: {node: '>=10'} @@ -3223,14 +3217,15 @@ packages: yargs: 15.4.1 dev: true - /source-map/0.6.1: - resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} + /source-map-js/0.6.2: + resolution: {integrity: sha512-/3GptzWzu0+0MBQFrDKzw/DvvMTUORvgY6k6jd/VS6iCR4RDTKWH6v6WPwQoUO8667uQEf9Oe38DxAYWY5F/Ug==} engines: {node: '>=0.10.0'} dev: false /source-map/0.7.3: resolution: {integrity: sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==} engines: {node: '>= 8'} + dev: true /sourcemap-codec/1.4.8: resolution: {integrity: sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==} @@ -3403,8 +3398,8 @@ packages: - sugarss dev: true - /svelte-hmr/0.14.3_svelte@3.38.2: - resolution: {integrity: sha512-N56xX405zLMw2tpGHKRx5h+kmdeZwxI21pvyC6OyBHJDCF6DlwWBm9TifdQmSD4dloWSmpDPzHWYa3CSjfopUg==} + /svelte-hmr/0.14.4_svelte@3.38.2: + resolution: {integrity: sha512-kItFF7vqzStckSigoFmMnxJpTOdB9TWnQAW6Js+yAB4277tLbJIIE5KBlGHNmJNpA7MguqidsPB27Uw5UzQPCA==} peerDependencies: svelte: '>=3.19.0' dependencies: @@ -3737,13 +3732,13 @@ packages: engines: {node: '>= 0.8'} dev: true - /vite/2.3.6: - resolution: {integrity: sha512-fsEpNKDHgh3Sn66JH06ZnUBnIgUVUtw6ucDhlOj1CEqxIkymU25yv1/kWDPlIjyYHnalr0cN6V+zzUJ+fmWHYw==} + /vite/2.3.7: + resolution: {integrity: sha512-Y0xRz11MPYu/EAvzN94+FsOZHbSvO6FUvHv127CyG7mV6oDoay2bw+g5y9wW3Blf8OY3chaz3nc/DcRe1IQ3Nw==} engines: {node: '>=12.0.0'} hasBin: true dependencies: - esbuild: 0.12.5 - postcss: 8.2.14 + esbuild: 0.12.8 + postcss: 8.3.2 resolve: 1.20.0 rollup: 2.47.0 optionalDependencies: From 1dffefb7ded501b8c12a25617b5b68237172c784 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 11 Jun 2021 16:17:14 +0200 Subject: [PATCH 09/10] Version Packages (next) (#1668) Co-authored-by: github-actions[bot] --- .changeset/pre.json | 3 +++ packages/kit/CHANGELOG.md | 9 +++++++++ packages/kit/package.json | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.changeset/pre.json b/.changeset/pre.json index bb48f7ef81d0..ec148e3b9817 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -145,6 +145,7 @@ "light-roses-teach", "little-shirts-happen", "long-bulldogs-invent", + "long-hotels-hunt", "long-moles-fold", "loud-seals-remember", "lovely-apricots-fail", @@ -229,6 +230,7 @@ "sharp-days-exercise", "sharp-mangos-tickle", "sharp-pigs-study", + "shy-jeans-fly", "shy-mails-share", "silver-elephants-tap", "silver-hounds-clean", @@ -250,6 +252,7 @@ "smooth-rockets-sneeze", "smooth-shoes-mix", "smooth-shrimps-fly", + "soft-bikes-bake", "soft-houses-pump", "soft-students-cover", "spicy-geese-accept", diff --git a/packages/kit/CHANGELOG.md b/packages/kit/CHANGELOG.md index b34f34465963..1e78e67daff9 100644 --- a/packages/kit/CHANGELOG.md +++ b/packages/kit/CHANGELOG.md @@ -1,5 +1,14 @@ # @sveltejs/kit +## 1.0.0-next.115 + +### Patch Changes + +- 523c3e2: Allow vite.alias to be an array +- 6fd46d1: \* update vite-plugin-svelte to 1.0.0-next.11 and use its named export + - update vite to 2.3.7 +- dc56d3c: Fix navigation when `base` path is set and validate that option's value + ## 1.0.0-next.114 ### Patch Changes diff --git a/packages/kit/package.json b/packages/kit/package.json index 424c49030a0b..9832eba85b3a 100644 --- a/packages/kit/package.json +++ b/packages/kit/package.json @@ -1,6 +1,6 @@ { "name": "@sveltejs/kit", - "version": "1.0.0-next.114", + "version": "1.0.0-next.115", "type": "module", "dependencies": { "@sveltejs/vite-plugin-svelte": "^1.0.0-next.11", From 9a7195bf5c24a7b3859710296f725baecb9bbe55 Mon Sep 17 00:00:00 2001 From: Ivan Starkov Date: Fri, 11 Jun 2021 23:06:23 +0300 Subject: [PATCH 10/10] Allow sirv to looks for precompiled gzip and brotli files by default (#1672) --- .changeset/heavy-ways-agree.md | 5 +++++ packages/adapter-node/src/server.js | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changeset/heavy-ways-agree.md diff --git a/.changeset/heavy-ways-agree.md b/.changeset/heavy-ways-agree.md new file mode 100644 index 000000000000..7f9c99c3d50a --- /dev/null +++ b/.changeset/heavy-ways-agree.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/adapter-node': minor +--- + +Allow sirv to looks for precompiled gzip and brotli files by default diff --git a/packages/adapter-node/src/server.js b/packages/adapter-node/src/server.js index 266dd10df1e0..ce8cb5f20f4c 100644 --- a/packages/adapter-node/src/server.js +++ b/packages/adapter-node/src/server.js @@ -30,7 +30,9 @@ export function createServer({ render }) { const assets_handler = fs.existsSync(paths.assets) ? sirv(paths.assets, { maxAge: 31536000, - immutable: true + immutable: true, + gzip: true, + brotli: true }) : noop_handler;