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

Support webpack's config.resolve.modules paths #75

Open
kevinokerlund opened this issue Nov 28, 2017 · 3 comments
Open

Support webpack's config.resolve.modules paths #75

kevinokerlund opened this issue Nov 28, 2017 · 3 comments

Comments

@kevinokerlund
Copy link

kevinokerlund commented Nov 28, 2017

In our source code, we have imports that do not have paths, and that are not node-modules. For example:

import 'special-library.lib.js'

Currently, when I try to get the dependency tree, this file shows up in the nonExistent array and is not resolved.


These libfiles are common library style files we use in our app that we don't want in node_modules. This is made possible by webpack's config.resolve.modules option:

resolve: {
    modules: {
        'node_modules',
        '_libs/' //this tells webpack to search in _libs for imports
    }
}

How can I get dependency-tree to understand my extra webpack modules?

@mrjoelkemp
Copy link
Collaborator

Hey @kevinokerlund! Thanks for contributing!

This is already handled here https://github.com/dependents/node-filing-cabinet/blob/f11d3229e718b57a8b2c8f0eb5e6c952c596cda7/index.js#L256-L268 if you provide a webpack config to dependency tree.

Can you let me know what your dependency-tree config looks like? Are you using this lib via https://github.com/pahen/madge?

It's either a configuration error or an intricate bug that needs to be fixed in the linked code above.

@kevinokerlund
Copy link
Author

kevinokerlund commented Nov 30, 2017

@mrjoelkemp, thanks for getting back to me. I went ahead and set up a [temporary repository](removed) with the most basic setup I could do to reproduce what I'm seeing if you want to run it for yourself.

I dove a bit into filing-cabinet and in my case, it is failing here: https://github.com/dependents/node-filing-cabinet/blob/f11d3229e718b57a8b2c8f0eb5e6c952c596cda7/index.js#L279

I found that it does work when I update internal-libs in the resolve.modules to:

modules: [
	'node_modules',
	'src/internal-libs' // prepended src/ 
]

but I feel that it's pretty common to have the resolve.modules the way I have it set.


For debugging purposes, I logged out lookupPath and partial in filing-cabinet, and the values were as follows in both cases:

lookupPath = /Users/my-user/Sandbox/dep-tree
partial    =  special.lib.js

@mrjoelkemp
Copy link
Collaborator

@kevinokerlund Thanks for the additional details. I haven't forgotten about this. Webpack resolution via enhanced-resolve was intentionally lagging behind due to their move to es6 and deprecation of older node versions without a major version bump.

I figured it would be good to finally try getting up to their most recent version. I did that within filing-cabinet but have some test issues to work out with mock-fs in upstream libraries before calling that work complete. In the mean time, if you do a fresh install of the dependencies, you should get filing-cabinet v1.13.0. I'm curious if that works as you'd expect.

Thanks and sorry for the delay in replying. I'm glad there's a workaround in the mean time.

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

2 participants