Nuxt Content 3.0 breaks Nuxt Layer file resolution
Environment
Working directory:
- Operating System: Darwin
- Node Version: v22.11.0
- Nuxt Version: 3.15.2
- CLI Version: 3.20.0
- Nitro Version: 2.10.4
- Package Manager: [email protected]
- Builder: -
- User Config: devtools, modules, content, app, css, build, nitro, compatibilityDate
- Runtime Modules: @nuxt/[email protected], @nuxtjs/[email protected]
- Build Modules: -
👉 Report an issue: https://github.com/nuxt/nuxt/issues/new?template=bug-report.yml 👉 Suggest an improvement: https://github.com/nuxt/nuxt/discussions/new 👉 Read documentation: https://nuxt.com
Reproduction
- Initialize Nuxt Layer Starter Template:
npx nuxi init --template layer nuxt-layer - Add Nuxt Content:
npm install @nuxt/content - Add Nuxt Content module to Nuxt Config:
export default defineNuxtConfig({
...
modules: ['@nuxt/content']
...
})
When you run the app, notice that the settings found in .playground/app.config.ts are not overriding the settings from the root app.config.ts file. If you remove the Nuxt Content module from the Nuxt Config, everything works as expected.
This breaks tailwind.config.js from Nuxt Tailwind CSS as well.
Describe the bug
When you add Nuxt Content as a module when authoring a Nuxt Layer, it breaks file resolutions.
Examples of broken files:
app.config.ts tailwind.config.js
Additional context
There doesn't seem to be an easy way to quickly create reproductions for Nuxt Layers that I could find. That is why the reproduction is more manual in nature.
Logs
On a related note, the Nuxt Content example on the Nuxt Tailwind CSS website is completely broken:
https://tailwindcss.nuxtjs.org/examples/content
On this I am getting this log
WARN [nuxt] Failed to stringify dev server logs. Received DevalueError: Cannot stringify a function. You can define your own reducer/reviver for rich types following the instructions in https://nuxt.com/docs/api/composables/use-nuxt-app#payload.
WARN [Vue warn]: Failed to resolve component: ContentDoc
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.
at <[...slug] onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< undefined > >
at <Anonymous key="/blog/some" vnode= { __v_isVNode: true,
__v_skip: true,
type:
{ setup: [Function (anonymous)],
ssrRender: [Function: _sfc_ssrRender],
__file: '/home/orinda/Desktop/vite-content/pages/blog/[...slug].vue' },
props:
{ onVnodeUnmounted: [Function: onVnodeUnmounted],
ref:
RefImpl {
dep: [Dep],
__v_isRef: true,
__v_isShallow: false,
_rawValue: undefined,
_value: undefined } },
key: null,
WARN [nuxt] Failed to stringify dev server logs. Received DevalueError: Cannot stringify a function. You can define your own reducer/reviver for rich types following the instructions in https://nuxt.com/docs/api/composables/use-nuxt-app#payload.
Seems like going back to lower version <3.x.x seems to be working
This is due to a side-effect of Nuxt Content v3. And fixed by https://github.com/nuxt/content/commit/b4e7dec2a96c02ec19125af602766bfa04ce6b14
Until next release, you can try using the commit release
npm i https://pkg.pr.new/@nuxt/content@b4e7dec
I used the lower version <3of it and it's working. It could not even load the <ContentDoc/> component. If it's fixed then it's great news :)
I used the lower version
<3of it and it's working. It could not even load the<ContentDoc/>component. If it's fixed then it's great news :)
ContentDoc has been removed in Nuxt Content 3. Its no longer supported: https://content.nuxt.com/docs/getting-started/migration#components
The issue found in this ticket is different.
This is due to a side-effect of Nuxt Content v3. And fixed by b4e7dec
Until next release, you can try using the commit release
npm i https://pkg.pr.new/@nuxt/content@b4e7dec
I noticed that Nuxt Content v3 breaks Nuxt UI Pro 1.x.x. I assume that's caused by the same issue, as Nuxt UI Pro is loaded as a layer?
I noticed that Nuxt Content v3 breaks Nuxt UI Pro 1.x.x. I assume that's caused by the same issue, as Nuxt UI Pro is loaded as a layer?
Yes UI Pro 1.x is a Nuxt layer and this side-effect might cause issues.
I experienced this too after upgrading.
.nuxt/content/components.ts was adding a path prefix to my nested layer components which broke the auto importing around the rest of the app.
The workaround for me was to define the components.dirs in each layer nuxt config (it's already in the root config in my project)
/layers/file/nuxt.config.ts
export default defineNuxtConfig({
components: {
dirs: [
{
path: '~~/layers/file/app/components',
pathPrefix: false,
},
],
},
Below is how my root nuxt config has always been, but Nuxt Content is now ignoring it
/nuxt.config.ts
components: {
dirs: [
{
path: '~/components',
pathPrefix: false,
},
{
path: '~~/layers/file/app/components',
pathPrefix: false, <-- this was already in my root config but is now being ignored by Nuxt Content
},
],
},
Below is how my root nuxt config has always been, but Nuxt Content is now ignoring it
What do you mean by Nuxt Content ignoring it? Do you mean that you can't use them in Vue files? or it happens only in the markdown files?
It is strange, Nuxt Content does not manipulate components dirs and only adds its own dir into this config.
Do you mind sharing a small reproduction?
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.
This issue was closed because it has been stalled for 30 days with no activity.