You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This does a few things:
* Renames APP_* events
* Renames getConfig & company into getSiteConfig
* Removes standalone mode: we don't foresee an intermediate step in MFE
migration, anymore
* This means the `appConfig` structure is not needed anymore, so remove
it
* ... which necessitated a refactor of the `App` type and associated
functions
frontend-platform used environment variables to seed the configuration object, meaning it had default values at the time code is loaded based on `process.env` variables. frontend-base has a hard-coded, minimal configuration object that _must_ be augmented by a valid site config file at initialization time. This means that any tests that rely on configuration (e.g., via `getConfig()`) must first initialize the configuration object. This can be done for tests by adding these lines to `setupTest.js`:
306
+
frontend-platform used environment variables to seed the configuration object, meaning it had default values at the time code is loaded based on `process.env` variables. frontend-base has a hard-coded, minimal configuration object that _must_ be augmented by a valid site config file at initialization time. This means that any tests that rely on configuration (e.g., via `getSiteConfig()`) must first initialize the configuration object. This can be done for tests by adding these lines to `setupTest.js`:
309
307
310
308
```
311
309
import siteConfig from 'site.config';
312
-
import { mergeConfig } from '@openedx/frontend-base';
310
+
import { mergeSiteConfig } from '@openedx/frontend-base';
313
311
314
-
mergeConfig(siteConfig);
312
+
mergeSiteConfig(siteConfig);
315
313
316
314
```
317
315
@@ -413,7 +411,7 @@ Replace all imports from @edx/frontend-platform with @openedx/frontend-base
413
411
- import { logInfo } from '@edx/frontend-platform/logging';
414
412
- import { FormattedMessage } from '@edx/frontend-platform/i18n';
415
413
+ import {
416
-
+getConfig,
414
+
+getSiteConfig,
417
415
+ logInfo,
418
416
+ FormattedMessage
419
417
+ } from '@openedx/frontend-base';
@@ -520,6 +518,7 @@ Note that the .env files and env.config.js files also include a number of URLs f
520
518
```
521
519
// Creating a route role with for 'example' in an App
App-specific configuration can be expressed by adding a `standalone` section to SiteConfig which allows arbitrary config variables.
539
+
App-specific configuration can be expressed by adding an `config` section to the app, allowing arbitrary variables:
541
540
542
541
```
543
-
const config: SiteConfig = {
544
-
// ... Other config
545
-
546
-
standalone: {
542
+
const app: App = {
543
+
...
544
+
config: {
547
545
appId: 'myapp',
548
546
myCustomVariableName: 'my custom variable value',
549
-
}
550
-
}
547
+
},
548
+
};
551
549
```
552
550
553
551
These variables can be used in code with the `getAppConfig` function:
@@ -556,16 +554,16 @@ These variables can be used in code with the `getAppConfig` function:
556
554
getAppConfig('myapp').myCustomVariableName
557
555
```
558
556
559
-
If you have fully converted your app over to the new architecture, you can add custom variables to the `config` object in your `App` definition and they will be available via `getAppConfig`.
557
+
Or via `useAppConfig()` (with no need to specify the appId), if `AppProvider` is wrapping your app.
560
558
561
559
562
560
Replace the .env.test file with configuration in site.config.test.tsx file
We're moving away from .env files because they're not expressive enough (only string types!) to configure an Open edX frontend. Instead, the test suite has been configured to expect a `site.config.test.tsx` file. If you're initializing an application in your tests, `frontend-base` will pick up this configuration and make it available to `getConfig()`, etc. If you need to manually access the variables, you can import `site.config` in your test files:
563
+
We're moving away from .env files because they're not expressive enough (only string types!) to configure an Open edX frontend. Instead, the test suite has been configured to expect a `site.config.test.tsx` file. If you're initializing an application in your tests, `frontend-base` will pick up this configuration and make it available to `getSiteConfig()`, etc. If you need to manually access the variables, you can import `site.config` in your test files:
566
564
567
565
```diff
568
-
+ import config from 'site.config';
566
+
+ import siteConfig from 'site.config';
569
567
```
570
568
571
569
The Jest configuration has been set up to find `site.config` in a `site.config.test.tsx` file.
@@ -577,26 +575,37 @@ A sample `site.config.test.tsx` file:
577
575
```
578
576
import { SiteConfig } from '@openedx/frontend-base';
0 commit comments