From bec50ed57debe0056ba99bbeded24830a9c097e5 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Tue, 24 May 2022 17:46:06 -0700 Subject: [PATCH] [chore] trigger sync and other setup from plugin (#5067) * [chore] trigger sync and other setup from plugin * format Co-authored-by: Rich Harris --- .changeset/odd-bottles-drop.md | 5 +++++ packages/kit/src/core/dev/index.js | 3 --- packages/kit/src/core/dev/plugin.js | 18 ++++++++++-------- 3 files changed, 15 insertions(+), 11 deletions(-) create mode 100644 .changeset/odd-bottles-drop.md diff --git a/.changeset/odd-bottles-drop.md b/.changeset/odd-bottles-drop.md new file mode 100644 index 000000000000..1737672eb698 --- /dev/null +++ b/.changeset/odd-bottles-drop.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +[chore] trigger sync and other setup from plugin diff --git a/packages/kit/src/core/dev/index.js b/packages/kit/src/core/dev/index.js index 2afd4151e055..734f626f55ee 100644 --- a/packages/kit/src/core/dev/index.js +++ b/packages/kit/src/core/dev/index.js @@ -5,7 +5,6 @@ import { deep_merge } from '../../utils/object.js'; import { load_config, print_config_conflicts } from '../config/index.js'; import { get_aliases, get_runtime_path } from '../utils.js'; import { create_plugin } from './plugin.js'; -import * as sync from '../sync/sync.js'; const cwd = process.cwd(); @@ -23,8 +22,6 @@ export async function dev({ port, host, https }) { /** @type {import('types').ValidatedConfig} */ const config = await load_config(); - sync.init(config); - const [vite_config] = deep_merge( { server: { diff --git a/packages/kit/src/core/dev/plugin.js b/packages/kit/src/core/dev/plugin.js index 3c9b4d4202d4..8140511caf67 100644 --- a/packages/kit/src/core/dev/plugin.js +++ b/packages/kit/src/core/dev/plugin.js @@ -24,19 +24,21 @@ const cwd = process.cwd(); * @returns {Promise} */ export async function create_plugin(config) { - const runtime = get_runtime_path(config); - - process.env.VITE_SVELTEKIT_APP_VERSION_POLL_INTERVAL = '0'; - - /** @type {import('types').Respond} */ - const respond = (await import(`${runtime}/server/index.js`)).respond; - return { name: 'vite-plugin-svelte-kit', - configureServer(vite) { + async configureServer(vite) { installPolyfills(); + sync.init(config); + + const runtime = get_runtime_path(config); + + process.env.VITE_SVELTEKIT_APP_VERSION_POLL_INTERVAL = '0'; + + /** @type {import('types').Respond} */ + const respond = (await import(`${runtime}/server/index.js`)).respond; + /** @type {import('types').SSRManifest} */ let manifest;