Skip to content

Commit 2a39313

Browse files
committed
make robust
1 parent 855ead8 commit 2a39313

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/index.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,19 @@ export const parsers: Record<string, Parser> = {
3333
hasPragma,
3434
parse: async (text, options: ParserOptions) => {
3535
try {
36-
const _parse = options.svelte5CompilerPath
37-
? (await import(options.svelte5CompilerPath)).parse
38-
: parse;
36+
let _parse = parse;
37+
if (options.svelte5CompilerPath) {
38+
try {
39+
_parse = (await import(options.svelte5CompilerPath)).parse;
40+
} catch (e) {
41+
console.warn(
42+
`Failed to load Svelte 5 compiler from ${options.svelte5CompilerPath}`,
43+
);
44+
console.warn(e);
45+
options.svelte5CompilerPath = undefined;
46+
}
47+
}
48+
3949
return <ASTNode>{ ..._parse(text), __isRoot: true };
4050
} catch (err: any) {
4151
if (err.start != null && err.end != null) {

0 commit comments

Comments
 (0)