Skip to content

Commit eda7263

Browse files
committed
docs: touch up docs
1 parent de67956 commit eda7263

2 files changed

Lines changed: 43 additions & 86 deletions

File tree

README.md

Lines changed: 29 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Open edX frontend framework
22

3-
| :rotating_light: Pre-alpha |
3+
| :rotating_light: Alpha |
44
|:------------------------------------------------------------------------------------------|
55
| frontend-base is under **active development** and may change significantly without warning. |
66

@@ -34,39 +34,50 @@ Feel free to reach out in [#wg-frontend on Slack](https://openedx.slack.com/arch
3434

3535
## Development
3636

37-
This library is under development and has not yet been published to npm.
37+
This library is under development and for now is released manually to npm.
3838

39-
## Migrating an MFE to `frontend-base` (Work in progress)
39+
### Developing with Tutor
4040

41-
See the [Frontend App Migration How To](./docs/how_tos/migrate-frontend-app.md).
41+
In order to use develop frontend-base with Tutor, you need to create a Tutor plugin which patches some of the LMS's development settings.
4242

43-
## Merging repositories
43+
```
44+
from tutormfe.hooks import MFE_APPS, MFE_ATTRS_TYPE
4445
45-
Followed this process: https://stackoverflow.com/questions/13040958/merge-two-git-repositories-without-breaking-file-history
46+
from tutor import hooks
4647
47-
After adding a remote of the repo to merge in, run this command:
48+
hooks.Filters.ENV_PATCHES.add_item(
49+
(
50+
"openedx-lms-development-settings",
51+
"""
52+
CORS_ORIGIN_WHITELIST.append("http://{{ MFE_HOST }}:8080")
53+
LOGIN_REDIRECT_WHITELIST.append("http://{{ MFE_HOST }}:8080")
54+
CSRF_TRUSTED_ORIGINS.append("http://{{ MFE_HOST }}:8080")
55+
"""
56+
)
57+
)
58+
```
59+
60+
Once you enable this plugin, you can start the development site with:
4861

4962
```
50-
git merge other-repo-remote/master --allow-unrelated-histories
63+
nvm use
64+
npm ci
65+
npm run dev
5166
```
5267

53-
Then work through the conflicts and use a merge commit to add the history into the frontend-base.
68+
The development site will be available at `http://apps.local.openedx.io:8080`.
5469

55-
Then move the files out of the way (move src to some other sub-dir, mostly) to make room for the next repo.
70+
## Migrating an MFE to `frontend-base`
5671

57-
### Latest repository merges
72+
See the [Frontend App Migration How To](./docs/how_tos/migrate-frontend-app.md).
5873

59-
- frontend-build - Up to date as of 9/12/2024
60-
- frontend-platform - Up to date as of 9/13/2024
61-
- frontend-plugin-framework - Up to date as of 9/13/2024
62-
- frontend-component-header - Up to date as of 9/12/2024
63-
- frontend-component-footer - Up to date as of 9/12/2024
74+
# Notable changes
6475

65-
# Other notable changes
76+
This is a list of notable changes from the previous paradigm:
6677

6778
- Cease using `AUTHN_MINIMAL_HEADER`, replace it with an actual minimal header.
6879
- No more using `process.env` in runtime code.
69-
- Removed dotenv. Use site.config.tsx.
80+
- Removed dotenv. Use `site.config.*.tsx`.
7081
- Removed Purge CSS. We do not believe that Purge CSS works properly with Paragon in general.
7182
- Removed `ensureConfig` function. This sort of type safety should happen with TypeScript types in the site config file.
7283
- Removed `ensureDefinedConfig` function. Similar to ensureConfig, this sort of type safety should be handled by TypeScript.
@@ -99,39 +110,3 @@ The following config variables have been removed, in favor of defining roles for
99110
- DISCOVERY_API_BASE_URL
100111
- CREDENTIALS_BASE_URL
101112
- PUBLISHER_BASE_URL
102-
103-
# Working with Tutor
104-
105-
In order to use tutor with frontend-base, you need to create a tutor plugin which patches some of the LMS's development settings.
106-
107-
```
108-
from tutormfe.hooks import MFE_APPS, MFE_ATTRS_TYPE
109-
110-
from tutor import hooks
111-
112-
hooks.Filters.ENV_PATCHES.add_item(
113-
(
114-
"openedx-lms-development-settings",
115-
"""
116-
CORS_ORIGIN_WHITELIST.append("http://{{ MFE_HOST }}:8080")
117-
LOGIN_REDIRECT_WHITELIST.append("http://{{ MFE_HOST }}:8080")
118-
CSRF_TRUSTED_ORIGINS.append("http://{{ MFE_HOST }}:8080")
119-
MFE_CONFIG = {
120-
# override MFE CONFIG values appropriate to the shell, if necessary
121-
}
122-
"""
123-
)
124-
)
125-
```
126-
127-
Customizing the MFE config API:
128-
129-
https://github.com/overhangio/tutor-mfe?tab=readme-ov-file#customising-mfes
130-
131-
Creating a Tutor plugin:
132-
133-
https://docs.tutor.edly.io/tutorials/plugin.html
134-
135-
Adding new MFEs:
136-
137-
https://github.com/overhangio/tutor-mfe?tab=readme-ov-file#adding-new-mfes

docs/how_tos/migrate-frontend-app.md

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Migrating an MFE to frontend-base
33
=================================
44

5-
To use `frontend-base`, you'll need to use `npm pack` and install it into your MFE from the resulting `.tgz` file.
5+
To use the latest version of `frontend-base` from a git repository, you'll need to use `npm pack` and install it into your MFE from the resulting `.tgz` file.
66

77
Following these steps turns your MFE into a library that can be built using frontend-base and its shell application. It involves deleting a lot of unneeded dependencies and code.
88

@@ -58,21 +58,19 @@ Dependencies shared with the shell should be moved to peerDependencies. These i
5858
```diff
5959
"dependencies" {
6060
- "@openedx/paragon": "^22.8.1",
61+
- "@tanstack/react-query": "^5.81.2",
6162
- "react": "^17.0.2",
6263
- "react-dom": "^17.0.2",
63-
- "react-redux": "^8.1.3",
6464
- "react-router": "^6.26.1",
6565
- "react-router-dom": "^6.26.1",
66-
- "redux": "^4.2.1"
6766
},
6867
"peerDependencies": {
6968
+ "@openedx/paragon": "^22.8.1",
69+
+ "@tanstack/react-query": "^5.81.2",
7070
+ "react": "^17.0.2",
7171
+ "react-dom": "^17.0.2",
72-
+ "react-redux": "^8.1.3",
7372
+ "react-router": "^6.26.1",
7473
+ "react-router-dom": "^6.26.1",
75-
+ "redux": "^4.2.1"
7674
}
7775
```
7876

@@ -127,14 +125,10 @@ With the exception of any custom scripts, replace the `scripts` section of your
127125

128126
```
129127
"scripts": {
130-
"build": "openedx build",
131128
"dev": "PORT=YOUR_PORT openedx dev",
132129
"i18n_extract": "openedx formatjs extract",
133130
"lint": "openedx lint .",
134131
"lint:fix": "openedx lint --fix .",
135-
"pack": "openedx pack",
136-
"release": "openedx release",
137-
"serve": "PORT=YOUR_PORT openedx serve",
138132
"snapshot": "openedx test --updateSnapshot",
139133
"test": "openedx test --coverage --passWithNoTests"
140134
},
@@ -168,8 +162,6 @@ This means that the code from the library can be safely tree-shaken by webpack.
168162
],
169163
```
170164

171-
// TODO: Maybe put scss and css files in side effects. They have side effects and need to be excluded so they get bundled.
172-
173165

174166
Add a Type Declaration file (app.d.ts)
175167
======================================
@@ -294,9 +286,11 @@ Add a babel.config.js file for Jest
294286
Jest needs a babel.config.js file to be present in the repository. It should look like:
295287

296288
```
297-
const config = require('@openedx/frontend-base/config/babel/babel.base.config');
289+
const { createConfig } = require('@openedx/frontend-base/config');
298290
299-
module.exports = config;
291+
module.exports = createConfig('test', {
292+
...
293+
});
300294
```
301295

302296

@@ -542,7 +536,6 @@ App-specific configuration can be expressed by adding an `config` section to the
542536
const app: App = {
543537
...
544538
config: {
545-
appId: 'myapp',
546539
myCustomVariableName: 'my custom variable value',
547540
},
548541
};
@@ -554,7 +547,7 @@ These variables can be used in code with the `getAppConfig` function:
554547
getAppConfig('myapp').myCustomVariableName
555548
```
556549

557-
Or via `useAppConfig()` (with no need to specify the appId), if `AppProvider` is wrapping your app.
550+
Or via `useAppConfig()` (with no need to specify the appId), if `CurrentAppProvider` is wrapping your app.
558551

559552

560553
Replace the .env.test file with configuration in site.config.test.tsx file
@@ -625,8 +618,7 @@ Export the modules of your app in your index.ts file.
625618

626619
This may require a little interpretation. In spirit, the modules of your app are the 'pages' of an Open edX Frontend site that it provides. This likely corresponds to the top-level react-router routes in your app. In frontend-app-profile, for instance, this is the `ProfilePage` component, amongst a few others. Some MFEs have put their router and pages directly into the `index.jsx` file inside the initialization callback - this code will need to be moved to a single component that can be exported.
627620

628-
These modules should be unopinionated about the path prefix where they are mounted. The exact way we handle routing is still being figured out. In the short term, the react-router data APIs are not suppored until we can figure out how to implement lazy route discovery (a.k.a., "Fog of War") Using `<Routes>` with `<Route>` components inside it works today. **This functionality is still a work in progress, and is one of the big things we need to figure out.**
629-
621+
These modules should be unopinionated about the path prefix where they are mounted.
630622

631623
Remove core-js and regenerator-runtime
632624
======================================
@@ -639,7 +631,7 @@ Create a site.scss file
639631

640632
This is required if you intend to run builds from the app itself.
641633

642-
Create a new `site.scss` file at the top of your application. It's responsible for:
634+
Create a new `app.scss` file at the top of your application. It's responsible for:
643635

644636
1. Importing the shell's stylesheet, which includes Paragon's core stylesheet.
645637
2. Importing your brand stylesheet.
@@ -648,7 +640,7 @@ Create a new `site.scss` file at the top of your application. It's responsible
648640
You must then import this new stylesheet into your `site.config` file:
649641

650642
```diff
651-
+ import './site.scss';
643+
+ import './app.scss';
652644

653645
const siteConfig: SiteConfig = {
654646
// config document
@@ -721,6 +713,8 @@ Upgrade react-query
721713

722714
If the MFE uses react-query version 4 or below, upgrade it to 5 as per [this guide](https://tanstack.com/query/latest/docs/framework/react/guides/migrating-to-v5).
723715

716+
If the MFE uses Redux, consider porting the app over to react-query, as it will make it much easier to handle header (and footer) customization.
717+
724718

725719
Removal of pubsub-js
726720
====================
@@ -742,16 +736,4 @@ Refactor plugin-slots
742736

743737
First, rename `src/plugin-slots`, if it exists, to `src/slots`. Modify imports and documentation across the codebase accordingly.
744738

745-
Next, the frontend-base equivalent to `<PluginSlot />` is `<Slot />`, and has a different API. This includes a change in the slot ID, according to the [new slot naming ADR](../decisions/0009-slot-naming-and-lifecycle.rst) in this repository. Rename them accordingly. You can refer to the `src/shell/dev-site` in this repository for examples.
746-
747-
748-
Find your module boundaries
749-
===========================
750-
751-
From this step on, things get a bit more subjective. At this point you need to ensure that the modules in your library are decoupled and well-bounded. If you use Redux, this may mean creating individual redux stores for each module, including adding a context so that they're separate from any "upstream" redux stores that may exist.
752-
753-
https://react-redux.js.org/using-react-redux/accessing-store#multiple-stores
754-
755-
756-
react-router: move to data router
757-
=================================
739+
Next, the frontend-base equivalent to `<PluginSlot />` is `<Slot />`, and has a different API. This includes a change in the slot ID, according to the [new slot naming ADR](../decisions/0009-slot-naming-and-lifecycle.rst) in this repository. Rename them accordingly. You can refer to the `src/shell/dev` in this repository for examples.

0 commit comments

Comments
 (0)