Skip to content
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

dev server hangs on initial load when importing from #components #20272

Closed
danielroe opened this issue Apr 14, 2023 · 4 comments · Fixed by vitest-dev/vitest#3196
Closed

dev server hangs on initial load when importing from #components #20272

danielroe opened this issue Apr 14, 2023 · 4 comments · Fixed by vitest-dev/vitest#3196

Comments

@danielroe
Copy link
Member

danielroe commented Apr 14, 2023

My dev server hangs on specific routes on page reload when I import and use components imported from #components. It seems like a Vite issue, but if I import the same component from it's direct location the issue is gone. It also applies to built-in components like NuxtLink.

I was able to create a small reproduction of the issue, you can find it here: https://stackblitz.com/edit/nuxt-starter-azudzq?file=pages%2Findex.vue

Originally posted by @zsilbi in #13413 (comment)

Copy link
Member Author

Looking into this, I think this is likely due to the circular dependency of importing from #components within a component which will be exposed through #components. It works in build, and within dev mode you can workaround with this config:

export default defineNuxtConfig({
  vite: {
    devBundler: 'legacy',
  }
})

I think it might be an issue from vite-node (cc: @antfu).

@antfu
Copy link
Member

antfu commented Apr 14, 2023

I can confirm it's a bug of vite-node, still investigating

@antfu
Copy link
Member

antfu commented Apr 14, 2023

This bug can count as my top 5 most challenging bugs to debug I have ever encountered 🤣 But I enjoyed the process :P

Helpfully vitest-dev/vitest#3196 could solve it (it works now in repro).

It would be great if you could help test if the changes fix your issue in your real-world project.

You can build from the PR source, or I have pre-packed one for you to test:

https://temp.sh/BawXf/vite-node-0.30.1-3196a.tgz

Download it in your project root, and add

  "resolutions": {
    "vite-node": "./vite-node-0.30.1-3196a.tgz"
  }

To your package.json, run pnpm install or yarn install to apply it.

Thanks!

@zsilbi
Copy link

zsilbi commented Apr 14, 2023

This bug can count as my top 5 most challenging bugs to debug I have ever encountered 🤣 But I enjoyed the process 📦

I wish I had known this sooner.. that way I might have enjoyed that few hours a bit more that I spent trying to reproduce this. 🤣
But at least I am glad I could contribute to that list 😉

Helpfully vitest-dev/vitest#3196 could solve it (it works now in repro).

It would be great if you could help test if the changes fix your issue in your real-world project.

Great job! Works like a charm. thank you guys!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants