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

Properly ignore hoisted popular transitive devDeps in --prod mode. Fi… #3465

Merged

Conversation

blexrob
Copy link
Contributor

@blexrob blexrob commented May 21, 2017

Summary

This PR fixes #3439 (Installed devDependencies in --production).

Because of this issue, yarn can install some packages which are only reachable through devDependencies. Those packages installed are the ones hoisted to the root because they are the popular versions of a package with multiple versions.

** Analysis **

The _seed function in the package hoister assumes that it is called with a depencency from the package.json file if no parent is provided. If no parent is provided, it looks at the package reference's ignore field to determine if the package should initially be ignored (that field is set for direct devDependencies in --production mode).

The prepass function which pre-hoists the packages versions with the highest usage counts does not provide a parent HoistManifest to the _seed function. The _seed function then incorrectly assumes that those packages are package.json dependencies, and immediately marks them as required (because their package reference's ignore field isn't set). It should just wait for the reset of the hoisting precess to dedupe to those packages, and let the after-processing mark them as required only if a path from a normal dependency to those packages exist.

This PR adds a parameter to the _seed function to indicate whether a pattern to hoist is a reference from the package.json file, instead of relying on the parent parameter.

Test plan
A test was added which reproduces the error (in integration-hoisting.js). This test fails without the fix, passes with it. The rest of the test suite also passes.

@voxsim
Copy link
Contributor

voxsim commented May 22, 2017

Thanks for the PR :D

The _seed function seems quite complex, have you ever thought of covering of unit tests?
Maybe we can shrink the number of integration tests, which are slower, and after refactoring in some way.

I suggest you to see #3472 for your next prs :)

Btw @bestander I think we should merge it.

@blexrob
Copy link
Contributor Author

blexrob commented May 22, 2017

I read #3472 today, and I wholly concur 👍. I'll adjust the PR.

@blexrob
Copy link
Contributor Author

blexrob commented May 22, 2017

I'll look into unit tests the next time I'll touch the hoister. For now, it was a lot easier (and quicker) to copy and slightly modify the test for hoisting popular packages.

@bestander bestander merged commit ca81403 into yarnpkg:master May 23, 2017
@bestander
Copy link
Member

Thanks, @blexrob and @voxsim.

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.

Installed devDependencies in --production
3 participants