Skip to content

[DRAFT] Various improvements to the MFE build process #184

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

Open
14 of 26 tasks
regisb opened this issue Apr 1, 2025 · 6 comments
Open
14 of 26 tasks

[DRAFT] Various improvements to the MFE build process #184

regisb opened this issue Apr 1, 2025 · 6 comments

Comments

@regisb
Copy link

regisb commented Apr 1, 2025

I'm listing here several changes I've experimented to improve the build process of MFEs. This is work-in-progress as I'm trying out different things. But the PRs listed below should be good for a review.

Notes

Semantic releases

It was decided in Paragon to use semantic releases: openedx/paragon#72

As a consequence, working on local versions of frontend-build, frontend-platform, etc. is extremely difficult. I was unable to test changes to devDependencies with npm link or even yalc.

Why did renovate[bot] stop upgrading fortawesome dependencies in frontend-component-header?

frontend-component-header depends on versions of @FortAwesome packages that are different from other MFEs. As a consequence, header has its own set of packages in node_modules/@openedx/frontend-component-header/node_modules/@FortAwesome. This adds extra data on disk, and probably in the compressed build as well.

Outdated 'file-loader'

frontend-build makes extensive use of file-loader, which was since replaced by assets-modules:

https://github.com/openedx/frontend-build/blob/master/config/webpack.prod.config.js
https://v4.webpack.js.org/loaders/file-loader/
https://webpack.js.org/guides/asset-modules/

Funky import resolution

Each and every frontend app is adding its own custom module resolution rules...

frontend-app-learning: @src imports

frontend-app-learning's webpack.prod.config.js has this weird section:

config.resolve.alias = {
  ...config.resolve.alias,
  '@src': path.resolve(__dirname, 'src'),
};

This change was introduced here: openedx/frontend-app-learning#1330

EDIT: Actually, I think this is the cleanest way to proceed, and we should implement the same resolve rule in all MFEs. Curious to learn what others think.

authoring: CourseAuthoring/* imports

const config = createConfig('webpack-prod', {
  resolve: {
    alias: {
      CourseAuthoring: path.resolve(__dirname, 'src/'),
    },
    fallback: {
      fs: false,
      constants: false,
    },
  },
});

This change was introduced here: https://github.com/openedx/frontend-app-authoring/pull/638/files#diff-a60dea17f5d642506d3c4eb9e4f3d0890f7b1601be813adf18583a248f4ce78a

ora-grading, learner-dashboard: import straight from the src directory

https://github.com/openedx/frontend-app-ora-grading/blob/master/webpack.prod.config.js
https://github.com/openedx/frontend-app-learner-dashboard/blob/master/webpack.prod.config.js

config.resolve.modules = [
  path.resolve(__dirname, './src'),
  'node_modules',
];

Changes were made in the first commit:
openedx/frontend-app-ora-grading#2
openedx/frontend-app-learner-dashboard@787e780

MFE re-installing npm???

"npm" is part of the authoring dependencies: https://github.com/openedx/frontend-app-authoring/blob/d1a6af51a4945360ce0cf3f7a5720f9f61ebef25/package.json#L81

openedx/frontend-app-authoring#1133

Outdated frontend-build patches

We should really really revert this PR: openedx/frontend-app-learning#1350

EDIT: Braden already noticed this before me and proposed a fix: openedx/frontend-app-learning#1621 🥇

Replacing webpack by rsbuild

I've managed to produce an rsbuild-based configuration file that works across all MFEs, with only minor changes to MFE apps. Details are here: overhangio/tutor-mfe#252

(tl;dr: results are very promising)

@regisb regisb changed the title Various improvements to the MFE build process [DRAFT] Various improvements to the MFE build process Apr 1, 2025
@bradenmacdonald
Copy link

bradenmacdonald commented Apr 2, 2025

It was decided in Paragon to use semantic releases: openedx/paragon#72 As a consequence, working on local versions of frontend-build, frontend-platform, etc. is extremely difficult. I was unable to test changes to devDependencies with npm link or even yalc.

Can you expand on this? I believe I've gotten it to work for local build purposes at least by linking it in with Local module configuration for Webpack, though this approach doesn't support other tooling like TypeScript checks.

@regisb
Copy link
Author

regisb commented Apr 3, 2025

So my goal was to test the changes of devDependencies in frontend-build. But whenever I installed my local version of frontend-build, I could not run npm install in frontend-app-profile anymore, because there was a clash in version: frontend-app-profile requires frontend-build >= 14.0.0 but I had frontend-build "1.0.0-semantically-released".

In the end I think I managed to get it wot work with lots of rm -rf, ln -s ... and explicit calls to npm install <all frontend-build dependencies>. I also modified the version in my local checkout of frontend-build. But I spent a few hours on this, and the result was not clean.

AFAIU local module configuration works for runtime loading, but not for installation of 3rd-party dependencies.

@bradenmacdonald
Copy link

bradenmacdonald commented Apr 3, 2025

@regisb If you see that, a workaround is to edit the package.json of your local copy of frontend-build and change the version number into the one that is expected. I personally think the semantically-released thing should be scrapped because of this annoyance.

@bradenmacdonald
Copy link

Outdated frontend-build patches

We should really really revert this PR: openedx/frontend-app-learning#1350

I have a PR here: openedx/frontend-app-learning#1621

@regisb
Copy link
Author

regisb commented Apr 9, 2025

On the topic of webpack vs rsbuild, I suggest we continue the conversation here @brian-smith-tcril @bradenmacdonald: overhangio/tutor-mfe#252 (spoiler: results are awesome)

@brian-smith-tcril
Copy link

MFE re-installing npm???

"npm" is part of the authoring dependencies: https://github.com/openedx/frontend-app-authoring/blob/d1a6af51a4945360ce0cf3f7a5720f9f61ebef25/package.json#L81

openedx/frontend-app-authoring#1133

Based on the changes in that PR my best guess is someone accidentally ran

npm install npm start

and ended up with npm and start added as dependencies.

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

No branches or pull requests

3 participants