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

fix: dynamic arg module search should ignore specific folder names #344

Conversation

dsherret
Copy link
Member

@dsherret dsherret commented Dec 9, 2023

I think the dynamic argument module search should ignore certain folder names as they are almost guaranteed to not be wanted. This excludes hidden folders and folders named node_modules or vendor.

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this aimed at LSP perf?

@dsherret
Copy link
Member Author

dsherret commented Dec 9, 2023

No, it's only runtime. The LSP doesn't do this search. See #275

.rsplit('/')
.find(|c| !c.is_empty())
.map(|c| {
!c.starts_with('.') && c != "node_modules" && c != "vendor"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This somewhat aligns with what the CLI does here:

https://github.com/denoland/deno/blob/393abed3873d83019feb5bcebb10a6929133862a/cli/util/fs.rs#L322-L324

I wonder if we should match it exactly and this instead should be .git | vendor | node_modules?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think we should unify it and also ignore .git directory

Copy link
Member Author

@dsherret dsherret Dec 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now this ignores the .git directory. To clarify, this code should be updated to instead only ignore the git directory and not all hidden folders?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry. I didn't read the code fully. I think that still makes sense - what if you try to import from .dist/ or .<framework_name>/? I can see a scenario where people try to do that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the current code, they would just have to be specific or import a sub folder in that case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, they could just do:

import(`./dist/${expr}`)

Thinking about it more, I think we should ignore all hidden folders here because there's this way to import and in many cases I think people wouldn't want it searching hidden folders.

@dsherret dsherret merged commit f9a2290 into denoland:main Dec 11, 2023
4 checks passed
@dsherret dsherret deleted the fix_dynamic_arg_search_ignore_node_modules_and_hidden branch December 11, 2023 16:13
dsherret added a commit to denoland/deno that referenced this pull request Dec 11, 2023
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

Successfully merging this pull request may close these issues.

3 participants