-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Properly skip installation of packages that do not need to be installed (incompatible optionalDependencies for example) #1997
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 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
1 change: 1 addition & 0 deletions
1
__tests__/fixtures/install/install-should-skip-incompatible-optional-dep/.npmrc
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
yarn-offline-mirror=./mirror-for-offline |
Binary file added
BIN
+234 Bytes
.../install/install-should-skip-incompatible-optional-dep/mirror-for-offline/dep-a-1.0.0.tgz
Binary file not shown.
Binary file added
BIN
+271 Bytes
...stall-should-skip-incompatible-optional-dep/mirror-for-offline/dep-incompatible-1.0.0.tgz
Binary file not shown.
5 changes: 5 additions & 0 deletions
5
__tests__/fixtures/install/install-should-skip-incompatible-optional-dep/package.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"optionalDependencies": { | ||
"dep-incompatible": "1.0.0" | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
__tests__/fixtures/install/install-should-skip-incompatible-optional-dep/yarn.lock
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
[email protected]: | ||
version "1.0.0" | ||
resolved dep-incompatible-1.0.0.tgz#d06b95482893472aabc08e86e76580cfae058333 | ||
dependencies: | ||
dep-a "1.0.0" | ||
|
||
[email protected]: | ||
version "1.0.0" | ||
resolved dep-a-1.0.0.tgz#13cb7dfcabff56d3ce39c10c1b9a0900134e615d |
This file contains 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 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 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 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
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.
Why is fetch true for a check operation?
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.
It's for this bit:
It seems that if the fetcher is not run beforehand, the compatibility check does not have the os and cpu data for each package to properly do the check.
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.
Would this work offline?
I am afraid that initing fetcher may cause a longer check
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.
That's a good question. I mean if the package is in the cache, it doesn't actually fetch anything, 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.
This happens if the fetch is not a part of the check:
Because the check does not exclude those package due to incompatibility, it expects them to be there, which it shouldn't.
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.
Ah, it makes sense.
For cross platform modules - they are installed in node_modules and could be verified in place but the missing ones could be either "missing" or not installed because they are "optional".
Adding "optional" property to lockfile makes more sense but this needs a discussion involving more people, maybe an RFC?
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.
As a matter of fact, I think there should be a third mode for check - #1934.
I would rather rely on that and the integrity check than the default one
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 don't think adding whether a package is optional to the lock file is enough alone.
You still want it to be installed on an OS where it is supported, but skipped on an OS where it isn't.
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 wonder, if package is optional but it failed to install because you don't have a compiler, is it an error or is it ok?
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.
That should be an error.
In my opinion, if it is determined by the OS and CPU requirements of the package that your system is compatible, then any installation error that occurs, are out of the scope of what yarn should handle.