BerkinAKKAYA / svelte-image-gallery

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

Crash with SvelteKit and Vite #12

Closed macabeus closed 11 months ago

macabeus commented 2 years ago

When trying to import this package on a SvelteKit project using Vite, it crashes

Unknown file extension ".svelte" for /Users/macabeus/ApenasMeu/gambiconf/gambiconf.github.io/node_modules/svelte-image-gallery/Gallery.svelte
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".svelte" for /Users/macabeus/ApenasMeu/gambiconf/gambiconf.github.io/node_modules/svelte-image-gallery/Gallery.svelte
    at new NodeError (node:internal/errors:372:5)
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:76:11)
    at defaultGetFormat (node:internal/modules/esm/get_format:118:38)
    at defaultLoad (node:internal/modules/esm/load:21:20)
    at ESMLoader.load (node:internal/modules/esm/loader:407:26)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:326:22)
    at new ModuleJob (node:internal/modules/esm/module_job:66:26)
    at ESMLoader.#createModuleJob (node:internal/modules/esm/loader:345:17)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:304:34)
    at async ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:82:21)
fedorkanin commented 1 year ago

Writing this to vite.config.js solved the same problem for me: ssr: { noExternal: ['svelte-image-gallery'] }

ty-e-boyd commented 11 months ago

The true fix for this issue is to add "module" and "svelte" to the package.json, both pointing to index.mjs. @BerkinAKKAYA could you make this change? Otherwise, if you give me permission, I can push the change locally and open a pull request.

BerkinAKKAYA commented 11 months ago

Hi @ty-e-boyd, thank you for your contribution! Would be awesome if you can open the pull request @ty-e-boyd

ty-e-boyd commented 11 months ago

Awesome thanks! Could you please give me permission to do so? Also, appreciate the package a lot. Been using it for about a year now

macabeus commented 11 months ago

@ty-e-boyd The default GitHub permissions are enough to open a pull request. Just make a fork, push the changes to your fork, and then open a PR here

image
ty-e-boyd commented 11 months ago

Sweet, just did. Didn't realize you could compare across forks, that's pretty dope.

Fixed in PR #13