-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ssr : false - server still tries to render components #779
Comments
SvelteKit needs to import the page to determine whether or not it should be server-rendered. (I'd like to add a build step that figures that out earlier on, so that the component doesn't need to be imported at runtime if it's not being SSR'd, but it won't solve the problem.) For that reason, you have two options:
|
SvelteKit has both app-wide configuration and page-level configuration for SSR. I wonder if there's a way we can avoid importing the page is the app-level config option is set? |
Hey thanks for your answers ! If I understand correctly, the issue comes from librairies that manipulates the DOM as soon as imported. In that case I should import these kind of dependencies in onMount to prevent sveltekit from evaluating them in a non DOM env. Sveltekit needs to import the page in order to determine if it should be ssr'd so any library using the DOM at import will cause a bug. I'll try to raise an issue on Quill side then ! |
In case someone faces a similar issue: the |
Today even I ran into this... I am trying to use In their example, they have asked to use following way... <div class="editor" use:quill={options} on:text-change={e => content =
e.detail}/> ... and I'm not sure how will I make that When I looked-up here, svelte-quill, there is no mention of repository, sadly. So I had to do this to make it work... onMount(async () => {
const editor_host = document.querySelector('#description-editor');
if (editor_host) {
const { quill } = await import("svelte-quill");
quill(editor_host, quill_options);
}
}); ... and then in the template <div
id="description-editor"
class="editor"
on:text-change={(e) => (quill_content = e.detail)}
/> |
Apologies if this is the wrong place, but I'm importing a library in a similar way with: const { MicVAD, utils } = await import("@ricky0123/vad-web") And I'm seeing a 404 in the vite process:
Reading the vite docs, it sounds like it should be hitting |
Describe the bug
I can't use libraries like Quill which manipulates the DOM outside of onMount function when ssr : false
Logs
18:53:37 [vite] Error when evaluating SSR module C:\Users\Bastien\Desktop\svelte-spa\src\routes\index.svelte:
ReferenceError: document is not defined
at Object. (C:\Users\Bastien\Desktop\svelte-spa\node_modules\quill\dist\quill.js:7661:12)
at webpack_require (C:\Users\Bastien\Desktop\svelte-spa\node_modules\quill\dist\quill.js:36:30)
at Object. (C:\Users\Bastien\Desktop\svelte-spa\node_modules\quill\dist\quill.js:1030:1)
at webpack_require (C:\Users\Bastien\Desktop\svelte-spa\node_modules\quill\dist\quill.js:36:30)
at Object. (C:\Users\Bastien\Desktop\svelte-spa\node_modules\quill\dist\quill.js:5655:14)
at webpack_require (C:\Users\Bastien\Desktop\svelte-spa\node_modules\quill\dist\quill.js:36:30)
at Object. (C:\Users\Bastien\Desktop\svelte-spa\node_modules\quill\dist\quill.js:10045:13)
at webpack_require (C:\Users\Bastien\Desktop\svelte-spa\node_modules\quill\dist\quill.js:36:30)
at Object. (C:\Users\Bastien\Desktop\svelte-spa\node_modules\quill\dist\quill.js:11557:18)
at webpack_require (C:\Users\Bastien\Desktop\svelte-spa\node_modules\quill\dist\quill.js:36:30)
To Reproduce
Expected behavior
I understood I would not need to code my app as isomorphic when using ssr : false
Information about your SvelteKit Installation:
npx envinfo --system --npmPackages svelte,@sveltejs/kit --binaries --browsers
System:
OS: Windows 10 10.0.19041
CPU: (4) x64 Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
Memory: 2.36 GB / 7.73 GB
Binaries:
Node: 14.4.0 - ~\scoop\apps\nodejs\current\node.EXE
npm: 6.14.5 - ~\scoop\apps\nodejs\current\npm.CMD
Browsers:
Chrome: 89.0.4389.90
Edge: Spartan (44.19041.423.0), Chromium (89.0.774.63)
Internet Explorer: 11.0.19041.1
npmPackages:
@sveltejs/kit: next => 1.0.0-next.64
svelte: ^3.29.0 => 3.36.0
Brave
tested on node and static , both not working
Severity
I still can use classic onMount and if browser conditions.
The text was updated successfully, but these errors were encountered: