Skip to content

Build fails after upgrading to vite > 2.9.0 #5600

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

Closed
lmtr0 opened this issue Jul 18, 2022 · 6 comments
Closed

Build fails after upgrading to vite > 2.9.0 #5600

lmtr0 opened this issue Jul 18, 2022 · 6 comments

Comments

@lmtr0
Copy link

lmtr0 commented Jul 18, 2022

Describe the bug

It's expect to build the project when, in a dependency, I export a svelte component, and then import that component. However the build fails with this error:

500

Unknown file extension ".svelte" for /home/projects/vitejs-vite-14hxgx/node_modules/@higenku/theme/src/footer/Footer.svelte

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".svelte" for /home/projects/vitejs-vite-14hxgx/node_modules/@higenku/theme/src/footer/Footer.svelte
    at get (https://vitejs-vite-14hxgx.w-corp.staticblitz.com/blitz.9dc2007b053e3e7ca4daf0ec1a74b5c3910935fe.js:6:292488)
    at instantiateModule (file:///home/projects/vitejs-vite-14hxgx/node_modules/vite/dist/node/chunks/dep-1513d487.js:50382:13)
    at <anonymous> (<anonymous>)

You can check it yourself here

this should have fixed the problem, however It hasn't

Reproduction

Open https://stackblitz.com/edit/sveltekiterror and see the error yourself

  1. install the next version of my theme @higenku/[email protected] other versions work because you have to import the components yourself.
  2. Import a component (I only exported the footer ones to test the vite 3 update)
<script lang="ts">
import {Footer} from "@higenku/theme"
</script>

Logs

Unknown file extension ".svelte" for /home/projects/sveltekiterror/node_modules/@higenku/theme/src/footer/Footer.svelte
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".svelte" for /home/projects/sveltekiterror/node_modules/@higenku/theme/src/footer/Footer.svelte
    at get (https://sveltekiterror.w-corp.staticblitz.com/blitz.9dc2007b053e3e7ca4daf0ec1a74b5c3910935fe.js:6:292488)
    at instantiateModule (file:///home/projects/sveltekiterror/node_modules/vite/dist/node/chunks/dep-1513d487.js:50382:13)

System Info

System:
    OS: Linux 5.15 undefined
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
    Memory: 6.41 GB / 15.36 GB
    Container: Yes
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.4.0 - /usr/local/bin/node
    npm: 8.12.1 - /usr/local/bin/npm
  Browsers:
    Chromium: 103.0.5060.114
    Firefox: 102.0.1

Severity

blocking an upgrade

Additional Information

No response

@dominikg
Copy link
Member

This appears to be a packaging issue with the library you mention @higenku/theme

Looking at the content of node_modules/@higenku/theme/package.json it seems like there is no "svelte" field that helps to resolve imports of svelte sources.

Adding "svelte":"src/index.js" to that and restarting the dev server fixes the problem for me.

I highly recommend you check out svelte-kit package https://kit.svelte.dev/docs/packaging . Even though it is still in beta, it makes it a lot easier to release svelte libraries.

@lmtr0
Copy link
Author

lmtr0 commented Jul 18, 2022

I'm Investigating, but it seems to work better

@lmtr0
Copy link
Author

lmtr0 commented Jul 18, 2022

Ok, now there is another error:

Error: failed to load module for ssr: /home/me/repo/sdks/theme/node_modules/.pnpm/@[email protected]/node_modules/@higenku/theme/src/index.js
    at instantiateModule (file:///home/me/repo/sdks/theme/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-1513d487.js:50250:15)

I pushed the code to the repo and corrected the package 0.6.9-next is packaged with svelte-kit package

@dominikg
Copy link
Member

dominikg commented Jul 19, 2022

This tracker is not used for support/setup questions. It looks like this isn't a bug in kit.

Please open a discussion or ask for help in discord (#svelte-kit) to get this resolved.

@dominikg dominikg closed this as not planned Won't fix, can't repro, duplicate, stale Jul 19, 2022
@dominikg dominikg removed the vite label Jul 19, 2022
@lmtr0
Copy link
Author

lmtr0 commented Jul 19, 2022

Ok, thx

@lmtr0
Copy link
Author

lmtr0 commented Jul 19, 2022

I don't know how or why, but I started the project all over again and it worked

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

3 participants