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

Get only an array of paths #8

Open
jlgrall opened this issue Dec 12, 2014 · 4 comments
Open

Get only an array of paths #8

jlgrall opened this issue Dec 12, 2014 · 4 comments

Comments

@jlgrall
Copy link

jlgrall commented Dec 12, 2014

Add a requireDir.resolve() which would return a map of the paths instead of a map of the required paths.

It would help plugins like browserify to follow your requires, without loosing time loading unnecessary modules.

I chose the name .resolve() to stay consistent with require.resolve().

@aseemk
Copy link
Owner

aseemk commented Jan 29, 2015

Sorry for the delay here, but nice idea! Love it.

Just to be clear, the return value would be the exact same structure of map that requireDir() returns (which can be recursive, etc.), but the values would be (absolute) string paths instead of the results of require()'ing those paths?

This should be pretty easy to do. I'll see if I can get to it, but pull requests welcome too. =)

@yocontra
Copy link
Collaborator

yocontra commented Feb 7, 2018

Is this a feature you're still interested in? I'd take a PR for it if it doesn't add too much surface and is done in a generic way.

@jlgrall
Copy link
Author

jlgrall commented Feb 8, 2018

Thx for the follow up. Yep, I am still interested. It is to allow the listing and loading of plug-in modules on-demand.

Now, I had to put my project on hold, so if I go back to it and still need that feature, I can look into writing a PR for you.

As for @aseemk's first question, yes it would return string paths instead of the result of require()'ing those paths, and yes it would allow the use of the recurse option. But you shouldn't turn the paths to absolute paths: just keep the paths as they are given and append the filenames at the end, without transforming them into absolute paths.

@yocontra
Copy link
Collaborator

yocontra commented Feb 8, 2018

@jlgrall Great, looking forward to a PR from you (or somebody else reading this) - it shouldn't be too hard to replace the key = require(path) with key = path to achieve this behavior.

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

No branches or pull requests

3 participants