Skip to content

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

@regisb

Description

@regisb

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)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

Status

In Review

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions