Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ In a separate terminal, run Advisor with proxy enabled and list Inventory:
```
LOCAL_APPS=inventory:8003~http npm run start:proxy
```
## IOP mode
To run Advisor in IOP mode, follow the [IOP mode instructions](https://github.com/RedHatInsights/frontend-development-proxy#iop-mode) in the frontend-development-proxy repository.

You can start the local IOP proxy with `npm run start:proxy:iop` (requires `IOP_URL` to be set).

## Testing
Travis is used to test the build for this code.
Expand Down
22 changes: 22 additions & 0 deletions config/patchFederationForIop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* eslint-disable no-undef */
/**
* Foreman/IOP hosts provide react in the module federation shared scope but not
* react/jsx-runtime or react-intl. FEC defaults mark these as chromeProvided with
* import: false, so the remote fails with:
* Shared module react/jsx-runtime doesn't exist in shared scope default
* (0 , react_intl__WEBPACK_IMPORTED_MODULE_0__.createIntlCache) is not a function
*
* Remove these from chromeProvided so webpack bundles them in the remote.
*/
const federatedModulesPath = require.resolve(
'@redhat-cloud-services/frontend-components-config-utilities/federated-modules'
);
const federatedModulesUtil = require(federatedModulesPath);
const originalCreateIncludes = federatedModulesUtil.createIncludes;

federatedModulesUtil.createIncludes = () => {
const includes = originalCreateIncludes();
delete includes.chromeProvided['react/jsx-runtime'];
delete includes.chromeProvided['react-intl'];
return includes;
Comment on lines +17 to +21

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Preserve the original createIncludes signature and guard against missing chromeProvided.

Two robustness points:

  1. This override drops any arguments to createIncludes, so future upstream parameters would be ignored. Forward them instead:
federatedModulesUtil.createIncludes = (...args) => {
  const includes = originalCreateIncludes(...args);
  if (includes.chromeProvided) {
    delete includes.chromeProvided['react/jsx-runtime'];
    delete includes.chromeProvided['react-intl'];
  }
  return includes;
};
  1. Guard includes.chromeProvided to avoid a possible TypeError if that field is ever missing or the structure changes.

};
8 changes: 8 additions & 0 deletions custom_routes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"/assets/apps/advisor/*": {
"url": "http://host.docker.internal:8003"
},
"/api/insights/v1/advisor/*": {
"url": "http://host.docker.internal:8000"
}
}
18 changes: 12 additions & 6 deletions fec.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
const { resolve } = require('path');
const { sentryWebpackPlugin } = require('@sentry/webpack-plugin');

require('./config/patchFederationForIop');
Comment thread
Fewwy marked this conversation as resolved.

module.exports = {
appUrl: '/insights/advisor',
...(process.env.IOP === 'true'
? { deployment: 'assets/apps' }
: { publicPath: 'auto' }),
debug: true,
useProxy: process.env.PROXY === 'true',
proxyVerbose: true,
SPAFallback: process.env.IOP !== 'true',
devtool: 'hidden-source-map',
...(process.env.IOP === 'true' ? { deployment: 'assets/apps' } : { publicPath: 'auto' }),
plugins: [
// Put the Sentry Webpack plugin after all other plugins
...(process.env.ENABLE_SENTRY
Expand All @@ -30,9 +31,6 @@ module.exports = {
]
: []),
],
output: {
publicPath: 'auto',
},
moduleFederation: {
exclude: ['@unleash/proxy-client-react'],
shared: [
Expand Down Expand Up @@ -82,6 +80,14 @@ module.exports = {
__dirname,
'./src/SmartComponents/Recs/ListWrapped.js',
),
'./ListIop': resolve(
__dirname,
'./src/SmartComponents/Recs/ListIop.js',
),
'./IopRecommendationDetails': resolve(
__dirname,
'./src/SmartComponents/Recs/IopRecommendationDetails.js',
),
},
},
_unstableSpdy: true,
Expand Down
Loading
Loading