Skip to content

[discovery] fix: treat @openedx/frontend-build as an optional peerDep to avoid direct dep in consuming MFEs #790

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

adamstankiewicz
Copy link
Member

Related discussions:

Corresponding PR:

Description:

Demonstrates treating @openedx/frontend-build as an optional peer dependency within @edx/frontend-platform, such that consuming MFEs no longer considers @openedx/frontend-build as a direct dependency, via:

{
  "peerDependenciesMeta": {
      "@openedx/frontend-build": {
        "optional": true
      }
    }
}

From @brian-smith-tcril here:

As for frontend-build specifically, the fact that it is currently in frontend-platform's peerDependencies means that MFEs adding frontend-platform as a direct dependency end up with a non-dev dependency on frontend-build. In frontend-app-communications for example, @testing-library/react is in the package lock with "dev": true, while frontend-build (which is in package.json as a dev dep) is not in package-lock.json as dev.

This indeed does pose a problem for consuming MFEs as @openedx/frontend-build should not be considered as a direct dependencies when the MFE itself installs @openedx/frontend-build as a devDependencies.

Why might this optional peer dependency might work?

Npm will not automatically install optional peer dependencies (docs)

Testing the optional peer dependency approach with frontend-app-communications (PR), @openedx/frontend-build is no longer treated a direct dependency, but instead receives devOptional: true in package-lock.json (source).

While npm ci --omit=dev doesn't omit @openedx/frontend-build from being installed for the MFE, npm ci --omit=dev --omit=optional would.

Merge checklist:

  • Consider running your code modifications in the included example app within frontend-platform. This can be done by running npm start and opening http://localhost:8080.
  • Consider testing your code modifications in another local micro-frontend using local aliases configured via the module.config.js file in frontend-build.
  • Verify your commit title/body conforms to the conventional commits format (e.g., fix, feat) and is appropriate for your code change. Consider whether your code is a breaking change, and modify your commit accordingly.

Post merge:

  • After the build finishes for the merged commit, verify the new release has been pushed to NPM.

Copy link

codecov bot commented Apr 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.78%. Comparing base (455c45e) to head (21fc2cc).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #790   +/-   ##
=======================================
  Coverage   86.78%   86.78%           
=======================================
  Files          48       48           
  Lines        1400     1400           
  Branches      294      297    +3     
=======================================
  Hits         1215     1215           
  Misses        172      172           
  Partials       13       13           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant