@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 +29 -12
- package/dist/main.js +5 -5
- package/dist/main.js.LICENSE.txt +16 -0
- package/dist/types/axios.d.ts +3 -0
- package/dist/types/axios.d.ts.map +1 -0
- package/dist/types/configmap.d.ts +1 -1
- package/dist/types/generate.d.ts +4 -5
- package/dist/types/generate.d.ts.map +1 -1
- package/dist/types/generate.env.d.ts +3 -0
- package/dist/types/generate.env.d.ts.map +1 -0
- package/dist/types/generate.index.d.ts +4 -0
- package/dist/types/generate.index.d.ts.map +1 -0
- package/dist/types/generate.metadata.d.ts +4 -0
- package/dist/types/generate.metadata.d.ts.map +1 -0
- package/dist/types/index.d.ts +6 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/mappers/appshell.config.d.ts.map +1 -1
- package/dist/types/register.d.ts +4 -0
- package/dist/types/register.d.ts.map +1 -0
- package/dist/types/types.d.ts +11 -5
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/isValidUrl.d.ts +3 -0
- package/dist/types/utils/isValidUrl.d.ts.map +1 -0
- package/dist/types/utils/loadJson.d.ts +3 -0
- package/dist/types/utils/loadJson.d.ts.map +1 -0
- package/dist/types/validators/appshell.config.d.ts.map +1 -1
- package/dist/types/validators/appshell.manifest.d.ts.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
# @appshell/config
|
|
13
13
|
|
|
14
|
-
Utitliy for generating a `global
|
|
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
|
-
|
|
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 {
|
|
45
|
+
import { generateManifest } from '@appshell/config';
|
|
42
46
|
|
|
43
|
-
const manifest =
|
|
47
|
+
const manifest = generateManifest<MyMetadata>(process.env.CONFIGS_DIR);
|
|
44
48
|
```
|
|
45
49
|
|
|
46
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|