Skip to content

Commit f149c62

Browse files
authored
(fix) use fallback content when parsing fails
Prevents "X is not a module" errors when using the TS plugin and a Svelte file has errors, making the parser fail
1 parent 05024a6 commit f149c62

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/typescript-plugin/src/svelte-snapshots.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,11 @@ export class SvelteSnapshotManager {
308308
this.logger.log('Successfully read Svelte file contents of', path);
309309
return result.code;
310310
} catch (e) {
311-
this.logger.log('Error loading Svelte file:', path);
311+
this.logger.log('Error loading Svelte file:', path, ' Using fallback.');
312312
this.logger.debug('Error:', e);
313+
// Return something either way, else "X is not a module" errors will appear
314+
// in the TS files that use this file.
315+
return 'export default class extends Svelte2TsxComponent<any,any,any> {}';
313316
}
314317
} else {
315318
return readFile(path);

0 commit comments

Comments
 (0)