https://github.com/ifiokjr/vite3-unknown-file-extension
sveltekit issue reproduction with vite3
https://github.com/ifiokjr/vite3-unknown-file-extension
Last synced: 3 months ago
JSON representation
sveltekit issue reproduction with vite3
- Host: GitHub
- URL: https://github.com/ifiokjr/vite3-unknown-file-extension
- Owner: ifiokjr
- License: mit
- Created: 2022-07-15T06:14:51.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-07-15T11:30:11.000Z (almost 3 years ago)
- Last Synced: 2025-01-14T10:57:13.487Z (5 months ago)
- Language: TypeScript
- Size: 122 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# failure to run sveltekit with vite3 in a TypeScript monorepo
Run the following to enable corepack and install all dependencies (using `pnpm`).
```bash
npm run bootstrap
```At this point you'll notice the `dist` folders is created in `packages/simple`. Take a look at `packages/simple/dist/index.esm.js`. It is a symlink which links to this source file `packages/simple/src/index.ts` during development. It is replaced with the bundled output during a build.
## Expected
There is a svelte app built with vite in the `/svelte` folder. It imports from the `simple` package in `svelte/src/App.svelte`. Running the following command works fine.
```bash
cd svelte
pnpm dev
```You will be able to access the URL without error http://localhost:5173/.
## Issue
The issue arises when using the same import in a sveltekit setup.
I've imported the `simple` package in `sveltekit/src/routes/index.svelte`. Running the following:
```bash
cd sveltekit
pnpm dev
```Results in the following error when navigating to the URL: http://localhost:5173/
```bash
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)
```## Workaround
The current solution is to downgrade the vite version to `[email protected]` and `@sveltejs/[email protected]`. You can test this out by running the following:
```bash
cd sveltekit-previous
pnpm dev
```Navigating to http://localhost:3000/ will work.