sveltejs / kit

web development, streamlined
https://svelte.dev/docs/kit
MIT License
18.75k stars 1.95k forks source link

Support for SvelteKit-specific apps #11143

Open benmccann opened 11 months ago

benmccann commented 11 months ago

Describe the problem

Screenshot from 2023-11-29 09-57-12

prop:

Hey, so I'm creating a svelte library that doesn't use any dependencies. Problem is that my library won't work if I remove the svelte peerDependeny, unless I add ssr: { noExternal: ["library"] } to the vite config when using the lib. this is the issue im facing. Are there any workarounds for this? Not ideal having to add this to vite config when using the library nor is it ideal to have a useless peerDependency (edited)

Enrico (Etrain):

If you're creating a Svelte component library, then adding Svelte as a peerDependency is necessary since the user will require Svelte to use your library. Unless your library is strictly JS modules. Can you share it?

prop:

@ Enrico (Etrain) this is it https://github.com/propolies/svelte-api/tree/main/package I'm not using svelte in any way, only thing im using is sveltekits Request type.

Describe the proposed solution

Check if libraries have SvelteKit as a peer dep just as vite-plugin-svelte does for Svelte

Alternatives considered

No response

Importance

nice to have

Additional Information

No response

Rishab49 commented 11 months ago

what could be possible solution of this? @benmccann

benmccann commented 10 months ago

SvelteKit needs to add any packages which declare a peer dependency on SvelteKit to noExternal just as vite-plugin-svelte does for packages which declare a peer dependency on Svelte:

https://github.com/sveltejs/vite-plugin-svelte/blob/833d66cee57a0ec7cbfcf29b23796988dfdc7cf3/packages/vite-plugin-svelte/src/utils/options.js#L513