From d2dd9476335fbd9cc1a631fe76b07cedbccc7089 Mon Sep 17 00:00:00 2001 From: "Lyu, Wei Da" Date: Wed, 28 Jul 2021 13:21:11 +0800 Subject: [PATCH] improve error message while loading config --- .../language-server/src/lib/documents/configLoader.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/language-server/src/lib/documents/configLoader.ts b/packages/language-server/src/lib/documents/configLoader.ts index 909d2ca9a..add99576b 100644 --- a/packages/language-server/src/lib/documents/configLoader.ts +++ b/packages/language-server/src/lib/documents/configLoader.ts @@ -152,6 +152,12 @@ export class ConfigLoader { let config = this.disabled ? {} : (await this.dynamicImport(pathToFileURL(configPath)))?.default; + + if (!config) { + throw new Error( + 'Missing exports in the config. Make sure to include "export default config" or "module.exports = config"' + ); + } config = { ...config, compilerOptions: { @@ -163,7 +169,7 @@ export class ConfigLoader { Logger.log('Loaded config at ', configPath); return config; } catch (err) { - Logger.error('Error while loading config'); + Logger.error('Error while loading config at ', configPath); Logger.error(err); const config = { ...this.useFallbackPreprocessor(directory, true),