tutor-mfe icon indicating copy to clipboard operation
tutor-mfe copied to clipboard

Support Javascript configuration

Open arbrandes opened this issue 11 months ago • 18 comments

Description

tutor-mfe doesn't currently support Javascript configuration, except potentially by the old, abandoned expedient of baking it into the image. The latter is obviously not something we want to go back to, so a way must be devised to take advantage of JS configuration dynamically.

Why should we support it?

Because plugins will require it.

Solution Space

A list of potential solutions, for discussion.

1. Extend mfe_config

Extend the mfe_config API so that JS configuration can also be served. Extend runtimeConfig() so that it makes use of it.

  • Pros: uses the existing flow (no need to rethink the architecture)
  • Cons: storing Javascript in a string in site_configuration doesn't sound like the best idea ever. Editing it will be horrible, for one.

2. Refactor mfe_config

This is mostly the same as 1., except instead of piggy-backing on site_configuration, we write a dedicated admin page for it.

  • Pros: less horrible editing experience
  • Cons: more work

3. Move mfe_config to tutor-mfe

Note: this last option is the most similar to how Piral does - or can do - configuration. I suggest we explore it seriously, as it might make our jobs easier later.

Instead of relying on an edx-platform API, we build a mechanism in tutor-mfe to serve the correct JS file dynamically. We'd likely be able to leverage the fact that .env.config.js is just Javascript to make a request to a predictable location that Caddy can then service. This file would be user-overridable, so if the operator wants to do something fancy like fetching a different configuration depending on the domain, they totally could.

Pros:

  • The most flexible option. An operator could go as far as writing their own configuration backend, and then writing a JS config to use it.
  • Potentially the best performance: no need to deal with Django.
  • Very easy to implement for tutor-mfe developers.
  • For basic use, actually easier to modify MFE configuration than writing plugins to change MFE_CONFIG. You just edit the JS file.

Cons:

  • For the more complicated things like multi-tenancy, puts the brunt of the work on operators.
  • Unknown territory.

arbrandes avatar Mar 13 '24 18:03 arbrandes