From aec9b4c692c73d6bfa28aeb572a4e73e998eb8fd Mon Sep 17 00:00:00 2001 From: Simon Holthausen Date: Wed, 1 Jul 2020 08:32:24 +0200 Subject: [PATCH] (fix) always add fallback preprocessor #243 --- .../src/plugins/svelte/SveltePlugin.ts | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) 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 }, + }), + }; } }