feat: slot component for dynamic plugins#183
Closed
johnvente wants to merge 2 commits intoopenedx:masterfrom
Closed
feat: slot component for dynamic plugins#183johnvente wants to merge 2 commits intoopenedx:masterfrom
johnvente wants to merge 2 commits intoopenedx:masterfrom
Conversation
|
Thanks for the pull request, @johnvente! Please note that it may take us up to several weeks or months to complete a review and merge your PR. Feel free to add as much of the following information to the ticket as you can:
All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here. This is currently a draft pull request. When it is ready for our review and all tests are green, click "Ready for Review", or remove "WIP" from the title, as appropriate. |
|
@johnvente Even though your pull request wasn’t merged, please take a moment to answer a two question survey so we can improve your experience in the future. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
, we've created a reusable component that will dynamically import a module wherever it is called. The main idea is to be able to change the plugins with this mechanism, which means that instead of modifying the micro-frontend beforehand, we could change the plugin in isolation.
How does it work?
Any component can be wrapped with the pluggable component. For instance:
The prop
asindicates where is the plugin allocated. In this case, the component will be pointing to this route:node_modules/@openedx-plugins/communications-app-card.If the plugin was installed as a dependency, it will render the component that you have pointing to that one.
If the plugin isn't installed, it will return its children. In this case, it's this:
Why are we doing this?
This means that the plugin doesn't have to be installed if I'm making a feature. It's something that we can improve in the future. That way, another developer can replace that component and make more changes. This approach allows us to wrap as many components as we can, making most of the features pluggable and adaptable to various use cases. The component can be rendered without children as well, which means it won't return anything if the plugin is not installed.
How to test it
Check it out this branch and follow these steps:
Then you can run the mfe with
npm startIf you want to create another plugin you can do it in the folder plugins/communications-app/ with the structure of the other
plugins