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

AMD not finding nested depedencies #67

Closed
OliverJAsh opened this issue Nov 2, 2015 · 8 comments
Closed

AMD not finding nested depedencies #67

OliverJAsh opened this issue Nov 2, 2015 · 8 comments

Comments

@OliverJAsh
Copy link
Contributor

Given:

// app.js
define(['a'], function (a) {
    console.log('a');
});
// a.js
define(['b'], function (b) {
    console.log('a');
});
// b.js
define([], function () {
    return {};
});

When I run:

// api.js
var madge = require('madge');
var dependencyObject = madge('app.js', {
    format: 'amd',
    findNestedDependencies: true
});
console.log(dependencyObject.tree);

The output is:

$ node api.js
{ app: [ 'a' ] }

How come madge is not finding the nested AMD dependencies?

@mrjoelkemp
Copy link
Contributor

findNestedDependencies seems to allow dependencies within a module to be found. For example:

define(['dep'], function() {
  // Lazy load a file
  require(['some_file'], function() {});
});

That option would allow some_file to show up in the dependency list. It sounds like you want the entire dependency tree to be traversed. We can likely integrate https://github.com/mrjoelkemp/node-dependency-tree for that purpose.

@OliverJAsh
Copy link
Contributor Author

It sounds like you want the entire dependency tree to be traversed

Yes, that's right. I would like to see a graph for my entire dependency tree.

@OliverJAsh
Copy link
Contributor Author

That's what I thought this module did—showed you the whole dependency tree?

@OliverJAsh
Copy link
Contributor Author

Any thoughts on it? @pahen @mrjoelkemp? I'm quite surprised it only shows one level of dependencies. Is that intentional?

@mrjoelkemp
Copy link
Contributor

The expectation of the api seems to be such that you pass in a directory path if you want a scan of all files to be included in the tree. Your usage only specifies a single file. If you need to specify just that one file, then recursively tracing the tree is one solution. Alternatively, you could look into running madge on the bundled/optimized output using the mainRequireModule setting.

@OliverJAsh
Copy link
Contributor Author

That helps, thanks!

On Tue, 1 Dec 2015, 12:11 Joel Kemp notifications@github.com wrote:

The expectation of the api seems to be such that you pass in a directory
path if you want a scan of all files to be included in the tree. Your usage
only specifies a single file. If you need to specify just that one file,
then recursively tracing the tree is one solution. Alternatively, you could
look into running madge on the bundled/optimized output using the
mainRequireModule setting.


Reply to this email directly or view it on GitHub
#67 (comment).

@mrjoelkemp
Copy link
Contributor

No problem! Safe to close this issue?
On Dec 1, 2015 8:30 AM, "Oliver Joseph Ash" notifications@github.com
wrote:

That helps, thanks!

On Tue, 1 Dec 2015, 12:11 Joel Kemp notifications@github.com wrote:

The expectation of the api seems to be such that you pass in a directory
path if you want a scan of all files to be included in the tree. Your
usage
only specifies a single file. If you need to specify just that one file,
then recursively tracing the tree is one solution. Alternatively, you
could
look into running madge on the bundled/optimized output using the
mainRequireModule setting.


Reply to this email directly or view it on GitHub
#67 (comment).


Reply to this email directly or view it on GitHub
#67 (comment).

@ainthek
Copy link

ainthek commented Jun 17, 2016

this LIMITATION of one level dependencies,
shell be clearly stated at the beginning of the readme.

I have also wasted some time for this, trying to use another tool (dependo) which is using your project.

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

No branches or pull requests

3 participants