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

Require sub-path #16

Open
oliversturm opened this issue Sep 10, 2019 · 2 comments
Open

Require sub-path #16

oliversturm opened this issue Sep 10, 2019 · 2 comments

Comments

@oliversturm
Copy link

Trying to add this:

const _ = require('lodash/fp');

Currently I need to auto-require lodash, find the place where it's been inserted and add the /fp manually. When I enter lodash/fp directly, nothing happens when I hit Enter.

The material-ui library also suggests using sub-paths like this in certain circumstances. Would be nice to see this supported.

@tgreen7
Copy link
Owner

tgreen7 commented Sep 10, 2019

@oliversturm I am not exactly sure how to approach this one. Because lodash/fp is not a direct package it will not show up on the list. I was thinking maybe if there are no matches then maybe the package should prompt "insert require lodash/fp" but then would we still want the alias to get recognized.

@oliversturm
Copy link
Author

Well, like I said it's possible to enter lodash/fp when prompted for the dependency. Wouldn't it be possible to use that string directly (assuming I type it manually)? If necessary, you could always extract the module "base name" by looking for path delimiters. Perhaps it would be possible to add Tab support so I could auto-complete the name of the module, so I'd type something like lod<Tab>/fp for the whole thing.

Alternatively, you could query a sub-path separately, and optionally. I could set an option somewhere if I use sub-paths sometimes, or else bind a separate keystroke, and then I would select the module at the first prompt (as it is now) and enter the /fp at a second prompt - or just hit return once more if I don't have a sub-path that time.

Just to be clear - one main advantage for me is that I can add an import/require from any point in code. The main pain point with the way things are currently is that I need to manually find the newly inserted line and modify it, then go back to where I was.

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

2 participants