Skip to content

RFC: Proposal for new configuration scheme for dep-check #1638

@tido64

Description

@tido64

Goals

  • To make it easier to relate to profiles, especially for web only consumers
  • To make it easier to provide custom presets (collection of profiles)
    • This used to be hidden from the public, but will be exposed in this proposal. One example of a preset is the built-in one.
  • The old configuration scheme will still be supported and take precedence

Motivation

While dep-check is a tech agnostic solution for managing dependencies, its configuration schema is currently very coupled with React Native versions. This makes the configuration look out of place when used in web only packages. Further, users have expressed a desire to centralize their configuration around arbitrary dependencies (e.g. react or @fluentui/react instead of react-native). They also want the ability to bring their own presets.

Proposal

Taking inspiration from browserslist, we want to introduce queries as a way to pick profiles.

For example, to ensure that all packages are aligned on React 18.x:

{
  "dep-check": {
    "requirements": [
      "react@^18.0"
    ]
  }
}

To ensure all packages declare compatibility with React >=16, and align on 18.x for development:

{
  "dep-check": {
    "requirements": {
      "development": [
        "react@^18.0"
      ],
      "production": [
        "react@>=16.13"
      ]
    }
  }
}

You can bring your own presets to enrich the built-in one:

{
  "dep-check": {
    "presets": [
      "microsoft",
      "/path/to/my-collection-of-multiple-profiles"
    ],
    "requirements": [
      "react@^18.0"
    ]
  }
}

Or replace the built-in preset entirely:

{
  "dep-check": {
    "presets": [
      "/path/to/my-collection-of-multiple-profiles"
    ],
    "requirements": [
      "react@^18.0"
    ]
  }
}

You can also add single profiles:

{
  "dep-check": {
    "profiles": [
      "/path/to/additional-profile"
    ],
    "requirements": [
      "react@^18.0"
    ]
  }
}

Note that this config is just a different "frontend" to the tool. Everything else still works the same. For instance, the following configurations are equivalent:

{
  "rnx-kit": {
    "reactNativeVersion": "^0.66 || ^0.67 || ^0.68",
    "reactNativeDevVersion": "0.66",
  }
}
{
  "dep-check": {
    "requirements": {
      "development": [
        "core@0.66"
      ],
      "production": [
        "core@^0.66 || ^0.67 || ^0.68"
      ]
    }
  }
}

Though in this case, you should prefer using rnx-kit since it provides other benefits.

A Note on Conflict Resolution

What happens in the case of conflicts? For instance, React Native is not compatible with React 18 until 0.69. What happens if we require both React 18 and React Native below 0.69:

{
  "dep-check": {
    "requirements": [
      "core@<0.69",
      "react@^18.0"
    ]
  }
}

In this case, dep-check will throw an error since the built-in preset cannot fulfill the requirements. To resolve the conflict, we recommend that users move one of the requirements to the relevant packages. For instance:

// global config
{
  "dep-check": {
    "requirements": [
      "react@^18.0"
    ]
  }
}
// package config
{
  "rnx-kit": {
    "reactNativeVersion": "^0.66 || ^0.67 || ^0.68",
    "reactNativeDevVersion": "0.66",
  }
}

In short, dep-check will not try to resolve conflicts. It is up to users to build presets/profiles that fit their needs.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions