From afefafe0aa16f4b471571a19efd0db7cabb53e76 Mon Sep 17 00:00:00 2001 From: ComputerGuy <63362464+Ocean-OS@users.noreply.github.com> Date: Thu, 31 Jul 2025 16:25:10 -0700 Subject: [PATCH] fix: emit `snippet_invalid_export` instead of `undefined_export` for exported snippets --- .changeset/thick-snakes-look.md | 5 +++++ packages/svelte/src/compiler/phases/2-analyze/index.js | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 .changeset/thick-snakes-look.md diff --git a/.changeset/thick-snakes-look.md b/.changeset/thick-snakes-look.md new file mode 100644 index 0000000000..f5f22e8a6c --- /dev/null +++ b/.changeset/thick-snakes-look.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: emit `snippet_invalid_export` instead of `undefined_export` for exported snippets diff --git a/packages/svelte/src/compiler/phases/2-analyze/index.js b/packages/svelte/src/compiler/phases/2-analyze/index.js index cd44fd998a..88b181d9da 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/index.js +++ b/packages/svelte/src/compiler/phases/2-analyze/index.js @@ -789,7 +789,14 @@ export function analyze_component(root, source, options) { if (specifier.local.type !== 'Identifier') continue; const binding = analysis.module.scope.get(specifier.local.name); - if (!binding) e.export_undefined(specifier, specifier.local.name); + if (!binding) { + const instance_binding = analysis.instance.scope.get(specifier.local.name); + if (instance_binding?.kind === 'snippet') { + e.snippet_invalid_export(specifier); + } else { + e.export_undefined(specifier, specifier.local.name); + } + } } } }