BerkinAKKAYA / svelte-image-gallery

A Masonry-Like Image Container for Svelte
https://madewithsvelte.com/svelte-image-gallery
53 stars 13 forks source link

Export svelte component through JS module for publishing #4

Closed kale-stew closed 2 years ago

kale-stew commented 3 years ago

Currently, when trying to deploy a SvelteKit application that consumes this library using the import/from syntax pattern, one encounters an error that the '.svelte' file type is not recognized.

> Using @sveltejs/adapter-static
> Unknown file extension ".svelte" for /opt/build/repo/node_modules/svelte-image-gallery/Gallery.svelte

This can be resolved by require-ing the package instead of importing from it, but that's (1) a workaround and (2) not the syntax used in svelte-image-gallery's docs.

This PR addresses that issue by exporting the svelte component through a new default index.js as is recommended by the SvelteKit docs on packaging. I've tested these changes in the example repo, as well.

Additional info can be found at this SvelteKit FAQ answer about importing packages.

BerkinAKKAYA commented 2 years ago

Hi, sorry for the late response. I pulled your branch to test it but it says Error: 'Gallery' is not exported by ..\Gallery.svelte, imported by ..\index.js. I haven't been using svelte for months now and i would appreciate it if you could help.