sveltestrap icon indicating copy to clipboard operation
sveltestrap copied to clipboard

Browser downloads all components in SvelteKit

Open Brawl345 opened this issue 4 years ago • 4 comments

I'm somewhat confused by this. When I import a component (just a Button for example), it automatically downloads all other components:

img

This makes e.g. reloading very slow since it has to load all components. I'm importing them like so:

import { Button } from 'sveltestrap';

When I use

import Button from 'sveltestrap/src/Button.svelte';

it works but this is rather cumbersome since I have to type it out manually instead of letting my IDE complete it. Am I missing something or am I understanding something wrong?

Brawl345 avatar Aug 15 '21 21:08 Brawl345

Hi @Brawl345 , I've not been keeping up with the status of Sveltekit, as it seems to be changing quite a bit.
If you are using Sveltestrap in an SSR environment such as Sapper, the previous recommendation was you import the component src directly:

import { Card } from 'sveltestrap/src';

But I thought this was unnecessary in sveltekit.

bestguy avatar Aug 16 '21 00:08 bestguy

Same problem with your import: img

Brawl345 avatar Aug 16 '21 10:08 Brawl345

I'm not really sure what the recommended practice is with Sveltekit. I'm assuming it's reading the index.js and seeing all the imports, but this works fine with sapper and rollup. I'm happy to update our dist with whatever would improve this, but would need some help sorting through what Sveltekit needs here.

bestguy avatar Aug 16 '21 15:08 bestguy

This should now be addressed with the latest SvelteKit, which prebundles Svelte libraries: https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/config.md#prebundlesveltelibraries

benmccann avatar May 26 '23 18:05 benmccann