Skip to content

Commit

Permalink
fix: use vite2 compatible way to load vite version
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikg committed Jul 18, 2022
1 parent 5149a34 commit 9e7650a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/kit/src/vite/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from 'fs';
import path from 'path';
import colors from 'kleur';
import { svelte } from '@sveltejs/vite-plugin-svelte';
import { searchForWorkspaceRoot, version as vite_version } from 'vite';
import * as vite from 'vite';
import { mkdirp, posixify, rimraf } from '../utils/filesystem.js';
import * as sync from '../core/sync/sync.js';
import { build_server } from './build/build_server.js';
Expand Down Expand Up @@ -222,7 +222,7 @@ function kit() {
svelte_config.kit.outDir,
path.resolve(cwd, 'src'),
path.resolve(cwd, 'node_modules'),
path.resolve(searchForWorkspaceRoot(cwd), 'node_modules')
path.resolve(vite.searchForWorkspaceRoot(cwd), 'node_modules')
])
]
},
Expand Down Expand Up @@ -402,9 +402,11 @@ function kit() {
}

function check_vite_version() {
const current_vite_major = parseInt(vite_version.split('.')[0], 10);
// TODO parse from kit peer deps and maybe do a full semver compare if we ever require feature releases a min
const min_required_vite_major = 3;
const vite_version = vite.version ?? '2.x'; // vite started exporting it's version in 3.0
const current_vite_major = parseInt(vite_version.split('.')[0], 10);

if (current_vite_major < min_required_vite_major) {
throw new Error(
`Vite version ${current_vite_major} is no longer supported. Please upgrade to version ${min_required_vite_major}`
Expand Down

0 comments on commit 9e7650a

Please sign in to comment.