content icon indicating copy to clipboard operation
content copied to clipboard

Nuxt Content 3.0 breaks Nuxt Layer file resolution

Open sei-jdshimkoski opened this issue 1 year ago • 11 comments

Environment

Working directory: 1:15:52 PM Nuxt project info: (copied to clipboard) nuxi 1:15:52 PM


  • 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

  1. Initialize Nuxt Layer Starter Template: npx nuxi init --template layer nuxt-layer
  2. Add Nuxt Content: npm install @nuxt/content
  3. 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


sei-jdshimkoski avatar Jan 22 '25 18:01 sei-jdshimkoski

On a related note, the Nuxt Content example on the Nuxt Tailwind CSS website is completely broken:

https://tailwindcss.nuxtjs.org/examples/content

sei-jdshimkoski avatar Jan 23 '25 01:01 sei-jdshimkoski

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

forinda avatar Jan 23 '25 13:01 forinda

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

farnabaz avatar Jan 23 '25 13:01 farnabaz

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 :)

forinda avatar Jan 23 '25 13:01 forinda

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.

sei-jdshimkoski avatar Jan 23 '25 14:01 sei-jdshimkoski

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?

vernaillen avatar Jan 26 '25 08:01 vernaillen

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.

farnabaz avatar Jan 27 '25 16:01 farnabaz

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
      },
    ],
  },

alexcroox avatar Jan 31 '25 09:01 alexcroox

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?

farnabaz avatar Jan 31 '25 10:01 farnabaz

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.

github-actions[bot] avatar Feb 26 '26 13:02 github-actions[bot]

This issue was closed because it has been stalled for 30 days with no activity.

github-actions[bot] avatar Mar 28 '26 14:03 github-actions[bot]