Skip to content
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

External components not correctly compiled in SSR mode #366

Closed
Conduitry opened this issue Feb 4, 2021 · 7 comments
Closed

External components not correctly compiled in SSR mode #366

Conduitry opened this issue Feb 4, 2021 · 7 comments
Labels
bug Something isn't working

Comments

@Conduitry
Copy link
Member

It seems that external components (installed to node_modules) do not correctly work with Kit. We end up trying to run a browser-compiled version of them as part of the SSR code, which results in the runtime is not a valid SSR component error.

The issue does not seem to be that Kit and/or Snowpack is not correctly resolving pkg.svelte. It appears to be finding the correct component file to compile, and it is compiling it, but it's compiling it in DOM mode when it ought to be compiling it in SSR mode.

I haven't made any real progress on determining whether this is a Kit bug or a Snowpack (or its plugin) bug.

@Conduitry Conduitry added the bug Something isn't working label Feb 4, 2021
@Conduitry
Copy link
Member Author

The load method in @snowpack/plugin-svelte (the only place in there that seems to refer to SSR) does not appear to ever be getting run. If I put a process.abort(1) in there, npm run dev runs fine (and then proceeds to produce a broken build, as described above).

@benmccann
Copy link
Member

benmccann commented Feb 4, 2021

I encountered this when trying to use https://github.com/RobBrazier/svelte-awesome

I did see load being called, but only with my own code from the src/ directory and nothing from node_modules. I was wondering it the issue was related to local mode but I tried hardcoding generate: 'ssr' on the line below and nothing changed, so I'm still not quite sure where the error is

https://github.com/snowpackjs/snowpack/blob/41c29f25e53695ec84c07386af7eb140d0b22a8e/plugins/plugin-svelte/plugin.js#L25

@benmccann
Copy link
Member

@FredKSchott I'm not sure if you might have any idea about this one

@benmccann
Copy link
Member

It turns out this is because Snowpack pre-bundles dependencies. Rich also hit this when working on the SvelteKit documentation sveltejs/sites#1. Kit needs to build two apps, one SSR, one DOM. If components are prebundled, you're stuck with DOM

@Conduitry Conduitry added this to the public beta milestone Feb 4, 2021
@Rich-Harris
Copy link
Member

Previous discussion: FredKSchott/snowpack#1808

@FredKSchott
Copy link
Contributor

Thanks for tagging, that summary sounds correct. I'm actually just looking at our dependency story today and supporting passing some deps (like Svelte) through your normal build pipeline instead of pre-bundling. Will keep this thread (and the one Rich linked to) updated

@FredKSchott
Copy link
Contributor

FredKSchott commented Feb 22, 2021

Update: I've been working hard on a refactor of the Snowpack internals which adds support for (among other things) Svelte SSR packages. PR just opened here fixes this issue: FredKSchott/snowpack#2707

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants