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

SvelteKit 1.0.0-next.202 / Vite 2.7 issue #54

Closed
techniq opened this issue Dec 15, 2021 · 3 comments
Closed

SvelteKit 1.0.0-next.202 / Vite 2.7 issue #54

techniq opened this issue Dec 15, 2021 · 3 comments

Comments

@techniq
Copy link
Contributor

techniq commented Dec 15, 2021

After upgrading to SvelteKit 1.0.0-next.202 which includes Vite 2.7, I receive the following when importing LayerCake:

10:36:36 PM [vite] Error when evaluating SSR module /src/lib/components/Chart.svelte:
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".svelte" for /Users/techniq/Documents/Development/open-source/layerchart/node_modules/layercake/src/LayerCake.svelte
    at new NodeError (node:internal/errors:371:5)
    at Object.file: (node:internal/modules/esm/get_format:72:15)
    at defaultGetFormat (node:internal/modules/esm/get_format:85:38)
    at defaultLoad (node:internal/modules/esm/load:13:42)
    at ESMLoader.load (node:internal/modules/esm/loader:303:26)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:230:58)
    at new ModuleJob (node:internal/modules/esm/module_job:63:26)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:244:11)
    at async ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:78:21)
    at async Promise.all (index 0)

While I'm not 100% certain, I believe the heuristic changed with Vite 2.7 to detect a svelte package, and the best tell now is to include a svelte property in package.json (along with main/exports). If using SvelteKit to build packages, running svelte-kit package now sets this for you. This PR along with the associated issue and code provides some additional info.

Sending a PR your way...

@mhkeller
Copy link
Owner

Interestingly, I get this same error when using the new sveltekit version even though it has "svelte": "./index.js" in its package.json. I think I have to do some more configuration around exports though because it's currently exporting too much.

@techniq
Copy link
Contributor Author

techniq commented Dec 15, 2021

Hmm. It’s currently working for me and published/deployed an update to LayerChart with it. I know on my primary application I had layercake in optimizeDeps within svelte.config.js which was still giving me the error (or similar) until I removed it, although I don’t see that in your kit branch at all.

I was just calling it a night (typing on my phone) but if you’re still having issues I can take a look tomorrow sometime.

@mhkeller
Copy link
Owner

Nope not urgent and it seems to be working now. My next step is to see if it works with the layercake.graphics examples but that will be for another day.

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

2 participants