@redhat-cloud-services/frontend-components-config-utilities 1.5.18 → 1.5.21
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 +9 -4
- package/federated-modules.js +12 -10
- package/package.json +1 -1
- package/proxy.js +10 -4
package/README.md
CHANGED
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://badge.fury.io/js/%40redhat-cloud-services%2Ffrontend-components-config-utilities)
|
|
4
4
|
|
|
5
|
-
- [RedHat Cloud Services frontend components - webpack config](#redhat-cloud-services-frontend-components---webpack-config-utilities)
|
|
6
|
-
- [Chrome render loader](#chrome-render-
|
|
5
|
+
- [RedHat Cloud Services frontend components - webpack config utilities](#redhat-cloud-services-frontend-components---webpack-config-utilities)
|
|
6
|
+
- [Chrome render loader](#chrome-render-loader)
|
|
7
7
|
- [Disable chrome 2](#disable-chrome-2)
|
|
8
8
|
- [Chunk mapper](#chunk-mapper)
|
|
9
9
|
- [Federated modules](#federated-modules)
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
- [Override container ports](#override-container-ports)
|
|
11
|
+
- [List of shared deps](#list-of-shared-deps)
|
|
12
|
+
- [Extensions plugin](#extensions-plugin)
|
|
13
|
+
- [Arguments](#arguments)
|
|
14
|
+
- [`pluginConfig`](#pluginconfig)
|
|
15
|
+
- [extension object](#extension-object)
|
|
12
16
|
|
|
13
17
|
## Chrome render loader
|
|
14
18
|
|
|
@@ -95,6 +99,7 @@ We've aimed for easy plug and play, but feel free to override any fed mods parti
|
|
|
95
99
|
* `moduleName` - used to generate the file under this name (generally your `insights.appname` - if you have dashes in your name replace them with cammel case)
|
|
96
100
|
* `useFileHash` - in order to prevent caching we are using file hashes, you might want to turn this off in your dev env
|
|
97
101
|
* `exclude` - if you want to exclude any shared module you can do it trough here (even for general dependencies added by us)
|
|
102
|
+
* `eager` - if set to `true`, turns eager fetch for shared modules on
|
|
98
103
|
|
|
99
104
|
### Override container ports
|
|
100
105
|
The default ports for the RBAC server(**4012**) and/or the Keycloak server(**4001**) can be overridden using a corresponding variable in the environment.
|
package/federated-modules.js
CHANGED
|
@@ -3,24 +3,26 @@ const { resolve } = require('path');
|
|
|
3
3
|
const { ModuleFederationPlugin } = require('webpack').container;
|
|
4
4
|
const jsVarName = require('./jsVarName');
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
'@patternfly/react-core': { eager
|
|
8
|
-
'@patternfly/react-table': { eager
|
|
6
|
+
const createIncludes = (eager = false) => ({
|
|
7
|
+
'@patternfly/react-core': { eager },
|
|
8
|
+
'@patternfly/react-table': { eager },
|
|
9
9
|
'@patternfly/react-tokens': {},
|
|
10
10
|
'@patternfly/react-icons': {},
|
|
11
|
-
'@patternfly/quickstarts': { singleton: true, eager
|
|
11
|
+
'@patternfly/quickstarts': { singleton: true, eager },
|
|
12
12
|
'@redhat-cloud-services/frontend-components': {},
|
|
13
13
|
'@redhat-cloud-services/frontend-components-utilities': {},
|
|
14
14
|
'@redhat-cloud-services/frontend-components-notifications': {},
|
|
15
15
|
axios: {},
|
|
16
16
|
lodash: {},
|
|
17
17
|
'redux-promise-middleware': {},
|
|
18
|
-
react: { singleton: true, eager
|
|
19
|
-
'react-dom': { singleton: true, eager
|
|
20
|
-
'react-router-dom': { eager
|
|
21
|
-
};
|
|
18
|
+
react: { singleton: true, eager },
|
|
19
|
+
'react-dom': { singleton: true, eager },
|
|
20
|
+
'react-router-dom': { eager },
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
module.exports = ({ root, exposes, shared = [], debug, moduleName, useFileHash = true, libType = 'var', libName, exclude = [], eager = false }) => {
|
|
24
|
+
const include = createIncludes(eager);
|
|
22
25
|
|
|
23
|
-
module.exports = ({ root, exposes, shared = [], debug, moduleName, useFileHash = true, libType = 'var', libName, exclude = [] }) => {
|
|
24
26
|
const { dependencies, insights } = require(resolve(root, './package.json')) || {};
|
|
25
27
|
const appName = moduleName || (insights && jsVarName(insights.appname));
|
|
26
28
|
|
|
@@ -39,7 +41,7 @@ module.exports = ({ root, exposes, shared = [], debug, moduleName, useFileHash =
|
|
|
39
41
|
* No application should be installing/interacting with scalprum directly.
|
|
40
42
|
*/
|
|
41
43
|
if (dependencies['@redhat-cloud-services/frontend-components']) {
|
|
42
|
-
sharedDeps.push({ '@scalprum/react-core': { requiredVersion: '*', singleton: true, eager
|
|
44
|
+
sharedDeps.push({ '@scalprum/react-core': { requiredVersion: '*', singleton: true, eager } });
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
/**
|
package/package.json
CHANGED
package/proxy.js
CHANGED
|
@@ -38,6 +38,7 @@ module.exports = ({
|
|
|
38
38
|
onBeforeSetupMiddleware = () => {},
|
|
39
39
|
bounceProd = false,
|
|
40
40
|
useAgent = true,
|
|
41
|
+
useDevBuild = true,
|
|
41
42
|
}) => {
|
|
42
43
|
const proxy = [];
|
|
43
44
|
const majorEnv = env.split('-')[0];
|
|
@@ -60,6 +61,8 @@ module.exports = ({
|
|
|
60
61
|
const isProd = env.startsWith('prod');
|
|
61
62
|
const isStage = env.startsWith('stage');
|
|
62
63
|
|
|
64
|
+
const shouldBounceProdRequests = isProd && bounceProd && !useAgent;
|
|
65
|
+
|
|
63
66
|
if (isStage || (isProd && useAgent)) {
|
|
64
67
|
// stage is deployed with Akamai which requires a corporate proxy
|
|
65
68
|
agent = new HttpsProxyAgent(proxyURL);
|
|
@@ -205,7 +208,7 @@ module.exports = ({
|
|
|
205
208
|
* Use node-fetch to proxy all non-GET requests (this avoids all origin/host akamai policy)
|
|
206
209
|
* This enables using PROD proxy without VPN and agent
|
|
207
210
|
*/
|
|
208
|
-
if (
|
|
211
|
+
if (shouldBounceProdRequests && req.method !== 'GET') {
|
|
209
212
|
const result = await fetch((target + req.url).replace(/\/\//g, '/'), {
|
|
210
213
|
method: req.method,
|
|
211
214
|
body: JSON.stringify(req.body),
|
|
@@ -261,8 +264,10 @@ module.exports = ({
|
|
|
261
264
|
onBeforeSetupMiddleware({ app, compiler, options }) {
|
|
262
265
|
app.enable('strict routing'); // trailing slashes are mean
|
|
263
266
|
|
|
264
|
-
|
|
265
|
-
|
|
267
|
+
if (shouldBounceProdRequests) {
|
|
268
|
+
app.use(express.json());
|
|
269
|
+
app.use(express.urlencoded({ extended: true }));
|
|
270
|
+
}
|
|
266
271
|
|
|
267
272
|
/**
|
|
268
273
|
* Allow serving chrome assets
|
|
@@ -280,8 +285,9 @@ module.exports = ({
|
|
|
280
285
|
defaultServices.chrome = defaultServices.chrome({});
|
|
281
286
|
}
|
|
282
287
|
|
|
288
|
+
const chromeEnv = useDevBuild ? (env.includes('-beta') ? 'dev-beta' : 'dev-stable') : env;
|
|
283
289
|
chromePath = checkoutRepo({
|
|
284
|
-
repo: `${defaultServices.chrome.path}#${
|
|
290
|
+
repo: `${defaultServices.chrome.path}#${chromeEnv}`,
|
|
285
291
|
reposDir,
|
|
286
292
|
overwrite: true,
|
|
287
293
|
});
|