Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/language-server/src/lib/documents/configLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"'
Copy link
Member Author

@jasonlyu123 jasonlyu123 Jul 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benmccann It's this error message ok to you? It's modified from the one in svelte kit

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that looks good and would help make it clearer what the issue is. Thanks!

Even more than that I'd really like --ignore to avoid trying to load the config in the first place, but this is still helpful

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the problems I can think of it's that the ignored file could still be imported by another file. And when the svelte-preprocess default language config is set in that errored config file. The ignored file might be recognized as the wrong script type(js or ts). Thus creating some confusing typing errors in like props type check. I'll have to think about how to suppress the error message more.

);
}
config = {
...config,
compilerOptions: {
Expand All @@ -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),
Expand Down