Skip to content

Commit afefafe

Browse files
committed
fix: emit snippet_invalid_export instead of undefined_export for exported snippets
1 parent c04975d commit afefafe

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

.changeset/thick-snakes-look.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: emit `snippet_invalid_export` instead of `undefined_export` for exported snippets

packages/svelte/src/compiler/phases/2-analyze/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,14 @@ export function analyze_component(root, source, options) {
789789
if (specifier.local.type !== 'Identifier') continue;
790790

791791
const binding = analysis.module.scope.get(specifier.local.name);
792-
if (!binding) e.export_undefined(specifier, specifier.local.name);
792+
if (!binding) {
793+
const instance_binding = analysis.instance.scope.get(specifier.local.name);
794+
if (instance_binding?.kind === 'snippet') {
795+
e.snippet_invalid_export(specifier);
796+
} else {
797+
e.export_undefined(specifier, specifier.local.name);
798+
}
799+
}
793800
}
794801
}
795802
}

0 commit comments

Comments
 (0)