-
Notifications
You must be signed in to change notification settings - Fork 63
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
Set basename in order to allow the deployment of MFE in paths #113
Conversation
Thanks for the pull request, @morenol! I've created OSPR-5027 to keep track of it in JIRA, where we prioritize reviews. 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:
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. |
@morenol Thank you for your contribution. Please let me know once this is ready for our review (you can also just change it from Draft and remove [WIP] in the title). |
src/initialize.js
Outdated
export const history = createBrowserHistory(); | ||
|
||
export const history = createBrowserHistory({ | ||
basename: process.env.BASENAME || '/', |
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.
This should be able to use getConfig()
here, rather than the process.env
variable. We avoid using process.env
directly in the code so that we can easily switch out the configuration method/mock it/etc.
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.
I initially did that (you can see the first commit of this PR) and it worked (and that is what I used to deploy using paths.) but in the tests that is failing. It says that getConfig() is undefined. Not sure what I have to do in order to fix these tests
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.
I wonder if there's a circular import... Ugh, that's probably it. initialize.js imports getConfig
from config.js, and config.js imports some constants from initialize.js. Since history
is evaluated as the file is parsed, getConfig
isn't defined yet. Something like that.
An easy way to see if this is the problem with the tests would be to temporarily stop importing APP_CONFIG_INITIALIZED
in config.js and just dump its string value in ensureConfig
instead - I bet the test starts passing then.
If you're okay with a minor refactoring, I think the right move may be to move the constants (APP_TOPIC
, APP_CONFIG_INITIALIZED
, etc.) out of initialize.js into a constants.js file, which would keep config.js from needing to import initialize.js. The index.js file would then re-export them from constants.js instead. There may be other consumers that might need their imports updated as well.
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.
Hi @davidjoy, As you suggested, I created a constant.js file. Let me know if you think that it is Ok
f19a279
to
a999d26
Compare
src/react/AppProvider.jsx
Outdated
@@ -62,7 +63,7 @@ export default function AppProvider({ store, children }) { | |||
> | |||
<IntlProvider locale={locale} messages={getMessages()}> | |||
<OptionalReduxProvider store={store}> | |||
<Router history={history}> | |||
<Router history={history} basename={getConfig().BASENAME}> |
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.
We will have to use this, once we migrate to React-router v6
a999d26
to
3d7de9d
Compare
d514269
to
9372884
Compare
9372884
to
4aebccf
Compare
4aebccf
to
72296fa
Compare
Hi @natabene, this is now ready for review. |
@davidjoy Please review whenever you have a chance. |
@morenol Hi - heard this came up at the contributors meeting this morning! An update from my end - I'm working on a related PR to update the version of frontend-build in this repo, which has taken me a little time to pull together. It hit a snag because frontend-platform was 3 major versions behind on its frontend-build dependency, which caused all sorts of linting/test errors which I've almost worked through. This PR looks good - I'm planning on merging it as soon as I have a companion PR ready. (It was enough of a pain to upgrade that I decided I should just do it since I had context on the 3 major versions I had to upgrade through) We're close! |
@morenol 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
For proper usage in the devstack are needed the changes from openedx/frontend-build#119 and from openedx/frontend-build#131
In this image I am serving the frontend-app-learning MFE in the devstack in the /learning/ path: