-
Notifications
You must be signed in to change notification settings - Fork 203
Add support for resolving extensions in relative paths #259
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
Open
amosyuen
wants to merge
1
commit into
tleunen:master
Choose a base branch
from
amosyuen:relative
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do we really need to remove this condition?
I mean.. Resolving a relative path is only about potentially adding the custom extension, right?
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.
If we want to make sure the relative path is checked first we can change the order of the resolvers to have the relativeResolver first. Which is logically equivalent to having an if statement that explicitly runs the relative resolver.
I'm not opposed to that, but I think this is more a question of where we want the if checks of whether to run the resolver. For example, rather than have the array of resolvers, we could just have multiple if statements that decide whether to run each resolver. But I do think we should be consistent. My leaning is towards having the if checks in the resolvers.
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.
Agreed. Sorry, it's been a while since I worked in this area of the code and I didn't read it properly.
resolvePath
is called for every "resolvers" so indeed we have to remove it.But then, should we actually run
resolvePathFromAliasConfig
andresolvePathFromRootConfig
on relative paths? I don't think so, right? (cc @fatfisz)Should relative paths only run
resolvePathFromRelativeConfig
to potentially resolve the custom extension?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.
Possibly somebody might want a relative path alias "e.g. ./lib -> some/other/path/lib". So there might be a small case for running aliases for relative paths. resolving from root, probably not.
Depending on the order we put the resolvers, the others won't run. e.g. with the way I have it now, if the path is relative, it will always run resolvePathFromRelativeConfig first, and so will never reach the other two resolvers.
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.
i agree with @amosyuen . it might slow down resolution but perhaps we should add an exclude/include option so we can exclude/include specific directories/regexes, ....
for the android, ios case you probably have different babel configs, one that looks for ios.js & .js and another one that does for android.js and .js