Skip to content

Commit

Permalink
Skip Vite resolve workaround on Vite 4.1+
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Apr 18, 2023
1 parent f1b9c78 commit bcfb7fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/chilled-tigers-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/vite-plugin-svelte': patch
---

Skip Vite resolve workaround on Vite 4.1+
6 changes: 4 additions & 2 deletions packages/vite-plugin-svelte/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'fs';
import { HmrContext, ModuleNode, Plugin, ResolvedConfig, UserConfig } from 'vite';
import { HmrContext, ModuleNode, Plugin, ResolvedConfig, UserConfig, version } from 'vite';
// eslint-disable-next-line node/no-missing-import
import { isDepExcluded } from 'vitefu';
import { handleHotUpdate } from './handle-hot-update';
Expand Down Expand Up @@ -135,7 +135,9 @@ export function svelte(inlineOptions?: Partial<Options>): Plugin[] {
}
}

if (ssr && importee === 'svelte') {
// TODO: remove this after bumping peerDep on Vite to at least 4.1
const vers = version.split('.').map((s) => parseInt(s));
if (vers[0] === 4 && vers[1] === 0 && ssr && importee === 'svelte') {
if (!resolvedSvelteSSR) {
resolvedSvelteSSR = this.resolve('svelte/ssr', undefined, { skipSelf: true }).then(
(svelteSSR) => {
Expand Down

0 comments on commit bcfb7fc

Please sign in to comment.