nuxt: Circular dependency in nuxt with nitropack
Environment
- Operating System:
Windows_NT - Node Version:
v16.17.0 - Nuxt Version:
3.1.2 - Nitro Version:
2.1.1 - Package Manager:
yarn@1.22.18 - Builder:
vite - User Config:
- - Runtime Modules:
- - Build Modules:
-
and stackblitz
Reproduction
https://stackblitz.com/edit/nuxt-starter-kqf57y?file=README.md
Describe the bug
Hi 👋 ! Nuxt build in 3.1.2 logs a warning about circular dependency
Additional context
No response
Logs
`
Export "useNitroApp" of module "node_modules/nitropack/dist/runtime/app.mjs" was reexported through module "node_modules/nitropack/dist/runtime/index.mjs" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.
Either change the import in "node_modules/nuxt/dist/core/runtime/nitro/renderer.mjs" to point directly to the exporting module or reconfigure "output.manualChunks" to ensure these modules end up in the same chunk.
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 7
- Comments: 43 (17 by maintainers)
Thanks! Can be reproduced with a clean starter running
npm buildIndeed, it’s still present in 3.2.0, but it should be resolved in the edge channel, or in the next release.
Did you guys try this? https://github.com/nuxt/nuxt/pull/22785#issuecomment-1697171634
import { useNitroApp } from '#internal/nitro/app'Thank you for clarification 🙂
Hi @manniL My code was working fine from early versions of Nuxt3 up to v3.1.2. The warning message started after updating to Nuxt 3.2.0 and I think I’m not the only one. If some more people could verify that would be great!
https://github.com/StefanoTesla/nuxtproject
Nuxt 3.2.0 dependency use
"nitropack": "^2.2.1""node_modules/nuxt": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/nuxt/-/nuxt-3.2.0.tgz", "integrity": "sha512-8jAYyjU1Ht+MXPLLDIdIUmV56KiI0g7KusKwzvqn+vlzyCNtSHg2W/VBCGw5QWplb/MXruogcMl2sDenlQRZFg==", "dev": true, "dependencies": { [..] "nitropack": "^2.2.1", "nuxi": "3.2.0", [..] },Windows_NTv19.4.03.2.02.2.1npm@9.4.2vitepages,css,modules,i18n@nuxtjs/i18n@8.0.0-beta.9-27926914.891e694-I continue to get the message
Nuxt project info: 09:03:47
Windows_NTv19.4.03.1.22.2.1npm@9.4.2vitepages,css,modules,i18n@nuxtjs/i18n@8.0.0-beta.9-27926914.891e694-@fabianwohlfart This indeed suppressed the error
please open a new issue with reproduction 🙏🏼
I can reproduce with Nuxt 3.10.1, Nitropack 2.8.1
Here is the link to reproduction: https://codesandbox.io/p/sandbox/quirky-lovelace-pd9l7w
Yes this can be closed out again. Sorry for the confusion
Ah I found the issue. We had a config that was being imported into our core layer’s app config. That config was importing composable functions. When I commented those out the error went away. I’m going to rework the config so that we don’t directly import those composables into the config. Just a casualty of converting a lot of JSON based configs into one main app.config.ts file.
Is there a recent minimal reproduction based on either Nuxt or Nitro latest versions?
Given the detailed description, I reopen this issue.
I’m seeing a similar circular dependency in Nuxt 3.8.2 with Nitro 2.8.1 (and Nuxt 3.8.0 before I tried an update) where
useRuntimeConfigis being flagged.And these errors when I run the build command
At first, I suspected this was due to a use of
useRuntimeConfigin a Nitro hook plugin. But I rewrote that plugin to remove the use of the runtime config, and it was still being flagged in the build and when trying to run dev.Thanks for the report. Raised https://github.com/nuxt/nuxt/pull/22785.
Fix is released in nitro 2.2.1 but nuxt 3.2.0 use nitro 2.2.0
There is similar issue raised at nuxt content repo
this might be related, i’m using 3.1.2 while @Barbapapazes is using 3.1.1. I tried to use
useHeadin a component and then build a project but this did not trigger the warning withuseHeadRelated https://github.com/nuxt/nuxt/issues/18766 (?)