GithubHelp home page GithubHelp logo

Comments (12)

kevinmarrec avatar kevinmarrec commented on May 29, 2024 4

Hello @HerrBertling , I found what cause the issue, and is is not related to @nuxt/components :)

Here's an image with a color scheme, RED, BLUE & PURPLE that will explaings things in a convenient way with my following explanations :

image

First (RED), it's the big hint of the issue. Indeed, you're requiring image this way :

require(`~/${variable}`)

which, according to https://webpack.js.org/guides/dependency-management/#require-with-expression, will make Webpack create a regex that match all subsequent files (^\.\/.*$) to be handled by some loader, which means all your files in your source folder which is also your root folder (as Nuxt default source folder is root one).

Furthermore (BLUE), as Webpack has no information about the extension of what you're requiring, it will likely go through the same context where it has found the require, which means a .vue file, which are theirselves handled by a combination of :

  • vue-loader
  • @nuxt/components custom loader, if you're using @nuxt/components
  • babel-loader

Finally (PURPLE), the last output of the error is just the webpack entries, which includes installComponents when using @nuxt/component (https://github.com/nuxt/components/blob/master/src/index.ts#L120)

Ultimately, I've created a CSB to reproduce the issue when using ~/${variable}, which includes a failing and working version of require : https://codesandbox.io/s/infallible-mcnulty-uyhhw.

I invite you to look at it so you can guess what to do in your project to fix all your require statements (hint: you'll unfortunately need to change your markdown metadatas as well 😁)

Hope it helped :)

from components.

HerrBertling avatar HerrBertling commented on May 29, 2024 2

Oh wow, thank you so much @kevinmarrec! I’ll have a look πŸ˜ŠπŸ‘πŸ™πŸΌ

And I’m sure I can find a way to automate the markdown changes πŸ˜…

from components.

Atinux avatar Atinux commented on May 29, 2024 1

@kevinmarrec if you have time to look at this it would be great ❀️

from components.

kevinmarrec avatar kevinmarrec commented on May 29, 2024 1

@HerrBertling Sorry for the delay, I've been just diving into your issue today.

If you look closely, your issues all come from .vue files which contain require('~/somePath), and with @nuxt/components it tries to requiring it at runtime but as it's runtime and not webpack build, it doesn't know how to load these files (that's why it says You may need an appropriate loader to handle this file type)

I'm not sure how to go deeper to find a fix, I think Webpack expertise from @pi0 may help

from components.

pi0 avatar pi0 commented on May 29, 2024 1

You can also add me to the repo to check 😊

from components.

Atinux avatar Atinux commented on May 29, 2024

Hi @HerrBertling

Could you also show your directory structure please? (Only directories should be enough)

from components.

HerrBertling avatar HerrBertling commented on May 29, 2024

Sure!

It's justβ„’ the basic setup + a content folder since I'm using nuxt/content 😊

image

from components.

HerrBertling avatar HerrBertling commented on May 29, 2024

@Atinux my repo is private right now but I can give you access if you want to have a look, there's no super secret stuff in there πŸ˜†

from components.

HerrBertling avatar HerrBertling commented on May 29, 2024

I've been working with this for a few days and the content grew quite a bit since then. This lead to webpack basically freaking out by now because it throws so many warnings about "unknown" file formats. Any news here? :-|

Oh, and I'm on the latest nuxt version, so I've removed the package from the buildModules :)

from components.

HerrBertling avatar HerrBertling commented on May 29, 2024

Any update on this? I've updated all nuxt-related packages right now and thought that maybe #70 would in some way help here, but to no avail. This is really annoying 😞

from components.

kevinmarrec avatar kevinmarrec commented on May 29, 2024

@HerrBertling Is there a way you can do a minimal repository reproduction (the less files there are, easier is the debug :D) ? Or give me access to your project so I can take a look :)

from components.

HerrBertling avatar HerrBertling commented on May 29, 2024

@HerrBertling Is there a way you can do a minimal repository reproduction (the less files there are, easier is the debug :D) ? Or give me access to your project so I can take a look :)

Sure! Adding you :)

from components.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.