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

Make redux and react-redux optional peer dependencies #766

Open
adamstankiewicz opened this issue Feb 18, 2025 · 3 comments
Open

Make redux and react-redux optional peer dependencies #766

adamstankiewicz opened this issue Feb 18, 2025 · 3 comments

Comments

@adamstankiewicz
Copy link
Member

Currently, frontend-platform requires MFEs to install redux and react-redux even if the MFE doesn't use Redux. frontend-platform renders an OptionalReduxProvider component, where if no store prop is passed to <AppProvider> within the MFE, Redux's Provider is not rendered.

However, for MFEs that opt to NOT use Redux (e.g., frontend-app-learner-portal-enterprise), these peer dependencies are still required to install, even though they're not used.

Ideally, frontend-platform could denote these peer dependencies as being optional, handling it accordingly when the package is not installed.

@adamstankiewicz
Copy link
Member Author

See #763, which includes a fix for this issue.

Note it uses the following:

{
  "peerDependenciesMeta": {
    "redux": {
      "optional": true
    },
    "react-redux": {
      "optional": true
    }
  }
}

instead of optionalDependencies, which corresponds to how many common React libraries handle optional peer dependencies.

@adamstankiewicz
Copy link
Member Author

adamstankiewicz commented Feb 21, 2025

The changes in #763 ended up breaking tests on consuming MFEs due to the async lazy import of Provider from react-redux in OptionalReduxProvider.

Next steps:

  • Reintroduce the changes to make redux and react-redux truly optional from the above PR.
    • Ideally, see if it can be done in a non-breaking way (e.g., does it make sense to move the lazy inside OptionalReduxProvider vs. externally to the component, such that the suspended component only impacts tests when rendered?
    • If it must be a breaking change, ensure it is released as such.

@adamstankiewicz
Copy link
Member Author

adamstankiewicz commented Feb 21, 2025

[inform] Opened a new standalone PR for this contribution: #768

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In review
Development

No branches or pull requests

1 participant