@appshell/config 0.2.1-alpha.2 → 0.3.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
 
12
12
  # @appshell/config
13
13
 
14
- Utitliy for generating a `global runtime manifest` for Webpack Module federation micro-frontends.
14
+ Utitliy for generating a `global appshell manifest` for Webpack Module federation micro-frontends.
15
15
 
16
16
  Working examples can be found [here](https://github.com/navaris/appshell/tree/main/examples).
17
17
 
@@ -35,21 +35,23 @@ or
35
35
  pnpm add -D @appshell/config
36
36
  ```
37
37
 
38
- The primary export from this package is the `generate` function. It is given a configs dir to process and produces a global runtime manifest.
38
+ ## Functions
39
+
40
+ ### `generateManifest`
41
+
42
+ The `generateManifest` function is given a configs dir to process and produces a merged appshell manifest.
39
43
 
40
44
  ```ts
41
- import { generate } from '@appshell/config';
45
+ import { generateManifest } from '@appshell/config';
42
46
 
43
- const manifest = generate<MyMetadata>(process.env.APPSHELL_CONFIGS_DIR);
47
+ const manifest = generateManifest<MyMetadata>(process.env.CONFIGS_DIR);
44
48
  ```
45
49
 
46
- ![Sample APPSHELL_CONFIGS_DIR](https://github.com/navaris/appshell/blob/main/assets/docs/appshell_configs_dir.png 'APPSHELL_CONFIGS_DIR')
47
-
48
- **Where does the content of APPSHELL_CONFIGS_DIR come from?**
50
+ **Where does the content of CONFIGS_DIR come from?**
49
51
 
50
52
  > Each micro-frontend configured to use [@appshell/manifest-webpack-plugin](https://www.npmjs.com/package/@appshell/manifest-webpack-plugin) emits it's configuration to the configs directory at build time, which is subsequently processed with this utility to reflect the current runtime environment.
51
53
 
52
- Sample content from APPSHELL_CONFIGS_DIR:
54
+ Sample content from CONFIGS_DIR:
53
55
 
54
56
  ```json
55
57
  {
@@ -82,15 +84,21 @@ Sample content from APPSHELL_CONFIGS_DIR:
82
84
  "requiredVersion": "^18.2.0"
83
85
  }
84
86
  }
87
+ },
88
+ "environment": {
89
+ "RUNTIME_ARG_1": "${RUNTIME_ARG_1}",
90
+ "RUNTIME_ARG_2": "${RUNTIME_ARG_2}"
85
91
  }
86
92
  }
87
93
  ```
88
94
 
89
- **How does my runtime environment get reflected in the global runtime manifest?**
95
+ **How does my runtime environment get reflected in the global appshell manifest?**
96
+
97
+ > Note the variable expansion syntax `${CRA_MFE_URL}`. When `generateManifest` is called the actual runtime environment values are injected and an appshell manifest is emitted.
90
98
 
91
- > Note the variable expansion syntax `${CRA_MFE_URL}`. When `generate` is called the actual runtime environment values are injected and all configurations are merged into a global runtime manifest.
99
+ > **Note** the `environment` section defines runtime environment variables that are injected into the global namesapce `window.__appshell_env__[module_name]` when a federated component is loaded. See the examples for a use case.
92
100
 
93
- Sample global runtime manifest produced by the `generate` function:
101
+ Sample global appshell manifest produced by the `generate` function:
94
102
 
95
103
  ```json
96
104
  {
@@ -170,11 +178,20 @@ Sample global runtime manifest produced by the `generate` function:
170
178
  }
171
179
  }
172
180
  }
181
+ },
182
+ "environment": {
183
+ "CraModule": {
184
+ "RUNTIME_ARG_1": "Foo",
185
+ "RUNTIME_ARG_2": "Biz"
186
+ },
187
+ "VanillaModule": {
188
+ "RUNTIME_ARG_1": "Bar"
189
+ }
173
190
  }
174
191
  }
175
192
  ```
176
193
 
177
- This `global runtime manifest` can be consumed by your micro-frontend Appshell host and used to configure the Appshell accordingly.
194
+ This `global appshell manifest` is consumed by your micro-frontend Appshell host and used to configure the Appshell accordingly.
178
195
 
179
196
  **What if I want to generate the manifest by a startup script instead?**
180
197