Skip to content

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.79%. Comparing base (455c45e) to head (41031e4).
Report is 15 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #790   +/-   ##
=======================================
  Coverage   86.78%   86.79%           
=======================================
  Files          48       48           
  Lines        1400     1401    +1     
  Branches      294      294           
=======================================
+ Hits         1215     1216    +1     
  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.

@adamstankiewicz adamstankiewicz changed the title [discovery] fix: treat @openedx/frontend-build as an optional peerDep to avoid direct dep in consuming MFEs fix: treat @openedx/frontend-build as an optional peerDep to avoid direct dep in consuming MFEs Jun 5, 2025
@adamstankiewicz adamstankiewicz marked this pull request as ready for review June 5, 2025 16:00
Copy link
Contributor

@brian-smith-tcril brian-smith-tcril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's go for it!

@adamstankiewicz adamstankiewicz merged commit 79d211a into openedx:master Jun 6, 2025
6 checks passed
@adamstankiewicz adamstankiewicz deleted the ags/frontend-build-opt-peer-dep branch June 17, 2025 23:06
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.

2 participants