Skip to content

feat: add INJECTED_SCRIPTS hook for MFE script injection#289

Closed
sagrodat wants to merge 1 commit into
overhangio:releasefrom
sagrodat:feat/injected-scripts
Closed

feat: add INJECTED_SCRIPTS hook for MFE script injection#289
sagrodat wants to merge 1 commit into
overhangio:releasefrom
sagrodat:feat/injected-scripts

Conversation

@sagrodat

Copy link
Copy Markdown

Creates a parallel pipeline to the PLUGIN_SLOTS pattern specifically for injecting raw JavaScript classes into env.config.jsx. Prevents injected scripts from clobbering default external scripts or React components by injecting before the PLUGIN_SLOTS mechanism which uses FPF (frontend-plugin-framework) that this slot mechanism does not need.

How to test this PR

To verify the injection pipeline works, you can drop this simple test plugin into your local environment.

from tutormfe.hooks import INJECTED_SCRIPTS

test_content = """
class TestScriptLoader {
  constructor(data) { this.data = data; }
  loadScript() {
    console.log("Test Script injected successfully from Tutor!");
  }
}
"""

# Injecting into the 'authn' MFE for testing
INJECTED_SCRIPTS.add_item(
  ("authn", "test_script", test_content)
)

Install, enable and save config it:

tutor plugins install test_script.py
tutor plugins enable test_script
tutor config save

Check the generated file at env/plugins/mfe/build/mfe/env.config.jsx to see the script appended, or copy to the mounted MFE's directory and run the MFE to see the console in dev tools.

@arbrandes

Copy link
Copy Markdown
Collaborator

Superseded by #290.

@arbrandes arbrandes closed this Apr 18, 2026
@Abdul-Muqadim-Arbisoft Abdul-Muqadim-Arbisoft moved this from Pending Triage to Won't fix in Tutor project management Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Won't fix

Development

Successfully merging this pull request may close these issues.

4 participants