Giter VIP home page Giter VIP logo

Comments (3)

layershifter avatar layershifter commented on July 20, 2024 1

However, @fluentui/style-utilities doesn't implement them in the parent child sense.

And this has perfect sense 🐱

To clarify, @fluentui/style-utilities does not use react or react-dom, so it should not depend on it either in dependencies or peerDependencies.


What MYS sees as the solution here is to forward them as "peerDependencies" instead of implementing them as "dependencies".

I would like to see an example there 🐱 In meantime, I can share some expectations on how it could work ⬇️

Let's use @fluentui/react-components as an example as the issue started with it. Unlike your example, I think that graph should start in a reverse order:

flowchart LR
 TOKENS("`@fluentui/tokens
    _peerDependencies: {}_
    `")
    THEME("`@fluentui/react-theme
    _peerDependencies: {}_
    `")
    MENU("`@fluentui/react-menu
    peerDependencies: {'react', 'react-dom'}
    `")
    SELECTOR("`@fluentui/react-context-selector
    peerDependencies: {'react', 'react-dom', 'scheduler'}
    `")
    COMPONENTS("`@fluentui/react-components`")

    classDef align text-align:left

    TOKENS:::align --> THEME:::align --> MENU:::align
    SELECTOR:::align --> MENU
    MENU --> COMPONENTS
    COMPONENTS --> APP[app-pkg]
Loading

The branch with @fluentui/tokens & @fluentui/react-theme can be ignored as it does not have dependencies.

The base principle:

  • If package has matching dependencies in peerDependencies - they SHOULD satisfy the declared range
  • If package has matching dependencies in dependencies - peerDependencies SHOULD be merged and bubble up
  • If package has no matching dependencies in dependencies & peerDependencies - peerDependencies SHOULD bubble up

The example:

  1. @fluentui/react-context-selector declares peerDependencies, they should be resolved on @fluentui/react-menu
  • react is present is both package.json#peerDependencies, range matches, bubble up 🆙
  • react-dom is present is both package.json#peerDependencies, range matches, bubble up 🆙
  • scheduler is not present in @fluentui/react-menu#dependencies & @fluentui/react-menu#peerDependencies, should bubble up 🆙
  1. @fluentui/react-menu declares peerDependencies + got scheduler, they should be resolved on @fluentui/react-components
  • react is present is both package.json#peerDependencies, range matches, bubble up 🆙
  • react-dom is present is both package.json#peerDependencies, range matches, bubble up 🆙
  • scheduler is not present is @fluentui/react-components#dependencies & @fluentui/react-components#peerDependencies, should bubble up 🆙
  1. @fluentui/react-components declares peerDependencies + got scheduler, they should be resolved on app-pkg
  • react is present is app-pkg#dependencies
  • react-dom is present is app-pkg#dependencies
  • scheduler is not present is app-pkg#dependencies, break install 🔴

from midgard-yarn-strict.

ling1726 avatar ling1726 commented on July 20, 2024

PNPM will also not throw errors when peer depenencies are not forwarded up the dep tree https://github.com/ling1726/pnpm-peer-deps FYI @sjwilczynski

from midgard-yarn-strict.

jcreamer898 avatar jcreamer898 commented on July 20, 2024

pnpm treats peers as regular dependencies from my understanding...

So, here's how I think I view things... Midgard Yarn Strict definitely is the most strict of all the above package managers, for better or worse.

image

If you look at the above image, I think the issue MYS has is that...

An app takes a dependency on @fluentui/react.

@fluentui/react has peerDeps on react, react-dom, @types/react and @types/react-dom.

Ok, cool so far, but @fluentui/style-utilities depends on @fluentui/theme, and here's where things get interesting.

@fluentui/theme also has peerDeps on react, react-dom, @types/react and @types/react-dom.

However, @fluentui/style-utilities doesn't implement them in the parent child sense.

What MYS sees as the solution here is to forward them as "peerDependencies" instead of implementing them as "dependencies".

That's just how the current MYS algorithm views the world.

We've investigated the idea of changing the algorithm a bit to look and see if any parent has correctly implemented the peers, and allowing them to point to the parent, but haven't gotten around to a very performant way to do that.

I'd very much love to have an open dialog and conversation around this as this is definitely a pain point for us too. :)

from midgard-yarn-strict.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.