Hey, first time using Madge so I admit I might have missed an important detail!
In my ESM Node project, I use the top-level package.json imports property to make certain import names accessible no matter what file I'm importing them from. For example:
import {openAggregate} from '#aggregate';
import {getColors} from '#colors';
...anywhere in my project at all! It makes keeping track of imports way easier, since I don't need to think how many levels deep the current JS file is nested, or where anything else is. (Plus I can move around the actual imported files and just update the corresponding record in package.json, instead of changing every single import, as long as the # name stays the same!)
But, I don't think Madge recognizes this syntax (and cross-references with package.json appropriately)? I created a graph using madge --image graph.svg src/upd8.js and it only contains nodes for the imports which use the normal from './write/build-modes/index.js' syntax (for example).
Unfortunately that means Madge really can't do anything for my project. Luckily my code doesn't really involve dynamic imports, so I could probably write a series of find-replaces that more or less swap out all the from '#aggregate'-style lines with the normal syntax, but that's a pretty inconvenient barrier for using Madge, obviously.
Hey, first time using Madge so I admit I might have missed an important detail!
In my ESM Node project, I use the top-level package.json
imports
property to make certain import names accessible no matter what file I'm importing them from. For example:This makes it so I can use this code...
...anywhere in my project at all! It makes keeping track of imports way easier, since I don't need to think how many levels deep the current JS file is nested, or where anything else is. (Plus I can move around the actual imported files and just update the corresponding record in package.json, instead of changing every single import, as long as the
#
name stays the same!)But, I don't think Madge recognizes this syntax (and cross-references with package.json appropriately)? I created a graph using
madge --image graph.svg src/upd8.js
and it only contains nodes for the imports which use the normalfrom './write/build-modes/index.js'
syntax (for example).Unfortunately that means Madge really can't do anything for my project. Luckily my code doesn't really involve dynamic imports, so I could probably write a series of find-replaces that more or less swap out all the
from '#aggregate'
-style lines with the normal syntax, but that's a pretty inconvenient barrier for using Madge, obviously.