-
-
Notifications
You must be signed in to change notification settings - Fork 433
500: <component> is not a valid SSR component #774
Comments
Not a bug. This happens because If you view source on the page you are seeing "break" the error is right there:
|
@antony, how is it then, that a regular Svelte app does not throw such an error? https://svelte.dev/repl/c1d2319031a04bdd81dffc9501300ded?version=3.6.2 |
@Vehmloewff Svelte doesn't use SSR. It's just a client framework. |
Svelte does use SSR. If you compile with the option |
Apologies - I meant that it didn't use SSR by default, which is why the error is not occuring when the component is imported into a regular Svelte application. I hadn't realised @Vehmloewff that you were the author of |
In the case of your repro - If you move svelte-toolbox from a dependency to a devdependency, everything seems fine. See https://github.com/sveltejs/sapper-template#using-external-components |
Thanks @Conduitry and @antony . Moving |
Moving to devDependency worked, but why? |
Because of this. |
In my case, I've had crashes using the ResizeObserver component. The solution for this problem can actually be found in the sapper docs and initializes the component dynamically in <svelte:component this={ResizeObserver} on:resize={onPanelResize}/> import {onMount} from 'svelte';
let ResizeObserver;
onMount(async () => {
const module = await import('svelte-resize-observer');
ResizeObserver = module.default;
}); Hints:
|
@Dan1ve Thank you so much for you solution, took me so much time to find the solution. |
I ran into this with svelte-mui and found the solution (in the docs of all places):
Need to import from src dir. |
In addition to @Dan1ve solution I had to import my component as follows: import { ValidationMessage as ValidationMessageSSR } from '@felte/reporter-svelte'; Then in my onMount: let ValidationMessage
onMount(async () => {
ValidationMessage = ValidationMessageSSR
}) And finally in my template: <svelte:component this={ValidationMessage} for="newPassword" let:messages={messages}>
<span class="text-red-500 mt-5">{messages || ''}</span>
</svelte:component> That worked for me using rollup as a javascript-api and not by a |
I'm using svelte-kit with dino color picker and even after making it a dev dependency I still get this error |
Add -D to npm install per sveltejs/sapper#774
When a component is imported from
node_modules
, Sapper shows a 500 page for about 400ms before displaying the content. After that, both the page and imported component display and work correctly.This happens on Chrome, Firefox, and Safari with both Rollup and Webpack, but it does not happen on a regular Svelte app.
See this example repo
Note: The
package.json
of the imported component has asvelte
field, andresolve.mainFields
inwebpack.config.js
is set to includesvelte
.The text was updated successfully, but these errors were encountered: