Skip to content

Commit be3d46d

Browse files
authored
fix: svelte version detection was broken (#495)
1 parent 50db140 commit be3d46d

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

packages/vite-plugin-svelte/src/utils/__tests__/svelte-version.spec.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,42 +61,42 @@ describe('svelte-version', () => {
6161
expect(atLeastSvelte(VERSION)).toBe(true);
6262
});
6363

64-
it('should return true for patch bump', async () => {
64+
it('should return false for higher patch', async () => {
6565
const patch = svelteVersion.concat();
6666
patch[2] += 1;
6767
const patchBump = patch.join('.');
68-
expect(atLeastSvelte(patchBump)).toBe(true);
68+
expect(atLeastSvelte(patchBump)).toBe(false);
6969
});
70-
it('should return true for minor bump', async () => {
70+
it('should return false for higher minor', async () => {
7171
const minor = svelteVersion.concat();
7272
minor[1] += 1;
7373
const minorBump = minor.join('.');
74-
expect(atLeastSvelte(minorBump)).toBe(true);
74+
expect(atLeastSvelte(minorBump)).toBe(false);
7575
});
76-
it('should return true for major bump', async () => {
76+
it('should return false for higher major', async () => {
7777
const major = svelteVersion.concat();
7878
major[0] += 1;
7979
const majorBump = major.join('.');
80-
expect(atLeastSvelte(majorBump)).toBe(true);
80+
expect(atLeastSvelte(majorBump)).toBe(false);
8181
});
8282

83-
it('should return false for lower patch', async () => {
83+
it('should return true for lower patch', async () => {
8484
const patch = svelteVersion.concat();
8585
patch[2] -= 1;
8686
const lowerPatch = patch.join('.');
87-
expect(atLeastSvelte(lowerPatch)).toBe(false);
87+
expect(atLeastSvelte(lowerPatch)).toBe(true);
8888
});
89-
it('should return false for lower minor', async () => {
89+
it('should return true for lower minor', async () => {
9090
const minor = svelteVersion.concat();
9191
minor[1] -= 1;
9292
const lowerMinor = minor.join('.');
93-
expect(atLeastSvelte(lowerMinor)).toBe(false);
93+
expect(atLeastSvelte(lowerMinor)).toBe(true);
9494
});
95-
it('should return false for lower major', async () => {
95+
it('should return true for lower major', async () => {
9696
const major = svelteVersion.concat();
9797
major[0] -= 1;
9898
const lowerMajor = major.join('.');
99-
expect(atLeastSvelte(lowerMajor)).toBe(false);
99+
expect(atLeastSvelte(lowerMajor)).toBe(true);
100100
});
101101
});
102102
});

packages/vite-plugin-svelte/src/utils/esbuild.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ async function compileSvelte(
4343
): Promise<string> {
4444
let css = options.compilerOptions.css;
4545
if (css !== 'none') {
46-
css = isCssString ? 'inject' : true;
46+
css = isCssString ? 'injected' : true;
4747
}
4848
const compileOptions: CompileOptions = {
4949
...options.compilerOptions,

packages/vite-plugin-svelte/src/utils/svelte-version.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ export function compareToSvelte(version: string): 1 | 0 | -1 {
3232
}
3333

3434
export function atLeastSvelte(version: string) {
35-
return compareToSvelte(version) >= 0;
35+
const result = compareToSvelte(version) <= 0;
36+
return result;
3637
}

0 commit comments

Comments
 (0)