Comments (12)
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 :
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.
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.
@kevinmarrec if you have time to look at this it would be great β€οΈ
from components.
@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.
You can also add me to the repo to check π
from components.
Could you also show your directory structure please? (Only directories should be enough)
from components.
Sure!
It's justβ’ the basic setup + a content
folder since I'm using nuxt/content
π
from components.
@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.
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.
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.
@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 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)
- Render function or template not defined in component HOT 9
- feat: get list of components at runtime HOT 5
- Dependency Dashboard
- Since updating from Nuxt 2.15.4 to 2.15.8, auto import components no longer work HOT 15
- Support custom resolvers HOT 1
- Problem after 2.1.8, app breaks if using lodash as plugin HOT 6
- Auto import components with nested directory cant use go to define on Visual Studio Code HOT 3
- Size after building is bigger with `components: true`
- Can a library module still import components manually? HOT 1
- Autoloading breaks when file exports multiple components at once.
- Nuxt build fails when using yarn berry plug-n-play mode
- Production build with directories marked with `isAsync: false` imports components asynchronously HOT 2
- A way to get an array of all the components that are autoloaded
- How to have typescript inference with this? HOT 1
- How to avoid nuxt-i18n error when you doing testing with Jest?
- SCSS variables not working
- Nuxt 3.0.0 support HOT 1
- Component automatically introduces the generated component name.
- Remove suffix (.component.vue)
- How to use Lazy loading component when auto imports for component is disabled? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from components.