diff --git a/src/compiler/compile/render_dom/wrappers/InlineComponent/index.ts b/src/compiler/compile/render_dom/wrappers/InlineComponent/index.ts index e6eab33fbd..7523d79e41 100644 --- a/src/compiler/compile/render_dom/wrappers/InlineComponent/index.ts +++ b/src/compiler/compile/render_dom/wrappers/InlineComponent/index.ts @@ -416,6 +416,7 @@ export default class InlineComponentWrapper extends Wrapper { } if (${switch_value}) { + ${component.compile_options.dev && b`@validate_svelte_component(${switch_value});`} ${name} = new ${switch_value}(${switch_props}(#ctx)); ${munged_bindings} @@ -460,6 +461,7 @@ export default class InlineComponentWrapper extends Wrapper { } if (${switch_value}) { + ${component.compile_options.dev && b`@validate_svelte_component(${switch_value});`} ${name} = new ${switch_value}(${switch_props}(#ctx)); ${munged_bindings} diff --git a/src/runtime/internal/dev.ts b/src/runtime/internal/dev.ts index 3144911672..502afd88d6 100644 --- a/src/runtime/internal/dev.ts +++ b/src/runtime/internal/dev.ts @@ -121,6 +121,12 @@ export function validate_void_dynamic_element(tag: undefined | string) { } } +export function validate_svelte_component(component: any) { + if (!(component.prototype instanceof SvelteComponent)) { + throw new Error('this={...} of should specify a Svelte component.'); + } +} + type Props = Record; export interface SvelteComponentDev { $set(props?: Props): void; diff --git a/src/runtime/internal/ssr.ts b/src/runtime/internal/ssr.ts index 2c7d24a2cd..c51c2827df 100644 --- a/src/runtime/internal/ssr.ts +++ b/src/runtime/internal/ssr.ts @@ -122,7 +122,7 @@ export const missing_component = { export function validate_component(component, name) { if (!component || !component.$$render) { if (name === 'svelte:component') name += ' this={...}'; - throw new Error(`<${name}> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules`); + throw new Error(`<${name}> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules. Otherwise you may need to fix a <${name}>.`); } return component;