Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

Failed to resolve async components, failure in references to static folder #109

Open
Tahul opened this issue Mar 17, 2021 · 5 comments
Open
Labels
bug Something isn't working

Comments

@Tahul
Copy link
Contributor

Tahul commented Mar 17, 2021

Versions

nuxt-vite: 0.0.36
nuxt: 2.16.0-26932357.0a988668 (nuxt-edge)

Reproduction

https://codesandbox.io/s/nifty-jones-p9kqf?file=/components/Logo.vue

Description

Had an issue with SVG imports from tags, tried to resolve it using:

vite: {
    publicDir: resolve(__dirname, 'static')
  }

Fixed the imports, but I still have failures to resolve components, marked by these error messages:

[Vue warn]: Failed to resolve async component: () => import('/@fs/Users/tahul/Projets/nuxt/nuxtjs.com/components/templates/Home/HomeDiscover.vue').then(c => c.default || c)
Reason: TypeError: Failed to fetch dynamically imported module: http://localhost:3000/@fs/Users/tahul/Projets/nuxt/nuxtjs.com/components/templates/Home/HomeDiscover.vue

I don't know if this is an issue or just a misconfiguration from my side, we investigated with @farnabaz but couldn't find the source of this problem.

Also tried installing @nuxt/components just to be sure it wasn't a problem from that side and it didn't solved the problem.

Thank you a lot for your help, amazing work on nuxt-vite, can't wait to use it on this project. 🚀

@Tahul Tahul added the bug Something isn't working label Mar 17, 2021
@Tahul
Copy link
Contributor Author

Tahul commented Mar 22, 2021

I've updated the reproduction to a CodeSandbox example.

You can visit it here.

@Tahul
Copy link
Contributor Author

Tahul commented Mar 22, 2021

The problem seem to happen when the src attribute from an image is used to point to an image directly:

<img src="/img/test.svg" />

^ This seem to be throwing an error.

<template>
  <img :src="src" />
</template>

<script>
export default {
  setup() {
    return {
      src: '/img/test.svg'
    }
  }
}
</script>

^ This seem to work.

@Tahul
Copy link
Contributor Author

Tahul commented Mar 22, 2021

I fixed it temporarily on my repository by doing that:

<img src="~/static/img/test.svg" />

I think this is a bug, or at least an update in the behavior that needs to be document on nuxt-vite docs.

@pi0
Copy link
Member

pi0 commented Mar 22, 2021

Hi dear @Tahul. Indeed this is related to #7. I think at the moment using nuxt-vite is safe by disabling ssr.

PR welcome to update this in readme checklist.

@Tahul
Copy link
Contributor Author

Tahul commented Mar 22, 2021

@pi0 ; #111

Here is a PR including explanations to work around this issue until this is fixed.

I added it to the "Common issues" section of nuxt-vite documentation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants