Skip to content

Commit

Permalink
enforce vite 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Jul 14, 2022
1 parent 3f5eb6a commit 293d564
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/kit/src/vite/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ function kit() {
};
}

// TODO remove this for 1.0
check_vite_version();

return {
name: 'vite-plugin-svelte-kit',

Expand Down Expand Up @@ -388,6 +391,23 @@ function kit() {
};
}

function check_vite_version() {
let vite_major = 3;

try {
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'));
vite_major = +pkg.devDependencies['vite'].replace(/^[~^]/, '')[0];
} catch {
// do nothing
}

if (vite_major < 3) {
throw new Error(
`Vite version ${vite_major} is no longer supported. Please upgrade to version 3`
);
}
}

/** @param {import('rollup').OutputBundle} bundle */
function collect_output(bundle) {
/** @type {import('rollup').OutputChunk[]} */
Expand Down

0 comments on commit 293d564

Please sign in to comment.