feat: add EXTERNAL_SCRIPTS hook for configuring MFE external scripts#290
feat: add EXTERNAL_SCRIPTS hook for configuring MFE external scripts#290arbrandes wants to merge 1 commit intooverhangio:mainfrom
Conversation
a5378e3 to
8433b34
Compare
Co-Authored-By: Claude <noreply@anthropic.com>
8433b34 to
008be3c
Compare
|
One thing that is not clear to me in this one is whether the default GA loader is kept if we do this: and if it is, how would one remove it if they want to completely replace the external scripts. |
It's not kept. If you add any loaders here, the defaults are replaced. (The flip side is that if you still want it, you have to add it explicitly.) |
Ok, so it's not really an "add_items" (i.e. "add_items" kind of means that this only adds new scripts, not remove default ones). And if you call |
Correct. The replacement is just about the frontend-platform default, Google Analytics, which will soon be deprecated (by frontend-platform), anyway. We expect it to become a standalone Tutor plugin that takes advantage of the mechanism introduced here. |
Description
frontend-platform recently made
externalScriptsconfigurable viaenv.config.js, following the same pattern used forloggingService,analyticsService, andauthService. This allows script loaders (such asGoogleAnalyticsLoader) to be declared in configuration rather than hardcoded ininitialize().This PR adds an
EXTERNAL_SCRIPTShook to tutor-mfe so that Tutor plugins can register external scripts without resorting to patches. The hook follows the same pattern asPLUGIN_SLOTS: each item is a(mfe_name, script_config)tuple, wheremfe_nameis"all"or a specific MFE name, andscript_configis the JavaScript expression to add to theexternalScriptsconfig array.In the
env.config.jsxtemplate, external scripts are wired up outside the frontend-plugin-framework try/catch block, since they don't depend on FPF. TheexternalScriptskey is only set when scripts are actually configured, so MFE-level defaults are preserved when no scripts are registered.Depends on openedx/frontend-platform#876.
LLM usage notice
Built with assistance from Claude.