Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use namespace import for vite to support upcoming vite 3.0 esm #5030

Merged
merged 3 commits into from May 23, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/short-guests-sort.md
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

use named imports of vite to support upcoming vite 3.0
14 changes: 7 additions & 7 deletions packages/kit/src/core/build/build_service_worker.js
@@ -1,5 +1,5 @@
import fs from 'fs';
import vite from 'vite';
import { build } from 'vite';
import { s } from '../../utils/misc.js';
import { deep_merge } from '../../utils/object.js';
import { normalize_path } from '../../utils/url.js';
Expand All @@ -22,12 +22,12 @@ export async function build_service_worker(
prerendered,
client_manifest
) {
const build = new Set();
const build_files = new Set();
for (const key in client_manifest) {
const { file, css = [], assets = [] } = client_manifest[key];
build.add(file);
css.forEach((file) => build.add(file));
assets.forEach((file) => build.add(file));
build_files.add(file);
css.forEach((file) => build_files.add(file));
assets.forEach((file) => build_files.add(file));
}

const service_worker = `${config.kit.outDir}/generated/service-worker.js`;
Expand All @@ -43,7 +43,7 @@ export async function build_service_worker(
};

export const build = [
${Array.from(build)
${Array.from(build_files)
.map((file) => `${s(`${config.kit.paths.base}/${config.kit.appDir}/${file}`)}`)
.join(',\n\t\t\t\t')}
];
Expand Down Expand Up @@ -96,5 +96,5 @@ export async function build_service_worker(

print_config_conflicts(conflicts, 'kit.vite.', 'build_service_worker');

await vite.build(merged_config);
await build(merged_config);
}
4 changes: 2 additions & 2 deletions packages/kit/src/core/build/utils.js
@@ -1,4 +1,4 @@
import vite from 'vite';
import { build } from 'vite';

/**
* @typedef {import('rollup').RollupOutput} RollupOutput
Expand All @@ -8,7 +8,7 @@ import vite from 'vite';

/** @param {import('vite').UserConfig} config */
export async function create_build(config) {
const { output } = /** @type {RollupOutput} */ (await vite.build(config));
const { output } = /** @type {RollupOutput} */ (await build(config));

const chunks = output.filter(
/** @returns {output is OutputChunk} */ (output) => output.type === 'chunk'
Expand Down
6 changes: 3 additions & 3 deletions packages/kit/src/core/dev/index.js
@@ -1,6 +1,6 @@
import path from 'path';
import { svelte } from '@sveltejs/vite-plugin-svelte';
import vite from 'vite';
import { createServer, searchForWorkspaceRoot } from 'vite';
import { deep_merge } from '../../utils/object.js';
import { print_config_conflicts } from '../config/index.js';
import { get_aliases, get_runtime_path } from '../utils.js';
Expand Down Expand Up @@ -33,7 +33,7 @@ export async function dev({ cwd, port, host, https, config }) {
config.kit.outDir,
path.resolve(cwd, 'src'),
path.resolve(cwd, 'node_modules'),
path.resolve(vite.searchForWorkspaceRoot(cwd), 'node_modules')
path.resolve(searchForWorkspaceRoot(cwd), 'node_modules')
])
]
},
Expand Down Expand Up @@ -94,7 +94,7 @@ export async function dev({ cwd, port, host, https, config }) {
merged_config.server.port = port;
}

const server = await vite.createServer(merged_config);
const server = await createServer(merged_config);
await server.listen(port);

const address_info = /** @type {import('net').AddressInfo} */ (
Expand Down