`@sveltejs/kit` and `vite@3` in typescript monorepo fails with `ERR_UNKNOWN_FILE_EXTENSION`
See original GitHub issueDescribe the bug
A pnpm
monorepo with symlinked TypeScript packages during development fails with the message ERR_UNKNOWN_FILE_EXTENSION
.
@sveltejs/vite-plugin-svelte
works fine. Things only break with the kit()
plugin from the @sveltejs/kit/vite
endpoint.
Reproduction
Here is a minimal(ish) reproduction: https://github.com/ifiokjr/vite3-unknown-file-extension
The readme describes where the error occurs, along with an example of vite
handling the typescript package files correctly without @sveltejs/kit
.
Logs
Unknown file extension ".ts" for /path/to/root/vite3-unknown-file-extension/packages/simple/src/index.ts
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /path/to/root/vite3-unknown-file-extension/packages/simple/src/index.ts
at new NodeError (node:internal/errors:377:5)
at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:80:11)
at defaultGetFormat (node:internal/modules/esm/get_format:122:38)
at defaultLoad (node:internal/modules/esm/load:21:20)
at ESMLoader.load (node:internal/modules/esm/loader:431:26)
at ESMLoader.moduleProvider (node:internal/modules/esm/loader:350:22)
at new ModuleJob (node:internal/modules/esm/module_job:66:26)
at #createModuleJob (node:internal/modules/esm/loader:369:17)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:328:34)
at async Promise.all (index 0)
System Info
System:
OS: macOS 12.4
CPU: (8) x64 Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
Memory: 17.79 GB / 64.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 18.3.0 - ~/Library/Caches/fnm_multishells/43378_1657864625724/bin/node
npm: 8.11.0 - ~/Library/Caches/fnm_multishells/43378_1657864625724/bin/npm
Watchman: 2022.07.04.00 - /usr/local/bin/watchman
Browsers:
Brave Browser: 103.1.40.107
Chrome: 103.0.5060.114
Chrome Canary: 105.0.5179.0
Firefox: 99.0.1
Safari: 15.5
npmPackages:
@sveltejs/adapter-auto: 1.0.0-next.60 => 1.0.0-next.60
@sveltejs/kit: 1.0.0-next.375 => 1.0.0-next.375
svelte: 3.44.0 => 3.44.0
vite: 3.0.0 => 3.0.0
Severity
blocking an upgrade
Additional Information
No response
Issue Analytics
- State:
- Created a year ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
TypeError: Unknown file extension ".svelte" : r/sveltejs - Reddit
In my svelte project, I am using TypeScript, vite and vitest When I included a 3rd party svelte module layercake , my unit...
Read more >Routing • Docs • SvelteKit
This is a file SvelteKit creates for you in a hidden directory if you're using TypeScript (or JavaScript with JSDoc type annotations) to...
Read more >svelte - Vite+SvelteKit Build Failing - Stack Overflow
Edit: Vite 3.1.0 is out now, if you just npm update the project it should be fine. Original answer: This is because in...
Read more >Learn How SvelteKit Works As a Framework - Joy of Code
The svelte-kit and vite binaries are under node_modules/.bin that get executed when you run the development server and if you open the file...
Read more >TypeScript support in Svelte - Learn web development
npx degit sveltejs/template svelte-typescript-app cd svelte-typescript-app ... check command being run inside vs code showing type error, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@benmccann I think you’re right about this being an upstream issue. As a temporary workaround setting your vite config to the following allows it to build.
I found it in the migration guide. https://vitejs.dev/guide/migration.html#ssr-changes
adding another two errors from Discord:
(still waiting for second error)