-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: A leaner example app that is built using Vite #54
Conversation
Thanks for the pull request, @bradenmacdonald! 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. Please let us know once your PR is ready for our review and all tests are green. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #54 +/- ##
=======================================
Coverage 96.53% 96.53%
=======================================
Files 10 10
Lines 173 173
Branches 35 35
=======================================
Hits 167 167
Misses 5 5
Partials 1 1 ☔ View full report in Codecov by Sentry. |
@@ -39,7 +39,7 @@ Using the Example Apps | |||
|
|||
2. Run ``npm run start`` in the root directory. | |||
|
|||
3. Open another terminal and run ``npm run start:example`` to start the example app. You can visit http://localhost:8080 to see the example app. | |||
3. Open another terminal and run ``npm run start:example-vite`` to start the example app. You can visit http://localhost:8080 to see the example app. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quick clarification on this: wouldn't changing the instruction here thus make the script npm run start:example
irrelevant, and thus the Hostexample
app irrelevant? If there's a benefit to keeping both, then I think this instruction could flesh out the reasoning between using one over the other.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, if we decided we were OK with maintaining the Vite version (see also https://discuss.openedx.org/t/experiment-build-an-mfe-with-vite-instead-of-frontend-build-webpack/12702 ) then we could just straight-up replace the example
app. I just thought some people might prefer to have one based on frontend-build
for consistency.
Super huge thanks for this PR, @bradenmacdonald ! @MaxFrank13 is on call this week, so he'll be the one to triage this. On your thoughts, I think that there's some that can immediately be made into issue tickets (ie. address console logs, iFrame rendering fallback, type definitions), and I can write those up this week. The ones that would need further discussion (ie. switch to Vite from Webpack for FPF example apps, remove LMS requirement, etc.) could either be issue tickets that live here as well or moved to wherever is more appropriate -- like extracting simple configuration needs from frontend-platform. Would you be able to get those issues/discussions created? |
I agree with Jason that it would be nice to get some of these into GitHub issues:
This is a good point. I think an issue for setting up FPF to have an injectable config belongs in this repo but the
I think this would be very helpful. What do you imagine the lift for that work would be? We are happy to assist as well — our team even has a ticket on the backlog for this
All good call outs. We have tickets for some of this work (again, on the backlog) but we are more than willing to be assisted here. If any of these changes seem trivial, feel free to work them in as you have time — we will do the same 🙂 FWIW, with regards to the Vite conversation — I'm in favor of making the switch. I will defer to the discourse thread though |
@MaxFrank13 |
@MaxFrank13 Whoops, got my wires crossed on the above comment... I was talking about a different repo. I think adding types to this repo wouldn't be a big lift at all! |
hey @bradenmacdonald , @MaxFrank13 and I got a chance to look at this PR again and we think it's a great solution to make the example apps accessible to the community. We also think the original "host" MFE isn't necessary to keep for the sake of having a build that uses |
@jsnwesson Sure, I'm happy to make that change in this PR - I think it's a nice simplification :) I'll let you know when I've gotten to it. |
Just chiming in here - To break the dependency on a running development environment in "example" MFEs, you can do the following:
Overriding the auth handler means it no longer makes requests to edx-platform, and can just run on its own. @bradenmacdonald - I'd hesitate to bring in a separate build tool and throw out dependencies on frontend-platform to solve this... in spirit I'd hope example apps act like normal MFEs as much as possible. I'm all for Vite experimentation, but I think we should be really measured about how and when we choose to add it to the platform. We don't even know if it's a viable alternative yet, as much as I'd like it to be. |
@davidjoy The app in question isn't really an MFE and it's never going to be deployed in the same way the "real" MFEs are - it's just a tech demo / teaching tool. So that's why I thought it was fine to use simpler/faster tooling even though it's different than our MFE standards. If you feel strongly about it though, we could just make the fix above that you're suggesting and live with the slower builds etc. |
@bradenmacdonald For what it's worth, we have pretty consistent example apps in most of our libraries that all resemble stripped down frontend-template-application apps, use frontend-build/frontend-platform, etc. They all run the same and have the same stack, (though I'm guessing many have this same unfortunate edx-platform dependency, which we should fix). I just feel like we should be intentional about diverging from that, or we're increasing cognitive load of developers going from repo to repo in yet another way, and we're trying so hard to find ways to make things more consistent. :) I ran the dev build myself just now and you're right, it seems to take about 7 seconds to build (more on first startup, from the look of it). Rebuilds for me are taking between 350-450ms, which is fast enough not to be noticeable. IMHO I'd rather have a few extra seconds cold start time and keep consistent tooling... at least while we strategize an approach to update our tooling to be faster. 😄 And, just thinking ahead... if for OEP-65 we want to merge FPF into frontend-platform and have a tighter integration between the two, I expect we'll want to keep the example app "MFE like". Funnily enough - the |
I'm totally fine closing this PR if we can fix the example app in the way you're suggesting, so there's no need to have a running LMS. I am still very much interested in letting people try out Vite though, and see how it can both simplify and improve our workflows. |
@bradenmacdonald 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. |
I wanted to run the
example
app today, but it seems like it depends on devstack, which I don't use. So this PR introduces a demo app that uses Vite instead offrontend-build
and which tries to bypass as much offrontend-platform
as possible.Current
example
appTakes ~7,000 ms⚠️ to initialize, then shows this error if you don't have devstack running:
ERR_CONNECTION_REFUSED http://localhost:18000/login_refresh
New
example-vite
appTakes ~110 ms 😎 to initialize, then works because it doesn't depend on devstack at all:
(the iframe plugin will be missing for a few seconds while the slow
example-plugin-app
is built using webpack, but it will hot-reload to display it once it's ready).Note that the Vite version still includes Paragon's SCSS since the demo uses it, transpiles TypeScript and JSX, and supports hot reloading and whatever else you might want.
Thoughts
inserted_direct_plugin
'data-testid
supplied toReact.Fragment
. React.Fragment can only havekey
andchildren
props.'example
code relevant to this repo (plugins) is completely unchanged and is identical between both versions, except that the Vite version doesn't need the unusedReact
imports that are present in the other one.getConfig()
and friends, but to run a demo of it you have to initialize all the other services like Auth, Logging, Analytics, i18n, Redux, etc. This project (frontend-plugin-framework
) should be modified so that the configuration service is an injectable dependency, andfrontend-platform
should be modified so you can initialize the config without unnecessary services.dist
folders and all that legacy stuff. Vite+ESM+TS is much nicer, and it provides all the same functionality.