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

Auto Imports don't work as expected with SubFolders #14990

Closed
f3oall opened this issue Sep 20, 2022 · 4 comments · Fixed by nuxt/framework#7713
Closed

Auto Imports don't work as expected with SubFolders #14990

f3oall opened this issue Sep 20, 2022 · 4 comments · Fixed by nuxt/framework#7713

Comments

@f3oall
Copy link

f3oall commented Sep 20, 2022

Environment

Nuxt project info: 22:30:41


  • Operating System: Linux
  • Node Version: v18.9.0
  • Nuxt Version: 3.0.0-rc.11
  • Nitro Version: 0.5.4
  • Package Manager: npm@8.19.1
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://github.com/f3oall/nuxt-auto-import-subfolders

Run npm run dev and see the errors.

Describe the bug

When auto imports are enabled and when the components folder contains two vue files with the same name, if you try to use one of them inside the other, you will get render errors. Seems like nuxt consider it as an infinite loop.

image

Error:

[nitro] [dev] [unhandledRejection] RangeError: Maximum call stack size exceeded
    at Object.get (/home/f3oall/coding/js/nuxt/nuxt-auto-import-error/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:3238:14)
    at Object.set (/home/f3oall/coding/js/nuxt/nuxt-auto-import-error/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:3151:14)
    at Object.defineProperty (/home/f3oall/coding/js/nuxt/nuxt-auto-import-error/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:3200:18)
    at Function.defineProperty (<anonymous>)
    at Object.def (/home/f3oall/coding/js/nuxt/nuxt-auto-import-error/node_modules/@vue/shared/dist/shared.cjs.js:568:12)
    at Object.markRaw (/home/f3oall/coding/js/nuxt/nuxt-auto-import-error/node_modules/@vue/reactivity/dist/reactivity.cjs.js:973:12)
    at setupStatefulComponent (/home/f3oall/coding/js/nuxt/nuxt-auto-import-error/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7098:33)
    at setupComponent (/home/f3oall/coding/js/nuxt/nuxt-auto-import-error/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7064:11)
    at renderComponentVNode (/home/f3oall/coding/js/nuxt/nuxt-auto-import-error/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:172:17)
    at Module.ssrRenderComponent (/home/f3oall/coding/js/nuxt/nuxt-auto-import-error/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:612:12)

Additional context

No response

Logs

No response

@danielroe
Copy link
Member

This is Vue core behaviour, rather than Nuxt's, and is deliberate. It assumes that a component can reference itself by means of its own file name.

See https://vuejs.org/api/sfc-script-setup.html#recursive-components

@danielroe danielroe closed this as not planned Won't fix, can't repro, duplicate, stale Sep 20, 2022
@danielroe danielroe reopened this Sep 20, 2022
@danielroe

This comment was marked as duplicate.

1 similar comment
@danielroe
Copy link
Member

Reopening to see if there is a way we can or should work around this.

@f3oall
Copy link
Author

f3oall commented Sep 20, 2022

"Note this has lower priority than imported components".

So as far as I understand by default Vue gives priority to imports rather than inferred names. In Nuxt's case, it should give priority to auto-imports since it's an implicit import (still import).

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.

2 participants