diff --git a/packages/language-server/src/plugins/svelte/SveltePlugin.ts b/packages/language-server/src/plugins/svelte/SveltePlugin.ts index b7fc289b7..d1e2b9b8e 100644 --- a/packages/language-server/src/plugins/svelte/SveltePlugin.ts +++ b/packages/language-server/src/plugins/svelte/SveltePlugin.ts @@ -166,24 +166,21 @@ export class SveltePlugin } private useFallbackPreprocessor(document: Document, foundConfig: boolean) { - if ( + const needsConfig = document.styleInfo?.attributes.lang || document.styleInfo?.attributes.type || document.scriptInfo?.attributes.lang || - document.scriptInfo?.attributes.type - ) { - Logger.log( - (foundConfig - ? 'Found svelte.config.js but there was an error loading it. ' - : 'No svelte.config.js found but one is needed. ') + - 'Using https://github.com/sveltejs/svelte-preprocess as fallback', - ); - return { - preprocess: importSveltePreprocess(document.getFilePath() || '')({ - typescript: { transpileOnly: true }, - }), - }; - } - return {}; + document.scriptInfo?.attributes.type; + Logger.log( + (foundConfig + ? 'Found svelte.config.js but there was an error loading it. ' + : 'No svelte.config.js found' + (needsConfig ? ' but one is needed. ' : '. ')) + + 'Using https://github.com/sveltejs/svelte-preprocess as fallback', + ); + return { + preprocess: importSveltePreprocess(document.getFilePath() || '')({ + typescript: { transpileOnly: true }, + }), + }; } }