Giter VIP home page Giter VIP logo

Comments (12)

Jym77 avatar Jym77 commented on May 24, 2024 2

…which should make it easy to fix 😁
The latest release of madge, v6.1.0 is from June '23.
dependency-tree has been updated to v10.0.9 in October '23.

So, I assume that simply making a new release would solve the problem… <= @pahen

from madge.

kirbysayshi avatar kirbysayshi commented on May 24, 2024 2

I can confirm that upgrading dependency-tree >= 10 fixes the issue! Madge 6.1.0. Since I'm using pnpm I did the following in my package.json:

 "overrides": {
      "madge>dependency-tree@<10": "10"
    }

I went from 1000s of skipped files to 7!

from madge.

Alegiter avatar Alegiter commented on May 24, 2024 1

+1

Adding "/index" to some path resolves madge skipping files

I have file extract.test.ts with imports:

import { ... } from "../../model"
import { ... } from "./extract"

And my madge result with --json for this file is:

{
  "call.ts": [],
  "extract.test.ts": [
    "extract.ts"
  ],
  "extract.ts": [
    "call.ts"
  ]
}

But if I change model import for ../../model/index:

{
  "../../model/***.ts": [],
  "../../model/index.ts": [
    "../../model/***.ts",
  ],
  "call.ts": [],
  "extract.test.ts": [
    "../../model/index.ts",
    "extract.ts"
  ],
  "extract.ts": [
    "call.ts"
  ]
}

from madge.

Jym77 avatar Jym77 commented on May 24, 2024 1

Is there anything else you did to get it to work?

Since I am only at the "experiment and play" step, I brutally edited madge.js in my node_modules to accept a DependencyTree parameter instead of using its own, installed 10.0.9 locally, and injected it that way.
Not my proudest hack 🙈
And definitely won't work once I try to actually use this… Or when try to use madge from command line rather than a script.

from madge.

aleksanderd avatar aleksanderd commented on May 24, 2024

same here, index.ts files seems to be ignored: all imports of dirs with index.ts are skipped(

is there any way to fix it?

from madge.

Jym77 avatar Jym77 commented on May 24, 2024

Facing the same issue and digging a bit.
I think it is a problem with dependency-tree, likely dependents/node-dependency-tree#118, which Madge uses to get its dependencies. At least the "skipping" message comes from there.

Trying to dig further into dependency-tree to see whether this is just an option to pass or a deeper issue…

from madge.

Jym77 avatar Jym77 commented on May 24, 2024

OK, I think this is a dependency-tree problem that was fixed in v10, madge is still running v9 and thus has the problem.

  • Adding a console.log statement to see the result of the call to DependencyTree at https://github.com/pahen/madge/blob/master/lib/tree.js#L121, I do not get the dependency:
    {
      '/mnt/c/Projects/a11y/alfa/packages/alfa-css/src/calculation/index.ts': {}
    }
    
  • Calling, with the same config, DependencyTree directly, and showing the result,
    • with v10.0.1 to v10.0.9 (somehow, v10.0.0 crashes), I get the dependency:
      {
        '/mnt/c/Projects/a11y/alfa/packages/alfa-css/src/calculation/index.ts': {
          '/mnt/c/Projects/a11y/alfa/packages/alfa-css/src/calculation/math-expression/index.ts': {
            '/mnt/c/Projects/a11y/alfa/packages/alfa-css/src/calculation/math-expression/math.ts': [Object]
          }
        }
      }
      
    • same with v9.0.0 (no other v9.* version) of dependency-tree, I do not get the dependency:
      {
        '/mnt/c/Projects/a11y/alfa/packages/alfa-css/src/calculation/index.ts': {}
      }
      

I'm not really able to see which update of dependency-tree did the trick, but it seems to be the root cause…
https://github.com/dependents/node-dependency-tree/releases/tag/v10.0.0

from madge.

bestickley avatar bestickley commented on May 24, 2024

@Jym77, I ran into this same issue and I used package.json#pnpm.overrides to enforce [email protected] to be used by madge and it still did not work for me :( Import identifiers that had implicit "index" files still showed up as warnings in madge because they could not be resolved.
Example output of madge with dependency-tree@10:

pnpx madge --warning --circular ./src/**/*
 WARN  1 deprecated subdependencies found: [email protected]
Packages: +179
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 178, reused 178, downloaded 0, added 179, done
Processed 57 files (1.2s) (15 warnings)

✔ No circular dependency found!

✖ Skipped 15 files

drizzle-orm/postgres-js
drizzle-orm
postgres
@aws-sdk/rds-signer
@aws-sdk/client-secrets-manager
drizzle-orm/pg-core
@aws-lambda-powertools/logger
drizzle-kit
drizzle-orm/postgres-js/migrator
../adapters/secondary
./types
zod
../base
./adapters/secondary

Then if I update all import specifiers with /index:

pnpx madge --warning --circular ./src/**/*

> @lh/[email protected] check-circular-dependencies /Users/stickb/Code/dos/lighthouse/core
> madge --circular --warning src/**/*

Processed 40 files (1s) (10 warnings)

✖ Found 1 circular dependency!

1) adapters/secondary/db-adapter.ts > modules/new-user/index.server.ts > modules/new-user/update-new-user.usecase.ts > modules/new-user/new-user.repo.ts > adapters/secondary/index.ts

✖ Skipped 10 files

postgres
@aws-sdk/rds-signer
@aws-sdk/client-secrets-manager
drizzle-kit
drizzle-orm/postgres-js
drizzle-orm/postgres-js/migrator
drizzle-orm
zod
drizzle-orm/pg-core
@aws-lambda-powertools/logger

Is there anything else you did to get it to work?

from madge.

Jym77 avatar Jym77 commented on May 24, 2024

For yarn, the workaround in package.json is:

"resolutions": {
    "dependency-tree": "^10.0.9"
  }

from madge.

Vovan-VE avatar Vovan-VE commented on May 24, 2024

Thanks for workaround!
npm:

  "overrides": {
    "madge": {
      "dependency-tree": "^10"
    }
  },

from madge.

Jym77 avatar Jym77 commented on May 24, 2024

FYI, updating to madge 7.0.0 fixed this for me (no need for custom resolution anymore). The correct dependency-tree is now a dependency 🎉

from madge.

pahen avatar pahen commented on May 24, 2024

FYI, updating to madge 7.0.0 fixed this for me (no need for custom resolution anymore). The correct dependency-tree is now a dependency 🎉

Nice :)

from madge.

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.