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

Support SSR #48

Closed
CaptainN opened this issue Sep 17, 2019 · 9 comments
Closed

Support SSR #48

CaptainN opened this issue Sep 17, 2019 · 9 comments

Comments

@CaptainN
Copy link

I have created a simple Svelte starter for Meteor, and it was reported that sveltestrap doesn't work with my SSR solution. I believe this is because your component is published in a pre-compiled state, instead of providing raw source and exposing that through a svelte key in package.json as is demonstrated in sveltejs/component-template.

Svelte's SSR support works by using an entirely different compiler for server rendering, and would seem to require raw source in order to function properly.

@bestguy
Copy link
Owner

bestguy commented Sep 21, 2019

Thanks for the the heads up @CaptainN , will take a look at the Svelte 3 options. I seem to remember a SSR option in Svelte or Rollup, will see if something can add there. I'm reluctant to include source in npm tarballs but can do so if is the recommended approach. Will look within next week.

@bestguy
Copy link
Owner

bestguy commented Sep 21, 2019

I've published a beta version of sveltestrap@3.1.2-1, I will try out with your template as well.
PR is #53 and will merge after I can confirm this works.

@bestguy
Copy link
Owner

bestguy commented Sep 22, 2019

Published fix in v3.2 (https://github.com/bestguy/sveltestrap/releases/tag/v3.2.0), I'll leave this open until one of us can confirm works with your template.

@bestguy
Copy link
Owner

bestguy commented Sep 23, 2019

I tested out using your template and unfortunately this is same error:

Error running template: Error: <Card> 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

It looks like Svelte has a generate: 'ssr' option (https://svelte.dev/docs#svelte_compile), but it's really not clear to me how this is supposed to be packaged - issues seem to imply that you build a separate SSR bundle? Ex: sveltejs/svelte#196

I'll leave this issue open and will investigate.

@bestguy
Copy link
Owner

bestguy commented Sep 23, 2019

Oh - actually this does work, however you must import the source directly @abigtoe,

import Card from 'sveltestrap/src/Card.svelte'

There is a "svelte" key in package.json, so unsure why the svelte SSR or template is not supporting this syntax:

import { Card } from 'sveltestrap';

I'll investigate if there is anything I can do in this library, but if not will close this week.

@abigtoe
Copy link

abigtoe commented Oct 1, 2019

@bestguy Confirmed, the direct import approach does work.

@bestguy
Copy link
Owner

bestguy commented Oct 1, 2019

Thanks! I'll close this for now, I appreciate the heads up.

@bestguy bestguy closed this as completed Oct 1, 2019
@larryosborn
Copy link
Contributor

This also works:
import { Card } from 'sveltestrap/src';

@CaptainN
Copy link
Author

CaptainN commented Oct 2, 2019

Thanks @bestguy !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants