question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@sveltejs/kit and vite@3 broke .svelte file processing in packages

See original GitHub issue

Describe the bug

We use the excellent @rgossiaux/svelte-heroicons package to render icons, and the recent change in Sveltekit and Vite broke the project. The page now fails to load with a 500 error and a Unknown file extension ".svelte" message.

The last known working version of Sveltekit is “1.0.0-next.360” with Vite “2.9.13”.

This might be related to https://github.com/sveltejs/kit/issues/5542

Reproduction

Here’s a an example of the issue

Logs

❯ npm run dev
$ vite dev

  VITE v3.0.0  ready in 1227 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
Unknown file extension ".svelte" for /home/projects/sveltejs-kit-template-default-mubpwk/node_modules/@rgossiaux/svelte-heroicons/outline/AcademicCap/AcademicCap.svelte
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".svelte" for /home/projects/sveltejs-kit-template-default-mubpwk/node_modules/@rgossiaux/svelte-heroicons/outline/AcademicCap/AcademicCap.svelte
    at TypeError.get (https://sveltejs-kit-template-default-mubpwk.w.staticblitz.com/blitz.9dc2007b053e3e7ca4daf0ec1a74b5c3910935fe.js:6:292488)
    at instantiateModule (file:///home/projects/sveltejs-kit-template-default-mubpwk/node_modules/vite/dist/node/chunks/dep-561c5231.js:50345:15)
^C

System Info

❯ npx envinfo --system --binaries --browsers --npmPackages "{svelte,@sveltejs/*,vite}"
success Install finished in 0.737s


  System:
    OS: Linux 5.0 undefined
    CPU: (4) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 16.14.2 - /usr/local/bin/node
    Yarn: 1.22.10 - /bin/yarn
    npm: 7.17.0 - /bin/npm
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.60 
    @sveltejs/kit: next => 1.0.0-next.377 
    svelte: ^3.46.0 => 3.49.0 
    vite: ^3.0.0 => 3.0.0

Severity

blocking an upgrade

Additional Information

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
dominikgcommented, Jul 15, 2022

yes, a vite release that includes the fix should be available in the next days. Until then you can continue to use one of the workarounds above or also something like pnpm patch to patch your local vite with that PR.

1reaction
dominikgcommented, Jul 15, 2022

another workaround is to add an ssr.noExternal entry for the problematic import that uses /** at the end. This is a bug in vite-3 and will be fixed.

// vite.config.js
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
 
export default defineConfig({
  plugins: [sveltekit()],
+  ssr: { noExternal: ['@rgossiaux/svelte-heroicons/**'] }
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Svelte-Kit Dev Is No Longer Available Use Vite Dev Instead
API Layer: https://apilayer.com/?utm_source=LevelUpTutorials&utm_medium=LeadsAcquisition&utm_content=july22Github PR ...
Read more >
FAQ • SvelteKit
Vite's SSR support has become fairly stable since Vite 2.7. Most issues related to including a library are due to incorrect packaging.
Read more >
Migrating Breaking Changes in SvelteKit - Netlify
SvelteKit has gone through a few breaking changes recently including an entire routing overhaul, changes to the load API, and a switch to ......
Read more >
Handling breaking changes in SvelteKit pre-1.0 - Thilo Maier
In August 2022, the SvelteKit team around Rich Harris released several refactorings in preparation for the release of SvelteKit 1.0.
Read more >
Getting started with Svelte - Learn web development | MDN
html : This is the main page of your app. Initially it's just an empty HTML page that loads the CSS files and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found