-
Notifications
You must be signed in to change notification settings - Fork 929
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
feat(envs API) - Support custom dep detectors for envs #7199
Conversation
444dd9d
to
5686995
Compare
5686995
to
1ab5f47
Compare
@Jinjiang , Great job with this PR! :) Regarding the points you mentioned:
|
scopes/dependencies/dependency-resolver/dependency-resolver.main.runtime.ts
Outdated
Show resolved
Hide resolved
* determine what type of content the detector is for. | ||
* if no type provided, the type would be the ext. | ||
*/ | ||
type?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What possible values are for this?
if it's general string, we should improve the comment above it to explain what it is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type
is what precinct()
previously receives as the second argument. Also, it's what the previous getType()
returns in paperwork()
. I added this field into the detector interface to combine the 2 steps directly.
The previous implementation has 2 steps: 1) get the type from the ext, 2) get detective from the type.
Sometimes ext names and types are not 1:1 matched. For example, .ts
and .tsx
both match the type ts
.
For custom env detectors, I think it's also a good practice for detector authors to specify what type of files it belongs to.
And I updated the code comment a little bit. What do you think now? :-)
Proposed Changes
detectors()
to the new env interface.DependencyDetector
by adding an optionaltype
member, which is better to be further processed rather thanext
member.Something needs to pay attention to:
precinct.ast
. Here I just passed the relevant test cases.precinct()
except inprecinct.paperwork()
. Here I just passed the relevant test cases. And since those 2 functions are not nested anymore, I skipped the case: paperwork -> when given detective configuration -> still does not filter out core module by default.