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

[feature] hint hoister algorithm #2306

Open
bestander opened this issue Dec 20, 2016 · 10 comments
Open

[feature] hint hoister algorithm #2306

bestander opened this issue Dec 20, 2016 · 10 comments
Assignees

Comments

@bestander
Copy link
Member

Do you want to request a feature or report a bug?
feature

What is the current behavior?

Yarn hoists dependencies consistently but sometimes unpredictable.
A very common version of a package (core-js@2) can fail to hoist on top of node_modules tree if a less common package (core-js@1) got hoisted there first.

What is the expected behavior?

  • Yarn can indicate that a dependency is getting hoisted too many times.
  • Yarn can indicate how to fix package.json so that we get optimised hoisting
  • package.json/.yarnrc can have hints for package-hoister to use as priorities
@bestander bestander self-assigned this Dec 20, 2016
@Daniel15
Copy link
Member

Shouldn't Yarn be able to solve this by hoisting the "most popular" version of a package? How does it determine the version to hoist at the moment?

@ljharb
Copy link

ljharb commented Dec 22, 2016

That's tricky tho, because what defines "most popular" - semver-latest? "latest" dist-tag on npm? most downloads reported on the registry? most packages requiring it in the current tree?

@Daniel15
Copy link
Member

most packages requiring it in the current tree?

Sorry, I should have clarified. This is what I meant - relative popularity. If 10 dependencies/packages depend on core-js@2 and only one package depends on core-js@1, then core-js@2 should be the one that's hoisted.

@ljharb
Copy link

ljharb commented Dec 22, 2016

Makes sense - what would be the deterministic tiebreaker?

@Daniel15
Copy link
Member

what would be the deterministic tiebreaker?

You mean if, for example, 5 packages depend on core-js@1 and 5 packages also depend on core-js@2? In that case, I think we should hoist the newest version.

@gaearon
Copy link
Contributor

gaearon commented Jan 16, 2017

Just a heads-up we plan to disable Create React App Yarn integration because of this.

@benjaminapetersen
Copy link

+1 for this! I just tried yarn for the first time, doing a simple 'hello world' install to play with react. Side by side, yarn & npm:

  • 131MB install to node_modules via nmp install
  • 556MB install to node_modules via yarn install

Over half a gig worth of dependencies was quite a surprise. That said, it still looks like yarn is bringing some excellent features to the table!

@hpurmann
Copy link
Contributor

Isn't this fixed by #2676?

@farhan711
Copy link

Yes Isn't fixed by #2676

@bestander
Copy link
Member Author

#2676 gives an acceptable hoisting structure for most cases based on how often a dependency would be repeated if installed without hoisting.
This feature request could address some edge cases where developers might want to override that logic.

I'd say this is now a low priority until we see some real life examples where it would help.
I don't think anyone is focusing on it currently, so anyone is welcome to claim and implement it

@bestander bestander removed the blocker label Feb 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants