Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

package.json name paths not included #182

Open
cjhines opened this issue Nov 14, 2018 · 5 comments
Open

package.json name paths not included #182

cjhines opened this issue Nov 14, 2018 · 5 comments
Labels
bug core dependency tree generation

Comments

@cjhines
Copy link

cjhines commented Nov 14, 2018

Paths using the name of my root directory package.json aren't included in dependency calculations

package.json:

{
  "name": "myproject",
  "version": "0.0.1",
...
}

Upon calling
madge --orphans --basedir ./ ./ or
madge --orphans ./
it lists a file as an orphan: src/services/Logger.js

This file isn't an orphan, however its dependant is using the package name in the import:
import Logger from 'myproject/src/services/Logger'

.madgerc:

{
  "detectiveOptions": {
    "es6.mixedImports": "true"
  },
  "includeNpm": "true",
}
@mrjoelkemp
Copy link
Contributor

This still might be unsupported at the commonjs resolution layer, but your madgerc might have a bug (may or may not fix it): "es6.mixedImports": true should be es6: { mixedImports: true }. Let me know if that fixes the issue.

@cjhines
Copy link
Author

cjhines commented Nov 14, 2018

Thanks for the correction. Unfortunately it seems to have the same output.

{
  "detectiveOptions": {
    "es6": { "mixedImports": true }
  },
  "includeNpm": true
}

@mrjoelkemp
Copy link
Contributor

Thanks for confirming! Assuming that's a valid import (curious why you need to qualify that import with the package name), there must be support for that missing in the node-filing-cabinet package. That package's commonjs resolution algorithm relies on the 'resolve' package. Is there something that we're not supplying there to make this work?

You can hack filing-cabinet in your node_modules folder to see what a fix could be.

@andersonaddo
Copy link

Sorry to revive this thread, but I'm wondering if there's been any development regarding this issue? I'm facing the same problem.

Here's my masgerc file:

{
	"tsConfig": "./jsconfig.json",
    "detectiveOptions": {
		"es6": {
			"mixedImports": true
		}
	},
    "includeNpm": true
}

and here's my jsconfig file:

{
    "compilerOptions": {
        "target": "ES6",
        "module": "commonjs",
        "baseUrl": ".",
        "paths": {
            "reusables/*": ["#reusableComponents/*"],
            "screens/*": ["#screens/*"],
            "styling/*": ["#styling/*"],
            "utils/*": ["#constants/*"],
            "media/*": ["_media/*"]
        }
    },
    
    "exclude": [
        "node_modules",
    ]
}

@PabloLION PabloLION added core dependency tree generation bug labels Jan 29, 2023
@PabloLION
Copy link
Collaborator

If this bug do exist, it's similar to #158 . I reckon we should solve them in a same PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug core dependency tree generation
Projects
None yet
Development

No branches or pull requests

4 participants