vite-plugin-svelte: Throwing an SSR error for svelte third-party packages with npm protocol
Describe the bug
When hot reloading and initially spinning up pnpm run dev an error that causes a 500 message to be displayed to the client is seen when attempting to import a .svelte component from a node_module.
Reproduction
dextermb/bug-hero-icons-svelte-kit
Steps to reproduce:
pnpm init svelte@next apppnpm i -D svelte-heroicons@npm:svelte-hero-icons- Import icon into page
pnpm run dev
Logs
18:29:23 [vite] Error when evaluating SSR module /src/routes/index.svelte:
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".svelte" for /Users/dexter/projects/svelte/hero-icons-svelte-kit/node_modules/.pnpm/svelte-hero-icons@4.0.3/node_modules/svelte-hero-icons/Icon.svelte
at Loader.defaultGetFormat [as _getFormat] (internal/modules/esm/get_format.js:71:15)
at Loader.getFormat (internal/modules/esm/loader.js:102:42)
at Loader.getModuleJob (internal/modules/esm/loader.js:231:31)
at async ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:58:21)
at async Promise.all (index 230)
at async link (internal/modules/esm/module_job.js:63:9)
System Info
npx: installed 1 in 1.125s
System:
OS: macOS 12.2.1
CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
Memory: 50.17 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.16.0 - ~/.nvm/versions/node/v14.16.0/bin/node
Yarn: 1.22.10 - ~/.nvm/versions/node/v14.16.0/bin/yarn
npm: 6.14.11 - ~/.nvm/versions/node/v14.16.0/bin/npm
Browsers:
Brave Browser: 97.1.34.81
Chrome: 99.0.4844.51
Firefox: 94.0.1
Safari: 15.3
npmPackages:
@sveltejs/adapter-auto: next => 1.0.0-next.30
@sveltejs/kit: next => 1.0.0-next.292
svelte: ^3.44.0 => 3.46.4
Severity
serious, but I can work around it
Additional Information
Seems to work fine in @sveltejs/kit:1.0.0-next.285 but not 1.0.0-next.292.
Edit: After further investigation it seems like it could be down to aliased modules.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (7 by maintainers)
or use it properly. Anyways please don’t use this bug to chat. your messages are off-topic here. The svelte discord https://svelte.dev/chat can be used to ask for help ( #svelte ). From what i’ve seen the author of svelte-heros is active there too,
Ah looks like that’s it. I didn’t notice the
pkg.sveltewas added before publishing. This would be a bug invite-plugin-sveltethen, moving it over.