Open CaitlinWeb opened 5 years ago
Were you able to solve this? I haven't tried what I'm about to suggest but..
There seems to be a config option in madge called webpackConfig
. This should point to a webpack config. I would try extracting the webpack config that is in the next.config.js into its own file. And then import that config in next.config.js and also point to that config in madge so you can use madge to detect circular references
Were you able to solve this?
I'm no longer working on a Next.js project and, no, I never solved this. I suspect you're right about using webpackConfig
with the next.config.js, though.
I know this is an old thread, but in case anyone else comes across this, doing the suggestions from the previous comments seems to work as expected for me:
next.config.js
:
const nextConfig = {
webpack: config => {
madge("src", {
tsConfig: "./tsconfig.json",
webpackConfig: config,
fileExtensions: ["js", "tsx", "ts"],
}).then(res => console.log(res.circular()));
return config;
}
}
I would like to list/graph dependencies for a Next.js project. Next.js comes with Webpack and Babel. You can also extend their configurations.
Webpack is extended with a
next.config.js
file and Babel with a.babelrc
file.Here is my
next.config.js
with irrelevant bits removed:Here's the relevant parts of my
.babelrc
:Problem
There is no central "app.js" but rather pages (located in
pages/
). Running madge on a page results in lots of warnings for ignored files or directories. Here's a debug for one of my pages that has dependencies incomponents/
(with filepaths removed):I think the relevant part is "cabinet could not resolve components". Why does this happen and how can I use Madge for Next.js pages/apps?